Java源码示例:javax.ejb.SessionBean
示例1
@Override
public void afterLoad(final Instance instance) throws SystemException, ApplicationException {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(instance.beanContext, instance.primaryKey, Operation.ACTIVATE);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method remove = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbActivate") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.ACTIVATE, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable callbackException) {
discardInstance(threadContext.getPrimaryKey(), instance);
EjbTransactionUtil.handleSystemException(threadContext.getTransactionPolicy(), callbackException, threadContext);
} finally {
ThreadContext.exit(oldContext);
}
}
示例2
@Override
public void beforeStore(final Instance instance) {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(beanContext, instance.primaryKey, Operation.PASSIVATE);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method passivate = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbPassivate") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, passivate, Operation.PASSIVATE, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable e) {
logger.error("An unexpected exception occured while invoking the ejbPassivate method on the Stateful SessionBean instance", e);
} finally {
ThreadContext.exit(oldContext);
}
}
示例3
@Override
public void timedOut(final Instance instance) {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(beanContext, instance.primaryKey, Operation.PRE_DESTROY);
threadContext.setCurrentAllowedStates(null);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method remove = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbRemove") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.PRE_DESTROY, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable e) {
logger.error("An unexpected exception occured while invoking the ejbRemove method on the timed-out Stateful SessionBean instance", e);
} finally {
logger.info("Removing the timed-out stateful session bean instance " + instance.primaryKey);
ThreadContext.exit(oldContext);
}
}
示例4
@Override
public void afterLoad(final Instance instance) throws SystemException, ApplicationException {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(instance.beanContext, instance.primaryKey, Operation.ACTIVATE);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method remove = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbActivate") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.ACTIVATE, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable callbackException) {
discardInstance(threadContext);
EjbTransactionUtil.handleSystemException(threadContext.getTransactionPolicy(), callbackException, threadContext);
} finally {
ThreadContext.exit(oldContext);
}
}
示例5
@Override
public void beforeStore(final Instance instance) {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(beanContext, instance.primaryKey, Operation.PASSIVATE);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method passivate = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbPassivate") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, passivate, Operation.PASSIVATE, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable e) {
logger.error("An unexpected exception occured while invoking the ejbPassivate method on the Stateful SessionBean instance", e);
} finally {
ThreadContext.exit(oldContext);
}
}
示例6
@Override
public void timedOut(final Instance instance) {
final BeanContext beanContext = instance.beanContext;
final ThreadContext threadContext = new ThreadContext(beanContext, instance.primaryKey, Operation.PRE_DESTROY);
threadContext.setCurrentAllowedStates(null);
final ThreadContext oldContext = ThreadContext.enter(threadContext);
try {
final Method remove = instance.bean instanceof SessionBean ? SessionBean.class.getMethod("ejbRemove") : null;
final List<InterceptorData> callbackInterceptors = beanContext.getCallbackInterceptors();
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, remove, Operation.PRE_DESTROY, callbackInterceptors, instance.interceptors);
interceptorStack.invoke();
} catch (final Throwable e) {
logger.error("An unexpected exception occured while invoking the ejbRemove method on the timed-out Stateful SessionBean instance", e);
} finally {
logger.info("Removing the timed-out stateful session bean instance " + instance.primaryKey);
ThreadContext.exit(oldContext);
}
}