Class RegistryWrapper
-
- org.apache.tapestry5.ioc.internal.RegistryWrapper
-
- All Implemented Interfaces:
ObjectLocator
,Registry
public class RegistryWrapper extends implements Registry
A wrapper aroundInternalRegistry
that exists to expand symbols in a service id before invokingObjectLocator.getService(String, Class)
.
-
-
Constructor Summary
Constructors Constructor Description RegistryWrapper(InternalRegistry registry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> T
<T> clazz)
Autobuilds a class by finding the public constructor with the most parameters.<T> T
description, <T> clazz)
Preferred version ofObjectLocator.autobuild(Class)
that tracks the operation usingOperationTracker.invoke(String, org.apache.tapestry5.ioc.Invokable)
.void
cleanupThread()
Invoked at the end of a request to discard any thread-specific information accumulated during the current request.<T> T
<T> objectType, AnnotationProvider annotationProvider)
Obtains an object indirectly, using theMasterObjectProvider
service.<T> T
<T> serviceInterface)
Locates a service given a service interface and (optionally) some marker annotation types.<T> T
<T> serviceInterface, <? extends >... markerTypes)
Locates a service given a service interface and (optionally) some marker annotation types.<T> T
serviceId, <T> serviceInterface)
Obtains a service via its unique service id.void
performRegistryStartup()
Invoked to eagerly load services marked with theEagerLoad
annotation, and to execute all contributions to the Startup service.<T> T
<T> interfaceClass, <? extends T> implementationClass)
Creates a proxy.void
shutdown()
Shuts down a Registry instance.
-
-
-
Constructor Detail
-
RegistryWrapper
public RegistryWrapper(InternalRegistry registry)
-
-
Method Detail
-
cleanupThread
public void cleanupThread()
Description copied from interface:Registry
Invoked at the end of a request to discard any thread-specific information accumulated during the current request.- Specified by:
cleanupThread
in interfaceRegistry
- See Also:
PerthreadManager
,ThreadCleanupListener
-
shutdown
public void shutdown()
Description copied from interface:Registry
Shuts down a Registry instance. Notifies all listeners that the registry has shutdown. Further method invocations on the Registry are no longer allowed, and the Registry instance should be discarded.- Specified by:
shutdown
in interfaceRegistry
- See Also:
RegistryShutdownHub
,RegistryShutdownListener
-
getObject
public <T> T <T> objectType, AnnotationProvider annotationProvider)
Description copied from interface:ObjectLocator
Obtains an object indirectly, using theMasterObjectProvider
service.- Specified by:
getObject
in interfaceObjectLocator
- Parameters:
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)- Returns:
- the requested object
- See Also:
ObjectProvider
-
getService
public <T> T serviceId, <T> serviceInterface)
Description copied from interface:ObjectLocator
Obtains a service via its unique service id. Returns the service's proxy. The service proxy implements the same interface as the actual service, and is used to instantiate the actual service only as needed (this is transparent to the application).- Specified by:
getService
in interfaceObjectLocator
- Parameters:
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)- Returns:
- the service instance
-
getService
public <T> T <T> serviceInterface)
Description copied from interface:ObjectLocator
Locates a service given a service interface and (optionally) some marker annotation types. A single service must implement the service interface (which * can be hard to guarantee) and by marked by all the marker types. The search takes into account inheritance of the service interface (not the service implementation), which may result in a failure due to extra matches.- Specified by:
getService
in interfaceObjectLocator
- Parameters:
serviceInterface
- the interface the service implements- Returns:
- the service's proxy
- See Also:
Marker
-
getService
public <T> T <T> serviceInterface, <? extends >... markerTypes)
Description copied from interface:ObjectLocator
Locates a service given a service interface and (optionally) some marker annotation types. A single service must implement the service interface (which * can be hard to guarantee) and by marked by all the marker types. The search takes into account inheritance of the service interface (not the service implementation), which may result in a failure due to extra matches. The ability to specify marker annotation types was added in 5.3- Specified by:
getService
in interfaceObjectLocator
- Parameters:
serviceInterface
- the interface the service implementsmarkerTypes
- Markers used to select a specific service that implements the interface- Returns:
- the service's proxy
- See Also:
Marker
-
autobuild
public <T> T <T> clazz)
Description copied from interface:ObjectLocator
Autobuilds a class by finding the public constructor with the most parameters. Services and other resources or dependencies will be injected into the parameters of the constructor and into private fields marked with theInject
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 the MasterObjectProvider service.- Specified by:
autobuild
in interfaceObjectLocator
- Parameters:
clazz
- the type of object to instantiate- Returns:
- the instantiated instance
-
autobuild
public <T> T description, <T> clazz)
Description copied from interface:ObjectLocator
Preferred version ofObjectLocator.autobuild(Class)
that tracks the operation usingOperationTracker.invoke(String, org.apache.tapestry5.ioc.Invokable)
.- Specified by:
autobuild
in interfaceObjectLocator
- Parameters:
description
- description used withOperationTracker
clazz
- the type of object to instantiate- Returns:
- the instantiated instance
-
performRegistryStartup
public void performRegistryStartup()
Description copied from interface:Registry
Invoked to eagerly load services marked with theEagerLoad
annotation, and to execute all contributions to the Startup service.- Specified by:
performRegistryStartup
in interfaceRegistry
-
proxy
public <T> T <T> interfaceClass, <? extends T> implementationClass)
Description copied from interface:ObjectLocator
Creates a proxy. The proxy will defer invocation ofObjectLocator.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 theMasterObjectProvider
(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).- Specified by:
proxy
in interfaceObjectLocator
- Parameters:
interfaceClass
- the interface implemented by the proxyimplementationClass
- a concrete class that implements the interface- Returns:
- a proxy
- See Also:
ObjectLocator.autobuild(Class)
-
-