Class JustInTimeObjectCreator<T>
- java.lang.Object
-
- org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator<T>
-
- All Implemented Interfaces:
java.lang.Runnable
,ObjectCreator<T>
,EagerLoadServiceProxy
public class JustInTimeObjectCreator<T> extends java.lang.Object implements ObjectCreator<T>, EagerLoadServiceProxy, java.lang.Runnable
Invoked from a fabricated service delegate to get or realize (instantiate and configure) the service implementation. This includes synchronization logic, to prevent multiple threads from attempting to realize the same service at the same time (a service should be realized only once). The additional interfaces implemented by this class support eager loading of services (at application startup), and orderly shutdown of proxies.
-
-
Constructor Summary
Constructors Constructor Description JustInTimeObjectCreator(ServiceActivityTracker tracker, ObjectCreator<T> creator, java.lang.String serviceId)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
createObject()
Checks to see if the proxy has been shutdown, then invokesObjectCreator.createObject()
if it has not already done so.void
eagerLoadService()
InvokescreateObject()
to force the creation of the underlying service.void
run()
Invoked when the Registry is shutdown; deletes the instantiated object (if it exists) and replaces the ObjectCreator with one that throws an IllegalStateException.
-
-
-
Constructor Detail
-
JustInTimeObjectCreator
public JustInTimeObjectCreator(ServiceActivityTracker tracker, ObjectCreator<T> creator, java.lang.String serviceId)
-
-
Method Detail
-
createObject
public T createObject()
Checks to see if the proxy has been shutdown, then invokesObjectCreator.createObject()
if it has not already done so.- Specified by:
createObject
in interfaceObjectCreator<T>
- Throws:
java.lang.IllegalStateException
- if the registry has been shutdown
-
eagerLoadService
public void eagerLoadService()
InvokescreateObject()
to force the creation of the underlying service.- Specified by:
eagerLoadService
in interfaceEagerLoadServiceProxy
-
run
public void run()
Invoked when the Registry is shutdown; deletes the instantiated object (if it exists) and replaces the ObjectCreator with one that throws an IllegalStateException.- Specified by:
run
in interfacejava.lang.Runnable
-
-