Include Tiles devMode, like devMode Struts, to reload tiles.xml with each request

Do Apache tiles have devMove like Struts that will reload the styles.xml file with every request? If so, how can this be activated?

+3
source share
3 answers

I used tiles, but I never tried to dynamically reload it.

However, this page: http://tiles.apache.org/tutorial/configuration.html

He speaks:

    Load the Tiles filter. It is useful if your definition files can be changed and you periodically need to reload them. 
+1
source

Here is another working configuration that uses Listener instead of Filter. (since tiles 2.1.2)

In web.xml:

<context-param>
  <param-name>org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO.CHECK_REFRESH</param-name>
  <param-value>true</param-value>
</context-param>
<listener>
  <listener-class>org.apache.tiles.web.startup.TilesListener</listener-class>
</listener>
+3
source

, 2.2.2 .

....
import org.apache.tiles.definition.DefinitionsFactory;
import org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory;
import org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO;
import org.apache.tiles.impl.BasicTilesContainer;
import org.apache.tiles.servlet.context.ServletUtil;

//When using SimpleTilesListener =>  BasicTilesContainer is returned
//When using StrutsTilesListener => CachingTilesContainer is returned which extends BasicTilesContainer
BasicTilesContainer tilesCont = (BasicTilesContainer) ServletUtil.getContainer(ServletActionContext.getServletContext());

DefinitionsFactory defFact = tilesCont.getDefinitionsFactory();
Field field= UnresolvingLocaleDefinitionsFactory.class.getDeclaredField("definitionDao");
field.setAccessible(true);
ResolvingLocaleUrlDefinitionDAO rludDAO = (ResolvingLocaleUrlDefinitionDAO)field.get(defFact);
rludDAO.refresh();
0

Source: https://habr.com/ru/post/1736204/


All Articles