org.apache.openejb.loader
Class SystemInstance

java.lang.Object
  extended by org.apache.openejb.loader.SystemInstance

public class SystemInstance
extends Object

This class aims to be the one and only static in the entire system A static, singleton, instance of this class can be created with the init(Properties) method It is assumed that only one singleton per classloader is possible in any given VM Thus loading this instance in a classloader will mean there can only be one OpenEJB instance for that classloader and all children classloaders.

Version:
$Revision: 752255 $ $Date: 2009-03-10 21:45:35 +0100 (Di, 10. Mär 2009) $

Method Summary
static SystemInstance get()
           
 FileUtils getBase()
           
 ClassLoader getClassLoader()
           
 ClassPath getClassPath()
           
<T> T
getComponent(Class<T> type)
          I'm not sure how this will play out, but I've used class instances instead of strings for lookups as class instances are classloader scoped and there is an implicit "namespace" associated with that.
 FileUtils getHome()
           
 Options getOptions()
           
 Properties getProperties()
           
 String getProperty(String key)
           
 String getProperty(String key, String defaultValue)
           
 long getStartTime()
           
 boolean hasProperty(String propName)
           
static void init(Properties properties)
           
static boolean isInitialized()
           
<T> T
removeComponent(Class<T> type)
           
static void reset()
           
<T> T
setComponent(Class<T> type, T value)
           
 Object setProperty(String key, String value)
           
 Object setProperty(String key, String value, boolean isExternalProperty)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getStartTime

public long getStartTime()

getOptions

public Options getOptions()

getProperties

public Properties getProperties()

getProperty

public String getProperty(String key)

getProperty

public String getProperty(String key,
                          String defaultValue)

setProperty

public Object setProperty(String key,
                          String value)

setProperty

public Object setProperty(String key,
                          String value,
                          boolean isExternalProperty)
Parameters:
key - property name
value - property value
isExternalProperty - should the property be set to System by System.setProperty(String, String)
Returns:
property value

getHome

public FileUtils getHome()

getBase

public FileUtils getBase()

getClassPath

public ClassPath getClassPath()

getClassLoader

public ClassLoader getClassLoader()

getComponent

public <T> T getComponent(Class<T> type)
I'm not sure how this will play out, but I've used class instances instead of strings for lookups as class instances are classloader scoped and there is an implicit "namespace" associated with that. Theoretically, you can't lookup things that you can't already see in your classloader.

Parameters:
type -
Returns:
the object associated with the class type or null
Throws:
IllegalStateException - of the component isn't found

removeComponent

public <T> T removeComponent(Class<T> type)

setComponent

public <T> T setComponent(Class<T> type,
                          T value)
Parameters:
type - the class type of the component required

isInitialized

public static boolean isInitialized()

reset

public static void reset()

init

public static void init(Properties properties)
                 throws Exception
Throws:
Exception

get

public static SystemInstance get()

hasProperty

public boolean hasProperty(String propName)
Parameters:
propName - property name
Returns:
true when property is set; false otherwise


Copyright © 1999-2013 The Apache OpenEJB development community. All Rights Reserved.