use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.
the class UserInterceptorFactory method create.
@Override
public Interceptor create(final InterceptorFactoryContext context) {
final Interceptor aroundInvoke = this.aroundInvoke.create(context);
final Interceptor aroundTimeout;
if (this.aroundTimeout != null) {
aroundTimeout = this.aroundTimeout.create(context);
} else {
aroundTimeout = null;
}
return new Interceptor() {
@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
final InvocationType marker = context.getPrivateData(InvocationType.class);
if (marker == InvocationType.TIMER) {
return aroundTimeout.processInvocation(context);
} else {
return aroundInvoke.processInvocation(context);
}
}
};
}
use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.
the class StatefulSessionComponentInstance method execute.
private Object execute(final Interceptor interceptor, final Method method, final Object... parameters) {
if (interceptor == null)
return null;
final InterceptorContext interceptorContext = new InterceptorContext();
//we need the method so this does not count as a lifecycle invocation
interceptorContext.setMethod(method);
interceptorContext.putPrivateData(Component.class, getComponent());
interceptorContext.putPrivateData(ComponentInstance.class, this);
interceptorContext.putPrivateData(InvokeMethodOnTargetInterceptor.PARAMETERS_KEY, parameters);
interceptorContext.setContextData(new HashMap<String, Object>());
interceptorContext.setTarget(getInstance());
final AbstractTransaction transaction = ContextTransactionManager.getInstance().getTransaction();
interceptorContext.setTransactionSupplier(() -> transaction);
try {
return interceptor.processInvocation(interceptorContext);
} catch (Error e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new EJBException(e);
}
}
use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.
the class EJBContextImpl method setRollbackOnly.
public void setRollbackOnly() throws IllegalStateException {
// to allow override per invocation
final InterceptorContext context = CurrentInvocationContext.get();
if (context.getMethod() == null) {
throw EjbLogger.ROOT_LOGGER.lifecycleMethodNotAllowed("getRollbackOnly");
}
instance.getComponent().setRollbackOnly();
}
use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.
the class SessionContextImpl method getEJBObject.
public EJBObject getEJBObject() throws IllegalStateException {
AllowedMethodsInformation.checkAllowed(MethodType.GET_EJB_OBJECT);
// to allow override per invocation
final InterceptorContext invocation = CurrentInvocationContext.get();
return getComponent().getEJBObject(invocation);
}
use of org.jboss.invocation.InterceptorContext in project wildfly by wildfly.
the class SessionContextImpl method getInvokedBusinessInterface.
public Class<?> getInvokedBusinessInterface() throws IllegalStateException {
final InterceptorContext invocation = CurrentInvocationContext.get();
final ComponentView view = invocation.getPrivateData(ComponentView.class);
if (view.getViewClass().equals(getComponent().getEjbObjectType()) || view.getViewClass().equals(getComponent().getEjbLocalObjectType())) {
throw EjbLogger.ROOT_LOGGER.cannotCall("getInvokedBusinessInterface", "EjbObject", "EJBLocalObject");
}
return view.getViewClass();
}
Aggregations