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 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 - 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 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 jaxx.runtime.context.DefaultJAXXContext
data, PARENT_CONTEXT_ENTRY, parentContext
-
-
Constructor Summary
Constructors Constructor Description DefaultApplicationContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddPropertyChangeListener(PropertyChangeListener listener)voidaddPropertyChangeListener(String propertyName, PropertyChangeListener listener)voidaddPropertyChangeListener(JAXXContextEntryDef<?> entry, String name, PropertyChangeListener listener)To add a listen modification of the given entry in the context.protected voidfireEntryChanged(Class<?> klass, String name, Object oldValue, Object newValue)protected voidfireEntryChanged(JAXXContextEntryDef<?> entryDef, Object oldValue, Object newValue)protected voidfirePropertyChange(String name, Object oldValue, Object newValue)<T> TgetContextValue(Class<T> clazz, String name)Seek for a named entry in the contextPropertyChangeListener[]getPropertyChangeListeners()PropertyChangeListener[]getPropertyChangeListeners(String propertyName)booleanhasListeners(String propertyName)protected ObjectnewAccess(Class<?> clazz, Object parent, String methodName)protected ObjectnewAccess(Class<?> clazz, Object parent, String methodName, String name)protected ObjectnewInstance(Class<?> clazz)<T> voidremoveContextValue(Class<T> klass, String name)Remove from context the value with the given klazz as an unamed (if name is null) or named entryvoidremovePropertyChangeListener(PropertyChangeListener listener)voidremovePropertyChangeListener(String propertyName, PropertyChangeListener listener)voidremovePropertyChangeListener(JAXXContextEntryDef<?> entry, String name, PropertyChangeListener listener)To remove a listen modification of the given entry in the context.<T> voidsetContextValue(T o, 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, setParentContext
-
-
-
-
Field Detail
-
forwards
protected 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 PropertyChangeSupport pcs
to manage properties modifications
-
-
Method Detail
-
getContextValue
public <T> T getContextValue(Class<T> clazz, 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(Class<T> klass, 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, 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, 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
-
-