Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
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. 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), Network Computing: Java Beans JavaBeans Network Component Computing Model JavaBeans OSes Supported Virtually all HTTP Servers Supported JavaSoft’s Java Web Server; others to come Programming Languages Java Component Model JavaBeans Network Component Model CORBA IIOP or Java RMI Java Beans in the Java Enterprise Architecture 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. 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. 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. 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. 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 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) Java BeanBox