|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.tapestry5.ioc.internal.RegistryImpl
public class RegistryImpl
Constructor Summary | |
---|---|
RegistryImpl(Collection<ModuleDef> moduleDefs,
ClassFactory classFactory,
PlasticProxyFactory proxyFactory,
LoggerSource loggerSource)
Constructs the registry from a set of module definitions and other resources. |
Method Summary | ||
---|---|---|
void |
addRegistryShutdownListener(RegistryShutdownListener listener)
Adds a listener for eventual notification. |
|
void |
addRegistryShutdownListener(Runnable listener)
Adds a listener for eventual notification when the registry shuts down. |
|
void |
addRegistryWillShutdownListener(Runnable listener)
Adds a listener for eventual notification. |
|
|
autobuild(Class<T> clazz)
Autobuilds a class by finding the public constructor with the most parameters. |
|
|
autobuild(String description,
Class<T> clazz)
Preferred version of ObjectLocator.autobuild(Class) that tracks the operation using
OperationTracker.invoke(String, Invokable) . |
|
void |
cleanupThread()
Invoked at the end of a request to discard any thread-specific information accumulated during the current request. |
|
String |
expandSymbols(String input)
Given an input string that may contain symbols, returns the string with any and all symbols fully expanded. |
|
List<ServiceAdvisor> |
findAdvisorsForService(ServiceDef3 serviceDef)
Searches for advisors for a particular service, returning them in order of application. |
|
List<ServiceDecorator> |
findDecoratorsForService(ServiceDef3 serviceDef)
Searches for decorators for a particular service. |
|
|
getMappedConfiguration(ServiceDef3 serviceDef,
Class<K> keyType,
Class<V> objectType)
Builds up a map of key/value pairs by invoking service contribution methods that target the service (from any module, unless the service is private). |
|
Set<Class> |
getMarkerAnnotations()
Returns a Set of Annotation classes that are used as service markers. |
|
|
getObject(Class<T> objectType,
AnnotationProvider annotationProvider)
Obtains an object indirectly, using the MasterObjectProvider service. |
|
|
getObject(Class<T> objectType,
AnnotationProvider annotationProvider,
ObjectLocator locator,
Module localModule)
As with ObjectLocator.getObject(Class, org.apache.tapestry5.ioc.AnnotationProvider) ,
but handles the Local annotation. |
|
|
getOrderedConfiguration(ServiceDef3 serviceDef,
Class<T> objectType)
Builds up an ordered collection by invoking service contributor methods that target the service (from any module, unless the service is private). |
|
|
getService(Class<T> serviceInterface)
Locates a service given a service interface and (optionally) some marker annotation types. |
|
|
getService(Class<T> serviceInterface,
Class<? extends Annotation>... markerTypes)
Locates a service given a service interface and (optionally) some marker annotation types. |
|
|
getService(String serviceId,
Class<T> serviceInterface)
Obtains a service via its unique service id. |
|
ServiceLifecycle2 |
getServiceLifecycle(String scope)
Returns a service lifecycle by service scope name. |
|
org.slf4j.Logger |
getServiceLogger(String serviceId)
Returns a logger for the service, which consists of the Module's log name suffixed
with a period and the service id. |
|
|
getUnorderedConfiguration(ServiceDef3 serviceDef,
Class<T> objectType)
Builds up an unordered collection by invoking service contributor methods that target the service (from any module, unless the service is private). |
|
|
invoke(String description,
Invokable<T> operation)
Executes the operation, returning its value. |
|
ClassFab |
newClass(Class serviceInterface)
Convieience for creating a new ClassFab instance using a
ClassFactory . |
|
void |
performRegistryStartup()
It's not unreasonable for an eagerly-loaded service to decide to start a thread, at which point we raise issues about improper publishing of the Registry instance from the RegistryImpl constructor. |
|
Object |
provideServiceProxy(String serviceId)
Look up the service and return it's proxy. |
|
|
proxy(Class<T> interfaceClass,
Class<? extends T> implementationClass)
Creates a proxy. |
|
|
proxy(Class<T> interfaceClass,
Class<? extends T> implementationClass,
ObjectLocator locator)
Creates a just-in-time (and possibly, live reloading) proxy for the indicated class and interface, using the provided locator to autobuild the implementationClass (when necessary). |
|
void |
run(String description,
Runnable operation)
Executes the operation. |
|
void |
shutdown()
Shuts down a Registry instance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, PlasticProxyFactory proxyFactory, LoggerSource loggerSource)
moduleDefs
- defines the modules (and builders, decorators, etc., within)classFactory
- TODOproxyFactory
- TODOloggerSource
- used to obtain Logger instancesMethod Detail |
---|
public void performRegistryStartup()
performRegistryStartup
in interface Registry
public org.slf4j.Logger getServiceLogger(String serviceId)
InternalRegistry
log name
suffixed
with a period and the service id.
getServiceLogger
in interface InternalRegistry
public void shutdown()
Registry
shutdown
in interface Registry
RegistryShutdownHub
,
RegistryShutdownListener
public <T> T getService(String serviceId, Class<T> serviceInterface)
ObjectLocator
getService
in interface ObjectLocator
serviceId
- unique Service id used to locate the service object (may contain symbols,
which
will be expanded), case is ignoredserviceInterface
- the interface implemented by the service (or an interface extended by the service
interface)
public void cleanupThread()
Registry
cleanupThread
in interface Registry
PerthreadManager
,
ThreadCleanupListener
public <T> Collection<T> getUnorderedConfiguration(ServiceDef3 serviceDef, Class<T> objectType)
InternalRegistry
getUnorderedConfiguration
in interface InternalRegistry
serviceDef
- defines the service for which configuration data is being assembledobjectType
- identifies the type of object allowed into the collection
public <T> List<T> getOrderedConfiguration(ServiceDef3 serviceDef, Class<T> objectType)
InternalRegistry
getOrderedConfiguration
in interface InternalRegistry
serviceDef
- defines the service for which configuration data is being assembledobjectType
- identifies the type of object allowed into the collection
public <K,V> Map<K,V> getMappedConfiguration(ServiceDef3 serviceDef, Class<K> keyType, Class<V> objectType)
InternalRegistry
getMappedConfiguration
in interface InternalRegistry
serviceDef
- defines the service for which configuration data is being assembledkeyType
- identifies the type of key object allowed into the mapobjectType
- identifies the type of value object allowed into the map
public <T> T getService(Class<T> serviceInterface)
ObjectLocator
getService
in interface ObjectLocator
serviceInterface
- the interface the service implements
Marker
public <T> T getService(Class<T> serviceInterface, Class<? extends Annotation>... markerTypes)
ObjectLocator
getService
in interface ObjectLocator
serviceInterface
- the interface the service implementsmarkerTypes
- Markers used to select a specific service that implements the interface
Marker
public ServiceLifecycle2 getServiceLifecycle(String scope)
InternalRegistry
getServiceLifecycle
in interface InternalRegistry
scope
- the name of the service scope (case insensitive)
public List<ServiceDecorator> findDecoratorsForService(ServiceDef3 serviceDef)
InternalRegistry
DecoratorDef
s
are ordered, then converted into ServiceDecorator
s.
findDecoratorsForService
in interface InternalRegistry
public List<ServiceAdvisor> findAdvisorsForService(ServiceDef3 serviceDef)
InternalRegistry
findAdvisorsForService
in interface InternalRegistry
public ClassFab newClass(Class serviceInterface)
InternalRegistry
ClassFab
instance using a
ClassFactory
.
newClass
in interface InternalRegistry
serviceInterface
- the interface to be implemented by the provided classpublic <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator, Module localModule)
InternalRegistry
ObjectLocator.getObject(Class, org.apache.tapestry5.ioc.AnnotationProvider)
,
but handles the Local
annotation.
getObject
in interface InternalRegistry
objectType
- type of object o be injectedannotationProvider
- access to annotations at point of injectionlocator
- used to resolve any subsequent injectionslocalModule
- module to limit services to, if Local annotaton present
public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
ObjectLocator
MasterObjectProvider
service.
getObject
in interface ObjectLocator
objectType
- the type of object to be returnedannotationProvider
- provides access to annotations on the field or parameter for which a value is to
be
obtained, which may be utilized in selecting an appropriate object, use
null when annotations are not available (in which case, selection
will
be based only on the object type)
ObjectProvider
public void addRegistryShutdownListener(RegistryShutdownListener listener)
RegistryShutdownHub
addRegistryShutdownListener
in interface RegistryShutdownHub
public void addRegistryShutdownListener(Runnable listener)
RegistryShutdownHub
addRegistryShutdownListener
in interface RegistryShutdownHub
public void addRegistryWillShutdownListener(Runnable listener)
RegistryShutdownHub
addRegistryWillShutdownListener
in interface RegistryShutdownHub
public String expandSymbols(String input)
InternalRegistry
expandSymbols
in interface InternalRegistry
public <T> T autobuild(String description, Class<T> clazz)
ObjectLocator
ObjectLocator.autobuild(Class)
that tracks the operation using
OperationTracker.invoke(String, Invokable)
.
autobuild
in interface ObjectLocator
description
- description used with OperationTracker
clazz
- the type of object to instantiate
MasterObjectProvider
public <T> T autobuild(Class<T> clazz)
ObjectLocator
Inject
annotation. There are two cases: constructing a service implementation, and constructing
an arbitrary object. In the former case, many service resources are also available for injection, not
just dependencies or objects provided via
MasterObjectProvider.provide(Class, AnnotationProvider, ObjectLocator, boolean)
.
autobuild
in interface ObjectLocator
clazz
- the type of object to instantiate
MasterObjectProvider
public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
ObjectLocator
ObjectLocator.autobuild(Class)
until
just-in-time (that is, first method invocation). In a limited number of cases, it is necessary to use such a
proxy to prevent service construction cycles, particularly when contributing (directly or indirectly) to the
MasterObjectProvider
(which is itself at the heart
of autobuilding).
If the class file for the class is a file on the file system (not a file packaged in a JAR), then the proxy will
autoreload: changing the class file will result in the new class being reloaded and re-instantiated
(with dependencies).
proxy
in interface ObjectLocator
interfaceClass
- the interface implemented by the proxyimplementationClass
- a concrete class that implements the interface
ObjectLocator.autobuild(Class)
public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass, ObjectLocator locator)
InternalRegistry
proxy
in interface InternalRegistry
public Object provideServiceProxy(String serviceId)
ServiceProxyProvider
provideServiceProxy
in interface ServiceProxyProvider
serviceId
- the id of the service to obtain
public void run(String description, Runnable operation)
OperationTracker
run
in interface OperationTracker
description
- used if there is an exceptionoperation
- to executepublic <T> T invoke(String description, Invokable<T> operation)
OperationTracker
invoke
in interface OperationTracker
description
- used if there is an exceptionoperation
- to invoke
public Set<Class> getMarkerAnnotations()
InternalRegistry
getMarkerAnnotations
in interface InternalRegistry
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |