Package org.apache.cayenne.configuration
Class CayenneRuntime
java.lang.Object
org.apache.cayenne.configuration.CayenneRuntime
- Direct Known Subclasses:
ClientRuntime
,ServerRuntime
public abstract class CayenneRuntime extends Object
A superclass of various Cayenne runtime stacks. A Runtime is the main access
point to Cayenne for a user application. It provides a default Cayenne
configuration as well as a way to customize this configuration via a built-in
dependency injection (DI) container. In fact implementation-wise, Runtime
object is just a convenience thin wrapper around a DI
Injector
.- Since:
- 3.1
-
Field Summary
Fields Modifier and Type Field Description protected Injector
injector
protected Collection<Module>
modules
protected static ThreadLocal<Injector>
threadInjector
A holder of an Injector bound to the current thread. -
Constructor Summary
Constructors Modifier Constructor Description protected
CayenneRuntime(Collection<Module> modules)
Creates a CayenneRuntime with configuration based on the supplied collection of DI modules. -
Method Summary
Modifier and Type Method Description static void
bindThreadInjector(Injector injector)
Binds a DIInjector
bound to the current thread.DataChannel
getChannel()
Returns the runtimeDataChannel
.Injector
getInjector()
Returns DI injector used by this runtime.Collection<Module>
getModules()
Returns the collection of modules used to initialize this runtime.static Injector
getThreadInjector()
Returns theInjector
bound to the current thread.ObjectContext
newContext()
Returns a new ObjectContext instance based on the runtime's main DataChannel.ObjectContext
newContext(DataChannel parentChannel)
Returns a new ObjectContext which is a child of the specified DataChannel.void
shutdown()
Shuts down the DI injector of this runtime, giving all services that need to release some resources a chance to do that.
-
Field Details
-
threadInjector
A holder of an Injector bound to the current thread. Used mainly to allow serializable contexts to attach to correct Cayenne stack on deserialization.- Since:
- 3.1
-
injector
-
modules
-
-
Constructor Details
-
CayenneRuntime
Creates a CayenneRuntime with configuration based on the supplied collection of DI modules.
-
-
Method Details
-
bindThreadInjector
Binds a DIInjector
bound to the current thread. It is primarily intended for deserialization of ObjectContexts.- Since:
- 3.1
-
getThreadInjector
Returns theInjector
bound to the current thread. Will return null if none is bound.- Since:
- 3.1
-
getModules
Returns the collection of modules used to initialize this runtime.- Since:
- 4.0
-
getInjector
Returns DI injector used by this runtime. -
shutdown
Shuts down the DI injector of this runtime, giving all services that need to release some resources a chance to do that. -
getChannel
Returns the runtimeDataChannel
. -
newContext
Returns a new ObjectContext instance based on the runtime's main DataChannel.- Since:
- 4.0
-
newContext
Returns a new ObjectContext which is a child of the specified DataChannel. This method is used for creation of nested ObjectContexts, with parent ObjectContext passed as an argument.- Since:
- 4.0
-