Package org.nuiton.jaxx.runtime.context
Class DefaultApplicationContext
- java.lang.Object
-
- org.nuiton.jaxx.runtime.context.DefaultJAXXContext
-
- org.nuiton.jaxx.runtime.context.DefaultApplicationContext
-
- All Implemented Interfaces:
JAXXContext
public class DefaultApplicationContext extends DefaultJAXXContext
The default context to be used for an application. This extends theDefaultJAXXContextand add a possibility to auto-instanciate some classes asked viaDefaultJAXXContext.getContextValue(Class)andgetContextValue(Class, String)methods. To registred a such class, just annotate your class withDefaultApplicationContext.AutoLoad.- Since:
- 1.2
- Author:
- Tony Chemit - dev@tchemit.fr
- 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 Map<JAXXContextEntryDef<?>,String>entryListenedMap of entries to watch associated with the property to fires if a modification was found.protected Map<Class<?>,Class<?>>forwardsMap of forwarded classes (key) to classes (values).protected PropertyChangeSupportpcsto manage properties modifications-
Fields inherited from class org.nuiton.jaxx.runtime.context.DefaultJAXXContext
data, PARENT_CONTEXT_ENTRY, parentContext
-
-
Constructor Summary
Constructors Constructor Description DefaultApplicationContext()
-
Method Summary
-
Methods inherited from class org.nuiton.jaxx.runtime.context.DefaultJAXXContext
clear, getContextValue, getEntry, getKey, getKeys, getParentContext, remove0, removeContextValue, setContextValue, setParentContext
-
-
-
-
Field Detail
-
forwards
protected final Map<Class<?>,Class<?>> forwards
Map of forwarded classes (key) to classes (values).
-
entryListened
protected Map<JAXXContextEntryDef<?>,String> entryListened
Map of entries to watch associated with the property to fires if a modification was found.
-
pcs
protected final PropertyChangeSupport pcs
to manage properties modifications
-
-
Method Detail
-
getContextValue
public <T> T getContextValue(Class<T> clazz, String name)
- Specified by:
getContextValuein interfaceJAXXContext- Overrides:
getContextValuein classDefaultJAXXContext
-
removeContextValue
public <T> void removeContextValue(Class<T> klass, String name)
- Specified by:
removeContextValuein interfaceJAXXContext- Overrides:
removeContextValuein classDefaultJAXXContext
-
setContextValue
public <T> void setContextValue(T o, String name)- Specified by:
setContextValuein interfaceJAXXContext- Overrides:
setContextValuein classDefaultJAXXContext
-
addPropertyChangeListener
public void addPropertyChangeListener(JAXXContextEntryDef<?> entry, String name, 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, String name, 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(PropertyChangeListener listener)
-
addPropertyChangeListener
public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
-
removePropertyChangeListener
public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
-
hasListeners
public boolean hasListeners(String propertyName)
-
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
-
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners()
-
fireEntryChanged
protected void fireEntryChanged(Class<?> klass, String name, Object oldValue, Object newValue)
-
fireEntryChanged
protected void fireEntryChanged(JAXXContextEntryDef<?> entryDef, Object oldValue, Object newValue)
-
newInstance
protected Object newInstance(Class<?> clazz) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
newAccess
protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
newAccess
protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
-