use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.
the class NonPooledEJBComponentInstanceAssociatingInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
final EJBComponent component = getComponent(context, EJBComponent.class);
// create the instance
final ComponentInstance componentInstance = component.createInstance();
context.putPrivateData(ComponentInstance.class, componentInstance);
// if this is set to true we do not invoke instance.destroy
// as we are not allowed to invoke pre-destroy callbacks
boolean discard = false;
try {
return context.proceed();
} catch (Exception ex) {
final EJBComponent ejbComponent = component;
// Detect app exception
if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
// it's an application exception, just throw it back.
throw ex;
}
if (ex instanceof ConcurrentAccessTimeoutException || ex instanceof ConcurrentAccessException) {
throw ex;
}
if (ex instanceof RuntimeException || ex instanceof RemoteException) {
discard = true;
}
throw ex;
} catch (final Error e) {
discard = true;
throw e;
} catch (final Throwable t) {
discard = true;
throw new RuntimeException(t);
} finally {
// destroy the instance
if (!discard) {
componentInstance.destroy();
}
}
}
use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.
the class ExecutionTimeInterceptor method processInvocation.
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
final EJBComponent component = getComponent(context, EJBComponent.class);
if (!component.isStatisticsEnabled())
return context.proceed();
final Long startWaitTime = (Long) context.getPrivateData(WaitTimeInterceptor.START_WAIT_TIME);
final long waitTime = startWaitTime != null && startWaitTime != 0L ? System.currentTimeMillis() - startWaitTime : 0L;
component.getInvocationMetrics().startInvocation();
final long start = System.currentTimeMillis();
try {
return context.proceed();
} finally {
final long executionTime = System.currentTimeMillis() - start;
component.getInvocationMetrics().finishInvocation(context.getMethod(), waitTime, executionTime);
}
}
use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.
the class AllowedMethodsInformation method checkAllowed.
/**
* Checks that the current method
*/
public static void checkAllowed(final MethodType methodType) {
final InterceptorContext context = CurrentInvocationContext.get();
if (context == null) {
return;
}
final Component component = context.getPrivateData(Component.class);
if (!(component instanceof EJBComponent)) {
return;
}
final InvocationType invocationType = context.getPrivateData(InvocationType.class);
((EJBComponent) component).getAllowedMethodsInformation().realCheckPermission(methodType, invocationType);
}
use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.
the class PooledInstanceInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
PooledComponent<ComponentInstance> component = (PooledComponent<ComponentInstance>) getComponent(context, EJBComponent.class);
ComponentInstance instance = component.getPool().get();
context.putPrivateData(ComponentInstance.class, instance);
boolean discarded = false;
try {
return context.proceed();
} catch (Exception ex) {
final EJBComponent ejbComponent = (EJBComponent) component;
// Detect app exception
if (ejbComponent.getApplicationException(ex.getClass(), context.getMethod()) != null) {
// it's an application exception, just throw it back.
throw ex;
}
if (ex instanceof ConcurrentAccessTimeoutException || ex instanceof ConcurrentAccessException) {
throw ex;
}
if (ex instanceof RuntimeException || ex instanceof RemoteException) {
discarded = true;
component.getPool().discard(instance);
}
throw ex;
} catch (final Error e) {
discarded = true;
component.getPool().discard(instance);
throw e;
} catch (final Throwable t) {
discarded = true;
component.getPool().discard(instance);
throw new RuntimeException(t);
} finally {
if (!discarded) {
component.getPool().release(instance);
}
}
}
use of org.jboss.as.ejb3.component.EJBComponent in project wildfly by wildfly.
the class LocalEjbReceiver method createSession.
@Override
protected <T> StatefulEJBLocator<T> createSession(StatelessEJBLocator<T> statelessLocator, NamingProvider namingProvider) throws Exception {
final EjbDeploymentInformation ejbInfo = findBean(statelessLocator);
final EJBComponent component = ejbInfo.getEjbComponent();
if (!(component instanceof StatefulSessionComponent)) {
throw EjbLogger.ROOT_LOGGER.notStatefulSessionBean(statelessLocator.getAppName(), statelessLocator.getModuleName(), statelessLocator.getDistinctName(), statelessLocator.getBeanName());
}
final StatefulSessionComponent statefulComponent = (StatefulSessionComponent) component;
final SessionID sessionID = statefulComponent.createSession();
return statelessLocator.withSession(sessionID);
}
Aggregations