Class InitialEventContext
java.lang.Object
nl.tudelft.simulation.naming.context.event.InitialEventContext
- All Implemented Interfaces:
ContextInterface,EventContext,EventContextInterface,org.djutils.event.EventProducer
InitialEventContext class. This class is the starting context for performing naming operations. The class is loosely based on
InitialContext in the Java JNDI package, but creates a lightweight Context that implements the DSOL ContextInterface. The
InitialEventContext is a singleton class.
Copyright (c) 2002-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
- Author:
- Alexander Verbraeck
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe event producer to which context events will be delegated for handling.protected ContextInterfaceThe initial context, usually built by a factory.protected booleanhas the default context been generated?static final StringConstant that holds the name of the environment property for specifying the initial context factory to use.protected Hashtable<?,?> the properties of the initialEventContext.static final StringConstant that holds the name of the environment property for specifying configuration information for the service provider to use.static final StringConstant that holds the name of the environment property for specifying the initial context factory to use, as embedded factory in a remote context that is specified by the INITIAL_CONTEXT_FACTORY constant.Fields inherited from interface nl.tudelft.simulation.naming.context.ContextInterface
OBJECT_ADDED_EVENT, OBJECT_CHANGED_EVENT, OBJECT_REMOVED_EVENT, REPLACE_SEPARATOR, ROOT, SEPARATORFields inherited from interface org.djutils.event.EventProducer
FIRST_POSITION, LAST_POSITION -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) Add a listener for the provided scope as strong reference to the BEGINNING of a queue of listeners.booleanaddListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position) Add a listener for the provided scope as strong reference to the specified position of a queue of listeners.booleanaddListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position, org.djutils.event.reference.ReferenceType referenceType) Add a listener for the provided scope to the specified position of a queue of listeners.booleanaddListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, org.djutils.event.reference.ReferenceType referenceType) Add a listener for the provided scope to the BEGINNING of a queue of listeners.booleanaddListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType) booleanaddListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, int position) booleanaddListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, int position, org.djutils.event.reference.ReferenceType referenceType) booleanaddListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, org.djutils.event.reference.ReferenceType referenceType) voidBinds an object into the Context using the name.bindings()Returns a (raw) map of bindings in the current context, mapping the name on the registered objects.voidbindObject(Object object) Binds an object into the Context using the toString() method of the object as the key.voidbindObject(String key, Object object) Binds an object into this Context using the key.protected Hashtable<?,?> buildEnvironment(Hashtable<?, ?> environment) Build the properties that the generation of the initial event context will use.voidcheckCircular(Object newObject) Check whether a circular reference would occur when the object would be inserted into the current context.voidclose()Closes the context and removes all content from the context.createSubcontext(String name) Creates and binds a new context into the current Context using the name.voiddestroySubcontext(String name) Removes the binding for an existing, empty subcontext with the given name, and recursively unbinds all objects and contexts in the context indicated by the name.booleanIndicates whether an object with the given name has been registered in the Context.voidFire an OBJECT_CHANGED_EVENT for an object with the given key in the current context.voidfireObjectChangedEventValue(Object object) Fire an OBJECT_CHANGED_EVENT for an object within the current context.Retrieves the named object from the Context.Returns the absolute path for this context, or an empty string when this is the root context.Retrieves the atomic name of this context.protected ContextInterfacegetDefaultInitCtx(String atomicName) Retrieves the initial context by calling NamingManager.getInitialContext() and cache it in defaultInitCtx.Hashtable<?,?> Return a safe copy of the used environment variables.org.djutils.event.EventListenerMapRetrieves the named object from the Context.Retrieves the parent context for this context, or null when this is the root context.Retrieves the root context for this context, or the current context when this is the root context.booleanIndicates whether the key has been registered in the current Context.booleanIndicates whether the object has been registered (once or more) in the current Context.protected voidInitializes the initial context using the supplied environment.static InitialEventContextinstantiate(String atomicName) Constructs an initial context using the supplied environment; no overriding environment variables are provided.static InitialEventContextinstantiate(Hashtable<?, ?> environment, String atomicName) Constructs an initial context using the supplied environment.booleanisEmpty()Indicates whether the current context is empty.keySet()Returns a set of registered keys in the current context.voidReplaces an object in the Context with the given name, or registers the object when a registration with the name does not exist yet.voidrebindObject(String key, Object object) Replaces an object in this Context with the given key, or registers the object when a registration with the key does not exist yet.intbooleanremoveListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) Remove the subscription of a listener for the provided scope for a specific event.booleanremoveListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType) voidReplaces the name under which an object has been registered in the Context.toString()toString(boolean verbose) Return a String with the hierarchical content of the Context in case verbose is true; otherwise return the atomic name.voidRemoves the binding for an object in the Context with the given name.voidunbindObject(String key) Removes the binding for an object in this Context with the given key.values()Returns a (raw) collection of registered values in the current context.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.djutils.event.EventProducer
fireEvent, fireEvent, fireEvent, fireTimedEvent, fireTimedEvent, fireTimedEvent, fireUnverifiedEvent, fireUnverifiedEvent, fireUnverifiedTimedEvent, fireUnverifiedTimedEvent, getEventTypesWithListeners, getListenerReferences, hasListeners, numberOfListeners, removeAllListeners
-
Field Details
-
INITIAL_CONTEXT_FACTORY
Constant that holds the name of the environment property for specifying the initial context factory to use. The value of the property should be the fully qualified class name of the factory class that will create an initial context. This property may be specified in the environment parameter passed to the initial context constructor, a system property, or an application resource file. If it is not specified in any of these sources,NoInitialContextExceptionis thrown when an initial context is required to complete an operation.The value of this constant is "java.naming.factory.initial".
- See Also:
-
PROVIDER_URL
Constant that holds the name of the environment property for specifying configuration information for the service provider to use. The value of the property should contain a URL string (e.g. "http://localhost:1099/remoteContext"). This property may be specified in the environment, a system property, or a resource file. If it is not specified in any of these sources, the default configuration is determined by the service provider.The value of this constant is "java.naming.provider.url".
- See Also:
-
WRAPPED_CONTEXT_FACTORY
Constant that holds the name of the environment property for specifying the initial context factory to use, as embedded factory in a remote context that is specified by the INITIAL_CONTEXT_FACTORY constant. The value of the property should be the fully qualified class name of the factory class that will create an initial context that will be embedded within the remote context. This property may be specified in the environment parameter passed to the initial context constructor, a system property, or an application resource file. If it is not specified in any of these sources,NoInitialContextExceptionis thrown when an initial context is required to complete an operation.The value of this constant is "wrapped.naming.factory.initial".
- See Also:
-
properties
the properties of the initialEventContext. -
defaultInitCtx
The initial context, usually built by a factory. It is set by getDefaultInitCtx() the first time getDefaultInitCtx() is called. Subsequent invocations of getDefaultInitCtx() return the value of defaultInitCtx until close() is called. -
gotDefault
protected boolean gotDefaulthas the default context been generated? -
contextEventProducerImpl
The event producer to which context events will be delegated for handling.
-
-
Method Details
-
instantiate
Constructs an initial context using the supplied environment; no overriding environment variables are provided.- Parameters:
atomicName- the name under which the root context will be registered- Returns:
- a singleton instance of InitialEventContext
- Throws:
NamingException- when the provided ContextFactory was not able to instantiate the wrapped context
-
instantiate
public static InitialEventContext instantiate(Hashtable<?, ?> environment, String atomicName) throws NamingExceptionConstructs an initial context using the supplied environment.- Parameters:
environment- environment used to create the initial context. Null indicates an empty environment.atomicName- the name under which the root context will be registered- Returns:
- a singleton instance of InitialEventContext
- Throws:
NamingException- when the provided ContextFactory was not able to instantiate the wrapped context
-
init
Initializes the initial context using the supplied environment.- Parameters:
environment- environment used to create the initial context. Null indicates an empty environment.atomicName- the name under which the root context will be registered- Throws:
NamingException- when the provided ContextFactory was not able to instantiate the wrapped context
-
buildEnvironment
Build the properties that the generation of the initial event context will use. In sequence, the following sources of properties are explored: (1) default values, (2) system environment, (3) Java system properties, (4) content of the /resources/jndi.properties file, (5) the provided environment. If a property is available in a later evaluation, it takes precedence over an earlier definition.- Parameters:
environment- the final overwriting environment to use (can be null)- Returns:
- a combined Hashtable with information from system properties, jndi.properties and the provided environment Hashtable
-
getDefaultInitCtx
Retrieves the initial context by calling NamingManager.getInitialContext() and cache it in defaultInitCtx. SetgotDefaultso that we know we've tried this before.- Parameters:
atomicName- the name under which the root context will be registered- Returns:
- The non-null cached initial context.
- Throws:
NamingException- if a naming exception was encountered
-
getEnvironment
Return a safe copy of the used environment variables.- Returns:
- a safe copy of the used environment variables
-
close
Description copied from interface:ContextInterfaceCloses the context and removes all content from the context. No events will be fired that the content of the context has been removed. Some contexts, such as the FileContext could have to be really closed as well.- Specified by:
closein interfaceContextInterface- Throws:
NamingException- when a problem occurs during closing (e.g., of a FileContext)
-
getAtomicName
Description copied from interface:ContextInterfaceRetrieves the atomic name of this context.- Specified by:
getAtomicNamein interfaceContextInterface- Returns:
- the atomic name of this context
-
getParent
Description copied from interface:ContextInterfaceRetrieves the parent context for this context, or null when this is the root context.- Specified by:
getParentin interfaceContextInterface- Returns:
- parent context for this context, or null when this is the root context
-
getRootContext
Description copied from interface:ContextInterfaceRetrieves the root context for this context, or the current context when this is the root context.- Specified by:
getRootContextin interfaceContextInterface- Returns:
- the root context for this context
-
getAbsolutePath
Description copied from interface:ContextInterfaceReturns the absolute path for this context, or an empty string when this is the root context.- Specified by:
getAbsolutePathin interfaceContextInterface- Returns:
- the absolute path for this context, or an empty string when this is the root context
-
get
Description copied from interface:ContextInterfaceRetrieves the named object from the Context. The name may be a compound name where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts must exist. When name is the empty String or "/", the current Context is returned.- Specified by:
getin interfaceContextInterface- Parameters:
name- the name of the object to look up; may be a compound name- Returns:
- the Context or Object indicated by the name
- Throws:
NamingException- as a placeholder overarching exceptionNameNotFoundException- if an intermediate context or the reference does not exist
-
getObject
Description copied from interface:ContextInterfaceRetrieves the named object from the Context. The key is not compound. Key cannot be empty or contain "/".- Specified by:
getObjectin interfaceContextInterface- Parameters:
key- the name of the object to look up; NOT a compound name- Returns:
- the Context or Object indicated by the key
- Throws:
NamingException- when key is the empty string or when key contains "/"NameNotFoundException- if the key does not exist in the current context
-
exists
Description copied from interface:ContextInterfaceIndicates whether an object with the given name has been registered in the Context. The name may be a compound name where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts must exist. When name is the empty String or "/", the method returns true.- Specified by:
existsin interfaceContextInterface- Parameters:
name- the name of the object to look up; may be a compound name- Returns:
- whether an object with the given name has been registered
- Throws:
NamingException- as a placeholder overarching exceptionNameNotFoundException- when an intermediate context does not exist
-
hasKey
Description copied from interface:ContextInterfaceIndicates whether the key has been registered in the current Context. The name is not compound. When name is the empty String or "/", the method returns an exception.- Specified by:
hasKeyin interfaceContextInterface- Parameters:
key- the name of the object to look up; NOT compound- Returns:
- whether an object with the given key has been registered in the current context
- Throws:
NamingException- when key is the empty string or when key contains "/"
-
hasObject
Description copied from interface:ContextInterfaceIndicates whether the object has been registered (once or more) in the current Context. The object may be null.- Specified by:
hasObjectin interfaceContextInterface- Parameters:
object- the object to look up; mey be null- Returns:
- whether an object with the given key has been registered once or more in the current context
-
isEmpty
public boolean isEmpty()Description copied from interface:ContextInterfaceIndicates whether the current context is empty.- Specified by:
isEmptyin interfaceContextInterface- Returns:
- whether the current context is empty
-
bind
Description copied from interface:ContextInterfaceBinds an object into the Context using the name. The name may be a compound name where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts must already exist. The object will be registered using the terminal atomic reference in the deepest subcontext provided. Name cannot be empty or "/". An OBJECT_ADDED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the object when a new binding has taken place.- Specified by:
bindin interfaceContextInterface- Parameters:
name- the name under which the object will be stored; may be a compound name with the terminal reference indicating the key under which the object will be storedobject- the Context or Object to be stored into the given context; a null object is allowed- Throws:
NamingException- when the reference is "/" or emptyNameAlreadyBoundException- if name is already bound to an objectNameNotFoundException- when an intermediate context does not exist
-
bindObject
Description copied from interface:ContextInterfaceBinds an object into this Context using the key. The key is not compound. The key cannot be empty or "/". An OBJECT_ADDED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the object when a new binding has taken place.- Specified by:
bindObjectin interfaceContextInterface- Parameters:
key- the key under which the object will be stored; NOT a compound nameobject- the Context or Object to be stored into this Context using the given name; a null object is allowed- Throws:
NamingException- when key is the empty string or when key contains "/"NameAlreadyBoundException- if key is already bound to an object
-
bindObject
Description copied from interface:ContextInterfaceBinds an object into the Context using the toString() method of the object as the key. All "/" characters in the toString() result will be replaced by "#" characters. An OBJECT_ADDED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the object when a new binding has taken place.- Specified by:
bindObjectin interfaceContextInterface- Parameters:
object- the Context or Object to be stored into this Context using the toString() result as the key; a null object is not allowed- Throws:
NamingException- when the toString() of the object results in an empty stringNameAlreadyBoundException- if key is already bound to an object
-
unbind
Description copied from interface:ContextInterfaceRemoves the binding for an object in the Context with the given name. The name may be a compound name where parts are separated by separation strings indicating subcontexts. Name cannot be empty or "/". It is not a problem when there is no object registered with the given name. An OBJECT_REMOVED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the removed object when a binding has been removed.- Specified by:
unbindin interfaceContextInterface- Parameters:
name- the name of the object that has to be removed; may be a compound name with the terminal reference indicating the key under which the object is stored- Throws:
NamingException- when the reference is "/" or emptyNameNotFoundException- when an intermediate context does not exist
-
unbindObject
Description copied from interface:ContextInterfaceRemoves the binding for an object in this Context with the given key. The key is not compound. The key cannot be empty or "/". It is not a problem when there is no object registered with the given key. An OBJECT_REMOVED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the removed object when a binding has been removed.- Specified by:
unbindObjectin interfaceContextInterface- Parameters:
key- the key of the object that has to be removed; NOT a compound name- Throws:
NamingException- when key is the empty string or when key contains "/"
-
rebind
Description copied from interface:ContextInterfaceReplaces an object in the Context with the given name, or registers the object when a registration with the name does not exist yet. The name may be a compound name where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts must already exist. The object will be (re)registered using the terminal atomic reference in the deepest subcontext provided. Name cannot be empty or "/". An OBJECT_REMOVED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the removed object when a binding had to be removed, followed by an OBJECT_ADDED_EVENT containing an object array with a pointer to the context, the key, and the new object when a new binding has taken place.- Specified by:
rebindin interfaceContextInterface- Parameters:
name- the name of the object to be replaced, or under which the object will be stored; may be a compound name with the terminal reference indicating the key under which the object will be storedobject- the Context or Object to be replaced or stored into this Context using the given name; a null object is allowed- Throws:
NamingException- when the reference is "/" or emptyNameNotFoundException- when an intermediate context does not exist
-
rebindObject
Description copied from interface:ContextInterfaceReplaces an object in this Context with the given key, or registers the object when a registration with the key does not exist yet. The key is not a compound name. Name cannot be empty or "/". An OBJECT_REMOVED_EVENT is fired containing an object array with a pointer to the context, the relative key, and the removed object when a binding had to be removed, followed by an OBJECT_ADDED_EVENT containing an object array with a pointer to the context, the key, and the new object when a new binding has taken place.- Specified by:
rebindObjectin interfaceContextInterface- Parameters:
key- the key of the object to be replaced, or under which the object will be stored; NOT a compound nameobject- the Context or Object to be replaced or stored into this Context using the given name; a null object is allowed- Throws:
NamingException- when key is the empty string or when key contains "/"
-
rename
Description copied from interface:ContextInterfaceReplaces the name under which an object has been registered in the Context. Both names are relative to the current Context, and may be compound names where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts of the new name must already exist. The object will be deregistered under the old name, and reregistered using the terminal atomic reference in the deepest subcontext of the newName. Nether the oldName, nor the newName can be empty or "/". An OBJECT_REMOVED_EVENT is fired containing an object array with a pointer to the old context, the old relative key, and the object when a binding had to be removed, followed by an OBJECT_ADDED_EVENT containing an object array with a pointer to the new context, the new relative key, and the object when a new binding has taken place. When the new name is illegal or occupied, the object will not be renamed.- Specified by:
renamein interfaceContextInterface- Parameters:
oldName- the (compound) name of the object to be moved to a new locationnewName- the (compound) name with the terminal reference indicating where the object will be stored- Throws:
NamingException- when the reference of oldName or newName is "/" or emptyNameNotFoundException- when an intermediate context of oldName or newName does not exist, or when there is no registration at the oldName referenceNameAlreadyBoundException- if newName is already bound to an object
-
createSubcontext
Description copied from interface:ContextInterfaceCreates and binds a new context into the current Context using the name. The name may be a compound name where parts are separated by separation strings indicating subcontexts. All intermediate subcontexts that do not yet exist, will be created. The new context will be registered using the terminal atomic reference in the deepest subcontext provided. Name cannot be empty or "/". On success, OBJECT_ADDED_EVENTs are fired for the created context and each new intermediate context, containing an object array with an object array with a pointer to the embedding context, the local key in the embedding context, and the newly created (intermediate) context.- Specified by:
createSubcontextin interfaceContextInterface- Parameters:
name- the name under which the new context will be stored; may be a compound name with the terminal reference indicating the key under which the new context will be stored- Returns:
- a pointer to the newly created subcontext
- Throws:
NamingException- when the terminal reference is "/" or emptyNameNotFoundException- when an intermediate context does not existNameAlreadyBoundException- if name is already bound to an object or context
-
destroySubcontext
Description copied from interface:ContextInterfaceRemoves the binding for an existing, empty subcontext with the given name, and recursively unbinds all objects and contexts in the context indicated by the name. The name may be a compound name where parts are separated by separation strings indicating subcontexts. Name cannot be empty or "/". A context has to be registered with the given name. For all removed objects and contexts, OBJECT_REMOVED_EVENT events are fired containing an object array with a pointer to the context from which content has been removed, the key of the binding that has been removed, and the removed object. The OBJECT_REMOVED_EVENT events are fired in depth-first order.- Specified by:
destroySubcontextin interfaceContextInterface- Parameters:
name- the name of the object that has to be removed; may be a compound name with the terminal reference indicating the key under which the object is stored- Throws:
NamingException- when the reference is "/" or emptyNotContextException- if the name is bound but does not name a contextNameNotFoundException- when an intermediate context does not exist, or when no object is registered with the terminating atomic reference
-
checkCircular
Description copied from interface:ContextInterfaceCheck whether a circular reference would occur when the object would be inserted into the current context. Insertion potentially causes a problem when the object to be inserted is a Context.- Specified by:
checkCircularin interfaceContextInterface- Parameters:
newObject- the object to be inserted- Throws:
NamingException- when a circular reference would occur
-
keySet
Description copied from interface:ContextInterfaceReturns a set of registered keys in the current context.- Specified by:
keySetin interfaceContextInterface- Returns:
- a set of registered keys in the current context
-
values
Description copied from interface:ContextInterfaceReturns a (raw) collection of registered values in the current context.- Specified by:
valuesin interfaceContextInterface- Returns:
- a raw set of registered objects in the current context
-
bindings
Description copied from interface:ContextInterfaceReturns a (raw) map of bindings in the current context, mapping the name on the registered objects. Both regular objects and subcontexts are returned. Mappings to null objects can exist.- Specified by:
bindingsin interfaceContextInterface- Returns:
- a map of registered names and their bound (possibly null) object in the current context
-
fireObjectChangedEventValue
public void fireObjectChangedEventValue(Object object) throws NameNotFoundException, NullPointerException, NamingException Description copied from interface:ContextInterfaceFire an OBJECT_CHANGED_EVENT for an object within the current context. Look up if the the object exists using the toString() method of the object as the key. All "/" characters in the toString() result will be replaced by "#" characters. When the object does not exist directly in the context, a NameNotFoundException is thrown.- Specified by:
fireObjectChangedEventValuein interfaceContextInterface- Parameters:
object- the object that has changed and for which an event should be fired- Throws:
NameNotFoundException- when no object is registered with object.toString() as the keyNullPointerException- when object is nullNamingException- on general error in the method, e.g., a problem with remote connections
-
fireObjectChangedEventKey
public void fireObjectChangedEventKey(String key) throws NameNotFoundException, NullPointerException, NamingException Description copied from interface:ContextInterfaceFire an OBJECT_CHANGED_EVENT for an object with the given key in the current context. If the the key does not exist directly in the context, a NameNotFoundException is thrown. The key should not be the empty String or contain "/" characters.- Specified by:
fireObjectChangedEventKeyin interfaceContextInterface- Parameters:
key- the key within the context of the object that has changed and for which an event should be fired- Throws:
NameNotFoundException- when no object is registered with the key in the given contextNullPointerException- when key is nullNamingException- when key is the empty string or when key contains "/", or on a general error in the method, e.g., a problem with remote connections
-
toString
-
toString
Description copied from interface:ContextInterfaceReturn a String with the hierarchical content of the Context in case verbose is true; otherwise return the atomic name.- Specified by:
toStringin interfaceContextInterface- Parameters:
verbose- whether the information is exhaustive or very brief- Returns:
- formatted content of the context when verbose is true; otherwise the atomic name
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType) - Specified by:
addListenerin interfaceorg.djutils.event.EventProducer
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, org.djutils.event.reference.ReferenceType referenceType) - Specified by:
addListenerin interfaceorg.djutils.event.EventProducer
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, int position) - Specified by:
addListenerin interfaceorg.djutils.event.EventProducer
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType, int position, org.djutils.event.reference.ReferenceType referenceType) - Specified by:
addListenerin interfaceorg.djutils.event.EventProducer
-
removeListener
public boolean removeListener(org.djutils.event.EventListener listener, org.djutils.event.EventType eventType) - Specified by:
removeListenerin interfaceorg.djutils.event.EventProducer
-
getEventListenerMap
public org.djutils.event.EventListenerMap getEventListenerMap()- Specified by:
getEventListenerMapin interfaceorg.djutils.event.EventProducer
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException Description copied from interface:EventContextInterfaceAdd a listener for the provided scope as strong reference to the BEGINNING of a queue of listeners.- Specified by:
addListenerin interfaceEventContextInterface- Parameters:
listener- the listener which is interested at events of eventType.absolutePath- the absolute path of the context or object to subscribe tocontextScope- the part of the tree that the listener is aimed at (current node, current node and keys, subtree).- Returns:
- the success of adding the listener. If a listener was already added false is returned.
- Throws:
NameNotFoundException- when the absolutePath could not be found in the parent context, or when an intermediate context does not existInvalidNameException- when the scope is OBJECT_SCOPE, but the key points to a (sub)contextNotContextException- when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary objectNamingException- as an overarching exception for context errorsNullPointerException- when one of the arguments is null
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, org.djutils.event.reference.ReferenceType referenceType) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException Description copied from interface:EventContextInterfaceAdd a listener for the provided scope to the BEGINNING of a queue of listeners.- Specified by:
addListenerin interfaceEventContextInterface- Parameters:
listener- the listener which is interested at events of eventType.absolutePath- the absolute path of the context or object to subscribe tocontextScope- the part of the tree that the listener is aimed at (current node, current node and keys, subtree).referenceType- whether the listener is added as a strong or as a weak reference.- Returns:
- the success of adding the listener. If a listener was already added false is returned.
- Throws:
NameNotFoundException- when the absolutePath could not be found in the parent context, or when an intermediate context does not existInvalidNameException- when the scope is OBJECT_SCOPE, but the key points to a (sub)contextNotContextException- when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary objectNamingException- as an overarching exception for context errorsNullPointerException- when one of the arguments is null
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException Description copied from interface:EventContextInterfaceAdd a listener for the provided scope as strong reference to the specified position of a queue of listeners.- Specified by:
addListenerin interfaceEventContextInterface- Parameters:
listener- the listener which is interested at events of eventType.absolutePath- the absolute path of the context or object to subscribe tocontextScope- the part of the tree that the listener is aimed at (current node, current node and keys, subtree).position- the position of the listener in the queue.- Returns:
- the success of adding the listener. If a listener was already added, or an illegal position is provided false is returned.
- Throws:
NameNotFoundException- when the absolutePath could not be found in the parent context, or when an intermediate context does not existInvalidNameException- when the scope is OBJECT_SCOPE, but the key points to a (sub)contextNotContextException- when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary objectNamingException- as an overarching exception for context errorsNullPointerException- when one of the arguments is null
-
addListener
public boolean addListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope, int position, org.djutils.event.reference.ReferenceType referenceType) throws NameNotFoundException, InvalidNameException, NotContextException, NamingException, NullPointerException Description copied from interface:EventContextInterfaceAdd a listener for the provided scope to the specified position of a queue of listeners.- Specified by:
addListenerin interfaceEventContextInterface- Parameters:
listener- which is interested at certain events,absolutePath- the absolute path of the context or object to subscribe tocontextScope- the part of the tree that the listener is aimed at (current node, current node and keys, subtree).position- the position of the listener in the queuereferenceType- whether the listener is added as a strong or as a weak reference.- Returns:
- the success of adding the listener. If a listener was already added or an illegal position is provided false is returned.
- Throws:
NameNotFoundException- when the absolutePath could not be found in the parent context, or when an intermediate context does not existInvalidNameException- when the scope is OBJECT_SCOPE, but the key points to a (sub)contextNotContextException- when the scope is LEVEL_SCOPE, OBJECT_LEVEL_SCOPE or SUBTREE_SCOPE, and the key points to an ordinary objectNamingException- as an overarching exception for context errorsNullPointerException- when one of the arguments is null
-
removeListener
public boolean removeListener(org.djutils.event.EventListener listener, String absolutePath, ContextScope contextScope) throws InvalidNameException, NullPointerException Description copied from interface:EventContextInterfaceRemove the subscription of a listener for the provided scope for a specific event.- Specified by:
removeListenerin interfaceEventContextInterface- Parameters:
listener- which is no longer interested.absolutePath- the absolute path of the context or object to subscribe tocontextScope- ContextScope;the scope which is of no interest any more.- Returns:
- the success of removing the listener. If a listener was not subscribed false is returned.
- Throws:
InvalidNameException- when the path does not start with a slashNullPointerException- when one of the arguments is null
-
removeAllListeners
public int removeAllListeners()- Specified by:
removeAllListenersin interfaceorg.djutils.event.EventProducer
-