Java Beans.  Java offers software component development through java Beans  Java Beans are based on a software component model for java.  The model.

Slides:



Advertisements
Similar presentations
Java Graphical User Interface (GUI) using Visual Editor in eclipse CSI 1390 – Java Programming Instructor: Saeid Nourian University.
Advertisements

Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.
L3:CSC © Dr. Basheer M. Nasef Lecture #3 By Dr. Basheer M. Nasef.
1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
By Dr. Jiang B. Liu 12. The Java Beans. Java Beans n JavaBeans is a portable, platform-independent software component model written in Java. It enables.
JavaBeans A component architecture. What is JavaBeans? NC World (New Computing) Dictionary: JavaBeans n. 1. JavaSoft technology. 2. Component object model.
JAVA BEANS By Madhuri Kakumanu. What is a Java Bean? “ A Java Bean is a reusable software component that can be visually manipulated in builder tools.”
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
Introduction to Java.
JAVA BEANS (Unit-V) K.Phani Sirisha.
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
Introducing JavaBeans Identify the features of a JavaBean Create and add a bean to an application Manipulate bean properties using accessor and mutator.
Java Beans Component Technology Integrated, Visual Development Environments Reusable Platform-Independent Modular.
Component-Based Software Engineering Introduction to Java Beans Paul Krause and Sotiris Moschoyiannis.
Java Beans.
Chapter 10 Introduction to Components. Process Phases Discussed in This Chapter Requirements Analysis Design Implementation ArchitectureFramework Detailed.
Jaeki Song ISQS6337 JAVA Lecture 16 Other Issues in Java.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
SWE 316: Software Design and Architecture Objectives Lecture # 19 Java Beans SWE 316: Software Design and Architecture  Understand  what JavaBeans (“Beans”)
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
Last update October 18, 2004 Advanced Programming 2004 Java Beans.
Introduction to Java Beans by Anders Børjesson. Introduction to JavaBeans2 JavaBeans components JavaBeans are the components in the Java environment Many.
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
POS 406 Java Technology And Beginning Java Code
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Prachi Chitnis.  The CSS feel  SDS – Synoptic Display Studio  ADL Converter  PV table, Probe…
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
SWE 316: Software Design and Architecture Objectives Lecture # 18 Introduction to Components SWE 316: Software Design and Architecture To learn:  benefits.
Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.
Java Bean Definition “A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”
Introduction to Java Beans CIS 421 Web-based Java Programming.
Introduction to Java 120 February 2004Sifei HE © 2004 Introduction to Java for CS381, EE4.Web By Sifei HE Department of Computing.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Introduction to Java Beans by Anders Børjesson. Introduction to JavaBeans2 JavaBeans components JavaBeans are the components in the Java environment –COM.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 2 – Welcome Application Introduction to Graphical.
JavaBean Component Java bean is a reusable software component that can be manipulated visually in a builder tool Graphic bean and Non-graphic bean Javabean.
Introduction to Java Beans From Anders Børjesson.
Introduction to Software Components: the JavaBeans specs Babak Esfandiari.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 32 JavaBeans and Bean.
1 Java Server Pages A Java Server Page is a file consisting of HTML or XML markup into which special tags and code blocks are inserted When the page is.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Slides prepared by Rose Williams, Binghamton University Chapter 20 Java Never Ends.
Java Beans - Basics CIS 421 Web-based Java Programming.
Chapter 32 JavaBeans and Bean Events
Chapter 36 JavaBeans and Bean Events
Java Beans Sagun Dhakhwa.
JAR Files Objectives: 1. Archiving and Packaging Java Code
Java Applets.
Pre-assessment Questions
Knowledge Byte In this section, you will learn about:
Java Programming: Advanced Topics
Plug-In Architecture Pattern
Presentation transcript:

Java Beans

 Java offers software component development through java Beans  Java Beans are based on a software component model for java.  The model is designed to allow third party vendors to create and sell Java components that can be integrated into other software products.

 Java beans is an architecture and platform independent set of classes for creating and using Java software components.  Beans support the software component model which focuses on the use of components and containers.

Advantages  It has write once, run anywhere paradigm  A bean may be designed to operate in different locations which makes it useful in global market.  A bean may register to receive events from other objects and can generate events that are sent to other objects.

Application Builder Tools  A utility that enables you to configure a set of Beans, connect them together and produce a working application.  A palette is provided that lists all the available beans. As additional beans are developed / purchased they can be added to the palette.  Worksheet allows the designer to lay out beans in GUI.  Special editors and customizers allow a bean to be configured.  Commands allow a designer to inquire about the state and behavior of a bean.  Capabilities exist to interconnect beans.  When a collection of beans have been configured and connected, it is possible to save all in a persistent storage area. Later on this information can be used to restore the state of the application.

BDK  Bean Developer Kit  JDK must be installed for BDK.  BDK can be downloaded from sun java site.  Using BDK

Sample Beans  Blue Button A simple button with background, foreground, label and font properties. A simple button with background, foreground, label and font properties.  Orange Button Same as Blue button Same as Blue button  Our Button A grey button with additional font properties. A grey button with additional font properties.  Explicit Button Same as Blue button Same as Blue button  EventMonitor A text area that is used to view events as they happen. A text area that is used to view events as they happen.

 Jelly Bean A simple visual component that draws a colored oval “jelly bean”. A simple visual component that draws a colored oval “jelly bean”.  Juggler Represnts a threaded animated component. Represnts a threaded animated component.  Voter By default the bean will reject all change requests but change requests will be accepted if the the vetoAll propterty is set to false. By default the bean will reject all change requests but change requests will be accepted if the the vetoAll propterty is set to false.

 ChangeReporter A text filed A text filed  Molecule Similar to juggler and accept mouse input. Similar to juggler and accept mouse input.  QuoteMonitor Uses RMI to contact a remote server. Uses RMI to contact a remote server.  JDBC Select Uses JDBC API to connect a database. Uses JDBC API to connect a database.  BridgeTester Provides set of property types and events that may be used to test other bean components. Provides set of property types and events that may be used to test other bean components.

JAR files  BDK expect beans to be packaged within JAR files.  A JAR file allows to deploy a set of classes and their associate resources.  The package java.util.zip contains classes that read and write JAR files.

Manifest Files  Indicate which of the components in a JAR file are java Beans.  A manifest file may reference several.class files.  If a.class file is a java Bean, its entry must be immediately followed by the line “java- Bean: True”.

Creating a jar file  Command jar cf XY.jar *.class *.gif creates XY jar file that contains all.class and all gif files of current directory. Syntax: jar options files jar options files

Options  ca new archive is to be created  ffirst element in file list is the name of the archive that is to be created.  uupdate existing JAR file  vverbose output  xfiles are to be extracted from the archive.  0 don’t use compression.

Properties  It is a subset of Beans state.  Value of properties determine behavior and appearance of component.  3 types of properties Simple Simple Boolean Boolean Indexed Indexed

Simple Property  Has a single value  N for name of property  T for its type public T getN(); public T getN(); public void setN(T arg); public void setN(T arg);  A read / write have both these  Read only has only get method.  A write only has only set method.

  The following listing shows a class that has three read/write simple properties: public class Box { private double depth, height, width; public double getDepth( ) { return depth; } public void setDepth(double d) { depth = d; } public double getHeight( ) { return height; } public void setHeight(double h) { height = h; } public double getWidth( ) { return width; } public void setWidth(double w) { width = w; } }

Boolean Properties  Has value true or false public boolean isN(); public boolean isN(); public boolean getN(); public boolean getN(); public void setN(boolean value); public void setN(boolean value); public class Line { private boolean dotted = false; public boolean isDotted( ) { return dotted; } public void setDotted(boolean dotted) { this.dotted = dotted; } }

Indexed property  Consists of multiple values.  Public T getN(int index);  Public T[ ] getN();  Public void setN(int index, T value);  Public void setN(T values[ ]);

public class PieChart { private double data[ ]; public double getData(int index) { return data[index]; } public void setData(int index, double value) { data[index] = value; } public double[ ] getData( ) { return data; } public void setData(double[ ] values) { data = new double[values.length]; System.arraycopy(values, 0, data, 0, values.length); }

Events  public void addTListener(TListener el); For multiple listeners For multiple listeners  public void addTListener(TListener el) throws TooManyListeners; For one listener For one listener  public void removeTListener(TListener el);

  These methods are used by event listeners to register an interest in events of a specific type.   The first pattern indicates that a Bean can multicast an event to multiple listeners.   The second pattern indicates that a Bean can unicast an event to only one listener.   The third pattern is used by a listener when it no longer wishes to receive a specific type of event notification from a Bean.

Reflection  It is the ability to obtain information about the fields, constructors and methods of any class at run time.  Introspection uses reflection to obtain information about a bean.  JVM creates an instance of the class “Class” for each type including classes, interfaces, arrays and simple types.  Class provides various instance methods to get information about the type.  “Member” is an interface in java.lang.reflect that defines methods that are common to the fields, constructors and methods of a class.

 “Field” class in java.lang.reflect package contains methods to read and write the value of a field within another object.  This class implements Member interface.  The class Constructor in java.lang.reflect contains methods to get information about a constructor. It implements Member interface.

 The class Method in java.lang.reflect is used to get information about a method. It implements Member interface.  The class Array in java.lang.reflect is used to built an array at run time.

Introspection  It enables to find out information about the structure and functionality of the bean.  Introspection services are provided by JavaBeans API are divided in-  Low-level API Used by application builder tools. Used by application builder tools. Reflection work at low-level. Reflection work at low-level.  High-level API Used by developers. Used by developers. Limited access of a bean’s internal. Limited access of a bean’s internal. Introspection works at high-level. Introspection works at high-level.

Introspector  This class in java.beans provides static methods to obtain information about the properties, events and methods of a bean.  When a bean named Abc is encountered, the introspection looks for a class AbcBeanInfo. If it exists, it is used to provide information about the properties, events and methods of component. If it doesn’t exist, a BeanInfo object is constructed by default.  getBeanInfo() encapsulates all information about a bean and wraps it up into a single BeanInfo object.  static BeanInfo getBeanInfo(Class beanClass)  static BeanInfo getBeanInfo(Class beanClass, Class ignoreClass)

Developing a simple bean  Create a directory for new bean c:\\bdk\\demo\\sunw\\demo\\colors  Create java source file Colors.java Colors.java  Compile java file  Create a Manifest File switch to the c:\\bdk\\demo directory. This is the directory in which the manifest files for the BDK demos are located. Put the source code for your manifest file in the file colors.mft. It is shown here: Name: sunw/demo/colors/Colors.class Java-Bean: True   This file indicates that there is one.class file in the JAR file and that it is a Java Bean.   Colors.class file is in the package sunw.demo.colors and in the subdirectory sunw\\demo\\colors relative to the current directory.

 Generate JAR file   Beans are included in the ToolBox window of the BDK only if they are in JAR files in the directory c:\\bdk\\jars.   These files are generated with the jar utility. Enter the following:   jar cfm colors.jar colors.mft sunw\\demo\\colors\\*.class   This command creates the file colors.jar and places it in the directory c:\\bdk\\jars.  Start BDK  Test.

Example C:\beans\demo\sunw\demo\my\> javac My.java C:\beans\demo\> jar cfm..\jars\my.jar My.mf sunw\demo\my\*.class

BeanInfo interface  PropertyDescriptor[] getPropertyDescriptors()  EventSetDescriptor[] getEventSetDescriptors()  MethodDescriptor[] getMethodDescriptors()

Constrained properties  A bean has constrained property generates an event when an attempt is made to change its value.  The event is of type PropertyChangeEvent.