sqlj.runtime
Class RuntimeContext
java.lang.Object
|
+--sqlj.runtime.RuntimeContext
- Direct Known Subclasses:
- DefaultRuntime
- public abstract class RuntimeContext
- extends java.lang.Object
The runtime context defines system-specific services to be provided by
the runtime environment. The runtime context is an abstract class whose
implementation may vary according to the Java VM environment.
Type | Field |
static java.lang.String |
DEFAULT_DATA_SOURCE
The JNDI name of the data source used to create the default connection. |
static java.lang.String |
DEFAULT_RUNTIME
The fully qualified class name of the default runtime implementation
used when no other implementation has been defined for a VM
environment. |
static java.lang.String |
PROPERTY_KEY
The key under which the RuntimeContext implementation class name is
stored in the system properties. |
Type | Method |
abstract java.sql.Connection |
getDefaultConnection()
Returns the default connection object, if one exists, or null
otherwise. |
abstract sqlj.runtime.profile.Loader |
getLoaderForClass(java.lang.Class forClass)
Returns a loader associated with a class. |
static RuntimeContext |
getRuntime()
Returns the runtime context associated with the current java
virtual machine instance. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
PROPERTY_KEY
public static final java.lang.String PROPERTY_KEY
- The key under which the RuntimeContext implementation class name is
stored in the system properties.
DEFAULT_RUNTIME
public static final java.lang.String DEFAULT_RUNTIME
- The fully qualified class name of the default runtime implementation
used when no other implementation has been defined for a VM
environment.
- See Also:
DefaultRuntime
DEFAULT_DATA_SOURCE
public static final java.lang.String DEFAULT_DATA_SOURCE
- The JNDI name of the data source used to create the default connection.
RuntimeContext
public RuntimeContext()
getRuntime
public static RuntimeContext getRuntime()
- Returns the runtime context associated with the current java
virtual machine instance. Each java virtual machine instance has a
single unique runtime context instance. Subsequent calls to this method
within the same VM instace will return the same object. The
appropriate runtime context implementation is discovered by examining the
value of the RuntimeContext.PROPERTY_KEY System property. If this
property is set, it will indicate the full name of a class that is
able to be instantiated as a runtime context instance. If no such
property is defined or access to this system property is not allowed,
the class given by RuntimeContext.DEFAULT_RUNTIME is used.
Note: all runtime implementations must be able to be constructed
via the Class.newInstance
method. That is, they must
have a public no-arg constructor.
- Returns:
- the runtime instance
- See Also:
PROPERTY_KEY
,
DEFAULT_RUNTIME
getLoaderForClass
public abstract sqlj.runtime.profile.Loader getLoaderForClass(java.lang.Class forClass)
- Returns a loader associated with a class. Resources and classes
loaded from this loader will be found in the same location that the
passed class was found in. Note that the definition of location may
vary depending on class loading and resolution semantics of the
runtime implementation.
It is assumed that the passed class argument contains enough
information that a java virtual machine implementation will be able to
determine the location in which to find related resources. Most VM
implementations will be able to use the passed class's class loader
(or the system class loader if the class has no loader). However,
some VM implementations may need additional information to resolve
resources. For example, a VM running in a DB server might use the
schema in which the passed class is located to search for related
resources.
- Parameters:
forClass
- the class with which the resulting loader is to be
associated.
getDefaultConnection
public abstract java.sql.Connection getDefaultConnection()
- Returns the default connection object, if one exists, or null
otherwise. Some environments may have an implicit connection object
available. For example, a virtual machine running in a DB server
might have an implicit connection associated with the current session.
If the default data source is defined in JNDI, then it is used to
establish the default connection.
- Returns:
- the default connection, or null if none exists.