1 / 11

By Dr. Jiang B. Liu

Java Computing. By Dr. Jiang B. Liu. 12. The Java Beans. Java Beans. 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.

landry
Download Presentation

By Dr. Jiang B. Liu

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Java Beans • 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. • 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. • 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 • JavaBeans Network Component Computing Model

  4. Java Beans in the Java Enterprise Architecture

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

  6. Java Beans: Create a Java Bean • 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) • 2. Copy the Bean file to C:\BDK1.0\jars • 3. Test the Bean in the BeanBox.

  7. Java Beans: JAR Files • 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. • A JAR file consists of a normal ZIP format file, plus an optional manifest file describing the JAR contents. • You can use the JDK 1.1 jar command to create and read JAR files. • Manifest file: Each JAR file may contest a manifest file describing the contents of the JAR file.

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

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

  11. Java BeanBox

More Related