Package org.apache.cayenne.configuration
Class CayenneRuntime
java.lang.Object
org.apache.cayenne.configuration.CayenneRuntime
- Direct Known Subclasses:
ClientRuntime,ServerRuntime
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
FieldsModifier and TypeFieldDescriptionprotected Injectorprotected Collection<Module> protected static final ThreadLocal<Injector> A holder of an Injector bound to the current thread. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCayenneRuntime(Collection<Module> modules) Creates a CayenneRuntime with configuration based on the supplied collection of DI modules. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbindThreadInjector(Injector injector) Binds a DIInjectorbound to the current thread.Returns the runtimeDataChannel.Returns DI injector used by this runtime.Returns the collection of modules used to initialize this runtime.static InjectorReturns theInjectorbound to the current thread.Returns a new ObjectContext instance based on the runtime's main DataChannel.newContext(DataChannel parentChannel) Returns a new ObjectContext which is a child of the specified DataChannel.voidshutdown()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 DIInjectorbound to the current thread. It is primarily intended for deserialization of ObjectContexts.- Since:
- 3.1
-
getThreadInjector
Returns theInjectorbound 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
-