public interface EventContext
Contains methods for registering/deregistering listeners to be notified of events fired when objects named in a context changes.
If a service only supports registration for existing targets, an attempt to register for a nonexistent target results in a NameNotFoundException being thrown as early as possible, preferably at the time addNamingListener() is called, or if that is not possible, the listener will receive the exception through the NamingExceptionEvent.
Also, for service providers that only support registration for existing targets, when the target that a listener has registered for is subsequently removed from the namespace, the listener is notified via a NamingExceptionEvent (containing a NameNotFoundException).
An application can use the method targetMustExist() to check whether a EventContext supports registration of nonexistent targets.
For example, suppose a listener makes the following registration:
When an object named "x/y" is subsequently deleted, the corresponding NamingEvent (evt) must contain:
NamespaceChangeListener listener = ...; src.addNamingListener("x", SUBTREE_SCOPE, listener);
evt.getEventContext() == src evt.getOldBinding().getName().equals("x/y")
Furthermore, listener registration/deregistration is with the EventContext instance, and not with the corresponding object in the namespace. If the program intends at some point to remove a listener, then it needs to keep a reference to the EventContext instance on which it invoked addNamingListener() (just as it needs to keep a reference to the listener in order to remove it later). It cannot expect to do a lookup() and get another instance of a EventContext on which to perform the deregistration.
| Field Summary | |
|---|---|
static int |
OBJECT_SCOPE
Constant for expressing interest in events concerning the object named by the target. |
static int |
ONELEVEL_SCOPE
Constant for expressing interest in events concerning objects in the context named by the target, excluding the context named by the target. |
static int |
SUBTREE_SCOPE
Constant for expressing interest in events concerning objects in the subtree of the object named by the target, including the object named by the target. |
| Fields inherited from interface javax.naming.Context |
|---|
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES |
| Method Summary | |
|---|---|
void |
addNamingListener(Name target,
int scope,
NamingListener l)
Adds a listener for receiving naming events fired when the object(s) identified by a target and scope changes. |
void |
addNamingListener(String target,
int scope,
NamingListener l)
Adds a listener for receiving naming events fired when the object named by the string target name and scope changes. |
void |
removeNamingListener(NamingListener l)
Removes a listener from receiving naming events fired by this EventContext. |
boolean |
targetMustExist()
Determines whether a listener can register interest in a target that does not exist. |
| Methods inherited from interface javax.naming.Context |
|---|
addToEnvironment, bind, bind, close, composeName, composeName, createSubcontext, createSubcontext, destroySubcontext, destroySubcontext, getEnvironment, getNameInNamespace, getNameParser, getNameParser, list, list, listBindings, listBindings, lookup, lookup, lookupLink, lookupLink, rebind, rebind, removeFromEnvironment, rename, rename, unbind, unbind |
| Field Detail |
|---|
static final int OBJECT_SCOPE
The value of this constant is 0.
static final int ONELEVEL_SCOPE
The value of this constant is 1.
static final int SUBTREE_SCOPE
The value of this constant is 2.
| Method Detail |
|---|
void addNamingListener(Name target, int scope, NamingListener l) throws NamingException
target needs to name a context only when scope is ONELEVEL_SCOPE. target may name a non-context if scope is either OBJECT_SCOPE or SUBTREE_SCOPE. Using SUBTREE_SCOPE for a non-context might be useful, for example, if the caller does not know in advance whether target is a context and just wants to register interest in the (possibly degenerate subtree) rooted at target.
When the listener is notified of an event, the listener may in invoked in a thread other than the one in which addNamingListener() is executed. Care must be taken when multiple threads are accessing the same EventContext concurrently. See the package description for more information on threading issues.
target - A nonnull name to be resolved relative to this context.scope - One of OBJECT_SCOPE, ONELEVEL_SCOPE, or
SUBTREE_SCOPE.l - The nonnull listener.
NamingException - If a problem was encountered while
adding the listener.removeNamingListener(javax.naming.event.NamingListener)void addNamingListener(String target, int scope, NamingListener l) throws NamingException
target - The nonnull string name of the object resolved relative
to this context.scope - One of OBJECT_SCOPE, ONELEVEL_SCOPE, or
SUBTREE_SCOPE.l - The nonnull listener.
NamingException - If a problem was encountered while
adding the listener.removeNamingListener(javax.naming.event.NamingListener)void removeNamingListener(NamingListener l) throws NamingException
l - The nonnull listener.
NamingException - If a problem was encountered while
removing the listener.addNamingListener(javax.naming.Name, int, javax.naming.event.NamingListener)
boolean targetMustExist()
throws NamingException
NamingException - If the context's behavior in this regard cannot
be determined.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.
7 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)