org.apache.tapestry5.ioc.internal.services
Class JustInTimeObjectCreator

java.lang.Object
  extended by org.apache.tapestry5.ioc.internal.services.JustInTimeObjectCreator
All Implemented Interfaces:
java.util.EventListener, EagerLoadServiceProxy, ObjectCreator, RegistryShutdownListener

public class JustInTimeObjectCreator
extends java.lang.Object
implements ObjectCreator, EagerLoadServiceProxy, RegistryShutdownListener

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
JustInTimeObjectCreator(ServiceActivityTracker tracker, ObjectCreator creator, java.lang.String serviceId)
           
 
Method Summary
 java.lang.Object createObject()
          Checks to see if the proxy has been shutdown, then invokes ObjectCreator.createObject() if it has not already done so.
 void eagerLoadService()
          Invokes createObject() to force the creation of the underlying service.
 void registryDidShutdown()
          Sets the shutdown flag and releases the object and the creator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JustInTimeObjectCreator

public JustInTimeObjectCreator(ServiceActivityTracker tracker,
                               ObjectCreator creator,
                               java.lang.String serviceId)
Method Detail

createObject

public java.lang.Object createObject()
Checks to see if the proxy has been shutdown, then invokes ObjectCreator.createObject() if it has not already done so.

Specified by:
createObject in interface ObjectCreator
Throws:
java.lang.IllegalStateException - if the registry has been shutdown

eagerLoadService

public void eagerLoadService()
Invokes createObject() to force the creation of the underlying service.

Specified by:
eagerLoadService in interface EagerLoadServiceProxy

registryDidShutdown

public void registryDidShutdown()
Sets the shutdown flag and releases the object and the creator.

Specified by:
registryDidShutdown in interface RegistryShutdownListener


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.