Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 By Dr. Jiang B. Liu 12. The Java Beans

2 Java Beans n JavaBeans is a portable, platform-independent software component model written in Java. It enables developers to write reusable components once and run them anywhere - benefiting from the platform-independent power of Java. n Beans may be manipulated in a visual builder tool and composed together into applications. A Bean is any Java class which adheres to certain property and event interface conventions. n The Beans Development Kit (BDK) provides support for the JavaBeans APIs and a test container (the “BeanBox” to test Bean behavior),

3 Network Computing: Java Beans n JavaBeans Network Component Computing Model

4 Java Beans in the Java Enterprise Architecture

5 Java Beans: Caracteristic features n Introspection: Enables a builder tool to analyze how a bean works. n Customization: Enables the developer of a Bean component to customize the appearance and behavior of a Bean. n Events: Enables beans to fire events and informing builder tools about the events they can fire and the events they can handle. n Properties:Supports the customization mentioned above. n Persistence: Enables developers to customize Beans, and then retrieve those Beans later, with customized features intact.

6 Java Beans: Create a Java Bean n 1. Create a Bean (jar) file jar cfm FancyButton.jar \ FancyButton.mf FancyButton.class FancyButton.gif FancyButton.au (FancyButton.mf: Manifest-Version: 1.0 Name: FancyButton.class Java-Bean: True) n 2. Copy the Bean file to C:\BDK1.0\jars n 3. Test the Bean in the BeanBox.

7 Java Beans: JAR Files n A JAR file is a convenient way of packaging together a set of class files and any associated GIF images, data files, or other resource files. n A JAR file consists of a normal ZIP format file, plus an optional manifest file describing the JAR contents. n You can use the JDK 1.1 jar command to create and read JAR files. n Manifest file: Each JAR file may contest a manifest file describing the contents of the JAR file.

8 Java Beans: JAR Files n The jar command The jar command is provided as part of JDK 1.1. It allows you to either create a JAR file or to extract the content of a jar file. n The jar command syntax is: jar [ctxvfm] [jar-file] [manifest-file] files … Option flags are: c create new archive t list table of contents for archive x extract named (or all) files from archive v generate verbose output on standard error f specify JAR file name m include manifest information from specified manifest file If any file is a directory then it is processed recursively.

9 Java Beans: BeanBox n The BeanBox is a very simple test container. It allows you to try out beans. n The BeanBox allows you to: n drop beans onto a composition window n resize and move beans around n edit the exported properties of a bean n run a customizer to configure a bean n connect a bean event source to an event handler method n connect together bound properties on different beans n save and restore sets of beans n get an introspection report on a bean n add new beans from JAR files

10 Java Beans: Create an Application using Beans n 1. Run BeanBox java sun.beanbox.BeanBoxFrameset (CLASSPATH=%CLASSPATH%;C:\JavaBdk1.0\beanbox\CLASSES) n 2. Create an instance of Juggler bean and two instance of OurButton beans. (using Toolbox) Rename the button label (using PropertySheet) n 3. Select the button bean and connected to the Juggler bean. (Edit->event->action->actionPerform->Click on the Juggler- >start/stop method in EventTargetDialog) n 4. Save the application (File->save)

11 Java BeanBox


Download ppt "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."

Similar presentations


Ads by Google