java.lang.Objectjava.beans.Beans
public class Beans
This class provides some general purpose beans control methods.
| Constructor Summary | |
|---|---|
Beans()
|
|
| Method Summary | |
|---|---|
static Object |
getInstanceOf(Object bean,
Class<?> targetType)
From a given bean, obtain an object representing a specified type view of that source object. |
static Object |
instantiate(ClassLoader cls,
String beanName)
Instantiate a JavaBean. |
static Object |
instantiate(ClassLoader cls,
String beanName,
BeanContext beanContext)
Instantiate a JavaBean. |
static Object |
instantiate(ClassLoader cls,
String beanName,
BeanContext beanContext,
AppletInitializer initializer)
Instantiate a bean. |
static boolean |
isDesignTime()
Test if we are in design-mode. |
static boolean |
isGuiAvailable()
Determines whether beans can assume a GUI is available. |
static boolean |
isInstanceOf(Object bean,
Class<?> targetType)
Check if a bean can be viewed as a given target type. |
static void |
setDesignTime(boolean isDesignTime)
Used to indicate whether of not we are running in an application builder environment. |
static void |
setGuiAvailable(boolean isGuiAvailable)
Used to indicate whether of not we are running in an environment where GUI interaction is available. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Beans()
| Method Detail |
|---|
public static Object instantiate(ClassLoader cls, String beanName) throws IOException, ClassNotFoundException
Instantiate a JavaBean.
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"
ClassNotFoundException - if the class of a serialized
object could not be found.
IOException - if an I/O error occurs.public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext) throws IOException, ClassNotFoundException
Instantiate a JavaBean.
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"beanContext - The BeanContext in which to nest the new bean
ClassNotFoundException - if the class of a serialized
object could not be found.
IOException - if an I/O error occurs.public static Object instantiate(ClassLoader cls, String beanName, BeanContext beanContext, AppletInitializer initializer) throws IOException, ClassNotFoundException
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.
If the bean is a subtype of java.applet.Applet, then it is given some special initialization. First, it is supplied with a default AppletStub and AppletContext. Second, if it was instantiated from a classname the applet's "init" method is called. (If the bean was deserialized this step is skipped.)
Note that for beans which are applets, it is the caller's responsiblity to call "start" on the applet. For correct behaviour, this should be done after the applet has been added into a visible AWT container.
Note that applets created via beans.instantiate run in a slightly different environment than applets running inside browsers. In particular, bean applets have no access to "parameters", so they may wish to provide property get/set methods to set parameter values. We advise bean-applet developers to test their bean-applets against both the JDK appletviewer (for a reference browser environment) and the BDK BeanBox (for a reference bean container).
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"beanContext - The BeanContext in which to nest the new beaninitializer - The AppletInitializer for the new bean
ClassNotFoundException - if the class of a serialized
object could not be found.
IOException - if an I/O error occurs.public static Object getInstanceOf(Object bean, Class<?> targetType)
The result may be the same object or a different object. If the requested target view isn't available then the given bean is returned.
This method is provided in Beans 1.0 as a hook to allow the addition of more flexible bean behaviour in the future.
bean - Object from which we want to obtain a view.targetType - The type of view we'd like to get.public static boolean isInstanceOf(Object bean, Class<?> targetType)
bean - Bean from which we want to obtain a view.targetType - The type of view we'd like to get.
public static boolean isDesignTime()
DesignModepublic static boolean isGuiAvailable()
Visibility
public static void setDesignTime(boolean isDesignTime)
throws SecurityException
Note that this method is security checked
and is not available to (for example) untrusted applets.
More specifically, if there is a security manager,
its checkPropertiesAccess
method is called. This could result in a SecurityException.
isDesignTime - True if we're in an application builder tool.
SecurityException - if a security manager exists and its
checkPropertiesAccess method doesn't allow setting
of system properties.SecurityManager.checkPropertiesAccess()
public static void setGuiAvailable(boolean isGuiAvailable)
throws SecurityException
Note that this method is security checked
and is not available to (for example) untrusted applets.
More specifically, if there is a security manager,
its checkPropertiesAccess
method is called. This could result in a SecurityException.
isGuiAvailable - True if GUI interaction is available.
SecurityException - if a security manager exists and its
checkPropertiesAccess method doesn't allow setting
of system properties.SecurityManager.checkPropertiesAccess()Ces informations proviennent du site de http://java.sun.com
Le contenu de cette page provient du site de Sun, et est généré depuis un cache sur l'infobrol après certains traitements automatisés. La présentation peut donc différer du document original, mais le contenu aussi. Vous pouvez utiliser ce bouton pour afficher la page originale du site de Sun :
Maintenir les pages en cache sur différents sites peut offrir plus de disponibilité.
Chaque page est indexée dans la base de donnée, ce qui permet de retrouver facilement les informations, au moyen des sommaires, du moteur de recherche interne, etc.
Des facilités sont mises en place pour que les membres de l'infobrol puissent effectuer des traductions en français des différents documents. Ceci devrait permettre aux débutants en programmation Java de consulter les API en français s'ils maîtrisent moins bien la langue de Shakespeare. Dans le cas où une traduction a été soumise, elle est disponible au moyen d'un lien en bas de page. Si la traduction a été validée, la page s'affiche par défaut en français, et un lien en bas de page permet d'atteindre la version en anglais.
Le code sur l'infobrol est automatiquement coloré selon la syntaxe, et les différents mots clés sont transformés en liens pour accéder rapidement aux informations.
Vous avez la possibilité de partager vos expériences en proposant vos propres extraits de code en utilisant le bouton "ajouter un commentaire" en bas de page. Si vous visitez simplement l'infobrol, vous avez déjà accès à cette fonction, mais si vous étes membre du brol, vous pouvez en plus utiliser des boutons supplémentaires de mise en forme, dont la coloration automatique de vos extraits de codes.
Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher les interactions avec les réseaux sociaux sur ces pages.
5 mots clés dont 0 définis manuellement (plus d'information...).
Avertissement
Cette page ne possède pas encore de mots clés manuels, ceci est donc un exemple automatique (les niveaux de pertinence sont fictifs, mais les liens sont valables). Pour tester le nuage avec une page qui contient des mots définis manuellement, vous pouvez cliquer ici.Vous pouvez modifier vos préférences dans votre profil pour ne plus afficher le nuage de mots clés.
Recherche (afficher)
Utilisateur (masquer)
Navigation (masquer)
Apparence (afficher)
Stats (afficher)
Citation (masquer)