Search in sources :

Example 6 with ComponentView

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

the class EJBComponent method getEjbLocalObjectType.

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

Example 7 with ComponentView

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

the class SessionBeanHomeInterceptorFactory method create.

@Override
public Interceptor create(final InterceptorFactoryContext context) {
    return new Interceptor() {

        @Override
        public Object processInvocation(final InterceptorContext context) throws Exception {
            final ComponentView view = viewToCreate.getValue();
            try {
                INIT_METHOD.set(method);
                INIT_PARAMETERS.set(context.getParameters());
                final ManagedReference instance = view.createInstance();
                return instance.getInstance();
            } finally {
                INIT_METHOD.remove();
                INIT_PARAMETERS.remove();
            }
        }
    };
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) InterceptorContext(org.jboss.invocation.InterceptorContext) ManagedReference(org.jboss.as.naming.ManagedReference) Interceptor(org.jboss.invocation.Interceptor)

Example 8 with ComponentView

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

the class EjbIIOPTransactionInterceptor method processInvocation.

@Override
public Object processInvocation(final InterceptorContext invocation) throws Exception {
    // Do we have a foreign transaction context?
    Transaction tx = TxServerInterceptor.getCurrentTransaction();
    if (tx instanceof ForeignTransaction) {
        final EJBComponent component = (EJBComponent) invocation.getPrivateData(Component.class);
        //for timer invocations there is no view, so the methodInf is attached directly
        //to the context. Otherwise we retrieve it from the invoked view
        MethodIntf methodIntf = invocation.getPrivateData(MethodIntf.class);
        if (methodIntf == null) {
            final ComponentView componentView = invocation.getPrivateData(ComponentView.class);
            if (componentView != null) {
                methodIntf = componentView.getPrivateData(MethodIntf.class);
            } else {
                methodIntf = MethodIntf.BEAN;
            }
        }
        final TransactionAttributeType attr = component.getTransactionAttributeType(methodIntf, invocation.getMethod());
        if (attr != TransactionAttributeType.NOT_SUPPORTED && attr != TransactionAttributeType.REQUIRES_NEW) {
            throw EjbLogger.ROOT_LOGGER.transactionPropagationNotSupported();
        }
    }
    return invocation.proceed();
}
Also used : Transaction(javax.transaction.Transaction) ForeignTransaction(org.wildfly.iiop.openjdk.tm.ForeignTransaction) ComponentView(org.jboss.as.ee.component.ComponentView) ForeignTransaction(org.wildfly.iiop.openjdk.tm.ForeignTransaction) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) Component(org.jboss.as.ee.component.Component) EJBComponent(org.jboss.as.ejb3.component.EJBComponent) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) TransactionAttributeType(javax.ejb.TransactionAttributeType)

Example 9 with ComponentView

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

the class RegisterManagementEJBService method start.

@Override
public void start(StartContext context) throws StartException {
    final DeploymentRepository repository = deploymentRepositoryValue.getValue();
    moduleIdentifier = new DeploymentModuleIdentifier(APP_NAME, MODULE_NAME, DISTINCT_NAME);
    final InjectedValue<ComponentView> injectedHomeView = new InjectedValue<ComponentView>();
    injectedHomeView.setValue(new ImmediateValue<ComponentView>(new ManagementHomeEjbComponentView()));
    final InjectedValue<ComponentView> injectedRemoteView = new InjectedValue<ComponentView>();
    injectedRemoteView.setValue(new ImmediateValue<ComponentView>(new ManagementRemoteEjbComponentView(mbeanServerValue.getValue())));
    Map<String, InjectedValue<ComponentView>> views = new HashMap<String, InjectedValue<ComponentView>>();
    views.put(ManagementHome.class.getName(), injectedHomeView);
    views.put(Management.class.getName(), injectedRemoteView);
    final EjbDeploymentInformation ejb = new ManagementEjbDeploymentInformation(EJB_NAME, views, SecurityActions.getClassLoader(this.getClass()));
    final ModuleDeployment deployment = new ModuleDeployment(moduleIdentifier, Collections.singletonMap(EJB_NAME, ejb));
    repository.add(moduleIdentifier, deployment);
    repository.startDeployment(moduleIdentifier);
    doPrivileged((PrivilegedAction<Void>) () -> {
        final ClassLoader classLoader = getClass().getClassLoader();
        EJBClientContext.getContextManager().setClassLoaderDefault(classLoader, ejbClientContextValue.getValue().getClientContext());
        Discovery.getContextManager().setClassLoaderDefault(classLoader, Discovery.create(associationServiceInjector.getValue().getLocalDiscoveryProvider()));
        return null;
    });
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ManagementEjbDeploymentInformation(org.jboss.as.jsr77.ejb.ManagementEjbDeploymentInformation) EjbDeploymentInformation(org.jboss.as.ejb3.deployment.EjbDeploymentInformation) HashMap(java.util.HashMap) Management(javax.management.j2ee.Management) ManagementHomeEjbComponentView(org.jboss.as.jsr77.ejb.ManagementHomeEjbComponentView) ManagementEjbDeploymentInformation(org.jboss.as.jsr77.ejb.ManagementEjbDeploymentInformation) ManagementRemoteEjbComponentView(org.jboss.as.jsr77.ejb.ManagementRemoteEjbComponentView) ManagementHome(javax.management.j2ee.ManagementHome) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) ManagementHomeEjbComponentView(org.jboss.as.jsr77.ejb.ManagementHomeEjbComponentView) ManagementRemoteEjbComponentView(org.jboss.as.jsr77.ejb.ManagementRemoteEjbComponentView) ComponentView(org.jboss.as.ee.component.ComponentView) DeploymentModuleIdentifier(org.jboss.as.ejb3.deployment.DeploymentModuleIdentifier) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository)

Example 10 with ComponentView

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

the class SessionObjectReferenceImpl method getBusinessObject.

@Override
@SuppressWarnings({ "unchecked" })
public synchronized <S> S getBusinessObject(Class<S> businessInterfaceType) {
    final String businessInterfaceName = businessInterfaceType.getName();
    ManagedReference managedReference = null;
    if (businessInterfaceToReference == null) {
        businessInterfaceToReference = new HashMap<String, ManagedReference>();
    } else {
        managedReference = businessInterfaceToReference.get(businessInterfaceName);
    }
    if (managedReference == null) {
        if (viewServices.containsKey(businessInterfaceType)) {
            final ServiceController<?> serviceController = currentServiceContainer().getRequiredService(viewServices.get(businessInterfaceType));
            final ComponentView view = (ComponentView) serviceController.getValue();
            try {
                managedReference = view.createInstance();
                businessInterfaceToReference.put(businessInterfaceType.getName(), managedReference);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        } else {
            throw WeldLogger.ROOT_LOGGER.viewNotFoundOnEJB(businessInterfaceType.getName(), ejbName);
        }
    }
    return (S) managedReference.getInstance();
}
Also used : ComponentView(org.jboss.as.ee.component.ComponentView) ManagedReference(org.jboss.as.naming.ManagedReference)

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