Search in sources :

Example 1 with WSComponent

use of org.jboss.as.webservices.injection.WSComponent in project wildfly by wildfly.

the class WSComponentInstanceAssociationInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext interceptorContext) throws Exception {
    final WSComponent wsComponent = (WSComponent) interceptorContext.getPrivateData(Component.class);
    BasicComponentInstance pojoComponentInstance = null;
    if (interceptorContext.getPrivateData(ManagedReference.class) != null) {
        ManagedReference reference = interceptorContext.getPrivateData(ManagedReference.class);
        pojoComponentInstance = (BasicComponentInstance) wsComponent.createInstance(reference.getInstance());
    } else {
        pojoComponentInstance = wsComponent.getComponentInstance();
    }
    interceptorContext.putPrivateData(ComponentInstance.class, pojoComponentInstance);
    return interceptorContext.proceed();
}
Also used : WSComponent(org.jboss.as.webservices.injection.WSComponent) ManagedReference(org.jboss.as.naming.ManagedReference) WSComponent(org.jboss.as.webservices.injection.WSComponent) Component(org.jboss.as.ee.component.Component) BasicComponentInstance(org.jboss.as.ee.component.BasicComponentInstance)

Example 2 with WSComponent

use of org.jboss.as.webservices.injection.WSComponent in project wildfly by wildfly.

the class AbstractInvocationHandler method invokeInternal.

public void invokeInternal(final Endpoint endpoint, final Invocation wsInvocation) throws Exception {
    // prepare for invocation
    onBeforeInvocation(wsInvocation);
    // prepare invocation data
    final ComponentView componentView = getComponentView();
    Component component = componentView.getComponent();
    // in case of @FactoryType annotation we don't need to go into EE interceptors
    final boolean forceTargetBean = (wsInvocation.getInvocationContext().getProperty("forceTargetBean") != null);
    if (forceTargetBean) {
        this.reference = new ManagedReference() {

            public void release() {
            }

            public Object getInstance() {
                return wsInvocation.getInvocationContext().getTargetBean();
            }
        };
        if (component instanceof WSComponent) {
            ((WSComponent) component).setReference(reference);
        }
    }
    final Method method = getComponentViewMethod(wsInvocation.getJavaMethod(), componentView.getViewMethods());
    final InterceptorContext context = new InterceptorContext();
    prepareForInvocation(context, wsInvocation);
    context.setMethod(method);
    context.setParameters(wsInvocation.getArgs());
    context.putPrivateData(Component.class, component);
    context.putPrivateData(ComponentView.class, componentView);
    // pull in any XTS transaction
    LocalTransactionContext.getCurrent().importProviderTransaction();
    context.setTransaction(ContextTransactionManager.getInstance().getTransaction());
    if (forceTargetBean) {
        context.putPrivateData(ManagedReference.class, reference);
    }
    // invoke method
    final Object retObj = componentView.invoke(context);
    // set return value
    wsInvocation.setReturnValue(retObj);
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) InterceptorContext(org.jboss.invocation.InterceptorContext) WSComponent(org.jboss.as.webservices.injection.WSComponent) ManagedReference(org.jboss.as.naming.ManagedReference) Method(java.lang.reflect.Method) WSComponent(org.jboss.as.webservices.injection.WSComponent) Component(org.jboss.as.ee.component.Component)

Aggregations

Component (org.jboss.as.ee.component.Component)2 ManagedReference (org.jboss.as.naming.ManagedReference)2 WSComponent (org.jboss.as.webservices.injection.WSComponent)2 Method (java.lang.reflect.Method)1 BasicComponentInstance (org.jboss.as.ee.component.BasicComponentInstance)1 ComponentView (org.jboss.as.ee.component.ComponentView)1 InterceptorContext (org.jboss.invocation.InterceptorContext)1