use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.
the class StatefulInitMethodInterceptor method processInvocation.
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
final Method method = SessionBeanHomeInterceptorFactory.INIT_METHOD.get();
final Object[] params = SessionBeanHomeInterceptorFactory.INIT_PARAMETERS.get();
//we remove them immediately, so they are not set for the rest of the invocation
//TODO: find a better way to handle this
SessionBeanHomeInterceptorFactory.INIT_METHOD.remove();
SessionBeanHomeInterceptorFactory.INIT_PARAMETERS.remove();
if (method != null) {
final InvocationType invocationType = context.getPrivateData(InvocationType.class);
try {
context.putPrivateData(InvocationType.class, InvocationType.SFSB_INIT_METHOD);
method.invoke(context.getTarget(), params);
} catch (InvocationTargetException e) {
if (CreateException.class.isAssignableFrom(e.getCause().getClass())) {
EjbExceptionTransformingInterceptorFactories.setCreateException((CreateException) e.getCause());
}
throw Interceptors.rethrow(e.getCause());
} finally {
context.putPrivateData(InvocationType.class, invocationType);
}
}
return context.proceed();
}
use of org.jboss.as.ee.component.interceptors.InvocationType 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.ee.component.interceptors.InvocationType in project wildfly by wildfly.
the class SessionBeanSetSessionContextMethodInvocationInterceptor method processInvocation.
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
SessionBeanComponentInstance instance = (SessionBeanComponentInstance) context.getPrivateData(ComponentInstance.class);
final InvocationType invocationType = context.getPrivateData(InvocationType.class);
try {
context.putPrivateData(InvocationType.class, InvocationType.DEPENDENCY_INJECTION);
((SessionBean) context.getTarget()).setSessionContext(instance.getEjbContext());
} finally {
context.putPrivateData(InvocationType.class, invocationType);
}
return context.proceed();
}
use of org.jboss.as.ee.component.interceptors.InvocationType in project wildfly by wildfly.
the class EjbSuspendInterceptor method processInvocation.
@Override
public Object processInvocation(InterceptorContext context) throws Exception {
InvocationType invocation = context.getPrivateData(InvocationType.class);
if (invocation != InvocationType.REMOTE && invocation != InvocationType.MESSAGE_DELIVERY) {
return context.proceed();
}
// see if control point accepts or rejects this invocation
EJBComponent component = getComponent(context, EJBComponent.class);
ControlPoint entryPoint = component.getControlPoint();
RunResult result = entryPoint.beginRequest();
if (result == RunResult.REJECTED) {
// if control point rejected, check with suspend handler
if (!component.getEjbSuspendHandlerService().acceptInvocation(context))
throw EjbLogger.ROOT_LOGGER.containerSuspended();
}
try {
return context.proceed();
} finally {
if (result == RunResult.REJECTED)
component.getEjbSuspendHandlerService().invocationComplete();
else
entryPoint.requestComplete();
}
}
Aggregations