com.dyuproject.ioc
Class ApplicationContext

java.lang.Object
  extended by com.dyuproject.ioc.ApplicationContext

public final class ApplicationContext
extends Object

The context where you can find/get objects configured via json

Author:
David Yu
Date created:
Feb 20, 2009

Field Summary
static String DEFAULT_RESOURCE_LOCATION
          The default resource location ("application.json")
 
Constructor Summary
ApplicationContext()
           
ApplicationContext(ApplicationContext imported)
           
 
Method Summary
 void addImport(ApplicationContext imported)
          Adds another ApplicationContext as an import to this context.
 void addRefs(References refs)
          Adds References to this context.
 void destroy()
          Destroys this object and clears all references to other objects.
 Object findPojo(String key)
          Finds an object from a given key - the imports are included in the lookup.
 Object findRef(String key)
          Finds an object bound to References in this context - the imports are included in the lookup.
 Object getPojo(String key)
          Finds an object from a given key.
 Object getRef(String key)
          Finds an object bound to References in this context.
static ApplicationContext load()
          Loads the ApplicationContext from the default resource DEFAULT_RESOURCE_LOCATION}.
static ApplicationContext load(File resource)
          Loads the ApplicationContext from the specified File.
static ApplicationContext load(InputStream resource)
          Loads the ApplicationContext from the specified InputStream.
static ApplicationContext load(Reader resource)
          Loads the ApplicationContext from the specified Reader.
static ApplicationContext load(Resource resource, Parser parser)
          Loads the ApplicationContext from the specified Resource and Parser.
static ApplicationContext load(String resource)
          Loads the ApplicationContext from the given resource which could be a file, remote url (prefixed with "http://") or from the classpath (prefixed with "classpath:").
static ApplicationContext load(String[] resources)
          Loads the ApplicationContext from multiple resources.
static ApplicationContext load(URL resource)
          Loads the ApplicationContext from the specified URL.
static void main(String[] args)
           
 boolean setPojo(String key, Object value)
          Sets an object identified by the key.
 void setPojos(Map<String,Object> pojos)
          Sets a map of objects on this context identified by their corresponding keys.
 boolean setRef(String key, Object value)
          Sets an object bound to References in this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_RESOURCE_LOCATION

public static final String DEFAULT_RESOURCE_LOCATION
The default resource location ("application.json")

See Also:
Constant Field Values
Constructor Detail

ApplicationContext

public ApplicationContext()

ApplicationContext

public ApplicationContext(ApplicationContext imported)
Method Detail

load

public static ApplicationContext load()
Loads the ApplicationContext from the default resource DEFAULT_RESOURCE_LOCATION}.


load

public static ApplicationContext load(String resource)
Loads the ApplicationContext from the given resource which could be a file, remote url (prefixed with "http://") or from the classpath (prefixed with "classpath:").


load

public static ApplicationContext load(File resource)
Loads the ApplicationContext from the specified File.


load

public static ApplicationContext load(URL resource)
Loads the ApplicationContext from the specified URL.


load

public static ApplicationContext load(InputStream resource)
Loads the ApplicationContext from the specified InputStream.


load

public static ApplicationContext load(Reader resource)
Loads the ApplicationContext from the specified Reader.


load

public static ApplicationContext load(Resource resource,
                                      Parser parser)
Loads the ApplicationContext from the specified Resource and Parser.


load

public static ApplicationContext load(String[] resources)
Loads the ApplicationContext from multiple resources. The contents are merged into a single ApplicationContext.


main

public static void main(String[] args)

findPojo

public Object findPojo(String key)
Finds an object from a given key - the imports are included in the lookup.


getPojo

public Object getPojo(String key)
Finds an object from a given key.


setPojo

public boolean setPojo(String key,
                       Object value)
Sets an object identified by the key. Returns false if the key is null.


findRef

public Object findRef(String key)
Finds an object bound to References in this context - the imports are included in the lookup.


getRef

public Object getRef(String key)
Finds an object bound to References in this context.


setRef

public boolean setRef(String key,
                      Object value)
Sets an object bound to References in this context.


addRefs

public void addRefs(References refs)
Adds References to this context.


addImport

public void addImport(ApplicationContext imported)
Adds another ApplicationContext as an import to this context.


setPojos

public void setPojos(Map<String,Object> pojos)
Sets a map of objects on this context identified by their corresponding keys.


destroy

public void destroy()
Destroys this object and clears all references to other objects.



Copyright © 2008-2013. All Rights Reserved.