Search in sources :

Example 11 with ComponentInstance

use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.

the class XTSPOJOInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
    Object serviceInstance = componentInstance.getInstance();
    Method serviceMethod = context.getMethod();
    Class serviceClass = serviceInstance.getClass();
    Object result;
    ProtocolHandler protocolHandler = HandlerFactory.getInstance(new ServiceInvocationMeta(serviceInstance, serviceClass, serviceMethod));
    try {
        protocolHandler.preInvocation();
        result = context.proceed();
        protocolHandler.notifySuccess();
    } catch (Exception e) {
        protocolHandler.notifyFailure();
        throw e;
    }
    return result;
}
Also used : ProtocolHandler(org.jboss.narayana.txframework.impl.handlers.ProtocolHandler) ComponentInstance(org.jboss.as.ee.component.ComponentInstance) ServiceInvocationMeta(org.jboss.narayana.txframework.impl.ServiceInvocationMeta) Method(java.lang.reflect.Method)

Example 12 with ComponentInstance

use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.

the class WeldInterceptorInjectionInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext context) throws Exception {
    WeldInjectionContext injectionContext = context.getPrivateData(WeldInjectionContext.class);
    final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
    //now inject the interceptors
    for (final Class<?> interceptorClass : interceptorClasses) {
        final ManagedReference instance = (ManagedReference) componentInstance.getInstanceData(interceptorClass);
        if (instance != null) {
            injectionContext.injectInterceptor(instance.getInstance());
        }
    }
    return context.proceed();
}
Also used : ComponentInstance(org.jboss.as.ee.component.ComponentInstance) ManagedReference(org.jboss.as.naming.ManagedReference)

Example 13 with ComponentInstance

use of org.jboss.as.ee.component.ComponentInstance in project wildfly by wildfly.

the class ComponentDispatcherInterceptor method processInvocation.

public Object processInvocation(final InterceptorContext context) throws Exception {
    ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class);
    if (componentInstance == null) {
        throw EeLogger.ROOT_LOGGER.noComponentInstance();
    }
    Method oldMethod = context.getMethod();
    try {
        context.setMethod(componentMethod);
        context.setTarget(componentInstance.getInstance());
        return componentInstance.getInterceptor(componentMethod).processInvocation(context);
    } finally {
        context.setMethod(oldMethod);
        context.setTarget(null);
    }
}
Also used : ComponentInstance(org.jboss.as.ee.component.ComponentInstance) Method(java.lang.reflect.Method)

Aggregations

ComponentInstance (org.jboss.as.ee.component.ComponentInstance)13 ManagedReference (org.jboss.as.naming.ManagedReference)3 Method (java.lang.reflect.Method)2 RemoteException (java.rmi.RemoteException)2 ConcurrentAccessException (javax.ejb.ConcurrentAccessException)2 ConcurrentAccessTimeoutException (javax.ejb.ConcurrentAccessTimeoutException)2 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)2 ExtendedEntityManager (org.jboss.as.jpa.container.ExtendedEntityManager)2 InterceptorInstances (org.jboss.as.weld.spi.InterceptorInstances)2 InterceptorBindings (org.jboss.weld.ejb.spi.InterceptorBindings)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 MessageDrivenBean (javax.ejb.MessageDrivenBean)1 MessageDrivenContext (javax.ejb.MessageDrivenContext)1 Interceptor (javax.enterprise.inject.spi.Interceptor)1 Component (org.jboss.as.ee.component.Component)1 ComponentClientInstance (org.jboss.as.ee.component.ComponentClientInstance)1 EjbComponentInstance (org.jboss.as.ejb3.component.EjbComponentInstance)1 ImmediateManagedReference (org.jboss.as.naming.ImmediateManagedReference)1 InterceptorContext (org.jboss.invocation.InterceptorContext)1