2 Replies Latest reply: Oct 5, 2008 2:57 PM by Laurent Mimoun RSS

Mistake in CacheListener documentation ????

paul carpenter Newbie

Hi.
I was looking at 2.1 cacheListener documentation
http://www.jboss.org/file-access/default/members/jbosscache/freezone/docs/2.1.0.GA/userguide_en/html/api.listener.html

and came across this code example mistake

 @CacheStarted

 @CacheStopped

public void cacheStartStopEvent(Event e)

 {

 switch (e.getType())

 {

 case Event.Type.CACHE_STARTED:

 System.out.println("Cache has started");

 break;

 case Event.Type.CACHE_STOPPED:

 System.out.println("Cache has stopped");

 break;

 }

 }


AFAICT Java don't allow Enums to qualify in a case label,
This won't compile, not with stock, hotspot JDK 5.
should be amended to this

 @CacheStarted

 @CacheStopped
 public void cacheStartStopEvent(Event e) {

 if (e.getType().equals(Event.Type.CACHE_STARTED)){
 System.out.println("Cache has started");
 }
 if (e.getType().equals(Event.Type.CACHE_STOPPED)){
 System.out.println("Cache has stopped");
 }

 }



Thanks and Regards