Sorted, I used the easy method and just created a new CacheController
controller class, which calls EHCache's CacheManager.clearAll() method,
which clears all of EHCache's Cache's. The default view is the same as the
current flushCache page, so OSCache should also be cleared.
The class:
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;
/**
* Simple controller cache that empties all EHCache caches, then forwards
the
* user to the original flushCache page (or whatever).
*
* @author Freek Wielstra
*/
public class CacheController implements Controller {
private String view;
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
net.sf.ehcache.CacheManager.getInstance().clearAll();
return new ModelAndView(getView());
}
public void setView(String view) {
this.view = view;
}
public String getView() {
return view;
}
}
The bean definition (I chucked it in dispatcher-servlet, but to be honest I
dunno which beans should go where):
<bean id="CacheController"
class="some.package.thingy.ma.bob.CacheController">
<property name="view" value="admin/flushCache"/>
</bean>
Further down the dispatcher-servlet.xml file, change the line in the
urlMapping bean:
/admin/flushCache.html=filenameController
to
/admin/flushCache.html=CacheController
and that's all. As far as I know, it shouldn't interfere with the existing
functionality.
mraible wrote:
>
> The view has an OSCache JSP tag that flushes OSCache's cache. If
> you're using OSCache to cache things, this should work.
>
> FWIW, I'm thinking of removing OSCache since EhCache is already used.
> If you're using EhCache and figure out how to flush the cache, we'd
> be happy to remove OSCache and add in some flush logic for EhCache.
> It may be best to use JMX to do the flushing.
>
> Matt
>
> On Nov 28, 2007, at 7:01 AM, Yopy wrote:
>
>>
>>
>>
>> I'm currently using ehcache as supplied with AppFuse to store a set of
>> large-ish objects, and now I'd like to add the specific cache used
>> to the
>> caches to be emptied in AppFuse's 'flush cache' admin menu option.
>> Usually,
>> this would be as easy as updating whichever controller is used for
>> that
>> particular option. However, searching through the files didn't give
>> me any
>> results - the dispatcher-servlet.xml seems to forward requests to
>> flushCache.html to the filenameController bean, which is an
>> instance of
>> Spring's UrlFilenameViewController. I've looked into the source of
>> that one,
>> but it doesn't seem to do anything with the cache - merely forward
>> the user
>> to some view, I believe.
>>
>> So, where's it hidden? Where can I find the bit 'o code that
>> empties the
>> cache(s), so I can make it empty an extra cache? Or, is there some
>> other way
>> to empty a given cache?
>> --
>> View this message in context: http://www.nabble.com/Adding-
>> something-to-%27flushCache%27-tf4888765s2369.html#a13993030
>> Sent from the AppFuse - User mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, e-mail: [EMAIL PROTECTED]
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
View this message in context:
http://www.nabble.com/Adding-something-to-%27flushCache%27-tp13993030s2369p14418886.html
Sent from the AppFuse - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]