clear jboss cache using java code -
i want clear jboss cache using java code , goal i'im implement following code:
public void clearcache(string s){ string[] st=cachemanager.getinstance().getcachenames(); cache cache =cachemanager.getinstance().getcache(s); cache.flush(); } is code correct? , how can sure jboss cache cleared successfully? thank you
you have 3 bugs in code. first, don't need query getcachenames(); you're passing in name of cache you're wanting clear, , you're throwing away results in st. next, there's no such method cachemanager#getcache(string); it's getcache(string, boolean) throws exception, , need passing s, false , handling (far broad exception). finally, never check whether cache exists; if passes in name representing nonexistent cache, cache null, , you'll npe when try flush() it.
Comments
Post a Comment