Hi,
I'm learning CDI, so I developed a @Cached annotations that cache function return type based on method name, object and parameters equality in a given scope. So I am using it in a bean:
@Named @Singleton
public class TestCache {
private int onePerRequest = 0;
private int onePerSession = 0;
@Cached(CacheScope.REQUEST)
public int runOncePerRequest(){
return ++onePerRequest;
}
@Cached(CacheScope.SESSION)
public int runOncePerSession(){
return ++onePerSession;
}
//here the value is not cached
public int delegatedOncePerRequest(){
return runOncePerRequest();
}
}
So when I'm using this bean in JSF2 view, first method returns the same value each time called in request. Second function always returns 1.
But the last function returns different value on each call.
Is it expected behavior, that inner class methods calls are not intercepted?
If it is expected, can it be changed?
I'm using Glassfish 3.1
ps. If I change the class extensions to 'groovy', the last method call will lead to an error. I have two types of errors in Groovy classes with inner calls, in this example I get
Illegal class name "cache/org$jboss$weld$bean-jsf_glasfish-ManagedBean-class_cache$TestCache_$$_WeldSubclass$runOncePerRequest
in different place (more complex @Named @SessionScoped bean) I've got
java.lang.IllegalArgumentException: object is not an instance of declaring class
Regards,
Krzysztof Kowalczyk