// We need to do this after initialization simply because we're reusing the
// original CompleteAutoloadTilesInitializer above. We cannot subclass
// CompleteAutoloadTilesInitializer when compiling against Tiles 2.1...
logger.debug("Registering Tiles 2.2 LocaleResolver for complete-autoload setup");
try {
BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getContainer(this.servletContext);
DefinitionsFactory definitionsFactory = container.getDefinitionsFactory();
Method setter = definitionsFactory.getClass().getMethod("setLocaleResolver", LocaleResolver.class);
setter.invoke(definitionsFactory, new SpringLocaleResolver());
}
catch (Exception ex) {
throw new IllegalStateException("Cannot override LocaleResolver with SpringLocaleResolver", ex);
}
}
if (activateEl && this.tilesInitializer instanceof SpringTilesInitializer) {
// Again, we need to do this after initialization since SpringTilesContainerFactory
// cannot override template methods that refer to Tiles 2.2 classes: in this case,
// AttributeEvaluatorFactory as createAttributeEvaluatorFactory return type.
BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getContainer(this.servletContext);
new TilesElActivator().registerEvaluator(container);
}
}