jaxx.runtime.context
Class DefaultApplicationContext

java.lang.Object
  extended by jaxx.runtime.context.DefaultJAXXContext
      extended by 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:
tchemit
See Also:
DefaultJAXXContext

Nested Class Summary
static interface DefaultApplicationContext.AutoLoad
          A class annotated @AutoLoad is used by context to auto instanciate the class when required.
static interface DefaultApplicationContext.MethodAccess
          A class annotated @MethodAccess is used by context to obtain the value of an entry via a declared method.
 
Field Summary
protected  Map<JAXXContextEntryDef<?>,String> entryListened
          Map of entries to watch associated with the property to fires if a modification was found.
protected  Map<Class<?>,Class<?>> forwards
          Map of forwarded classes (key) to classes (values).
protected  PropertyChangeSupport pcs
          to manage properties modifications
 
Fields inherited from class jaxx.runtime.context.DefaultJAXXContext
data, PARENT_CONTEXT_ENTRY, parentContext
 
Constructor Summary
DefaultApplicationContext()
           
 
Method Summary
 void addPropertyChangeListener(JAXXContextEntryDef<?> entry, String name, PropertyChangeListener listener)
          To add a listen modification of the given entry in the context.
 void addPropertyChangeListener(PropertyChangeListener listener)
           
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
protected  void fireEntryChanged(Class<?> klass, String name, Object oldValue, Object newValue)
           
protected  void fireEntryChanged(JAXXContextEntryDef<?> entryDef, Object oldValue, Object newValue)
           
protected  void firePropertyChange(String name, Object oldValue, Object newValue)
           
<T> T
getContextValue(Class<T> clazz, String name)
          Seek for a named entry in the context
 PropertyChangeListener[] getPropertyChangeListeners()
           
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
           
 boolean hasListeners(String propertyName)
           
protected  Object newAccess(Class<?> clazz, Object parent, String methodName)
           
protected  Object newAccess(Class<?> clazz, Object parent, String methodName, String name)
           
protected  Object newInstance(Class<?> clazz)
           
<T> void
removeContextValue(Class<T> klass, String name)
          Remove from context the value with the given klazz as an unamed (if name is null) or named entry
 void removePropertyChangeListener(JAXXContextEntryDef<?> entry, String name, PropertyChangeListener listener)
          To remove a listen modification of the given entry in the context.
 void removePropertyChangeListener(PropertyChangeListener listener)
           
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
           
<T> void
setContextValue(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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

Constructor Detail

DefaultApplicationContext

public DefaultApplicationContext()
Method Detail

getContextValue

public <T> T getContextValue(Class<T> clazz,
                             String name)
Description copied from interface: JAXXContext
Seek for a named entry in the context

Specified by:
getContextValue in interface JAXXContext
Overrides:
getContextValue in class DefaultJAXXContext
Type Parameters:
T - type of data to obtain from context
Parameters:
clazz - the class of named entry to seek in context
name - the name of the entry to seek in context
Returns:
the value of the named entry for the given class, or null if no such entry.

removeContextValue

public <T> void removeContextValue(Class<T> klass,
                                   String name)
Description copied from interface: JAXXContext
Remove from context the value with the given klazz as an unamed (if name is null) or named entry

Specified by:
removeContextValue in interface JAXXContext
Overrides:
removeContextValue in class DefaultJAXXContext
Type Parameters:
T - type of data to remove from context
Parameters:
klass - the klazz entry
name - 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:
setContextValue in interface JAXXContext
Overrides:
setContextValue in class DefaultJAXXContext
Type Parameters:
T - type of data to set in context
Parameters:
o - the value to push in context
name - 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 listen
name - the property name to fire if necessary
listener - 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 listen
name - the property name to fire if necessary
listener - 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

firePropertyChange

protected void firePropertyChange(String name,
                                  Object oldValue,
                                  Object newValue)


Copyright © 2008-2010 CodeLutin. All Rights Reserved.