Coinjema
1.7

org.coinjema.context
Class ContextFactory

java.lang.Object
  extended by org.coinjema.context.ContextFactory

public class ContextFactory
extends Object

Contains static methods for initializing Coinjema with context locations. Also contains methods for destroying contexts and refreshing the cached dependencies. Warning: don't expect refresh to magically reconfigure all your objects already in-memory.

Author:
mikes

Method Summary
static void createContext(String contextName, ContextSource directory)
          Create a new child context of the root context with the given name and ContextSource.
static void createRootContext()
          Creates the root context using the default working directory as the base context location.
static void createRootContext(ContextSource directory)
          Creates the root context using the given ContextSource object.
static void destroyContext(String contextName)
          Removes all the information stored for a context and prevents its further usage.
static Registry getRegistry(String contextName)
           
static void popContext()
          Remove the top context from the context stack.
static void pushContext(CoinjemaContext cc)
          For direct and quick control over a thread's current context, call this method to push a context onto its stack.
static void refresh(CoinjemaContext context)
          Clears all stored information for the given context and all its children.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

pushContext

public static void pushContext(CoinjemaContext cc)
For direct and quick control over a thread's current context, call this method to push a context onto its stack. Any objects created in this thread after pushing a context will be created in that context. You must remove the context when you are done via popContext();

Parameters:
cc -

popContext

public static void popContext()
Remove the top context from the context stack. DO NOT call this unless you added a context manually via pushContext(CoinjemaContext).


createRootContext

public static void createRootContext()
                              throws Exception
Creates the root context using the default working directory as the base context location. (ie System.getProperty("user.dir")). Until the root context is created, Coinjema will not function properly.

Throws:
Exception

createRootContext

public static void createRootContext(ContextSource directory)
                              throws Exception
Creates the root context using the given ContextSource object. Until the root context is created, Coinjema will not function properly.

Parameters:
directory -
Throws:
Exception

createContext

public static void createContext(String contextName,
                                 ContextSource directory)
                          throws Exception
Create a new child context of the root context with the given name and ContextSource. Use this to add a set of contexts from a location not found under the root context by default.

Parameters:
contextName -
directory -
Throws:
Exception

destroyContext

public static void destroyContext(String contextName)
Removes all the information stored for a context and prevents its further usage.

Parameters:
contextName -

refresh

public static void refresh(CoinjemaContext context)
Clears all stored information for the given context and all its children. This will not result in all your in-memory objects being reconfigured, but any newly created objects will result in the config scripts being re-evaluated.

Parameters:
context -

getRegistry

public static Registry getRegistry(String contextName)

Coinjema
1.7

Public Domain Software.