tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vibhore Anant <vibhore_an...@yahoo.com>
Subject Re: Support for reloading/refreshing Tile Definitions
Date Wed, 01 Apr 2009 20:28:05 GMT
Thanks for your reply Antonio.
 
You indicated that I can use CachingLocaleUrlDefinitionDAO with a parameter configured in
web.xml to support a refresh of definitions.  I assume this DAO is for the case when loading
definitions from tiles-defs.xml.  I suppose that since I need to load definitions from the
database I will _have_ to write a custom DefinitionDAO?  I am still unclear on how to implement
a "refresh" for a LocaleDbDefinitionDAO - where will the code for the "refresh" action be
implemented?
 
If I move to using DefinitionDAO without managing caching, my fear is that I will introduce
hundreds of new database calls for my web application.  Am I correct in understanding that
if caching is not used, every attempt to insert a tiles definition on a JSP will result in
database lookups for the definition (and attributes)?
 
I only have one set of global definitions for the web application.  What do you recommend
I use as my customisation key?

Regards
Vibhore
--- On Wed, 4/1/09, Antonio Petrelli <antonio.petrelli@gmail.com> wrote:


From: Antonio Petrelli <antonio.petrelli@gmail.com>
Subject: Re: Support for reloading/refreshing Tile Definitions
To: users@tiles.apache.org
Date: Wednesday, April 1, 2009, 8:07 PM


2009/4/1 Vibhore Anant <vibhore_anant@yahoo.com>:
> 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.

This way of refreshing is deprecated. It works only using
"TilesFilter" to startup Tiles.

> 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?

You can use CachingLocaleUrlDefinitionDAO, together with
LocaleDefinitionsFactory, forcing to "true" this parameter in web.xml:
org.apache.tiles.definition.dao.LocaleUrlDefinitionDAO.CHECK_REFRESH
(not documented, I will open a JIRA issue for this)
or, if you are using Java initialization, call
"CachingLocaleUrlDefinitionDAO.setCheckRefresh".
And yes, you should move definition loading into the DAO.
However, are you really sure that you *need* refresh? You can
implement your DefinitionDAO without managing caching, using
LocaleDefinitionsFactory (that does not cache anything).

>  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?

Think of a portal, in which definitions are customized per user. In
this case the customization key is the user.

> If anyone can shed some light on what my approach should be to support refresh of single Definitions,
that will be much appreciated.

The refresh operation is "global", so you cannot update a single
definition. However, as I said before, you can use a variant of
LocaleDbDefinitionDAO and LocaleDefinitionsFactory

HTH
Antonio



      
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message