What is Javabean?
1. Javabean and EJB (1) JavaBean and EJB specification have a common goal in the following: The Java program code is promoted through standard design patterns, enhances the repetitive applicability of development process and development tools. But the original problem of these two specifications is to solve different problems. Standard specification defined in the JavaBean component model, is designed to generate repeatable components, which are typically used for IDE development tools, and is usually visualizing components, of course, is not necessarily visualization components. (2) EJB specification The components defined are just the Java program used to develop the server. Since EJB may perform on a different server platform, including the large host without graphics, EJB cannot use AWT or SWING. Class graphics library .2.javabean and classification of class libraries: (1) Not all useful modules must be converted to bean. Bean is mainly to be used to visualize the operation to complete some effects. (2) Class library is a valid operation for providing function operations to the programmer, but does not benefit from visualization operations. (3) For example, provide an API of JDBC database access as a class library than A bean is better because the core of JDBC is to use a programmable API, which is not capable of directly displaying visualization. However, writing a log library Access bean is still meaningful in the top of the JDBC. For example, you can write a custom "SELECT" bean to help the user to form a query statement, and run this query statement with JDBC when running, and display the result set. 3. Javabean and Visual Programming 3.1 Visual Programming (1) Turning the components from the component board to the form by visual programming tools such as VB, Delphi, etc., when you are dragging, the program development tool begins to write code for you, these The code allows this component to be generated during program execution. (2) Just dragging the component to the form, usually not completing the program, usually you have to change the nature of the component such as color, text, connection database, etc .. The modified nature is called "attribute", and you can modify the properties of the component in the program development tool, which is built, and the configuration will be stored. When the program is executed, these settings can reply. (3) in the design During the period, a total of the visual components represents an event, meaning that these things can happen on this component. (4) The program development tool uses the reflex mechanism ("Reflection") mechanism dynamic query component, and finds the component Supported attributes, and events, after you know this information, it can display its properties and allow you to change, while displaying available events. 3.2javabean can be seen in the above visual programming programming programming programming, component It is a program code. By being deposited as Class, the key in program development tools discovers the properties and events of the component. VB and Delphi are achieved by a mechanism, while Java will develop visual components through JavaBeans. Enter a higher realm, because a bean is a class. For the above content, JavaBean has the following rules (1) For a attribute called XXX, you usually write two functions, getxxx () and setxxx ( (2) You can use the GET / SET method to handle Boolean, you can use IS to replace GET. (3) Bean's general function does not need to comply with the above naming rules, but need to be public. (4) for events, you You can use Swing listener processes. 3.3.3Javabean Key Technologies (1) Part of the BEAN architecture is that the program development tool can generate beans when dragging the Bean from the component disk Palette to the form (FORM). There is a default constructor, to get it), then all necessary information for "Producing the Property Sheet" and the event handler in the absence of the bean source code. (2) Java's Reflection can make We found any of all unknown functions,
The REFLECTION mechanism is used to solve the problem of Bean, very perfect, no need to use additional language keywords like other visualized languages. ** In fact, the Reflection mechanism will be added to Java's main reasons to support Beans (of course Reflection also provides the necessary skills for the serialization and remote method invocation). So, you may expect that the designer of the program development tool should use the reflection on each bean. Mechanism, find its functions, find BEAN's properties and events. (3) Java designers want to provide a standard tool, not only make BEANs more easy to use, but also provide standard ways to produce more complex beans. This tool is Introspector Class. The most important thing is Static getBeanInfo (). You can pass a Class Reference to this function, it will check the Class and return to the BeanInfo object. Then you can dissect it, get its properties, function ( Methods, events (event) .3.4 Bean Packaging Put Beans Before you support Bean's visual development tool, you must first put it in a standard Bean container. The so-called standard Bean container is a JAR file, including all Bean classes and a list of list files (Manifest File) The system structure of the JavaBean is the first comprehensive component-based standard model. In the integrated IDE, the JavaBean can be operated in design. (The component model is as follows :)
JavaBean component model provides developers with a standard way to define a Java class so that its components provide their properties, events and inner view information, which provides their properties, events, and inner view information, which provides their properties, events, and inner view information based on the various attributes definition models. Customization to achieve the purpose of bean itself during design. 6. JavaBean programming basic requirements: If you want to create a product class bean, remember the following things: (1) make the BEAN, better, but pay attention to whether the current browser supports small bean beans may result in tool lag Continue to lead the browser to lag, eventually leading to the JDK itself lag. If you have to use the classes of the Tie, or the nature of Bean requires Bean, you should consider using your bean as a plugin and send it in a self-contained JAR, or if possible, make it your own Small installation process. You will lose some of the advantages of some small beans: Web administrators must perform more steps: Remind users to download and install your JAR or installer online surfers before browsing the web page, you must perform a step: Browse the web page Before you download and install your JAR or installer. (2) Separate all translation text, including a short description and characteristics of Name and beans, including name and beans, are divided into .properties files. JAR wizards do this for you. You need to remember that both you have done is: Features Editor and customizers. Customizer, dialog feature editor, or all terms in the Selective Features Editor, such as high, medium, low, must also be separated by translation. Ideally, you can also actually translate beans and provide a .properties file in a variety of languages in Bean's JAR. However, if you provide at least the local language.properties file, the third party can translate beans for you. (3) Specifying Depends-ON in the file list: Tagging to identify all files in Bean's JAR as "Running requires VS. only when editing". All files needed at runtime will be listed on the JAR inventory file dependent: label. The JAR wizard release label makes this operation very simple and gives you a list of files. If you don't specify dependencies: labels, the tool will assume that all files are required at runtime. This is not good for downloading performance (eg, unnecessary download features editor and other files needed only when editing). (4) Give your bean a clear preferred size bean will implement the getPreferredSize method so that it is good when it is first constructed in a keyword characteristic that may not be defined. If the first place is placed, the bean is 0 x 0 pixels, then the user may be confused. When changing keyword features, the preferred size should work normally. For example, if the bean has a characteristic between vertical and horizontal orientation, the preferred size should be written to adjust itself accordingly. (5) Specify the default feature of the BEAN to use the default characteristic part of the JavaBean specification, which will make your bean are easy to use in some tools. JAR will make this operation simple and get BeanInfo right. (6) Specify a brief non-technical name and short description for Bean and its characteristics to find brief non-technical names instead of lengthy technical terms. For example, use SUM Interval instead of AccumulatorInterval. Also note that the preferences of the characterist name are indicated by lowercase and have spaces between the words and words, which will be more friendly for users. (7) Reduce the user-visible characteristics range to beans provide a clear beanfo to not display each instance variable as a BEAN, and do not display each method as a bean operation.