Search in sources :

Example 1 with InjectionException

use of org.jboss.msc.inject.InjectionException in project wildfly by wildfly.

the class PartitionManagerService method publishPartitionManager.

private void publishPartitionManager(StartContext context) {
    BindInfo bindInfo = createPartitionManagerBindInfo();
    ServiceName serviceName = bindInfo.getBinderServiceName();
    final BinderService binderService = new BinderService(serviceName.getCanonicalName());
    final ServiceBuilder<ManagedReferenceFactory> builder = context.getController().getServiceContainer().addService(serviceName, binderService).addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(this.jndiName));
    builder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
    builder.addDependency(createServiceName(this.alias), PartitionManager.class, new Injector<PartitionManager>() {

        @Override
        public void inject(final PartitionManager value) throws InjectionException {
            binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
        }

        @Override
        public void uninject() {
            binderService.getManagedObjectInjector().uninject();
        }
    });
    builder.setInitialMode(Mode.PASSIVE).install();
    ROOT_LOGGER.boundToJndi("PartitionManager " + this.alias, bindInfo.getAbsoluteJndiName());
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) InjectionException(org.jboss.msc.inject.InjectionException) DefaultPartitionManager(org.picketlink.idm.internal.DefaultPartitionManager) PartitionManager(org.picketlink.idm.PartitionManager) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo)

Example 2 with InjectionException

use of org.jboss.msc.inject.InjectionException in project wildfly by wildfly.

the class EJBClientDescriptorMetaDataProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // we only process top level deployment units
    if (deploymentUnit.getParent() != null) {
        return;
    }
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (module == null) {
        return;
    }
    // support for using capabilities to resolve service names
    CapabilityServiceSupport capabilityServiceSupport = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    // check for EJB client interceptor configuration
    final List<EJBClientInterceptor> deploymentEjbClientInterceptors = getClassPathInterceptors(module.getClassLoader());
    List<EJBClientInterceptor> staticEjbClientInterceptors = deploymentUnit.getAttachment(org.jboss.as.ejb3.subsystem.Attachments.STATIC_EJB_CLIENT_INTERCEPTORS);
    List<EJBClientInterceptor> ejbClientInterceptors = new ArrayList<>();
    if (deploymentEjbClientInterceptors != null) {
        ejbClientInterceptors.addAll(deploymentEjbClientInterceptors);
    }
    if (staticEjbClientInterceptors != null) {
        ejbClientInterceptors.addAll(staticEjbClientInterceptors);
    }
    final boolean interceptorsDefined = ejbClientInterceptors != null && !ejbClientInterceptors.isEmpty();
    final EJBClientDescriptorMetaData ejbClientDescriptorMetaData = deploymentUnit.getAttachment(Attachments.EJB_CLIENT_METADATA);
    // no explicit EJB client configuration in this deployment, so nothing to do
    if (ejbClientDescriptorMetaData == null && !interceptorsDefined) {
        return;
    }
    // install the descriptor based EJB client context service
    final ServiceName ejbClientContextServiceName = EJBClientContextService.DEPLOYMENT_BASE_SERVICE_NAME.append(deploymentUnit.getName());
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    // create the service
    final EJBClientContextService service = new EJBClientContextService();
    // add the service
    final ServiceBuilder<EJBClientContextService> serviceBuilder = serviceTarget.addService(ejbClientContextServiceName, service);
    if (appclient) {
        serviceBuilder.addDependency(EJBClientContextService.APP_CLIENT_URI_SERVICE_NAME, URI.class, service.getAppClientUri());
        serviceBuilder.addDependency(EJBClientContextService.APP_CLIENT_EJB_PROPERTIES_SERVICE_NAME, String.class, service.getAppClientEjbProperties());
    }
    // default transport providers: remote from config, local from service, in "else" below.
    serviceBuilder.addDependency(EJBClientConfiguratorService.SERVICE_NAME, EJBClientConfiguratorService.class, service.getConfiguratorServiceInjector());
    if (ejbClientDescriptorMetaData != null) {
        // profile and remoting-ejb-receivers cannot be used together
        checkDescriptorConfiguration(ejbClientDescriptorMetaData);
        final Injector<RemotingProfileService> profileServiceInjector = new Injector<RemotingProfileService>() {

            final Injector<EJBTransportProvider> injector = service.getLocalProviderInjector();

            boolean injected = false;

            public void inject(final RemotingProfileService value) throws InjectionException {
                final EJBTransportProvider provider = value.getLocalTransportProviderInjector().getOptionalValue();
                if (provider != null) {
                    injected = true;
                    injector.inject(provider);
                }
            }

            public void uninject() {
                if (injected) {
                    injected = false;
                    injector.uninject();
                }
            }
        };
        final String profile = ejbClientDescriptorMetaData.getProfile();
        final ServiceName profileServiceName;
        if (profile != null) {
            // set up a service for the named remoting profile
            profileServiceName = capabilityServiceSupport.getCapabilityServiceName(REMOTING_PROFILE_CAPABILITY_NAME, profile);
            // why below?
            serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, profileServiceInjector);
            serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, service.getProfileServiceInjector());
        } else {
            // if descriptor defines list of ejb-receivers instead of profile then we create internal ProfileService for this
            // application which contains defined receivers
            profileServiceName = ejbClientContextServiceName.append(INTERNAL_REMOTING_PROFILE);
            final Map<String, RemotingProfileService.RemotingConnectionSpec> remotingConnectionMap = new HashMap<>();
            final List<RemotingProfileService.HttpConnectionSpec> httpConnections = new ArrayList<>();
            final RemotingProfileService profileService = new RemotingProfileService(Collections.emptyList(), remotingConnectionMap, httpConnections);
            final ServiceBuilder<RemotingProfileService> profileServiceBuilder = serviceTarget.addService(profileServiceName, profileService);
            if (ejbClientDescriptorMetaData.isLocalReceiverExcluded() != Boolean.TRUE) {
                final Boolean passByValue = ejbClientDescriptorMetaData.isLocalReceiverPassByValue();
                profileServiceBuilder.addDependency(passByValue == Boolean.FALSE ? LocalTransportProvider.BY_REFERENCE_SERVICE_NAME : LocalTransportProvider.BY_VALUE_SERVICE_NAME, EJBTransportProvider.class, profileService.getLocalTransportProviderInjector());
            }
            final Collection<EJBClientDescriptorMetaData.RemotingReceiverConfiguration> receiverConfigurations = ejbClientDescriptorMetaData.getRemotingReceiverConfigurations();
            for (EJBClientDescriptorMetaData.RemotingReceiverConfiguration receiverConfiguration : receiverConfigurations) {
                final String connectionRef = receiverConfiguration.getOutboundConnectionRef();
                final long connectTimeout = receiverConfiguration.getConnectionTimeout();
                final Properties channelCreationOptions = receiverConfiguration.getChannelCreationOptions();
                final OptionMap optionMap = getOptionMapFromProperties(channelCreationOptions, EJBClientDescriptorMetaDataProcessor.class.getClassLoader());
                final InjectedValue<OutboundConnection> injector = new InjectedValue<>();
                final ServiceName internalServiceName = capabilityServiceSupport.getCapabilityServiceName(OUTBOUND_CONNECTION_CAPABILITY_NAME, connectionRef);
                profileServiceBuilder.addDependency(internalServiceName, OutboundConnection.class, injector);
                final RemotingProfileService.RemotingConnectionSpec connectionSpec = new RemotingProfileService.RemotingConnectionSpec(connectionRef, injector, optionMap, connectTimeout);
                remotingConnectionMap.put(connectionRef, connectionSpec);
            }
            for (EJBClientDescriptorMetaData.HttpConnectionConfiguration httpConfigurations : ejbClientDescriptorMetaData.getHttpConnectionConfigurations()) {
                final String uri = httpConfigurations.getUri();
                RemotingProfileService.HttpConnectionSpec httpConnectionSpec = new RemotingProfileService.HttpConnectionSpec(uri);
                httpConnections.add(httpConnectionSpec);
            }
            profileServiceBuilder.install();
            serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, profileServiceInjector);
            serviceBuilder.addDependency(profileServiceName, RemotingProfileService.class, service.getProfileServiceInjector());
        }
        // these items are the same no matter how we were configured
        final String deploymentNodeSelectorClassName = ejbClientDescriptorMetaData.getDeploymentNodeSelector();
        if (deploymentNodeSelectorClassName != null) {
            final DeploymentNodeSelector deploymentNodeSelector;
            try {
                deploymentNodeSelector = module.getClassLoader().loadClass(deploymentNodeSelectorClassName).asSubclass(DeploymentNodeSelector.class).getConstructor().newInstance();
            } catch (Exception e) {
                throw EjbLogger.ROOT_LOGGER.failedToCreateDeploymentNodeSelector(e, deploymentNodeSelectorClassName);
            }
            service.setDeploymentNodeSelector(deploymentNodeSelector);
        }
        final long invocationTimeout = ejbClientDescriptorMetaData.getInvocationTimeout();
        service.setInvocationTimeout(invocationTimeout);
        final int defaultCompression = ejbClientDescriptorMetaData.getDefaultCompression();
        service.setDefaultCompression(defaultCompression);
        // clusters
        final Collection<EJBClientDescriptorMetaData.ClusterConfig> clusterConfigs = ejbClientDescriptorMetaData.getClusterConfigs();
        if (!clusterConfigs.isEmpty()) {
            final List<EJBClientCluster> clientClusters = new ArrayList<>(clusterConfigs.size());
            AuthenticationContext clustersAuthenticationContext = AuthenticationContext.empty();
            for (EJBClientDescriptorMetaData.ClusterConfig clusterConfig : clusterConfigs) {
                MatchRule defaultRule = MatchRule.ALL.matchAbstractType("ejb", "jboss");
                AuthenticationConfiguration defaultAuthenticationConfiguration = AuthenticationConfiguration.EMPTY;
                final EJBClientCluster.Builder clientClusterBuilder = new EJBClientCluster.Builder();
                final String clusterName = clusterConfig.getClusterName();
                clientClusterBuilder.setName(clusterName);
                defaultRule = defaultRule.matchProtocol("cluster");
                defaultRule = defaultRule.matchUrnName(clusterName);
                final long maxAllowedConnectedNodes = clusterConfig.getMaxAllowedConnectedNodes();
                clientClusterBuilder.setMaximumConnectedNodes(maxAllowedConnectedNodes);
                final String clusterNodeSelectorClassName = clusterConfig.getNodeSelector();
                if (clusterNodeSelectorClassName != null) {
                    final ClusterNodeSelector clusterNodeSelector;
                    try {
                        clusterNodeSelector = module.getClassLoader().loadClass(clusterNodeSelectorClassName).asSubclass(ClusterNodeSelector.class).getConstructor().newInstance();
                    } catch (Exception e) {
                        throw EjbLogger.ROOT_LOGGER.failureDuringLoadOfClusterNodeSelector(clusterNodeSelectorClassName, clusterName, e);
                    }
                    clientClusterBuilder.setClusterNodeSelector(clusterNodeSelector);
                }
                final Properties clusterChannelCreationOptions = clusterConfig.getChannelCreationOptions();
                final OptionMap clusterChannelCreationOptionMap = getOptionMapFromProperties(clusterChannelCreationOptions, EJBClientDescriptorMetaDataProcessor.class.getClassLoader());
                final Properties clusterConnectionOptions = clusterConfig.getConnectionOptions();
                final OptionMap clusterConnectionOptionMap = getOptionMapFromProperties(clusterConnectionOptions, EJBClientDescriptorMetaDataProcessor.class.getClassLoader());
                final long clusterConnectTimeout = clusterConfig.getConnectTimeout();
                clientClusterBuilder.setConnectTimeoutMilliseconds(clusterConnectTimeout);
                if (clusterConnectionOptionMap != null) {
                    RemotingOptions.mergeOptionsIntoAuthenticationConfiguration(clusterConnectionOptionMap, defaultAuthenticationConfiguration);
                }
                clustersAuthenticationContext = clustersAuthenticationContext.with(defaultRule, defaultAuthenticationConfiguration);
                final Collection<EJBClientDescriptorMetaData.ClusterNodeConfig> clusterNodeConfigs = clusterConfig.getClusterNodeConfigs();
                for (EJBClientDescriptorMetaData.ClusterNodeConfig clusterNodeConfig : clusterNodeConfigs) {
                    MatchRule nodeRule = MatchRule.ALL.matchAbstractType("ejb", "jboss");
                    AuthenticationConfiguration nodeAuthenticationConfiguration = AuthenticationConfiguration.EMPTY;
                    final String nodeName = clusterNodeConfig.getNodeName();
                    nodeRule = nodeRule.matchProtocol("node");
                    nodeRule = nodeRule.matchUrnName(nodeName);
                    final Properties channelCreationOptions = clusterNodeConfig.getChannelCreationOptions();
                    final Properties connectionOptions = clusterNodeConfig.getConnectionOptions();
                    final OptionMap connectionOptionMap = getOptionMapFromProperties(connectionOptions, EJBClientDescriptorMetaDataProcessor.class.getClassLoader());
                    final long connectTimeout = clusterNodeConfig.getConnectTimeout();
                    if (connectionOptionMap != null) {
                        RemotingOptions.mergeOptionsIntoAuthenticationConfiguration(connectionOptionMap, nodeAuthenticationConfiguration);
                    }
                    clustersAuthenticationContext = clustersAuthenticationContext.with(0, nodeRule, nodeAuthenticationConfiguration);
                }
                final EJBClientCluster clientCluster = clientClusterBuilder.build();
                clientClusters.add(clientCluster);
            }
            service.setClientClusters(clientClusters);
            service.setClustersAuthenticationContext(clustersAuthenticationContext);
        }
        deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME, profileServiceName);
    } else {
        if (!appclient) {
            serviceBuilder.addDependency(LocalTransportProvider.DEFAULT_LOCAL_TRANSPORT_PROVIDER_SERVICE_NAME, EJBTransportProvider.class, service.getLocalProviderInjector());
        }
    }
    if (interceptorsDefined) {
        service.setClientInterceptors(ejbClientInterceptors);
    }
    // install the service
    serviceBuilder.install();
    EjbLogger.DEPLOYMENT_LOGGER.debugf("Deployment unit %s will use %s as the EJB client context service", deploymentUnit, ejbClientContextServiceName);
    // attach the service name of this EJB client context to the deployment unit
    phaseContext.addDeploymentDependency(ejbClientContextServiceName, EjbDeploymentAttachmentKeys.EJB_CLIENT_CONTEXT_SERVICE);
    deploymentUnit.putAttachment(EjbDeploymentAttachmentKeys.EJB_CLIENT_CONTEXT_SERVICE_NAME, ejbClientContextServiceName);
}
Also used : EJBClientInterceptor(org.jboss.ejb.client.EJBClientInterceptor) InjectedValue(org.jboss.msc.value.InjectedValue) OutboundConnection(org.jboss.as.network.OutboundConnection) AuthenticationContext(org.wildfly.security.auth.client.AuthenticationContext) HashMap(java.util.HashMap) EJBClientContextService(org.jboss.as.ejb3.remote.EJBClientContextService) ServiceBuilder(org.jboss.msc.service.ServiceBuilder) ArrayList(java.util.ArrayList) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ClusterNodeSelector(org.jboss.ejb.client.ClusterNodeSelector) Injector(org.jboss.msc.inject.Injector) RemotingProfileService(org.jboss.as.ejb3.remote.RemotingProfileService) ServiceTarget(org.jboss.msc.service.ServiceTarget) ServiceName(org.jboss.msc.service.ServiceName) Module(org.jboss.modules.Module) MatchRule(org.wildfly.security.auth.client.MatchRule) Properties(java.util.Properties) DeploymentNodeSelector(org.jboss.ejb.client.DeploymentNodeSelector) EJBClientDescriptorMetaData(org.jboss.as.ee.metadata.EJBClientDescriptorMetaData) EJBClientCluster(org.jboss.ejb.client.EJBClientCluster) AuthenticationConfiguration(org.wildfly.security.auth.client.AuthenticationConfiguration) InjectionException(org.jboss.msc.inject.InjectionException) DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) IOException(java.io.IOException) EJBTransportProvider(org.jboss.ejb.client.EJBTransportProvider) OptionMap(org.xnio.OptionMap) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 3 with InjectionException

use of org.jboss.msc.inject.InjectionException in project wildfly by wildfly.

the class TransactionSubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
    checkIfNodeIdentifierIsDefault(context, model);
    boolean jts = model.hasDefined(JTS) && model.get(JTS).asBoolean();
    final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(TransactionExtension.SUBSYSTEM_PATH), false);
    final List<ServiceName> deps = new LinkedList<>();
    for (String name : subsystemResource.getChildrenNames(CM_RESOURCE)) {
        deps.add(TxnServices.JBOSS_TXN_CMR.append(name));
    }
    // recovery environment
    performRecoveryEnvBoottime(context, model, jts, deps);
    // core environment
    performCoreEnvironmentBootTime(context, model);
    // coordinator environment
    performCoordinatorEnvBoottime(context, model, jts);
    // object store
    performObjectStoreBoottime(context, model);
    // always propagate the transaction context
    // TODO: need a better way to do this, but this value gets cached in a static
    // so we need to make sure we set it before anything tries to read it
    jtsPropertyManager.getJTSEnvironmentBean().setAlwaysPropagateContext(true);
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(final DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_TRANSACTION_ROLLBACK_ACTION, new TransactionLeakRollbackProcessor());
            processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_TRANSACTIONS_EE_CONCURRENCY, new EEConcurrencyContextHandleFactoryProcessor());
            processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_TRANSACTION_BINDINGS, new TransactionJndiBindingProcessor());
            processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_TRANSACTIONS, new TransactionDependenciesProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
    // bind the TransactionManger and the TSR into JNDI
    final BinderService tmBinderService = new BinderService("TransactionManager");
    final ServiceBuilder<ManagedReferenceFactory> tmBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("TransactionManager"), tmBinderService);
    tmBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tmBinderService.getNamingStoreInjector());
    tmBuilder.addDependency(TransactionManagerService.INTERNAL_SERVICE_NAME, javax.transaction.TransactionManager.class, new Injector<javax.transaction.TransactionManager>() {

        @Override
        public void inject(final javax.transaction.TransactionManager value) throws InjectionException {
            tmBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
        }

        @Override
        public void uninject() {
            tmBinderService.getManagedObjectInjector().uninject();
        }
    });
    tmBuilder.install();
    final BinderService tmLegacyBinderService = new BinderService("TransactionManager");
    final ServiceBuilder<ManagedReferenceFactory> tmLegacyBuilder = context.getServiceTarget().addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append("TransactionManager"), tmLegacyBinderService);
    tmLegacyBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tmLegacyBinderService.getNamingStoreInjector());
    tmLegacyBuilder.addDependency(TransactionManagerService.INTERNAL_SERVICE_NAME, javax.transaction.TransactionManager.class, new Injector<javax.transaction.TransactionManager>() {

        @Override
        public void inject(final javax.transaction.TransactionManager value) throws InjectionException {
            tmLegacyBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
        }

        @Override
        public void uninject() {
            tmLegacyBinderService.getManagedObjectInjector().uninject();
        }
    });
    tmLegacyBuilder.install();
    final BinderService tsrBinderService = new BinderService("TransactionSynchronizationRegistry");
    final ServiceBuilder<ManagedReferenceFactory> tsrBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("TransactionSynchronizationRegistry"), tsrBinderService);
    tsrBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tsrBinderService.getNamingStoreInjector());
    tsrBuilder.addDependency(TransactionSynchronizationRegistryService.INTERNAL_SERVICE_NAME, TransactionSynchronizationRegistry.class, new Injector<TransactionSynchronizationRegistry>() {

        @Override
        public void inject(final TransactionSynchronizationRegistry value) throws InjectionException {
            tsrBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
        }

        @Override
        public void uninject() {
            tsrBinderService.getManagedObjectInjector().uninject();
        }
    });
    tsrBuilder.install();
    // Install the UserTransactionAccessControlService
    final UserTransactionAccessControlService lookupControlService = new UserTransactionAccessControlService();
    context.getServiceTarget().addService(UserTransactionAccessControlService.SERVICE_NAME, lookupControlService).install();
    // Bind the UserTransaction into JNDI
    final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction");
    final ServiceBuilder<ManagedReferenceFactory> utBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("UserTransaction"), userTransactionBindingService);
    utBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()).addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class, userTransactionBindingService.getUserTransactionAccessControlServiceInjector()).addDependency(UserTransactionService.INTERNAL_SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector()));
    utBuilder.install();
    // install the EE Concurrency transaction setup provider's service
    final TransactionSetupProviderService transactionSetupProviderService = new TransactionSetupProviderService();
    context.getServiceTarget().addService(ConcurrentServiceNames.TRANSACTION_SETUP_PROVIDER_SERVICE_NAME, transactionSetupProviderService).addDependency(TransactionManagerService.INTERNAL_SERVICE_NAME, TransactionManager.class, transactionSetupProviderService.getTransactionManagerInjectedValue()).install();
}
Also used : TransactionLeakRollbackProcessor(org.jboss.as.txn.deployment.TransactionLeakRollbackProcessor) EEConcurrencyContextHandleFactoryProcessor(org.jboss.as.txn.ee.concurrency.EEConcurrencyContextHandleFactoryProcessor) TransactionDependenciesProcessor(org.jboss.as.txn.deployment.TransactionDependenciesProcessor) BinderService(org.jboss.as.naming.service.BinderService) InjectionException(org.jboss.msc.inject.InjectionException) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) UserTransaction(javax.transaction.UserTransaction) Resource(org.jboss.as.controller.registry.Resource) UserTransactionBindingService(org.jboss.as.txn.service.UserTransactionBindingService) LinkedList(java.util.LinkedList) TransactionSetupProviderService(org.jboss.as.txn.ee.concurrency.TransactionSetupProviderService) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) UserTransactionAccessControlService(org.jboss.as.txn.service.UserTransactionAccessControlService) TransactionManager(javax.transaction.TransactionManager) TransactionJndiBindingProcessor(org.jboss.as.txn.deployment.TransactionJndiBindingProcessor)

Example 4 with InjectionException

use of org.jboss.msc.inject.InjectionException in project wildfly by wildfly.

the class DiscoveryRegistrationProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    // we only process top level deployment units
    if (deploymentUnit.getParent() != null) {
        return;
    }
    final ServiceName profileServiceName = deploymentUnit.getAttachment(EjbDeploymentAttachmentKeys.EJB_REMOTING_PROFILE_SERVICE_NAME);
    final DiscoveryService discoveryService = new DiscoveryService();
    final ServiceName discoveryServiceName = DiscoveryService.BASE_NAME.append(deploymentUnit.getName());
    final ServiceBuilder<Discovery> builder = phaseContext.getServiceTarget().addService(discoveryServiceName, discoveryService);
    Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();
    new RemoteEJBDiscoveryConfigurator().configure(providerInjector::inject, registryProvider -> {
    });
    if (profileServiceName != null)
        builder.addDependency(profileServiceName, RemotingProfileService.class, new Injector<RemotingProfileService>() {

            Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();

            public void inject(final RemotingProfileService value) throws InjectionException {
                providerInjector.inject(new StaticDiscoveryProvider(value.getServiceUrls()));
            }

            public void uninject() {
                providerInjector.uninject();
            }
        });
    providerInjector = discoveryService.getDiscoveryProviderInjector();
    new HttpDiscoveryConfigurator().configure(providerInjector::inject, registryProvider -> {
    });
    // only add association service dependency if the context is configured to use the local EJB receiver & we are not app client
    final EJBClientDescriptorMetaData ejbClientDescriptorMetaData = deploymentUnit.getAttachment(Attachments.EJB_CLIENT_METADATA);
    final boolean useLocalReceiver = ejbClientDescriptorMetaData == null || ejbClientDescriptorMetaData.isLocalReceiverExcluded() != Boolean.TRUE;
    if (useLocalReceiver && !appClient) {
        builder.addDependency(AssociationService.SERVICE_NAME, AssociationService.class, new Injector<AssociationService>() {

            Injector<DiscoveryProvider> providerInjector = discoveryService.getDiscoveryProviderInjector();

            public void inject(final AssociationService value) throws InjectionException {
                providerInjector.inject(value.getLocalDiscoveryProvider());
            }

            public void uninject() {
                providerInjector.uninject();
            }
        });
    }
    builder.install();
}
Also used : RemoteEJBDiscoveryConfigurator(org.jboss.ejb.protocol.remote.RemoteEJBDiscoveryConfigurator) DiscoveryProvider(org.wildfly.discovery.spi.DiscoveryProvider) StaticDiscoveryProvider(org.wildfly.discovery.impl.StaticDiscoveryProvider) Discovery(org.wildfly.discovery.Discovery) HttpDiscoveryConfigurator(org.wildfly.httpclient.ejb.HttpDiscoveryConfigurator) AssociationService(org.jboss.as.ejb3.remote.AssociationService) InjectionException(org.jboss.msc.inject.InjectionException) ServiceName(org.jboss.msc.service.ServiceName) Injector(org.jboss.msc.inject.Injector) EJBClientDescriptorMetaData(org.jboss.as.ee.metadata.EJBClientDescriptorMetaData) StaticDiscoveryProvider(org.wildfly.discovery.impl.StaticDiscoveryProvider) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) RemotingProfileService(org.jboss.as.ejb3.remote.RemotingProfileService)

Aggregations

InjectionException (org.jboss.msc.inject.InjectionException)4 ServiceName (org.jboss.msc.service.ServiceName)4 EJBClientDescriptorMetaData (org.jboss.as.ee.metadata.EJBClientDescriptorMetaData)2 RemotingProfileService (org.jboss.as.ejb3.remote.RemotingProfileService)2 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)2 ValueManagedReferenceFactory (org.jboss.as.naming.ValueManagedReferenceFactory)2 BinderService (org.jboss.as.naming.service.BinderService)2 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)2 Injector (org.jboss.msc.inject.Injector)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 Properties (java.util.Properties)1 TransactionManager (javax.transaction.TransactionManager)1 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)1 UserTransaction (javax.transaction.UserTransaction)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 Resource (org.jboss.as.controller.registry.Resource)1 AssociationService (org.jboss.as.ejb3.remote.AssociationService)1