TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716)381-0260 x225.

Slides:



Advertisements
Similar presentations
Connecting to Databases. relational databases tables and relations accessed using SQL database -specific functionality –transaction processing commit.
Advertisements

Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.
Slide 10.1 Advanced Programming 2004, based on LY Stefanus’s Slides Object Serialization Object serialization: the process of converting an object into.
JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002.
Seminarium on Component-based Software Engineering Jan Willem Klinkenberg CORBA.
Mari Göransson - KaU - Datavetenskap - DAVD11 1 Java Beans - Events and Properties -
Component Models and Technology Component-based Software Engineering
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
Eclipse Architecture Dwight Deugo Nesa Matic
JavaBeans introduction Klaus-Peter Heidrich for the University of Karlstad Inst. for Information Technology Dept. of Computer Science.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of Creating Eclipse plug-ins.
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.”
Software Engineering Module 1 -Components Teaching unit 3 – Advanced development Ernesto Damiani Free University of Bozen - Bolzano Lesson 2 – Components.
Page 1 Building Reliable Component-based Systems Chapter 4 - Component Models and Technology Chapter 4 Component Models and Technology.
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
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.  Java offers software component development through java Beans  Java Beans are based on a software component model for java.  The model.
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.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
Java Beans.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 2, Week 4 Design by Contract, Java Exceptions, Eventing, Finding the Classes,
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.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
CG0165: Advanced Applications Development in Java Michael Brockway Sajjad Shami Week 5: JavaBeans Northumbria University School of Computing, Engineering.
Enterprise JavaBeans Understanding EJB Components Version 0.1 Kamal Wickramanayake
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
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.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
JAVA BEANS JSP - Standard Tag Library (JSTL) JAVA Enterprise Edition.
© 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.
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 EJB. What is an EJB ?  An enterprise java bean is a server-side component that encapsulates the business logic of an application. By.
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.
Lorenz: Visitor Beans: An Aspect-Oriented Pattern Aspect-oriented pattern: describes a solution to a tangling problem in a particular context.
Java Programming: Advanced Topics1 Introduction to Advanced Java Programming Chapter 1.
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Enterprise JavaBeans: Fundamentals. EJB Fundamentals(c)CDAC(Formerly NCST)2 Contents Introduction Technology Overview EJB Architecture EJB Specification.
Java Beans - Basics CIS 421 Web-based Java Programming.
Chapter 32 JavaBeans and Bean Events
Chapter 36 JavaBeans and Bean Events
Javabeans for dummies.
Introduction to Advanced Java Programming
JavaBeans* ICS 123 Richard N. Taylor & Eric M. Dashofy UC Irvine
Java Beans Sagun Dhakhwa.
Persistence & Bean Properties
Reusability 11/29/2018© 2006 ITT Educational Services Inc.
Pre-assessment Questions
Knowledge Byte In this section, you will learn about:
Component-Based Software Engineering
Java Programming: Advanced Topics
Presentation transcript:

TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225

TMOutline  Component Software Engineering  Event  Properties  Persistence and Versioning  Introspection and Customization  Packaging and Deployment  Future Directions

TM Component Framework  Component –A reusable software module that is supplied in a binary form and can be used to compose applications  Container –Provides the context that components can be assembled and interact with one another  Component Model –Defines the architecture of how components can interact in a dynamic environment

TM Component Model Features  Property Management  Event Handling  Persistence and Versioning  Portability and Interoperability  Distributed Computing Support

TM What is a JavaBean? “A JavaBean is a reusable software component that can be manipulated visually in a builder tool”

TM JavaBeans Objectives  Provide a platform neutral component architecture  Simple to develop  Leverage existing Java technologies  Provide design-time support for visual builder tools

TM JavaBeans Characteristics  Properties  Event  Persistence  Introspection  Customization

TMProperties  Discrete, named attributes that determine the appearance and behavior and state of a component  Accessible programmatically through accessor methods  Accessible visually through property sheets  Exposed as object fields in a scripting environment

TM Property Types  Simple Properties  Bound Properties  Constrained Properties

TM Simple Properties  Represent a single value  The accessor methods should follow standard naming conventions public get (); public void set ( value); Example: public String getHostName(); public void setHostName( String hostName );

TM Boolean Properties  They are simple properties  The getter methods follow an optional design pattern public boolean is (); Example: public boolean isConnected();

TM Indexed Properties  Represent an array of values public get (int index); public void set (int index, value); public [] get (); public void set ( [] values); Example: public Color setPalette(int index); public void setPalette(int index,Color value); public Color[] getPalette(); public void setPalette(Color[] values);

TM Bound Properties  Registered listeners object are notified when the value of the property changes  Listeners must implement the java.beans.PropertyChangeListener interface propertyChange(PropertyChangeEvent event);

TM Bound Properties Support Framework TerminalBean hostName portNumber addPropertyChangeListener() removePropertyChangeListener() PropertyChangeEvent source newValue propertyName oldValue generates uses notifies PropertyChangeListener propertyChange() > PropertyChangeSupport addPropertyC hangeListener() removePropertyChangeListener() firePropertyChange()

TM Bound Properties Notification Mechanism :PropertyEditor :Bean :PropertyChangeListener :PropertyChangeSupport 1. addPropertyChangeListener 2. addPropertyChangeListener 3. SetHostName(“hostName”) 4. firePropertyChange(event) 5. propertyChange(event)

TM Constrained Properties  Allow registered listeners to validate a proposed change  Listeners must implement the java.beans.VetoablecChangeListener interface vetoableChange( PropertyChangeEvent event ) throws PropertyVetoException;

TM Constrained Properties Support Framework Bean hostName portNumber addVetoableChangeListener() removeVetoableChangeListener() PropertyChangeEvent source newValue propertyName oldValue VetoableChangeSupport addVetoableC hangeListener() removeVetoableChangeListener() generatesusesnotifies VetoableChangeListener vetoableChange() >

TM Constrained Properties - Example public void setHostName( String newHostName ) throws java.beans.PropertyVetoException { String oldHostName = this.hostName; // First tell the vetoers about the change. If anyone objects, we // don't catch the exception but just let if pass on to our caller. vetoableChangeSupport.fireVetoableChange( "hostName", oldHostName, newHostName ); // change accepted; update state this.hostName = newHostName; // notify property change listeners propertyChangeSupport.firePropertyChange("hostName", oldHostName, newHostName ); }

TMDemo  Terminal Bean –Bound Properties connectedconnected connectedColorconnectedColor disconnectedColordisconnectedColor –Constrained Properties hostNamehostName portNumberportNumber –Methods connect()connect() disconnect()disconnect()

TM Overview of Event Model  Provides a notification mechanism between a source object and one or more listener objects  Source or listener objects does not need to be graphical components  Supports introspection  Extensible

TM Event Delegation Model Listener Event Source Event 3. Notify 2. Generate 1. Register

TM Event Objects  Encapsulate notification properties  Inherit from the java.util.EventObject class

TM Event Object - Example public class CursorEvent extends java.util.EventObject { public CursorEvent(Object source,Point location) { super( source ); this.location = location; } Point getLocation() { return location; } private Point location; }

TM Event Listeners  Implement an interface that is defined by the source  Register with source using published registration method  Listener interfaces –Inherit from java.util.EventListener –Have an individual method for each event type –Related event handling methods are usually grouped in the same interface

TM Event Listeners - Example public interface CursorListener extends java.util.EventListener { public void cursorMoved( CursorEvent cursorEvent); }

TM Event Sources  Provide methods for registering and de- registering event listeners –Singlecast support public void add ( listener) throws java.util.TooManyListenersException; public void remove ( listener) –Multicast support public void add ( listener) public void remove ( listener)

TM Event Source - Example public class TerminalBean { … public void addCursorListener( CursorListener listener ) { } public void removeCursorListener( CursorListener listener ) { }... }

TMPersistence  Java object serialization facilities provide an automatic mechanism to store out and restore the internal state of an object to/from a stream  Java externalization mechanism allow a Java object to have complete control over the format of the stream

TM Serialization Example public class TerminalBean implements java.io.Serializable { private String hostName; private transient boolean isConnected; static final long serialVersionUID = L; } ObjectOutputStream objectOutputStream=new ObjectOutputStream(outStream ); outputStream.writeObject( new TerminaBean() );... ObjectInputStream objectInputStream = new ObjectInputStream( inStream ); TerminalBean terminal = (TerminalBean) objectInputStream.readObject( );  Saving and Retrieving component state:

TMVersioning  Java Serialization support: –Reading streams written by order version of the same class –Writing stream intended to be read by order version of the same class –Identify and load streams that match the exact class used to write the stream

TMIntrospection  Discovering the properties, events, and method that a component supports  Two methods to perform introspection –Use low level reflection mechanism- –Explicit specification using the BeanInfo class

TM Reflection Mechanism  Uses reflection facilities of the Java API to determine the public methods, fields of the Java Bean  Apply design patterns to determine properties, methods, and events that the JavaBean supports

TMBeanInfo  Provides explicit information about a JavaBean  Defined by the creator of the bean  Does not need to provide complete information

TMCustomization  Customize the appearance and behavior of a component in a design time environment  Customization is supported through: –Property Editors –Property Sheets –Customizers

TM Property Editors  Visual element for editing a specific Java Type  For standard types editors are provided  Located using the PropertyEditorManger  Displayed on Property sheets

TM Property Sheets  Consist of all editors necessary to edit the properties of a component  Keep track of which editor’s values change  Update bean after each change

TMCustomizers  More elaborate visual interfaces to edit the properties of a bean in a multiple step process  Act like wizards or experts  Builder tools register with the customizers for property changes and update bean after each change

TM Packaging and Deployment  JAR (Java ARchive) files are the primary method of packaging and distributing JavaBeans  A JAR file contains: –Class files –Serialized prototypes of a bean –Documentation files –Resources

TM Jar File Example SRC_DIR=com/questra/beans CLASSFILES= \ $(SRC_DIR)\Terminal.class \ $(SRC_DIR)\CursorEvent.class \ $(SRC_DIR)\CursorListener.class \ $(SRC_DIR)\TerminalBeanInfo.class \ $(SRC_DIR)\Terminal$$VetoOpenConnection.class DATAFILES= $(SRC_DIR)\TerminalBeanIconColor16.gif JARFILE= bdk\jars\terminal.jar all: $(JARFILE) # Create a JAR file with a suitable manifest. $(JARFILE): $(CLASSFILES) $(DATAFILES) jar cfm $(JARFILE) <<manifest.tmp $(SRC_DIR)\*.class $(DATAFILES) Name: com/questra/beans/Terminal.classJava-Bean: True <<. SUFFIXES:.java.class {$(SRC_DIR)}.java{$(SRC_DIR)}.class : javac $< clean: -del $(SRC_DIR)\*.class -del $(JARFILE)

TMFuture  "Glasgow  "Glasgow" –Extensible runtime containment and services protocol –Drag and Drop subsystem –JavaBeans Activation framework  Enterprise Java Beans –Build distributed, scalable, transactional OO business applications –Runtime environment –Interoperability with non-Java applications –Compatible with CORBA

TMResources  JavaBeans Home Page –  Glasgow –  Books –Michael Morrison, presenting JavaBeans, Sams.net:Indianapolis, –Dan Brookshier, JavaBeans Developer’s Reference, News Riders Publishing:Indianapolis, 1997.