}
}
public class StatefulCacheListener implements CacheListener<Instance> {
public void afterLoad(Instance instance) throws SystemException, ApplicationException {
BeanContext beanContext = instance.beanContext;
ThreadContext threadContext = new ThreadContext(instance.beanContext, instance.primaryKey, Operation.ACTIVATE);
ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
Method remove = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbActivate") : null;
List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.ACTIVATE, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (Throwable callbackException) {
discardInstance(threadContext);