org.jpu.patterns.singleton.onePerContext
Interface IOnePerContextManager

All Known Implementing Classes:
OnePerContextManager

public interface IOnePerContextManager

Interface implemented by the OnePerContextManager class. See that class for more info.


Nested Class Summary
static interface IOnePerContextManager.IInitializer
          Interface to be implemented by classes that are registered as initializers via addInitializer(int, org.jpu.patterns.singleton.onePerContext.IOnePerContextManager.IInitializer).
static interface IOnePerContextManager.IInstantiator
          Interface to be implemented by classes that are registered as instantiators via setInstantiator(org.jpu.patterns.singleton.onePerContext.IOnePerContextManager.IInstantiator).
 
Field Summary
static IContext DEFAULT_CONTEXT
           
 
Method Summary
 void addInitializer(int i, IOnePerContextManager.IInitializer initializer)
          Adds the given initializer at position "i".
 java.util.List getInitializers()
          Returns a shallow copy of the internal list of IOnePerContextManager.IInitializer's.
 java.lang.Object getInstance(java.lang.Object ctx)
          Returns the One-Per-Context of the given class associated with the given context.
 IOnePerContextManager.IInstantiator getInstantiator()
          Returns the IOnePerContextManager.IInstantiator used for instantiating One-Per-Context's.
 java.util.Map getObjects()
          Returns a shallow copy of the internal map that maps contexts to One-Per-Context instances.
 java.lang.Class getOnePerContextClass()
          Returns the class passed as the first parameter to the constructor.
 IOnePerContextManager.IInitializer removeInitializer(int i)
          Removes the given initializer at position "i".
 boolean removeInitializer(IOnePerContextManager.IInitializer ini)
          Removes the given initializer.
 void setInstantiator(IOnePerContextManager.IInstantiator i)
          Sets the IOnePerContextManager.IInstantiator to be used for instantiating One-Per-Context's.
 

Field Detail

DEFAULT_CONTEXT

public static final IContext DEFAULT_CONTEXT
Method Detail

getOnePerContextClass

public java.lang.Class getOnePerContextClass()
Returns the class passed as the first parameter to the constructor.


getObjects

public java.util.Map getObjects()
Returns a shallow copy of the internal map that maps contexts to One-Per-Context instances. Since the Map is a copy, the caller can query and modify it at will without synchronization.


getInitializers

public java.util.List getInitializers()
Returns a shallow copy of the internal list of IOnePerContextManager.IInitializer's. Since the List is a copy, the caller can query and modify it at will without synchronization.


addInitializer

public void addInitializer(int i,
                           IOnePerContextManager.IInitializer initializer)
Adds the given initializer at position "i".


removeInitializer

public IOnePerContextManager.IInitializer removeInitializer(int i)
Removes the given initializer at position "i".


removeInitializer

public boolean removeInitializer(IOnePerContextManager.IInitializer ini)
Removes the given initializer.


getInstantiator

public IOnePerContextManager.IInstantiator getInstantiator()
Returns the IOnePerContextManager.IInstantiator used for instantiating One-Per-Context's.


setInstantiator

public void setInstantiator(IOnePerContextManager.IInstantiator i)
Sets the IOnePerContextManager.IInstantiator to be used for instantiating One-Per-Context's.


getInstance

public java.lang.Object getInstance(java.lang.Object ctx)
Returns the One-Per-Context of the given class associated with the given context. If no such instance exists, it is created and stored for subsequent reuse.

Parameters:
ctx - The context. Can be null in which case onePerContextClass is used as the context.


Copyright (c) 2001-2003 - Apache Software Foundation