JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002.

Slides:



Advertisements
Similar presentations
Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.
Advertisements

(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
JavaBeans introduction Klaus-Peter Heidrich for the University of Karlstad Inst. for Information Technology Dept. of Computer Science.
How is Java different from other languages Less than you think: –Java is an imperative language (like C++, Ada, C, Pascal) –Java is interpreted (like LISP,
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.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Attributes Basic Attributes are great tool for describing your services to clients and users. Attributes give you powerful ways to search for particular.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
How is Java different from other languages Less than you think: –Java is an imperative language (like C++, Ada, C, Pascal) –Java is interpreted (like LISP,
JAVA BEANS (Unit-V) K.Phani Sirisha.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
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.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Component-Based Software Engineering Introduction to Java Beans Paul Krause and Sotiris Moschoyiannis.
Java Beans.
MSIS 670 Object-Oriented Software Engineering Week 1 Introduction to Java: Applications
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.
CIS 644 Aug. 25, 1999 tour of Java. First … about the media lectures… we are experimenting with the media format please give feedback.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 26 Internationalization.
Comparing JavaBeans and OSGi Towards an Integration of Two Complementary Component Models HUMBERTO CERVANTES JEAN-MARIE FAVRE 09/02.
Object-Oriented Modeling Chapter 10 CSCI CSCI 1302 – Object-Oriented Modeling2 Outline The Software Development Process Discovering Relationships.
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
Java Bean Definition “A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”
MSIS 655 Advanced Business Applications Programming Week 1 Introduction to Java
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
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.
IFS410 Advanced Analysis and Design Week 1 Introduction to Java: Applications
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
CS884 (Prasad)java11Extn1 Java 1.1 Extensions Nested classes static public/protected/private.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Boris Milašinović Faculty of Electrical Engineering and Computing University of Zagreb, Croatia 15th Workshop on "Software Engineering Education and Reverse.
1 Chapter 20 Internationalization. 2 Objectives F To describe Java's internationalization features (§ 20.1). F To construct a locale with language, country,
Introduction to Java Beans by Anders Børjesson. Introduction to JavaBeans2 JavaBeans components JavaBeans are the components in the Java environment –COM.
CSCE 314 Programming Languages Reflection Dr. Hyunyoung Lee 1.
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.
Lorenz: Visitor Beans: An Aspect-Oriented Pattern Aspect-oriented pattern: describes a solution to a tangling problem in a particular context.
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Java Beans - Basics CIS 421 Web-based Java Programming.
Chapter 32 JavaBeans and Bean Events
Actions and Behaviours
Structure of a web application
Chapter 36 JavaBeans and Bean Events
Java Beans Sagun Dhakhwa.
JavaBeans and JSP CS-422.
Enterprise Java Bean. Overview of EJB View of EJB Conversation Roles in EJB, Types of Enterprise Beans Lifecycle of Beans Developing Applications using.
Interfaces.
Knowledge Byte In this section, you will learn about:
Component-Based Software Engineering
Java Programming: Advanced Topics
Presentation transcript:

JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002

Deploying Beans to the Enterprise  How do we treat beans as independent software components?  How do you examine a bean and expose its features: properties, events, and methods?  How do you create global international beans?

Reflection and Introspection  A Bean has to reveal it’s properties, methods and events to the builder tool.  Reflection is the ability to obtain information about the fields,constructors and methods of any class.  Introspection is the ability to obtain information about the properties, events and methods of a Bean.

Reflection  Is Java a true Object-Oriented language?  For reflection, all data types must be objects  Classes and interfaces exist for reflection:  class Array, Class, Constructor, Field, Method, Modifier  interface Member

Introspection  class Introspector uses core reflection API to discover a Bean’s methods  All java.beans.Introspector class methods are static  Call Introspector.getBeanInfo(…) method to get the BeanInfo object  Explicitly expose features  Rely on BeanInfo to expose some Bean features while relying on low-level reflection to expose others.

BeanInfo interface  BeanInfo defines methods that return descriptors for each property, method, or event that you want exposed:  PropertyDescriptor[] getPropertyDescriptors();  MethodDescriptor[] getMethodDescriptors();  EventSetDescriptor[] getEventSetDescriptors();

Creating a BeanInfo class (1) 1. Name your BeanInfo class Target class: ExplicitButton Bean information class: ExplicitButtonBeanInfo 2. Subclass SimpleBeanInfo public class ExplicitButtonBeanInfo extends SimpleBeanInfo

3. Override methods public PropertyDescriptor[] getPropertyDescriptors() { try { PropertyDescriptor background = new PropertyDescriptor("background", beanClass); PropertyDescriptor foreground = new PropertyDescriptor("foreground", beanClass); PropertyDescriptor font = new PropertyDescriptor("font", beanClass); PropertyDescriptor label = new PropertyDescriptor("label", beanClass); background.setBound(true); foreground.setBound(true); font.setBound(true); label.setBound(true); PropertyDescriptor rv[] = {background, foreground, font, label}; return rv; } catch (IntrospectionException e) { throw new Error(e.toString()); } Creating a BeanInfo class (2)

Creating a BeanInfo class (3) 4. Specify the target Bean class public BeanDescriptor getBeanDescriptor() { return new BeanDescriptor(beanClass); }... private final static Class beanClass = ExplicitButton.class

 A Bean's appearance and behavior can be customized at design time: 1. By using a property editor: Property sheet Associated with a property 2. By using customizers: Complete GUI control Associated with a bean Bean Customization

Property Editors  Explicit association via a BeanInfo object using the method setPropertyEditorClass(…)  Explicit registration via java.Beans.PropertyEditorManager.registerE ditor  Naming convention

Customizers  Extend java.awt.Component or one of its subclasses.  Implement the java.beans.Customizer interface This means implementing methods to register PropertyChangeListener objects, and firing property change events at those listeners when a change to the target Bean has occurred.  Implement a default constructor.  Associate the customizer with its target class via BeanInfo.getBeanDescriptor.

International Beans  Programs are written with one language and culture  What about localization?  Locale is a geographic, political, or culturally cohesive region sharing the same language and customs  Localizing objects:  Use Java’s locale class  Encapsulate locale-specific data in resource bundles  Locale localeUS = new Locale(“en”, “US”);  public Locale getLocale( )

References   JavaBeans Unleased, Dr. Don Doherty, Rick Leinecker  ftp://ftp.javasoft.com/docs/beans/beans.101.pdf JavaBeans 1.01 Specification  Beginning Java 2, Ivor Horton

 When should the reflection API not be used?  When to use BeanInfo and when to use low-level Reflection API?  What kind of applications might want to use the Reflection API? Discussion