I am running a Tiles-based application on WebLogic 9.2. I have recently
upgraded from Tiles v2.0.5 to v2.1.2 and my application is running without any
known problems. In the previous version running on v2.0.5, I implemented a
custom DefinitionsReader class to retrieve Definitions from the database. This
is a straightforward implementation, where the init() and read() methods are
overloaded. If a Definition changed, a restart of the application is required.
I now want to implement a feature where a single Definition can be reloaded if
it has changed. I see that there is a "refresh()" method available on the
UrlDefinitionsFactory class. I wrote a simple test program to see if I could
invoke the refresh() method directly:
--------
ServletContext servletContext = session.getServletContext();
TilesApplicationContext applicationContext = new
ServletTilesApplicationContext(servletContext);
AbstractTilesContainerFactory afactory =
AbstractTilesContainerFactory.getTilesContainerFactory(applicationContext);
TilesRequestContext requestContext = new
ServletTilesRequestContext(applicationContext, request, response);
BasicTilesContainer container = (BasicTilesContainer)
ServletUtil.getContainer(servletContext);
UrlDefinitionsFactory factory = (UrlDefinitionsFactory)
container.getDefinitionsFactory();
factory.refresh();
Definition d = factory.getDefinition("Classic", requestContext);
--------------
The above code does not appear to retrieve a reloaded version of my changed
definition from the database. Any ideas on why this does not work? I have
added some debugging code to the UrlDefinitionsFactory class but I can never
see the debugging code on the console or in the logs.
I have read the HOW-TO section on how to retrieve definitions from
the database. As indicated earlier, I have followed the approach of writing a
custom DefinitionsReader class - do I have to switch over to writing a custom
DefinitionsDAO class in order to get refresh support? I did look at the source
code for the refresh() method in UrlDefinitionsFactory and it is calling
refresh() on a defintionsDAO object. I haven't provided an implementation, so
what is getting called by default?
Having studied the example in the HOW-TO section, it wasn't entirely clear what
purpose the customisation Key serves. I have no intent to support localised
Definitions - what else could be used as the customisation Key if I must
migrate to this approach instead of the custom DefinitionsReader class I have
now?
If anyone can shed some light on what my approach should be to support refresh
of single Definitions, that will be much appreciated.