Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.

JSR 217 (Maintenance Release)

java.beans
Class Beans

java.lang.Object
  extended byjava.beans.Beans

public class Beans
extends Object

This class provides some general purpose beans control methods.


Constructor Summary
Beans()
           
 
Method Summary
static Object instantiate(ClassLoader cls, String beanName)
           Instantiate a JavaBean.
static boolean isDesignTime()
          Test if we are in design-mode.
static boolean isGuiAvailable()
          Determines whether beans can assume a GUI is available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Beans

public Beans()
Method Detail

instantiate

public static Object instantiate(ClassLoader cls,
                                 String beanName)
                          throws IOException,
                                 ClassNotFoundException

Instantiate a JavaBean.

The bean is created based on a name relative to a class-loader. This name should be a dot-separated name such as "a.b.c".

In Beans 1.0 the given name can indicate either a serialized object or a class. Other mechanisms may be added in the future. In beans 1.0 we first try to treat the beanName as a serialized object name then as a class name.

When using the beanName as a serialized object name we convert the given beanName to a resource pathname and add a trailing ".ser" suffix. We then try to load a serialized object from that resource.

For example, given a beanName of "x.y", Beans.instantiate would first try to read a serialized object from the resource "x/y.ser" and if that failed it would try to load the class "x.y" and create an instance of that class.

Parameters:
cls - the class-loader from which we should create the bean. If this is null, then the system class-loader is used.
beanName - the name of the bean within the class-loader. For example "sun.beanbox.foobah"
Throws:
ClassNotFoundException - if the class of a serialized object could not be found.
IOException - if an I/O error occurs.

isDesignTime

public static boolean isDesignTime()
Test if we are in design-mode.

This method always returns false in this Profile.

Returns:
True if we are running in an application construction environment.

isGuiAvailable

public static boolean isGuiAvailable()
Determines whether beans can assume a GUI is available.

Returns:
True if we are running in an environment where beans can assume that an interactive GUI is available, so they can pop up dialog boxes, etc. This will normally return true in a windowing environment, and will normally return false in a server environment or if an application is running as part of a batch job.
See Also:
Visibility

JSR 217 (Maintenance Release)

Copyright © 2006 Sun Microsystems, Inc. All rights reserved. Use is subject to License Terms. Your use of this web site or any of its content or software indicates your agreement to be bound by these License Terms.

For more information, please consult the JSR 217 specification.