package.html revision 3909
1178N/A<!--
1178N/A Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
1178N/A DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1178N/A
1178N/A This code is free software; you can redistribute it and/or modify it
1178N/A under the terms of the GNU General Public License version 2 only, as
1178N/A published by the Free Software Foundation. Oracle designates this
1178N/A particular file as subject to the "Classpath" exception as provided
1178N/A by Oracle in the LICENSE file that accompanied this code.
1178N/A
1178N/A This code is distributed in the hope that it will be useful, but WITHOUT
1178N/A ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1178N/A FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1178N/A version 2 for more details (a copy is included in the LICENSE file that
1178N/A accompanied this code).
1178N/A
1178N/A You should have received a copy of the GNU General Public License version
2362N/A 2 along with this work; if not, write to the Free Software Foundation,
2362N/A Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A
1178N/A Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1178N/A or visit www.oracle.com if you need additional information or have any
1178N/A questions.
1178N/A-->
1178N/A
1178N/A<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
1178N/A<html>
1178N/A<body bgcolor="white">
1178N/A
1178N/AContains classes related to developing
1178N/A<em>beans</em> -- components
1178N/Abased on the JavaBeans&trade; architecture.
1178N/AA few of the
1178N/Aclasses are used by beans while they run in an application.
1178N/AFor example, the event classes are
1178N/Aused by beans that fire property and vetoable change
1178N/Aevents (see
1178N/A{@link java.beans.PropertyChangeEvent}). However, most of the classes in this
0N/Apackage are meant to be used by a bean editor (that is, a development environment
1178N/Afor customizing and putting together beans to create an application). In
1178N/Aparticular, these classes help the bean editor create a user
1178N/Ainterface that the user can use to customize the bean. For example, a bean may
1178N/Acontain a property of a special type that a bean editor may not know how to handle.
1178N/ABy using the <code>PropertyEditor</code> interface, a bean developer can
1178N/Aprovide an editor for this special type.
1178N/A
1178N/A<p>
1178N/ATo minimize the resources used by a bean, the classes used by bean editors are loaded only
1178N/Awhen the bean is being edited. They are not needed while the bean is running in an application
1178N/Aand therefore not loaded. This information is kept in what's called a bean-info (see {@link java.beans.BeanInfo}).
1178N/A
1178N/A<p>
1178N/AUnless explicitly stated, null values or empty Strings are not valid
1178N/Aparameters for the methods in this package. You may expect to see
1178N/Aexceptions if these parameters are used.
1178N/A
1178N/A
1178N/A<h2>Long-Term Persistence</h2>
0N/A
1178N/AAs of v1.4,
1178N/Athe <code>java.beans</code> package provides support for
1178N/A<em>long-term persistence</em> -- reading and
1178N/Awriting a bean as a textual representation of its property values.
1178N/AThe property values are treated as beans,
1178N/Aand are recursively read or written to capture
1178N/Atheir publicly available state.
1178N/AThis approach is suitable for long-term storage
1178N/Abecause it relies only on public API,
1178N/Arather than the likely-to-change private implementation.
1178N/A
1178N/A<blockquote>
1178N/A<hr>
1178N/A<b>Note:</b>
1178N/AThe persistence scheme cannot automatically instantiate
1178N/Acustom inner classes, such as you might use for event handlers.
1178N/ABy using the {@link java.beans.EventHandler} class
1178N/Ainstead of inner classes for custom event handlers,
1178N/Ayou can avoid this problem.
1178N/A<hr>
0N/A</blockquote>
1178N/A
0N/A<p>
1178N/A
0N/AYou read and write beans in XML format using the
1178N/A{@link java.beans.XMLDecoder}
0N/Aand
1178N/A{@link java.beans.XMLEncoder}
1178N/Aclasses, respectively.
1178N/AOne notable feature of the persistence scheme is that
1178N/Areading in a bean requires no special knowledge of the bean.
1178N/A
1178N/A<p>
1178N/AWriting out a bean, on the other hand,
1178N/Asometimes requires special knowledge of the bean's type.
1178N/AIf the bean's state can be
0N/Aexpressed using only the no-argument constructor and
1178N/Apublic getter and setter methods for properties,
1178N/Ano special knowledge is required.
1178N/AOtherwise, the bean requires a custom <em>persistence delegate</em> --
1178N/Aan object that is in charge of writing out beans of a particular type.
1178N/AAll classes provided in the JDK that descend
1178N/Afrom <code>java.awt.Component</code>,
1178N/Aas well as all their properties,
1178N/Aautomatically have persistence delegates.
1178N/A
1178N/A<p>
1178N/A
0N/AIf you need (or choose) to provide a persistence delegate for a bean,
1178N/Ayou can do so either by using a
1178N/A{@link java.beans.DefaultPersistenceDelegate}
1178N/Ainstance
1178N/Aor by creating your own subclass of <code>PersistenceDelegate</code>.
1178N/AIf the only reason a bean needs a persistence delegate
1178N/Ais because you want to invoke the bean's constructor with
1178N/Aproperty values as arguments,
1178N/Ayou can create the bean's persistence delegate
1178N/Awith the one-argument
1178N/A<code>DefaultPersistenceDelegate</code>
1178N/Aconstructor.
1178N/AOtherwise,
1178N/Ayou need to implement your own persistence delegate,
0N/Afor which you're likely to need the following classes:
1178N/A
1178N/A<dl>
1178N/A<dt> {@link java.beans.PersistenceDelegate}
1178N/A<dd> The abstract class from which all persistence delegates descend.
1178N/A Your subclass should use its knowledge of the bean's type to provide
1178N/A whatever <code>Statement</code>s and <code>Expression</code>s
1178N/A are necessary to create the bean
1178N/A and restore its state.
1178N/A<dt> {@link java.beans.Statement}
1178N/A<dd> Represents the invocation of a single method on an object.
1178N/A Includes a set of arguments to the method.
1178N/A<dt> {@link java.beans.Expression}
1178N/A<dd> A subclass of <code>Statement</code>
1178N/A used for methods that return a value.
1178N/A</dl>
1178N/A
1178N/A<p>
1178N/AOnce you create a persistence delegate,
1178N/Ayou register it using the
1178N/A<code>setPersistenceDelegate</code> method of
1178N/A<code>XMLEncoder</code>.
1178N/A
1178N/A
1178N/A<h2>Related Documentation</h2>
1178N/A
1178N/AFor overview, architecture, and tutorial documentation, please see:
1178N/A<ul>
1178N/A <li><a href="http://java.sun.com/docs/books/tutorial/javabeans/">JavaBeans</a>, a trail in <em>The Java Tutorial</em>.
1178N/A <li><a href="http://java.sun.com/products/jfc/tsc/articles/persistence2/">Long-Term Persistence</a>, an article in <em>The Swing Connection</em>.
1178N/A</ul>
1178N/A<p>
1178N/A
1178N/A</body>
1178N/A</html>
1178N/A