use of org.apache.tapestry5.http.services.ApplicationInitializerFilter in project tapestry-5 by apache.
the class SpringModule method reportSpringContextDetailsAtStartup.
@Contribute(ApplicationInitializer.class)
@Primary
public void reportSpringContextDetailsAtStartup(OrderedConfiguration<ApplicationInitializerFilter> configuration, final ApplicationContext springContext) {
ApplicationInitializerFilter filter = new ApplicationInitializerFilter() {
@Override
public void initializeApplication(Context context, ApplicationInitializer initializer) {
logger.info(String.format("Spring version %s with %,d defined beans.", SpringVersion.getVersion(), springContext.getBeanDefinitionCount()));
initializer.initializeApplication(context);
}
};
configuration.add("SpringContextInitialization", filter);
}
use of org.apache.tapestry5.http.services.ApplicationInitializerFilter in project tapestry-5 by apache.
the class TapestryModule method contributeApplicationInitializer.
/**
* Adds a listener to the {@link org.apache.tapestry5.internal.services.ComponentInstantiatorSource} that clears the
* {@link PropertyAccess} and {@link TypeCoercer} caches on
* a class loader invalidation. In addition, forces the
* realization of {@link ComponentClassResolver} at startup.
*/
public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter> configuration, final TypeCoercer typeCoercer, final ComponentClassResolver componentClassResolver, @ComponentClasses final InvalidationEventHub invalidationEventHub, @Autobuild final RestoreDirtySessionObjects restoreDirtySessionObjects) {
final Runnable callback = new Runnable() {
public void run() {
propertyAccess.clearCache();
typeCoercer.clearCache();
}
};
ApplicationInitializerFilter clearCaches = new ApplicationInitializerFilter() {
public void initializeApplication(Context context, ApplicationInitializer initializer) {
// Snuck in here is the logic to clear the PropertyAccess
// service's cache whenever
// the component class loader is invalidated.
invalidationEventHub.addInvalidationCallback(callback);
endOfRequestEventHub.addEndOfRequestListener(restoreDirtySessionObjects);
// Perform other pending initialization
initializer.initializeApplication(context);
// We don't care about the result, but this forces a load of the
// service
// at application startup, rather than on first request.
componentClassResolver.isPageName("ForceLoadAtStartup");
}
};
configuration.add("ClearCachesOnInvalidation", clearCaches);
}
Aggregations