Search in sources :

Example 1 with RegistryImpl

use of org.apache.tapestry5.ioc.internal.RegistryImpl in project tapestry-5 by apache.

the class RegistryImpl method 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. Moving
 * eager loading of
 * services out to its own method should ensure thread safety.
 */
@Override
public void performRegistryStartup() {
    if (JDKUtils.JDK_1_5) {
        throw new RuntimeException("Your JDK version is too old." + " Tapestry requires Java 1.6 or newer since version 5.4.");
    }
    eagerLoadLock.lock();
    List<EagerLoadServiceProxy> proxies = CollectionFactory.newList();
    for (Module m : moduleToServiceDefs.keySet()) m.collectEagerLoadServices(proxies);
    for (EagerLoadServiceProxy proxy : proxies) {
        proxy.eagerLoadService();
    }
    for (Runnable startup : startups) {
        startup.run();
    }
    startups.clear();
    getService("RegistryStartup", Runnable.class).run();
    cleanupThread();
}
Also used : TapestryIOCModule(org.apache.tapestry5.ioc.modules.TapestryIOCModule)

Example 2 with RegistryImpl

use of org.apache.tapestry5.ioc.internal.RegistryImpl in project tapestry-5 by apache.

the class RegistryBuilder method build.

/**
 * Constructs and returns the registry; this may only be done once. The caller is responsible for invoking
 * {@link org.apache.tapestry5.ioc.Registry#performRegistryStartup()}.
 */
public Registry build() {
    lock.lock();
    PerThreadOperationTracker tracker = new PerThreadOperationTracker(loggerSource.getLogger(Registry.class));
    RegistryImpl registry = new RegistryImpl(modules, proxyFactory, loggerSource, tracker);
    return new RegistryWrapper(registry);
}
Also used : RegistryImpl(org.apache.tapestry5.ioc.internal.RegistryImpl) PerThreadOperationTracker(org.apache.tapestry5.ioc.internal.PerThreadOperationTracker) RegistryWrapper(org.apache.tapestry5.ioc.internal.RegistryWrapper)

Aggregations

PerThreadOperationTracker (org.apache.tapestry5.ioc.internal.PerThreadOperationTracker)1 RegistryImpl (org.apache.tapestry5.ioc.internal.RegistryImpl)1 RegistryWrapper (org.apache.tapestry5.ioc.internal.RegistryWrapper)1 TapestryIOCModule (org.apache.tapestry5.ioc.modules.TapestryIOCModule)1