Search in sources :

Example 1 with RemoteViewManagedReferenceFactory

use of org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory in project wildfly by wildfly.

the class JSR77ManagementSubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(JSR77ManagementExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JSR77, new Jsr77DependenciesProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
    if (!appclient) {
        context.addStep(new OperationStepHandler() {

            @Override
            public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                ServiceTarget target = context.getServiceTarget();
                ServiceName mbeanServerServiceName = context.getCapabilityServiceName(JSR77ManagementRootResource.JMX_CAPABILITY, MBeanServer.class);
                RegisterMBeanServerDelegateService mbeanServerService = new RegisterMBeanServerDelegateService();
                target.addService(RegisterMBeanServerDelegateService.SERVICE_NAME, mbeanServerService).addDependency(mbeanServerServiceName, PluggableMBeanServer.class, mbeanServerService.injectedMbeanServer).addDependency(Services.JBOSS_SERVER_CONTROLLER, ModelController.class, mbeanServerService.injectedController).setInitialMode(Mode.ACTIVE).install();
                RegisterManagementEJBService managementEjbService = new RegisterManagementEJBService();
                target.addService(RegisterManagementEJBService.SERVICE_NAME, managementEjbService).addDependency(DeploymentRepository.SERVICE_NAME, DeploymentRepository.class, managementEjbService.deploymentRepositoryValue).addDependency(mbeanServerServiceName, MBeanServer.class, managementEjbService.mbeanServerValue).addDependency(EJBClientContextService.DEFAULT_SERVICE_NAME, EJBClientContextService.class, managementEjbService.ejbClientContextValue).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, managementEjbService.associationServiceInjector).setInitialMode(Mode.ACTIVE).install();
                //TODO null for source ok?
                final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(JNDI_NAME);
                final BinderService binderService = new BinderService(bindInfo.getBindName(), null);
                final InjectedValue<ClassLoader> viewClassLoader = new InjectedValue<ClassLoader>();
                viewClassLoader.setValue(Values.immediateValue(ManagementHome.class.getClassLoader()));
                target.addService(bindInfo.getBinderServiceName(), binderService).addInjection(binderService.getManagedObjectInjector(), new RemoteViewManagedReferenceFactory(APP_NAME, MODULE_NAME, DISTINCT_NAME, EJB_NAME, ManagementHome.class.getName(), false, viewClassLoader, appclient)).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).setInitialMode(Mode.ACTIVE).install();
                // Rollback is handled by the parent step
                context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER);
            }
        }, Stage.RUNTIME);
    }
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) InjectedValue(org.jboss.msc.value.InjectedValue) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ServiceTarget(org.jboss.msc.service.ServiceTarget) OperationFailedException(org.jboss.as.controller.OperationFailedException) RemoteViewManagedReferenceFactory(org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory) AssociationService(org.jboss.as.ejb3.remote.AssociationService) BinderService(org.jboss.as.naming.service.BinderService) ManagementHome(javax.management.j2ee.ManagementHome) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ServiceName(org.jboss.msc.service.ServiceName) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) ModelNode(org.jboss.dmr.ModelNode) ModelController(org.jboss.as.controller.ModelController) PluggableMBeanServer(org.jboss.as.server.jmx.PluggableMBeanServer) MBeanServer(javax.management.MBeanServer)

Example 2 with RemoteViewManagedReferenceFactory

use of org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory in project wildfly by wildfly.

the class EjbInjectionSource method resolve.

/**
     * Checks if this ejb injection has been resolved yet, and if not resolves it.
     */
private void resolve() {
    if (!resolved) {
        synchronized (this) {
            if (!resolved) {
                final Set<ViewDescription> views = getViews();
                final Set<EJBViewDescription> ejbsForViewName = new HashSet<EJBViewDescription>();
                for (final ViewDescription view : views) {
                    if (view instanceof EJBViewDescription) {
                        final MethodIntf viewType = ((EJBViewDescription) view).getMethodIntf();
                        // @EJB injection *shouldn't* consider the @WebService endpoint view or MDBs
                        if (viewType == MethodIntf.SERVICE_ENDPOINT || viewType == MethodIntf.MESSAGE_ENDPOINT) {
                            continue;
                        }
                        ejbsForViewName.add((EJBViewDescription) view);
                    }
                }
                if (ejbsForViewName.isEmpty()) {
                    if (beanName == null) {
                        error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, bindingName);
                    } else {
                        error = EjbLogger.ROOT_LOGGER.ejbNotFound(typeName, beanName, bindingName);
                    }
                } else if (ejbsForViewName.size() > 1) {
                    if (beanName == null) {
                        error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, bindingName, ejbsForViewName);
                    } else {
                        error = EjbLogger.ROOT_LOGGER.moreThanOneEjbFound(typeName, beanName, bindingName, ejbsForViewName);
                    }
                } else {
                    final EJBViewDescription description = ejbsForViewName.iterator().next();
                    final EJBViewDescription ejbViewDescription = (EJBViewDescription) description;
                    if (ejbViewDescription.getMethodIntf() == MethodIntf.REMOTE || ejbViewDescription.getMethodIntf() == MethodIntf.HOME) {
                        final EJBComponentDescription componentDescription = (EJBComponentDescription) description.getComponentDescription();
                        final EEModuleDescription moduleDescription = componentDescription.getModuleDescription();
                        final String earApplicationName = moduleDescription.getEarApplicationName();
                        final Value<ClassLoader> viewClassLoader = new Value<ClassLoader>() {

                            @Override
                            public ClassLoader getValue() throws IllegalStateException, IllegalArgumentException {
                                final Module module = deploymentUnit.getAttachment(Attachments.MODULE);
                                return module != null ? module.getClassLoader() : null;
                            }
                        };
                        remoteFactory = new RemoteViewManagedReferenceFactory(earApplicationName, moduleDescription.getModuleName(), moduleDescription.getDistinctName(), componentDescription.getComponentName(), description.getViewClassName(), componentDescription.isStateful(), viewClassLoader, appclient);
                    }
                    final ServiceName serviceName = description.getServiceName();
                    resolvedViewName = serviceName;
                }
                resolved = true;
            }
        }
    }
}
Also used : EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) EJBViewDescription(org.jboss.as.ejb3.component.EJBViewDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) RemoteViewManagedReferenceFactory(org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory) MethodIntf(org.jboss.as.ejb3.component.MethodIntf) EJBComponentDescription(org.jboss.as.ejb3.component.EJBComponentDescription) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) Module(org.jboss.modules.Module) HashSet(java.util.HashSet)

Aggregations

RemoteViewManagedReferenceFactory (org.jboss.as.ejb3.remote.RemoteViewManagedReferenceFactory)2 ServiceName (org.jboss.msc.service.ServiceName)2 HashSet (java.util.HashSet)1 MBeanServer (javax.management.MBeanServer)1 ManagementHome (javax.management.j2ee.ManagementHome)1 ModelController (org.jboss.as.controller.ModelController)1 OperationContext (org.jboss.as.controller.OperationContext)1 OperationFailedException (org.jboss.as.controller.OperationFailedException)1 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 ViewDescription (org.jboss.as.ee.component.ViewDescription)1 EJBComponentDescription (org.jboss.as.ejb3.component.EJBComponentDescription)1 EJBViewDescription (org.jboss.as.ejb3.component.EJBViewDescription)1 MethodIntf (org.jboss.as.ejb3.component.MethodIntf)1 AssociationService (org.jboss.as.ejb3.remote.AssociationService)1 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)1 BinderService (org.jboss.as.naming.service.BinderService)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)1 PluggableMBeanServer (org.jboss.as.server.jmx.PluggableMBeanServer)1