public abstract class GCUBEContext extends Object
| Modifier and Type | Field and Description |
|---|---|
protected GCUBELog |
logger
Object logger.
|
protected Map<Thread,Long> |
timers
Timers, indexed by thread
|
| Constructor and Description |
|---|
GCUBEContext()
Creates and initialises an instance.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
debugContext(Context ctxt,
String... indent)
Convenience method for testing.
|
File |
getFile(String path,
boolean... writeMode)
Gives read or write access to a
File. |
protected Context |
getJNDIContext()
Returns the initial JNDI context of the naming service.
|
String |
getName()
Returns the name of the context as used in log entries.
|
Object |
getProperty(String prop,
boolean... required)
Resolve a configuration property against the naming service.
|
InputStream |
getResource(String resourceName)
Returns a classpath resource given its path.
|
float |
getTiming()
Returns the timing for the current thread.
|
static void |
printContext(Context context) |
void |
resetTimer()
Reset the timer for the current thread.
|
protected void |
setJNDIContext(Context jndiContext)
Sets the initial JNDI context of the naming service.
|
protected final GCUBELog logger
protected Context getJNDIContext()
protected void setJNDIContext(Context jndiContext)
jndiContext - the naming context.public Object getProperty(String prop, boolean... required) throws RuntimeException
prop - the property.required - (optional) true if the property is required, false or omitted if property is optional.
The only implication is a different handling of failure and logging. Failure in resolving optional properties results in a runtime
exception and fatal log entry, whereas failure in resolving optional properties results in a null result and warning
in the log.null if the property was optional and could not be resolved.RuntimeException - if the property is required but cannot be resolved.public String getName()
public InputStream getResource(String resourceName)
null if the path could not be resolved.public File getFile(String path, boolean... writeMode) throws IllegalArgumentException
File.
Write access induces backups and read access relies on backups to recover from failures.path - the file path.writeMode - (optional) the access mode, true for write access and false for read access (default).IllegalArgumentException - if access is in write mode and the path is to a folder.public static void debugContext(Context ctxt, String... indent) throws Exception
ctxt - the starting context.indent - used internally to format debug information in line with the context hierarchy.Exception - if the content could not be shown.public static void printContext(Context context)
public float getTiming()
public void resetTimer()
Copyright © 2015. All Rights Reserved.