Search in sources :

Example 21 with ComponentView

use of org.jboss.as.ee.component.ComponentView 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)

Example 22 with ComponentView

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

the class EJBComponent method getEjbObjectType.

public Class<?> getEjbObjectType() {
    if (ejbObjectViewServiceName == null) {
        return null;
    }
    final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbObjectViewServiceName);
    final ComponentView view = (ComponentView) serviceController.getValue();
    return view.getViewClass();
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView)

Example 23 with ComponentView

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

the class EJBComponent method createViewInstanceProxy.

protected <T> T createViewInstanceProxy(final Class<T> viewInterface, final Map<Object, Object> contextData, final ServiceName serviceName) {
    final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(serviceName);
    final ComponentView view = (ComponentView) serviceController.getValue();
    final ManagedReference instance;
    try {
        if (WildFlySecurityManager.isChecking()) {
            instance = WildFlySecurityManager.doUnchecked(new PrivilegedExceptionAction<ManagedReference>() {

                @Override
                public ManagedReference run() throws Exception {
                    return view.createInstance(contextData);
                }
            });
        } else {
            instance = view.createInstance(contextData);
        }
    } catch (Exception e) {
        //TODO: do we need to let the exception propagate here?
        throw new RuntimeException(e);
    }
    return viewInterface.cast(instance.getInstance());
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) ManagedReference(org.jboss.as.naming.ManagedReference) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) NamingException(javax.naming.NamingException) SystemException(javax.transaction.SystemException)

Example 24 with ComponentView

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

the class EJBComponent method getEJBHome.

public EJBHome getEJBHome() throws IllegalStateException {
    if (ejbHomeViewServiceName == null) {
        throw EjbLogger.ROOT_LOGGER.beanHomeInterfaceIsNull(getComponentName());
    }
    final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(ejbHomeViewServiceName);
    final ComponentView view = (ComponentView) serviceController.getValue();
    final String locatorAppName = earApplicationName == null ? "" : earApplicationName;
    return EJBClient.createProxy(createHomeLocator(view.getViewClass().asSubclass(EJBHome.class), locatorAppName, moduleName, getComponentName(), distinctName));
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView)

Aggregations

ComponentView (org.jboss.as.ee.component.ComponentView)24 ManagedReference (org.jboss.as.naming.ManagedReference)7 Method (java.lang.reflect.Method)6 Component (org.jboss.as.ee.component.Component)6 EJBComponent (org.jboss.as.ejb3.component.EJBComponent)6 EjbDeploymentInformation (org.jboss.as.ejb3.deployment.EjbDeploymentInformation)4 HashMap (java.util.HashMap)3 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)3 InterceptorContext (org.jboss.invocation.InterceptorContext)3 IOException (java.io.IOException)2 PrivilegedActionException (java.security.PrivilegedActionException)2 HashSet (java.util.HashSet)2 NamingException (javax.naming.NamingException)2 StartupCountdown (org.jboss.as.ee.component.deployers.StartupCountdown)2 CancellationFlag (org.jboss.as.ejb3.component.interceptors.CancellationFlag)2 DeploymentModuleIdentifier (org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier)2 ModuleDeployment (org.jboss.as.ejb3.deployment.ModuleDeployment)2 SessionID (org.jboss.ejb.client.SessionID)2 InjectedValue (org.jboss.msc.value.InjectedValue)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1