public abstract class CayenneRuntime extends Object
Injector
.Modifier and Type | Field and Description |
---|---|
protected Injector |
injector |
protected Module[] |
modules |
protected static ThreadLocal<Injector> |
threadInjector
A holder of an Injector bound to the current thread.
|
Constructor and Description |
---|
CayenneRuntime(Collection<Module> modules)
Creates a CayenneRuntime with configuration based on the supplied collection of DI
modules.
|
CayenneRuntime(Module... modules)
Creates a CayenneRuntime with configuration based on the supplied array of DI
modules.
|
Modifier and Type | Method and Description |
---|---|
static void |
bindThreadInjector(Injector injector)
Binds a DI
Injector bound to the current thread. |
DataChannel |
getChannel()
Returns the runtime
DataChannel . |
ObjectContext |
getContext()
Returns a new ObjectContext instance based on the runtime's main DataChannel.
|
ObjectContext |
getContext(DataChannel parentChannel)
Returns a new ObjectContext which is a child of the specified DataChannel.
|
Injector |
getInjector()
Returns DI injector used by this runtime.
|
Module[] |
getModules()
Returns an array of modules used to initialize this runtime.
|
static Injector |
getThreadInjector()
Returns the
Injector bound to the current thread. |
protected static Module[] |
mergeModules(Module mainModule,
Collection<Module> extraModules)
Internal helper method to add special extra modules in subclass constructors.
|
protected static Module[] |
mergeModules(Module mainModule,
Module... extraModules)
Internal helper method to add special extra modules in subclass constructors.
|
void |
shutdown()
Shuts down the DI injector of this runtime, giving all services that need to
release some resources a chance to do that.
|
protected static final ThreadLocal<Injector> threadInjector
protected Injector injector
protected Module[] modules
public CayenneRuntime(Module... modules)
public CayenneRuntime(Collection<Module> modules)
public static void bindThreadInjector(Injector injector)
Injector
bound to the current thread. It is primarily intended
for deserialization of ObjectContexts.
CayenneFilter
will automatically bind the right injector to each request
thread. If you are not using CayenneFilter, your application is responsible for
calling this method at appropriate points of the lifecycle.
public static Injector getThreadInjector()
Injector
bound to the current thread. Will return null if none
is bound.protected static Module[] mergeModules(Module mainModule, Module... extraModules)
protected static Module[] mergeModules(Module mainModule, Collection<Module> extraModules)
public Module[] getModules()
public Injector getInjector()
@BeforeScopeEnd public void shutdown()
public DataChannel getChannel()
DataChannel
.public ObjectContext getContext()
public ObjectContext getContext(DataChannel parentChannel)
Copyright © 2001–2018 Apache Cayenne. All rights reserved.