Package jaxx.runtime.context
Class DefaultApplicationContext
java.lang.Object
jaxx.runtime.context.DefaultJAXXContext
jaxx.runtime.context.DefaultApplicationContext
- All Implemented Interfaces:
JAXXContext
public class DefaultApplicationContext extends DefaultJAXXContext
The default context to be used for an application.
This extends the
DefaultJAXXContext and add a possibility to
auto-instanciate some classes asked via DefaultJAXXContext.getContextValue(Class) and
getContextValue(Class, String) methods.
To registred a such class, just annotate your class with DefaultApplicationContext.AutoLoad.- Since:
- 1.2
- Author:
- Tony Chemit - chemit@codelutin.com
- See Also:
DefaultJAXXContext
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceDefaultApplicationContext.AutoLoadA class annotated @AutoLoad is used by context to auto instanciate the class when required.static interfaceDefaultApplicationContext.MethodAccessA class annotated @MethodAccess is used by context to obtain the value of an entry via a declared method. -
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<JAXXContextEntryDef<?>,java.lang.String>entryListenedMap of entries to watch associated with the property to fires if a modification was found.protected java.util.Map<java.lang.Class<?>,java.lang.Class<?>>forwardsMap of forwarded classes (key) to classes (values).protected java.beans.PropertyChangeSupportpcsto manage properties modificationsFields inherited from class jaxx.runtime.context.DefaultJAXXContext
data, PARENT_CONTEXT_ENTRY, parentContext -
Constructor Summary
Constructors Constructor Description DefaultApplicationContext() -
Method Summary
Modifier and Type Method Description voidaddPropertyChangeListener(java.beans.PropertyChangeListener listener)voidaddPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)voidaddPropertyChangeListener(JAXXContextEntryDef<?> entry, java.lang.String name, java.beans.PropertyChangeListener listener)To add a listen modification of the given entry in the context.protected voidfireEntryChanged(java.lang.Class<?> klass, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)protected voidfireEntryChanged(JAXXContextEntryDef<?> entryDef, java.lang.Object oldValue, java.lang.Object newValue)protected voidfirePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)<T> TgetContextValue(java.lang.Class<T> clazz, java.lang.String name)Seek for a named entry in the contextjava.beans.PropertyChangeListener[]getPropertyChangeListeners()java.beans.PropertyChangeListener[]getPropertyChangeListeners(java.lang.String propertyName)booleanhasListeners(java.lang.String propertyName)protected java.lang.ObjectnewAccess(java.lang.Class<?> clazz, java.lang.Object parent, java.lang.String methodName)protected java.lang.ObjectnewAccess(java.lang.Class<?> clazz, java.lang.Object parent, java.lang.String methodName, java.lang.String name)protected java.lang.ObjectnewInstance(java.lang.Class<?> clazz)<T> voidremoveContextValue(java.lang.Class<T> klass, java.lang.String name)Remove from context the value with the given klazz as an unamed (if name is null) or named entryvoidremovePropertyChangeListener(java.beans.PropertyChangeListener listener)voidremovePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)voidremovePropertyChangeListener(JAXXContextEntryDef<?> entry, java.lang.String name, java.beans.PropertyChangeListener listener)To remove a listen modification of the given entry in the context.<T> voidsetContextValue(T o, java.lang.String name)* Push in the context a new amed entry.Methods inherited from class jaxx.runtime.context.DefaultJAXXContext
clear, getContextValue, getEntry, getKey, getKeys, getParentContext, remove0, removeContextValue, setContextValue, setParentContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
forwards
protected java.util.Map<java.lang.Class<?>,java.lang.Class<?>> forwardsMap of forwarded classes (key) to classes (values). -
entryListened
Map of entries to watch associated with the property to fires if a modification was found. -
pcs
protected java.beans.PropertyChangeSupport pcsto manage properties modifications
-
-
Constructor Details
-
DefaultApplicationContext
public DefaultApplicationContext()
-
-
Method Details
-
getContextValue
public <T> T getContextValue(java.lang.Class<T> clazz, java.lang.String name)Description copied from interface:JAXXContextSeek for a named entry in the context- Specified by:
getContextValuein interfaceJAXXContext- Overrides:
getContextValuein classDefaultJAXXContext- Type Parameters:
T- type of data to obtain from context- Parameters:
clazz- the class of named entry to seek in contextname- the name of the entry to seek in context- Returns:
- the value of the named entry for the given class, or
nullif no such entry.
-
removeContextValue
public <T> void removeContextValue(java.lang.Class<T> klass, java.lang.String name)Description copied from interface:JAXXContextRemove from context the value with the given klazz as an unamed (if name is null) or named entry- Specified by:
removeContextValuein interfaceJAXXContext- Overrides:
removeContextValuein classDefaultJAXXContext- Type Parameters:
T- type of data to remove from context- Parameters:
klass- the klazz entryname- extra name of the entry
-
setContextValue
public <T> void setContextValue(T o, java.lang.String name)Description copied from interface:JAXXContext* Push in the context a new amed entry. If a previous entry exists in context (same name and class), it will be removed.- Specified by:
setContextValuein interfaceJAXXContext- Overrides:
setContextValuein classDefaultJAXXContext- Type Parameters:
T- type of data to set in context- Parameters:
o- the value to push in contextname- the name of the new entry
-
addPropertyChangeListener
public void addPropertyChangeListener(JAXXContextEntryDef<?> entry, java.lang.String name, java.beans.PropertyChangeListener listener)To add a listen modification of the given entry in the context.- Parameters:
entry- the entry to listenname- the property name to fire if necessarylistener- the listener to notify if entry has changed- Since:
- 2.0.1
-
removePropertyChangeListener
public void removePropertyChangeListener(JAXXContextEntryDef<?> entry, java.lang.String name, java.beans.PropertyChangeListener listener)To remove a listen modification of the given entry in the context.- Parameters:
entry- the entry to listenname- the property name to fire if necessarylistener- the listener to notify if entry has changed- Since:
- 2.0.1
-
addPropertyChangeListener
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener) -
addPropertyChangeListener
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener) -
removePropertyChangeListener
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener) -
removePropertyChangeListener
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener) -
hasListeners
public boolean hasListeners(java.lang.String propertyName) -
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName) -
getPropertyChangeListeners
public java.beans.PropertyChangeListener[] getPropertyChangeListeners() -
fireEntryChanged
protected void fireEntryChanged(java.lang.Class<?> klass, java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue) -
fireEntryChanged
protected void fireEntryChanged(JAXXContextEntryDef<?> entryDef, java.lang.Object oldValue, java.lang.Object newValue) -
newInstance
protected java.lang.Object newInstance(java.lang.Class<?> clazz) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
newAccess
protected java.lang.Object newAccess(java.lang.Class<?> clazz, java.lang.Object parent, java.lang.String methodName, java.lang.String name) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
newAccess
protected java.lang.Object newAccess(java.lang.Class<?> clazz, java.lang.Object parent, java.lang.String methodName) throws java.lang.IllegalArgumentException- Throws:
java.lang.IllegalArgumentException
-
firePropertyChange
protected void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
-