Search in sources :

Example 1 with ProtocolHandler

use of org.jboss.narayana.txframework.impl.handlers.ProtocolHandler 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 2 with ProtocolHandler

use of org.jboss.narayana.txframework.impl.handlers.ProtocolHandler in project wildfly by wildfly.

the class XTSEJBInterceptor method processInvocation.

@Override
public Object processInvocation(InterceptorContext context) throws Exception {
    ComponentView cv = context.getPrivateData(ComponentView.class);
    ManagedReference mr = cv.createInstance();
    Object serviceInstance = mr.getInstance();
    Class serviceClass = context.getTarget().getClass();
    Method serviceMethod = context.getMethod();
    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) ComponentView(org.jboss.as.ee.component.ComponentView) ServiceInvocationMeta(org.jboss.narayana.txframework.impl.ServiceInvocationMeta) ManagedReference(org.jboss.as.naming.ManagedReference) Method(java.lang.reflect.Method)

Aggregations

Method (java.lang.reflect.Method)2 ServiceInvocationMeta (org.jboss.narayana.txframework.impl.ServiceInvocationMeta)2 ProtocolHandler (org.jboss.narayana.txframework.impl.handlers.ProtocolHandler)2 ComponentInstance (org.jboss.as.ee.component.ComponentInstance)1 ComponentView (org.jboss.as.ee.component.ComponentView)1 ManagedReference (org.jboss.as.naming.ManagedReference)1