Search in sources :

Example 6 with InterceptorContext

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);
            }
        }
    };
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) Interceptor(org.jboss.invocation.Interceptor)

Example 7 with InterceptorContext

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);
    }
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) AbstractTransaction(org.wildfly.transaction.client.AbstractTransaction) EJBException(javax.ejb.EJBException) EJBException(javax.ejb.EJBException) ObjectStreamException(java.io.ObjectStreamException)

Example 8 with InterceptorContext

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();
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext)

Example 9 with InterceptorContext

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);
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext)

Example 10 with InterceptorContext

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();
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) InterceptorContext(org.jboss.invocation.InterceptorContext)

Aggregations

InterceptorContext (org.jboss.invocation.InterceptorContext)29 Interceptor (org.jboss.invocation.Interceptor)8 Method (java.lang.reflect.Method)4 Component (org.jboss.as.ee.component.Component)4 ComponentView (org.jboss.as.ee.component.ComponentView)4 ManagedReference (org.jboss.as.naming.ManagedReference)4 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)3 SessionBeanComponent (org.jboss.as.ejb3.component.session.SessionBeanComponent)3 SecurityContext (org.jboss.security.SecurityContext)3 SecurityIdentity (org.wildfly.security.auth.server.SecurityIdentity)3 PrivilegedAction (java.security.PrivilegedAction)2 HashMap (java.util.HashMap)2 ComponentFactory (org.jboss.as.ee.component.ComponentFactory)2 StartupCountdown (org.jboss.as.ee.component.deployers.StartupCountdown)2 InvocationType (org.jboss.as.ee.component.interceptors.InvocationType)2 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)2 CancellationFlag (org.jboss.as.ejb3.component.interceptors.CancellationFlag)2 BAD_OPERATION (org.omg.CORBA.BAD_OPERATION)2 SkeletonStrategy (org.wildfly.iiop.openjdk.rmi.marshal.strategy.SkeletonStrategy)2 ObjectStreamException (java.io.ObjectStreamException)1