beans

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » beans 
OpenJDK: beans
License:The GNU General Public License (GPL)
URL:https://openjdk.dev.java.net
Description:
Package NameComment
java.beans Contains classes related to developing beans -- components based on the JavaBeansTM architecture. A few of the classes are used by beans while they run in an application. For example, the event classes are used by beans that fire property and vetoable change events (see {@link java.beans.PropertyChangeEvent}). However, most of the classes in this package are meant to be used by a bean editor (that is, a development environment for customizing and putting together beans to create an application). In particular, these classes help the bean editor create a user interface that the user can use to customize the bean. For example, a bean may contain a property of a special type that a bean editor may not know how to handle. By using the PropertyEditor interface, a bean developer can provide an editor for this special type.

To minimize the resources used by a bean, the classes used by bean editors are loaded only when the bean is being edited. They are not needed while the bean is running in an application and therefore not loaded. This information is kept in what's called a bean-info (see {@link java.beans.BeanInfo}).

Unless explicitly stated, null values or empty Strings are not valid parameters for the methods in this package. You may expect to see exceptions if these parameters are used.

Long-Term Persistence

As of v1.4, the java.beans package provides support for long-term persistence -- reading and writing a bean as a textual representation of its property values. The property values are treated as beans, and are recursively read or written to capture their publicly available state. This approach is suitable for long-term storage because it relies only on public API, rather than the likely-to-change private implementation.

Note: The persistence scheme cannot automatically instantiate custom inner classes, such as you might use for event handlers. By using the {@link java.beans.EventHandler} class instead of inner classes for custom event handlers, you can avoid this problem.

You read and write beans in XML format using the {@link java.beans.XMLDecoder} and {@link java.beans.XMLEncoder} classes, respectively. One notable feature of the persistence scheme is that reading in a bean requires no special knowledge of the bean.

Writing out a bean, on the other hand, sometimes requires special knowledge of the bean's type. If the bean's state can be expressed using only the no-argument constructor and public getter and setter methods for properties, no special knowledge is required. Otherwise, the bean requires a custom persistence delegate -- an object that is in charge of writing out beans of a particular type. All classes provided in the JDK that descend from java.awt.Component, as well as all their properties, automatically have persistence delegates.

If you need (or choose) to provide a persistence delegate for a bean, you can do so either by using a {@link java.beans.DefaultPersistenceDelegate} instance or by creating your own subclass of PersistenceDelegate. If the only reason a bean needs a persistence delegate is because you want to invoke the bean's constructor with property values as arguments, you can create the bean's persistence delegate with the one-argument DefaultPersistenceDelegate constructor. Otherwise, you need to implement your own persistence delegate, for which you're likely to need the following classes:

{@link java.beans.PersistenceDelegate}
The abstract class from which all persistence delegates descend. Your subclass should use its knowledge of the bean's type to provide whatever Statements and Expressions are necessary to create the bean and restore its state.
{@link java.beans.Statement}
Represents the invocation of a single method on an object. Includes a set of arguments to the method.
{@link java.beans.Expression}
A subclass of Statement used for methods that return a value.

Once you create a persistence delegate, you register it using the setPersistenceDelegate method of XMLEncoder.

Related Documentation

For overview, architecture, and tutorial documentation, please see:

java.beans.beancontext Provides classes and interfaces relating to bean context. A bean context is a container for beans and defines the execution environment for the beans it contains. There can be several beans in a single bean context, and a bean context can be nested within another bean context. This package also contains events and listener interface for beans being added and removed from a bean context. @since 1.2
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.