Search in sources :

Example 11 with Interceptor

use of org.jboss.invocation.Interceptor in project wildfly by wildfly.

the class ContainerManagedConcurrencyInterceptorFactory method create.

@Override
protected Interceptor create(final Component component, final InterceptorFactoryContext context) {
    final LockableComponent lockableComponent = (LockableComponent) component;
    synchronized (lockableComponent) {
        Interceptor interceptor = lockableComponent.getConcurrencyManagementInterceptor();
        if (interceptor != null) {
            return interceptor;
        }
        interceptor = new ContainerManagedConcurrencyInterceptor((LockableComponent) component, viewMethodToComponentMethodMap);
        lockableComponent.setConcurrencyManagementInterceptor(interceptor);
        return interceptor;
    }
}
Also used : Interceptor(org.jboss.invocation.Interceptor)

Example 12 with Interceptor

use of org.jboss.invocation.Interceptor in project wildfly by wildfly.

the class TimedObjectInvokerImpl method callTimeout.

@Override
public void callTimeout(final TimerImpl timer, final Method timeoutMethod) throws Exception {
    final Interceptor interceptor;
    synchronized (this) {
        if (!started) {
            //this can happen if an invocation has been triggered as the deployment is shutting down
            throw EjbLogger.EJB3_TIMER_LOGGER.timerInvocationFailedDueToInvokerNotBeingStarted();
        }
        interceptor = timeoutInterceptors.get(timeoutMethod);
    }
    if (interceptor == null) {
        throw EjbLogger.EJB3_TIMER_LOGGER.failToInvokeTimeout(timeoutMethod);
    }
    final InterceptorContext context = new InterceptorContext();
    context.setContextData(new HashMap<String, Object>());
    context.setMethod(timeoutMethod);
    if (timeoutMethod.getParameterTypes().length == 0) {
        context.setParameters(new Object[0]);
    } else {
        final Object[] params = new Object[1];
        params[0] = timer;
        context.setParameters(params);
    }
    context.setTimer(timer);
    context.putPrivateData(Component.class, ejbComponent.getValue());
    context.putPrivateData(MethodIntf.class, MethodIntf.TIMER);
    context.putPrivateData(InvocationType.class, InvocationType.TIMER);
    interceptor.processInvocation(context);
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) Interceptor(org.jboss.invocation.Interceptor)

Example 13 with Interceptor

use of org.jboss.invocation.Interceptor in project wildfly by wildfly.

the class TimedObjectInvokerImpl method start.

@Override
public synchronized void start(final StartContext context) throws StartException {
    SimpleInterceptorFactoryContext factoryContext = new SimpleInterceptorFactoryContext();
    factoryContext.getContextData().put(Component.class, ejbComponent.getValue());
    Map<Method, Interceptor> interceptors = new HashMap<Method, Interceptor>();
    for (Map.Entry<Method, InterceptorFactory> entry : ejbComponent.getValue().getTimeoutInterceptors().entrySet()) {
        interceptors.put(entry.getKey(), entry.getValue().create(factoryContext));
    }
    this.timeoutInterceptors = interceptors;
    started = true;
}
Also used : SimpleInterceptorFactoryContext(org.jboss.invocation.SimpleInterceptorFactoryContext) InterceptorFactory(org.jboss.invocation.InterceptorFactory) HashMap(java.util.HashMap) Method(java.lang.reflect.Method) Interceptor(org.jboss.invocation.Interceptor) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with Interceptor

use of org.jboss.invocation.Interceptor in project wildfly by wildfly.

the class ViewService method start.

public void start(final StartContext context) throws StartException {
    // Construct the view
    View view = new View(privateData);
    view.initializeInterceptors();
    this.view = view;
    final SimpleInterceptorFactoryContext factoryContext = new SimpleInterceptorFactoryContext();
    final Component component = view.getComponent();
    factoryContext.getContextData().put(Component.class, component);
    factoryContext.getContextData().put(ComponentView.class, view);
    clientPostConstructInterceptor = clientPostConstruct.create(factoryContext);
    clientPreDestroyInterceptor = clientPreDestroy.create(factoryContext);
    final Map<Method, InterceptorFactory> clientInterceptorFactories = ViewService.this.clientInterceptorFactories;
    clientInterceptors = new IdentityHashMap<Method, Interceptor>(clientInterceptorFactories.size());
    for (Method method : clientInterceptorFactories.keySet()) {
        clientInterceptors.put(method, clientInterceptorFactories.get(method).create(factoryContext));
    }
}
Also used : SimpleInterceptorFactoryContext(org.jboss.invocation.SimpleInterceptorFactoryContext) InterceptorFactory(org.jboss.invocation.InterceptorFactory) Method(java.lang.reflect.Method) Interceptor(org.jboss.invocation.Interceptor)

Example 15 with Interceptor

use of org.jboss.invocation.Interceptor in project wildfly by wildfly.

the class AroundConstructInterceptorFactory method create.

@Override
public Interceptor create(final InterceptorFactoryContext context) {
    final Interceptor aroundConstruct = aroundConstrctChain.create(context);
    return new Interceptor() {

        @Override
        public Object processInvocation(final InterceptorContext context) throws Exception {
            aroundConstruct.processInvocation(context);
            context.setParameters(null);
            return context.proceed();
        }
    };
}
Also used : InterceptorContext(org.jboss.invocation.InterceptorContext) Interceptor(org.jboss.invocation.Interceptor)

Aggregations

Interceptor (org.jboss.invocation.Interceptor)16 InterceptorContext (org.jboss.invocation.InterceptorContext)8 Method (java.lang.reflect.Method)5 InterceptorFactory (org.jboss.invocation.InterceptorFactory)5 ImmediateInterceptorFactory (org.jboss.invocation.ImmediateInterceptorFactory)4 ArrayList (java.util.ArrayList)2 Component (org.jboss.as.ee.component.Component)2 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)2 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)2 SessionBeanComponentDescription (org.jboss.as.ejb3.component.session.SessionBeanComponentDescription)2 LifecycleCMTTxInterceptor (org.jboss.as.ejb3.tx.LifecycleCMTTxInterceptor)2 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)2 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)2 SimpleInterceptorFactoryContext (org.jboss.invocation.SimpleInterceptorFactoryContext)2 PrivilegedAction (java.security.PrivilegedAction)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 IdentityHashMap (java.util.IdentityHashMap)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1