Introduction to Java Beans CIS 421 Web-based Java Programming.

Slides:



Advertisements
Similar presentations
Executional Architecture
Advertisements

Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.
2 Object-Oriented Analysis and Design with the Unified Process Objectives  Explain how statecharts can be used to describe system behaviors  Use statecharts.
Event Handling. In this class we will cover: Basics of event handling The AWT event hierarchy Semantic and low-level events in the AWT.
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
Graphical User Interface (GUI) Nelson Padua-Perez Bill Pugh Department of Computer Science University of Maryland, College Park.
Copyright W. Howden1 Lecture 19: Intro to O/O Components.
JavaBeans introduction Klaus-Peter Heidrich for the University of Karlstad Inst. for Information Technology Dept. of Computer Science.
Graphical User Interface (GUI) Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
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.”
Object-Oriented Programming with Java Lecture 2 The Java Event Model.
M.Sc. Course, Dept. of Informatics and Telecommunications, University of Athens S.Hadjiefthymiades “Web Application Servers” Basics on WAS WAS are necessary.
GUI Programming in Java Tim McKenna GUI Programming Concepts l conventional programming: sequence of operations is determined by the program.
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.
GUI Programming in Java
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.
WINDOWS SERVICES. Introduction You often need programs that run continuously in the background Examples: – servers –Print spooler You often need.
Java Beans.
An Introduction to Software Architecture
Introduction to J2EE Architecture Portions by Kunal Mehta.
第十四章 J2EE 入门 Introduction What is J2EE ?
Last update October 18, 2004 Advanced Programming 2004 Java Beans.
JavaBeans Components. To understand JavaBeans…  Proficient experience with the Java language required  Knowledge of classes and interfaces  Object-Oriented.
Learning objectives By the end of this lecture you should be able to:  have a well-earned rest! Ch 24 Beyond the second semester.
TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Component frameworks Roy Kensmil. Historical trens in software development. ABSTRACT INTERACTIONS COMPONENT BUS COMPONENT GLUE THIRD-PARTY BINDING.
Dale Roberts GUI Programming using Java - Event Handling Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer.
Systems Analysis and Design in a Changing World, 3rd Edition
– Advanced Programming P ROGRAMMING IN Lecture 21 Introduction to Swing.
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
Graphics and Event-Driven Programming in Java John C. Ramirez Department of Computer Science University of Pittsburgh.
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.”
Java Applets: GUI Components, Events, Etc. Ralph Westfall June, 2010.
Frameworks CompSci 230 S Software Construction.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Computer Science [3] Java Programming II - Laboratory Course Lab 4: Common GUI Event Types and Listener Interfaces Layout Mangers Faculty of Engineering.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 13. Review Shared Data Software Architectures – Black board Style architecture.
Introduction to Java Programming
Object Oriented Programming.  Interface  Event Handling.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
CSC 243 – Java Programming, Spring, 2009 Week 9 Java’s Event Infrastructure.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
Intelligent Agent Framework1 From Chapter 7 of Constructing Intelligent Agents with Java.
Advanced Java Session 4 New York University School of Continuing and Professional Studies.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
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 Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Java Beans - Basics CIS 421 Web-based Java Programming.
Chapter 32 JavaBeans and Bean Events
CSC 205 Programming II Lecture 5 AWT - I.
Chapter 36 JavaBeans and Bean Events
Java Beans Sagun Dhakhwa.
Introduction to J2EE Architecture
Ellen Walker Hiram College
Event Driven Systems and Modeling
An Introduction to Software Architecture
Pre-assessment Questions
Java Programming: Advanced Topics
Presentation transcript:

Introduction to Java Beans CIS 421 Web-based Java Programming

Components  Components are : 1. self-contained, 2. reusable software units that can be visually composed into 1. composite components, 2. applets, and 3. applications using visual application builder tools.

What are Component Models?  Component Models are the next step in object-oriented programming  Component Models allow us to: –Create objects as components –Customize a component –Introspect a component –Interact with other components –Build other higher level components

Desirable Properties of Components  A component should: –be modular –follow object oriented principles –be “plug & play” –be generic so that it can be used in different scenarios.

Java & Components Java is a good platform for component technology because : –It is object-oriented –It provides applets that run on a web server. –It has platform independence. –It has basic features like multi threading, security, etc. –It has features to communicate with remote objects. –It is able to furnish info on class contents at run-time.

Java Beans  A Java Bean is a reusable software component that can be manipulated visually in a builder tool –BeanBox is a simple tool  Note: Not all beans are visual beans.

Java Beans contd.. Features that distinguish a Java Bean from Java objects are: –introspection –customization –externally occurring events –properties –persistence

Java Beans contd..  A bean is not required to inherit from any particular base class or interface.  Visual beans inherit from java.awt.Component.  Though Beans are primarily targeted at builder tools, they are also entirely usable by human programmers.  Beans are more than class libraries. –ordinarily stored in jar files

Properties, Methods and Events  Properties are the named attributes associated with a bean.  Methods of a Bean are the normal Java methods which can be called from other components.  Events are a way of providing information to other components by notifying them about something which happened.

Design Time Vs. Run Time Design Environment  Provides Information used by builder tool to customize the appearance and behavior of Beans. Run-time Environment  Provides information for other beans as well as applications to use it. Java Beans API allows design time interfaces to be separated from run-time interfaces.

Java Features used in Beans  Beans can be stored and retrieved for a later use by implementing Java’s Serializable interface. –Remote Invocation  Java RMI provides a facility for remote Beans to communicate with each other.  JDBC Connectivity –JDBC provides a means to store Beans in a database.

Java Features used in Beans contd..  JAR Utility –Used for packaging beans  AWT and Swing –All visible beans are made from AWT or Swing components. –Beans use event handling of AWT.  Reflection –Used to know about the beans at run-time.  Security - Beans follows the same security model of Java.

Design Pattern  Beans follow strict design patterns.  Design pattern helps IDEs to detect various state variables for configuration and editing.  The common design patterns are:  Set / Get methods for properties  Add / Remove methods for events

Event-driven Designs Handling user interface events : - Mouse Actions -Keyboard events Managing / reporting inter-client connections. Other events:  Property changes in a bean  Any general-purpose notification

Delegation Event Model  Based on publish and subscribe system.  Objects that provide events are called publishers or sources.  Objects that subscribe, and can receive events, are listeners or targets.  Sources fire events and listeners wait for event to be fired on them.

Delegation Event Model [1] contd.. Public synchronized FooListener addFooListener (FooListener fel) Event Source FooEvent Event Listener Class fooey implements FooListner { Void fooBarHappened (FooEvent fe) { } } eListener Interface reference fire Event Register Listener

Event Handling in AWT  A listener object is an instance of a class that implements a special interface called listener interface.  An event source is an object that can register listener objects and send them event objects. –addActionListener(this)  The event source sends out event objects to all registered listeners when that event occurs.  The listener objects will then use the information in the event object to determine their reaction to the event.

Java Event Libraries  java.util.eventObject  java.awt.event  java.awt.dnd  javax.swing.event

Types of Events  Low-level events: –Tied to GUI component like focus, click, key-pressed, etc.  Semantic events: Used in a higher level where the user can customize the way of representing event.

Low-level Events EventObject CompoentEvent FocusEvent InputEvent MouseEvent

Semantic Events ActionEventItemEvent AdjustmentEvent

Event Sources  Sources are the objects which fire events.  Sources maintain a list of listeners. –keep track of added listeners  Listeners can register and unregister themselves with a source.  Listener registration methods are prepended by add and remove. Event Listeners  waits for events.  Listener names end with Listener

User-defined events?  Custom Events: –Can create and define events.  User defined event objects extend the EventObject class.

Event Delivery  Events can be delivered as either unicast or multicast. –Unicast – Only one listener possible.  Throws ToomanyListenersException –Multicast – Many listeners possible.

Adding an Event to the Bean  Create EventListener class.  Create EventListener objects in the bean.  Register the EventListener objects with Swing or AWT components.

Event Adapter  Event adaptors decouple the incoming event notifications from the listeners.  Event adaptors are placed in between source and the actual listeners to provide an additional policy in event delivery.  Typical use of event adapters are: –Implementing an event queuing mechanism between sources and listeners. –Acting as a filter. –Demultiplexing multiple event sources onto a single event listener.