Search in sources :

Example 41 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class EndpointService method isElytronSecurityDomain.

private static boolean isElytronSecurityDomain(DeploymentUnit unit, Endpoint endpoint, String domainName) {
    CapabilityServiceSupport capabilitySupport = unit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    if (capabilitySupport != null && !capabilitySupport.hasCapability(ELYTRON_SECURITY_CAPABILITY)) {
        return false;
    }
    final ServiceName serviceName;
    if (EndpointType.JAXWS_EJB3.equals(endpoint.getType())) {
        serviceName = EJB_APPLICATION_SECURITY_DOMAIN_RUNTIME_CAPABILITY.getCapabilityServiceName(domainName, ApplicationSecurityDomainService.ApplicationSecurityDomain.class);
    } else {
        serviceName = ServiceNameFactory.parseServiceName(WEB_APPLICATION_SECURITY_DOMAIN).append(domainName).append(Constants.SECURITY_DOMAIN);
    }
    return currentServiceContainer().getService(serviceName) != null;
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ApplicationSecurityDomain(org.jboss.as.ejb3.subsystem.ApplicationSecurityDomainService.ApplicationSecurityDomain) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport)

Example 42 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class EJB3SubsystemAdd method performBoottime.

@Override
protected void performBoottime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    final ModelNode model = resource.getModel();
    // Install the server association service
    final AssociationService associationService = new AssociationService();
    final ServiceName suspendControllerServiceName = context.getCapabilityServiceName("org.wildfly.server.suspend-controller", SuspendController.class);
    final ServiceBuilder<AssociationService> associationServiceBuilder = context.getServiceTarget().addService(AssociationService.SERVICE_NAME, associationService);
    associationServiceBuilder.addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, associationService.getDeploymentRepositoryInjector()).addDependency(suspendControllerServiceName, SuspendController.class, associationService.getSuspendControllerInjector()).addDependency(ServerEnvironmentService.SERVICE_NAME, ServerEnvironment.class, associationService.getServerEnvironmentServiceInjector()).setInitialMode(ServiceController.Mode.LAZY);
    if (resource.hasChild(EJB3SubsystemModel.REMOTE_SERVICE_PATH)) {
        ModelNode remoteModel = resource.getChild(EJB3SubsystemModel.REMOTE_SERVICE_PATH).getModel();
        String clusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, remoteModel).asString();
        // For each connector
        for (ModelNode connector : EJB3RemoteResourceDefinition.CONNECTORS.resolveModelAttribute(context, remoteModel).asList()) {
            String connectorName = connector.asString();
            Map.Entry<Injector<ProtocolSocketBinding>, Injector<Registry>> entry = associationService.addConnectorInjectors(connectorName);
            associationServiceBuilder.addDependency(context.getCapabilityServiceName(CONNECTOR_CAPABILITY_NAME, connectorName, ProtocolSocketBinding.class), ProtocolSocketBinding.class, entry.getKey());
            associationServiceBuilder.addDependency(ClusteringCacheRequirement.REGISTRY.getServiceName(context, clusterName, connectorName), Registry.class, entry.getValue());
        }
    }
    associationServiceBuilder.install();
    // setup IIOP related stuff
    // This goes here rather than in EJB3IIOPAdd as it affects the server when it is acting as an iiop client
    // setup our dynamic stub factory
    DelegatingStubFactoryFactory.setOverriddenDynamicFactory(new DynamicStubFactoryFactory());
    // setup the substitution service, that translates between ejb proxies and IIOP stubs
    final RemoteObjectSubstitutionService substitutionService = new RemoteObjectSubstitutionService();
    context.getServiceTarget().addService(RemoteObjectSubstitutionService.SERVICE_NAME, substitutionService).addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, substitutionService.getDeploymentRepositoryInjectedValue()).install();
    // register EJB context selector
    RemoteObjectSubstitutionManager.setRemoteObjectSubstitution(substitutionService);
    final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
    final ModelNode defaultDistinctName = EJB3SubsystemRootResourceDefinition.DEFAULT_DISTINCT_NAME.resolveModelAttribute(context, model);
    final DefaultDistinctNameService defaultDistinctNameService = new DefaultDistinctNameService(defaultDistinctName.isDefined() ? defaultDistinctName.asString() : null);
    context.getServiceTarget().addService(DefaultDistinctNameService.SERVICE_NAME, defaultDistinctNameService).install();
    final ModelNode ejbNameRegex = EJB3SubsystemRootResourceDefinition.ALLOW_EJB_NAME_REGEX.resolveModelAttribute(context, model);
    final EjbNameRegexService ejbNameRegexService = new EjbNameRegexService(ejbNameRegex.isDefined() ? ejbNameRegex.asBoolean() : false);
    context.getServiceTarget().addService(EjbNameRegexService.SERVICE_NAME, ejbNameRegexService).install();
    // set the default security domain name in the deployment unit processor, configured at the subsystem level
    final ModelNode defaultSecurityDomainModelNode = EJB3SubsystemRootResourceDefinition.DEFAULT_SECURITY_DOMAIN.resolveModelAttribute(context, model);
    final String defaultSecurityDomain = defaultSecurityDomainModelNode.isDefined() ? defaultSecurityDomainModelNode.asString() : null;
    this.defaultSecurityDomainDeploymentProcessor.setDefaultSecurityDomainName(defaultSecurityDomain);
    // set the default security domain name in the deployment unit processor, configured at the subsytem level
    final ModelNode defaultMissingMethod = EJB3SubsystemRootResourceDefinition.DEFAULT_MISSING_METHOD_PERMISSIONS_DENY_ACCESS.resolveModelAttribute(context, model);
    final boolean defaultMissingMethodValue = defaultMissingMethod.asBoolean();
    this.missingMethodPermissionsDenyAccessMergingProcessor.setDenyAccessByDefault(defaultMissingMethodValue);
    final ModelNode defaultStatefulSessionTimeout = EJB3SubsystemRootResourceDefinition.DEFAULT_STATEFUL_BEAN_SESSION_TIMEOUT.resolveModelAttribute(context, model);
    final ValueService<AtomicLong> defaultStatefulSessionTimeoutService = new ValueService<>(new ImmediateValue<>(defaultStatefulSessionTimeout.isDefined() ? new AtomicLong(defaultStatefulSessionTimeout.asLong()) : DefaultStatefulBeanSessionTimeoutWriteHandler.INITIAL_TIMEOUT_VALUE));
    context.getServiceTarget().addService(DefaultStatefulBeanSessionTimeoutWriteHandler.SERVICE_NAME, defaultStatefulSessionTimeoutService).install();
    final boolean defaultMdbPoolAvailable = model.hasDefined(DEFAULT_MDB_INSTANCE_POOL);
    final boolean defaultSlsbPoolAvailable = model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL);
    CapabilityServiceSupport capabilitySupport = context.getCapabilityServiceSupport();
    final boolean elytronJacc = capabilitySupport.hasCapability(ELYTRON_JACC_CAPABILITY);
    final boolean legacyJacc = !elytronJacc && capabilitySupport.hasCapability(LEGACY_JACC_CAPABILITY);
    context.addStep(new AbstractDeploymentChainStep() {

        @Override
        protected void execute(DeploymentProcessorTarget processorTarget) {
            // DUP's that are used even for app client deployments
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_EJB, new JBossAllXmlParserRegisteringProcessor<EjbJarMetaData>(EjbJarJBossAllParser.ROOT_ELEMENT, EjbJarJBossAllParser.ATTACHMENT_KEY, new EjbJarJBossAllParser()));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DEFAULT_DISTINCT_NAME, new EjbDefaultDistinctNameProcessor(defaultDistinctNameService));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_CONTEXT_BINDING, new EjbContextJndiBindingProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DEPLOYMENT, new EjbJarParsingDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_CREATE_COMPONENT_DESCRIPTIONS, new AnnotatedEJBComponentDescriptionDeploymentUnitProcessor(appclient, defaultMdbPoolAvailable, defaultSlsbPoolAvailable));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_SESSION_BEAN_DD, new SessionBeanXmlDescriptorProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_ANNOTATION_EJB, new EjbAnnotationProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_INJECTION_ANNOTATION, new EjbResourceInjectionAnnotationProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_ASSEMBLY_DESC_DD, new AssemblyDescriptorProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB, new EjbDependencyDeploymentUnitProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_HOME_MERGE, new HomeViewMergingProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_REF, new EjbRefProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_BUSINESS_VIEW_ANNOTATION, new BusinessViewAnnotationProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_ORB_BIND, new IIOPJndiBindingProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_JNDI_BINDINGS, new EjbJndiBindingsDeploymentUnitProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CLIENT_METADATA, new EJBClientDescriptorMetaDataProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DISCOVERY, new DiscoveryRegistrationProcessor(appclient));
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DEFAULT_SECURITY_DOMAIN, EJB3SubsystemAdd.this.defaultSecurityDomainDeploymentProcessor);
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND, new EJBComponentSuspendDeploymentUnitProcessor());
            // TODO: real phase numbers
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND + 1, new EjbClientContextSetupProcessor());
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EE_COMPONENT_SUSPEND + 2, new StartupAwaitDeploymentUnitProcessor());
            if (legacyJacc || elytronJacc) {
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EJB_JACC_PROCESSING, new JaccEjbDeploymentProcessor(elytronJacc ? ELYTRON_JACC_CAPABILITY : LEGACY_JACC_CAPABILITY));
            }
            processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.CLEANUP, Phase.CLEANUP_EJB, new EjbCleanUpProcessor());
            if (!appclient) {
                // add the metadata parser deployment processor
                // Process @DependsOn after the @Singletons have been registered.
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_TIMERSERVICE_BINDING, new TimerServiceJndiBindingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_APPLICATION_EXCEPTION_ANNOTATION, new ApplicationExceptionAnnotationProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_DD_INTERCEPTORS, new InterceptorClassDeploymentDescriptorProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_EJB_SECURITY_ROLE_REF_DD, new SecurityRoleRefDDProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PASSIVATION_ANNOTATION, new PassivationAnnotationParsingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_IMPLICIT_NO_INTERFACE_VIEW, new ImplicitLocalViewProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_APPLICATION_EXCEPTIONS, new ApplicationExceptionMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DD_INTERCEPTORS, new DeploymentDescriptorInterceptorBindingsProcessor(ejbNameRegexService));
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DD_METHOD_RESOLUTION, new DeploymentDescriptorMethodProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TRANSACTION_MANAGEMENT, new TransactionManagementMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CONCURRENCY_MANAGEMENT_MERGE, new ConcurrencyManagementMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CONCURRENCY_MERGE, new EjbConcurrencyMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_TX_ATTR_MERGE, new TransactionAttributeMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_RUN_AS_MERGE, new RunAsMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_RESOURCE_ADAPTER_MERGE, new ResourceAdaptorMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CLUSTERED, new ClusteredSingletonMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_DELIVERY_ACTIVE_MERGE, new MdbDeliveryMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_REMOVE_METHOD, new RemoveMethodMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_STARTUP_MERGE, new StartupMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_DOMAIN, new SecurityDomainMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_MISSING_METHOD_PERMISSIONS, missingMethodPermissionsDenyAccessMergingProcessor);
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_ROLES, new DeclareRolesMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_METHOD_PERMISSIONS, new MethodPermissionsMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_STATEFUL_TIMEOUT, new StatefulTimeoutMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SESSION_SYNCHRONIZATION, new SessionSynchronizationMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_INIT_METHOD, new InitMethodMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SESSION_BEAN, new SessionBeanMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SECURITY_PRINCIPAL_ROLE_MAPPING_MERGE, new SecurityRolesMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_LOCAL_HOME, new SessionBeanHomeProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_CACHE, new CacheMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SLSB_POOL_NAME_MERGE, new StatelessSessionBeanPoolMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_MDB_POOL_NAME_MERGE, new MessageDrivenBeanPoolMergingProcessor());
                // Add the deployment unit processor responsible for processing the user application specific container interceptors configured in jboss-ejb3.xml
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_USER_APP_SPECIFIC_CONTAINER_INTERCEPTORS, new ContainerInterceptorBindingsDDProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_HIBERNATE_VALIDATOR, new HibernateValidatorDeploymentUnitProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEPENDS_ON_ANNOTATION, new EjbDependsOnMergingProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_DEPLOYMENT_REPOSITORY, new DeploymentRepositoryProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EJB_MANAGEMENT_RESOURCES, new EjbManagementDeploymentUnitProcessor());
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_CACHE_DEPENDENCIES, new CacheDependenciesProcessor());
                // TODO Phase: replace by  Phase.INSTALL_MDB_DELIVERY_DEPENDENCIES
                processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_EE_MODULE_CONFIG + 1, new MdbDeliveryDependenciesProcessor());
                if (model.hasDefined(SERVER_INTERCEPTORS)) {
                    final List<ServerInterceptorMetaData> serverInterceptors = new ArrayList<>();
                    final ModelNode serverInterceptorsNode = model.get(SERVER_INTERCEPTORS);
                    for (final ModelNode serverInterceptor : serverInterceptorsNode.asList()) {
                        serverInterceptors.add(new ServerInterceptorMetaData(serverInterceptor.get("module").asString(), serverInterceptor.get("class").asString()));
                    }
                    processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB_SERVER_INTERCEPTORS, new StaticInterceptorsDependenciesDeploymentUnitProcessor(serverInterceptors));
                    final ServerInterceptorCache serverInterceptorCache = new ServerInterceptorCache(serverInterceptors);
                    processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_EJB_SERVER_INTERCEPTORS, new ServerInterceptorsBindingsProcessor(serverInterceptorCache));
                }
                if (model.hasDefined(CLIENT_INTERCEPTORS)) {
                    final List<ServerInterceptorMetaData> clientInterceptors = new ArrayList<>();
                    final ModelNode clientInterceptorsNode = model.get(CLIENT_INTERCEPTORS);
                    for (final ModelNode clientInterceptor : clientInterceptorsNode.asList()) {
                        clientInterceptors.add(new ServerInterceptorMetaData(clientInterceptor.get("module").asString(), clientInterceptor.get("class").asString()));
                    }
                    processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_EJB_SERVER_INTERCEPTORS, new StaticInterceptorsDependenciesDeploymentUnitProcessor(clientInterceptors));
                    final ClientInterceptorCache clientInterceptorCache = new ClientInterceptorCache(clientInterceptors);
                    processorTarget.addDeploymentProcessor(EJB3Extension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.POST_MODULE_EJB_SERVER_INTERCEPTORS, new ClientInterceptorsBindingsProcessor(clientInterceptorCache));
                }
            }
        }
    }, OperationContext.Stage.RUNTIME);
    // todo maybe needs EJB3SubsystemRootResourceDefinition.DEFAULT_MDB_INSTANCE_POOL.resolveModelAttribute(context,model).isDefined()
    if (model.hasDefined(DEFAULT_MDB_INSTANCE_POOL)) {
        EJB3SubsystemDefaultPoolWriteHandler.MDB_POOL.updatePoolService(context, model);
    }
    if (model.hasDefined(DEFAULT_SLSB_INSTANCE_POOL)) {
        EJB3SubsystemDefaultPoolWriteHandler.SLSB_POOL.updatePoolService(context, model);
    }
    if (model.hasDefined(DEFAULT_ENTITY_BEAN_INSTANCE_POOL)) {
        EJB3SubsystemDefaultPoolWriteHandler.ENTITY_BEAN_POOL.updatePoolService(context, model);
    }
    if (model.hasDefined(DEFAULT_SFSB_CACHE)) {
        EJB3SubsystemDefaultCacheWriteHandler.SFSB_CACHE.updateCacheService(context, model);
    }
    if (model.hasDefined(DEFAULT_SFSB_PASSIVATION_DISABLED_CACHE)) {
        EJB3SubsystemDefaultCacheWriteHandler.SFSB_PASSIVATION_DISABLED_CACHE.updateCacheService(context, model);
    }
    if (model.hasDefined(DEFAULT_RESOURCE_ADAPTER_NAME)) {
        DefaultResourceAdapterWriteHandler.INSTANCE.updateDefaultAdapterService(context, model);
    }
    if (model.hasDefined(DEFAULT_SINGLETON_BEAN_ACCESS_TIMEOUT)) {
        DefaultSingletonBeanAccessTimeoutWriteHandler.INSTANCE.updateOrCreateDefaultSingletonBeanAccessTimeoutService(context, model);
    }
    if (model.hasDefined(DEFAULT_STATEFUL_BEAN_ACCESS_TIMEOUT)) {
        DefaultStatefulBeanAccessTimeoutWriteHandler.INSTANCE.updateOrCreateDefaultStatefulBeanAccessTimeoutService(context, model);
    }
    if (model.hasDefined(DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING)) {
        EJB3SubsystemDefaultEntityBeanOptimisticLockingWriteHandler.INSTANCE.updateOptimisticLocking(context, model);
    }
    ExceptionLoggingWriteHandler.INSTANCE.updateOrCreateDefaultExceptionLoggingEnabledService(context, model);
    final ServiceTarget serviceTarget = context.getServiceTarget();
    context.getServiceTarget().addService(DeploymentRepositoryService.SERVICE_NAME, new DeploymentRepositoryService()).install();
    addRemoteInvocationServices(context, model, appclient);
    // add clustering service
    addClusteringServices(context, appclient);
    // add user transaction access control service
    final EJB3UserTransactionAccessControlService userTxAccessControlService = new EJB3UserTransactionAccessControlService();
    context.getServiceTarget().addService(EJB3UserTransactionAccessControlService.SERVICE_NAME, userTxAccessControlService).addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class, userTxAccessControlService.getUserTransactionAccessControlServiceInjector()).install();
    // add ejb suspend handler service
    boolean enableGracefulShutdown = EJB3SubsystemRootResourceDefinition.ENABLE_GRACEFUL_TXN_SHUTDOWN.resolveModelAttribute(context, model).asBoolean();
    final EJBSuspendHandlerService ejbSuspendHandlerService = new EJBSuspendHandlerService(enableGracefulShutdown);
    context.getServiceTarget().addService(EJBSuspendHandlerService.SERVICE_NAME, ejbSuspendHandlerService).addDependency(suspendControllerServiceName, SuspendController.class, ejbSuspendHandlerService.getSuspendControllerInjectedValue()).addDependency(TxnServices.JBOSS_TXN_LOCAL_TRANSACTION_CONTEXT, LocalTransactionContext.class, ejbSuspendHandlerService.getLocalTransactionContextInjectedValue()).addDependency(DeploymentRepositoryService.SERVICE_NAME, DeploymentRepository.class, ejbSuspendHandlerService.getDeploymentRepositoryInjectedValue()).install();
    if (!appclient) {
        // create the POA Registry use by iiop
        final POARegistry poaRegistry = new POARegistry();
        context.getServiceTarget().addService(POARegistry.SERVICE_NAME, poaRegistry).addDependency(CorbaPOAService.ROOT_SERVICE_NAME, POA.class, poaRegistry.getRootPOA()).setInitialMode(ServiceController.Mode.PASSIVE).install();
        StatisticsEnabledWriteHandler.INSTANCE.updateToRuntime(context, model);
        if (context.hasOptionalCapability(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, EJB3SubsystemRootResourceDefinition.EJB_CAPABILITY.getName(), null)) {
            EJB3RemoteHTTPService service = new EJB3RemoteHTTPService(FilterSpecClassResolverFilter.getFilterForOperationContext(context));
            context.getServiceTarget().addService(EJB3RemoteHTTPService.SERVICE_NAME, service).addDependency(context.getCapabilityServiceName(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, PathHandler.class), PathHandler.class, service.getPathHandlerInjectedValue()).addDependency(TxnServices.JBOSS_TXN_LOCAL_TRANSACTION_CONTEXT, LocalTransactionContext.class, service.getLocalTransactionContextInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, service.getAssociationServiceInjectedValue()).setInitialMode(ServiceController.Mode.PASSIVE).install();
        }
    }
}
Also used : EjbConcurrencyMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.EjbConcurrencyMergingProcessor) PathHandler(io.undertow.server.handlers.PathHandler) DynamicStubFactoryFactory(org.jboss.as.ejb3.iiop.stub.DynamicStubFactoryFactory) EJBComponentSuspendDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.EJBComponentSuspendDeploymentUnitProcessor) EjbDependsOnMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.EjbDependsOnMergingProcessor) AssemblyDescriptorProcessor(org.jboss.as.ejb3.deployment.processors.dd.AssemblyDescriptorProcessor) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) MdbDeliveryDependenciesProcessor(org.jboss.as.ejb3.deployment.processors.MdbDeliveryDependenciesProcessor) EjbJndiBindingsDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.EjbJndiBindingsDeploymentUnitProcessor) ServerEnvironment(org.jboss.as.server.ServerEnvironment) MdbDeliveryMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.MdbDeliveryMergingProcessor) EJBClientDescriptorMetaDataProcessor(org.jboss.as.ejb3.deployment.processors.EJBClientDescriptorMetaDataProcessor) StartupMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.StartupMergingProcessor) CacheDependenciesProcessor(org.jboss.as.ejb3.deployment.processors.CacheDependenciesProcessor) TransactionAttributeMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.TransactionAttributeMergingProcessor) EjbJarParsingDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.EjbJarParsingDeploymentUnitProcessor) SessionBeanHomeProcessor(org.jboss.as.ejb3.deployment.processors.SessionBeanHomeProcessor) InitMethodMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.InitMethodMergingProcessor) ServerInterceptorMetaData(org.jboss.as.ejb3.interceptor.server.ServerInterceptorMetaData) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) UserTransactionAccessControlService(org.jboss.as.txn.service.UserTransactionAccessControlService) ModelNode(org.jboss.dmr.ModelNode) Map(java.util.Map) MethodPermissionsMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.MethodPermissionsMergingProcessor) HibernateValidatorDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.HibernateValidatorDeploymentUnitProcessor) POARegistry(org.jboss.as.ejb3.iiop.POARegistry) HomeViewMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.HomeViewMergingProcessor) AnnotatedEJBComponentDescriptionDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.AnnotatedEJBComponentDescriptionDeploymentUnitProcessor) EjbDefaultDistinctNameProcessor(org.jboss.as.ejb3.deployment.processors.EjbDefaultDistinctNameProcessor) TransactionManagementMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.TransactionManagementMergingProcessor) IIOPJndiBindingProcessor(org.jboss.as.ejb3.deployment.processors.IIOPJndiBindingProcessor) BusinessViewAnnotationProcessor(org.jboss.as.ejb3.deployment.processors.BusinessViewAnnotationProcessor) SuspendController(org.jboss.as.server.suspend.SuspendController) EjbCleanUpProcessor(org.jboss.as.ejb3.deployment.processors.EjbCleanUpProcessor) RemoteObjectSubstitutionService(org.jboss.as.ejb3.iiop.RemoteObjectSubstitutionService) DeploymentRepositoryService(org.jboss.as.ejb3.deployment.DeploymentRepositoryService) ResourceAdaptorMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.ResourceAdaptorMergingProcessor) ContainerInterceptorBindingsDDProcessor(org.jboss.as.ejb3.deployment.processors.dd.ContainerInterceptorBindingsDDProcessor) ApplicationExceptionMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.ApplicationExceptionMergingProcessor) EjbJarJBossAllParser(org.jboss.as.ejb3.deployment.processors.EjbJarJBossAllParser) RunAsMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.RunAsMergingProcessor) AssociationService(org.jboss.as.ejb3.remote.AssociationService) AtomicLong(java.util.concurrent.atomic.AtomicLong) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) SecurityRoleRefDDProcessor(org.jboss.as.ejb3.deployment.processors.dd.SecurityRoleRefDDProcessor) EjbResourceInjectionAnnotationProcessor(org.jboss.as.ejb3.deployment.processors.EjbResourceInjectionAnnotationProcessor) SecurityDomainMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.SecurityDomainMergingProcessor) DeploymentRepositoryProcessor(org.jboss.as.ejb3.deployment.processors.DeploymentRepositoryProcessor) Injector(org.jboss.msc.inject.Injector) InterceptorClassDeploymentDescriptorProcessor(org.jboss.as.ejb3.deployment.processors.dd.InterceptorClassDeploymentDescriptorProcessor) ImplicitLocalViewProcessor(org.jboss.as.ejb3.deployment.processors.ImplicitLocalViewProcessor) ArrayList(java.util.ArrayList) List(java.util.List) EjbDependencyDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.EjbDependencyDeploymentUnitProcessor) ConcurrencyManagementMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.ConcurrencyManagementMergingProcessor) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentDescriptorMethodProcessor(org.jboss.as.ejb3.deployment.processors.dd.DeploymentDescriptorMethodProcessor) EJB3RemoteHTTPService(org.jboss.as.ejb3.remote.http.EJB3RemoteHTTPService) EjbRefProcessor(org.jboss.as.ejb3.deployment.processors.EjbRefProcessor) SessionSynchronizationMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.SessionSynchronizationMergingProcessor) MessageDrivenBeanPoolMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.MessageDrivenBeanPoolMergingProcessor) LocalTransactionContext(org.wildfly.transaction.client.LocalTransactionContext) ServerInterceptorCache(org.jboss.as.ejb3.interceptor.server.ServerInterceptorCache) ApplicationExceptionAnnotationProcessor(org.jboss.as.ejb3.deployment.processors.ApplicationExceptionAnnotationProcessor) ServiceName(org.jboss.msc.service.ServiceName) ProtocolSocketBinding(org.jboss.as.network.ProtocolSocketBinding) EjbManagementDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.EjbManagementDeploymentUnitProcessor) EjbAnnotationProcessor(org.jboss.as.ejb3.deployment.processors.annotation.EjbAnnotationProcessor) EjbClientContextSetupProcessor(org.jboss.as.ejb3.deployment.processors.EjbClientContextSetupProcessor) PassivationAnnotationParsingProcessor(org.jboss.as.ejb3.deployment.processors.PassivationAnnotationParsingProcessor) DeclareRolesMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.DeclareRolesMergingProcessor) CacheMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.CacheMergingProcessor) ValueService(org.jboss.msc.service.ValueService) StatelessSessionBeanPoolMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.StatelessSessionBeanPoolMergingProcessor) TimerServiceJndiBindingProcessor(org.jboss.as.ejb3.deployment.processors.TimerServiceJndiBindingProcessor) EJBSuspendHandlerService(org.jboss.as.ejb3.suspend.EJBSuspendHandlerService) DeploymentRepository(org.jboss.as.ejb3.deployment.DeploymentRepository) RemoveMethodMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.RemoveMethodMergingProcessor) DeploymentDescriptorInterceptorBindingsProcessor(org.jboss.as.ejb3.deployment.processors.dd.DeploymentDescriptorInterceptorBindingsProcessor) JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) StartupAwaitDeploymentUnitProcessor(org.jboss.as.ejb3.deployment.processors.StartupAwaitDeploymentUnitProcessor) SecurityRolesMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.SecurityRolesMergingProcessor) DiscoveryRegistrationProcessor(org.jboss.as.ejb3.deployment.processors.DiscoveryRegistrationProcessor) SessionBeanMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.SessionBeanMergingProcessor) ClusteredSingletonMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.ClusteredSingletonMergingProcessor) ClientInterceptorCache(org.jboss.as.ejb3.interceptor.server.ClientInterceptorCache) JaccEjbDeploymentProcessor(org.jboss.as.ejb3.deployment.processors.security.JaccEjbDeploymentProcessor) SessionBeanXmlDescriptorProcessor(org.jboss.as.ejb3.deployment.processors.dd.SessionBeanXmlDescriptorProcessor) StatefulTimeoutMergingProcessor(org.jboss.as.ejb3.deployment.processors.merging.StatefulTimeoutMergingProcessor) EjbContextJndiBindingProcessor(org.jboss.as.ejb3.deployment.processors.EjbContextJndiBindingProcessor)

Example 43 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class JaxrsComponentDeployer method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    if (module == null) {
        return;
    }
    final ResteasyDeploymentData resteasy = deploymentUnit.getAttachment(JaxrsAttachments.RESTEASY_DEPLOYMENT_DATA);
    if (resteasy == null) {
        return;
    }
    // Set up the context for managed threads
    phaseContext.getDeploymentUnit().addToAttachmentList(Attachments.ADDITIONAL_FACTORIES, ResteasyContextHandleFactory.INSTANCE);
    // right now I only support resources
    if (!resteasy.isScanResources())
        return;
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final ClassLoader loader = module.getClassLoader();
    final CapabilityServiceSupport support = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    boolean partOfWeldDeployment = false;
    if (support.hasCapability(WELD_CAPABILITY_NAME)) {
        partOfWeldDeployment = support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get().isPartOfWeldDeployment(deploymentUnit);
    }
    for (final ComponentDescription component : moduleDescription.getComponentDescriptions()) {
        Class<?> componentClass = null;
        try {
            componentClass = loader.loadClass(component.getComponentClassName());
        } catch (ClassNotFoundException e) {
            throw new DeploymentUnitProcessingException(e);
        }
        if (!GetRestful.isRootResource(componentClass))
            continue;
        if (isInstanceOf(component, SESSION_BEAN_DESCRIPTION_CLASS_NAME)) {
            if (isInstanceOf(component, STATEFUL_SESSION_BEAN_DESCRIPTION_CLASS_NAME)) {
                // using SFSB's as Jakarta RESTful Web Services endpoints is not recommended, but if people really want to do it they can
                JAXRS_LOGGER.debugf("Stateful session bean %s is being used as a Jakarta RESTful Web Services endpoint, this is not recommended", component.getComponentName());
                if (partOfWeldDeployment) {
                    // if possible just let CDI handle the integration
                    continue;
                }
            }
            Class<?>[] jaxrsType = GetRestful.getSubResourceClasses(componentClass);
            final String jndiName;
            if (component.getViews().size() == 1) {
                // only 1 view, just use the simple JNDI name
                jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName();
            } else {
                boolean found = false;
                String foundType = null;
                for (final ViewDescription view : component.getViews()) {
                    for (Class<?> subResource : jaxrsType) {
                        if (view.getViewClassName().equals(subResource.getName())) {
                            foundType = subResource.getName();
                            found = true;
                            break;
                        }
                    }
                    if (found) {
                        break;
                    }
                }
                if (!found) {
                    throw JAXRS_LOGGER.typeNameNotAnEjbView(Arrays.asList(jaxrsType), component.getComponentName());
                }
                jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName() + "!" + foundType;
            }
            JAXRS_LOGGER.debugf("Found Jakarta RESTful Web Services Managed Bean: %s local jndi jaxRsTypeName: %s", component.getComponentClassName(), jndiName);
            StringBuilder buf = new StringBuilder();
            buf.append(jndiName).append(";").append(component.getComponentClassName()).append(";").append("true");
            resteasy.getScannedJndiComponentResources().add(buf.toString());
            // make sure its removed from list
            resteasy.getScannedResourceClasses().remove(component.getComponentClassName());
        } else if (component instanceof ManagedBeanComponentDescription) {
            String jndiName = "java:app/" + moduleDescription.getModuleName() + "/" + component.getComponentName();
            JAXRS_LOGGER.debugf("Found Jakarta RESTful Web Services Managed Bean: %s local jndi name: %s", component.getComponentClassName(), jndiName);
            StringBuilder buf = new StringBuilder();
            buf.append(jndiName).append(";").append(component.getComponentClassName()).append(";").append("true");
            resteasy.getScannedJndiComponentResources().add(buf.toString());
            // make sure its removed from list
            resteasy.getScannedResourceClasses().remove(component.getComponentClassName());
        }
    }
}
Also used : DeploymentUnitProcessingException(org.jboss.as.server.deployment.DeploymentUnitProcessingException) ManagedBeanComponentDescription(org.jboss.as.ee.managedbean.component.ManagedBeanComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ManagedBeanComponentDescription(org.jboss.as.ee.managedbean.component.ManagedBeanComponentDescription) ViewDescription(org.jboss.as.ee.component.ViewDescription) WeldCapability(org.jboss.as.weld.WeldCapability) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 44 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class JaxrsSubsystemAdd method performBoottime.

protected void performBoottime(final OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    final ServiceTarget serviceTarget = context.getServiceTarget();
    JaxrsLogger.JAXRS_LOGGER.resteasyVersion(ResteasyDeployment.class.getPackage().getImplementationVersion());
    context.addStep(new AbstractDeploymentChainStep() {

        public void execute(DeploymentProcessorTarget processorTarget) {
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_JAXRS_ANNOTATIONS, new JaxrsAnnotationProcessor());
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JAXRS_SPRING, new JaxrsSpringProcessor(serviceTarget));
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JAXRS, new JaxrsDependencyProcessor());
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JAXRS_SCANNING, new JaxrsScanningProcessor());
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JAXRS_COMPONENT, new JaxrsComponentDeployer());
            CapabilityServiceSupport capabilities = context.getCapabilityServiceSupport();
            if (capabilities.hasCapability(WELD_CAPABILITY_NAME)) {
                processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JAXRS_CDI_INTEGRATION, new JaxrsCdiIntegrationProcessor());
            }
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_JAXRS_METHOD_PARAMETER, new JaxrsMethodParameterProcessor());
            processorTarget.addDeploymentProcessor(JaxrsExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_JAXRS_DEPLOYMENT, new JaxrsIntegrationProcessor());
        }
    }, OperationContext.Stage.RUNTIME);
    JaxrsServerConfig serverConfig = createServerConfig(operation, context);
    JaxrsServerConfigService.install(serviceTarget, serverConfig);
}
Also used : JaxrsIntegrationProcessor(org.jboss.as.jaxrs.deployment.JaxrsIntegrationProcessor) JaxrsAnnotationProcessor(org.jboss.as.jaxrs.deployment.JaxrsAnnotationProcessor) JaxrsScanningProcessor(org.jboss.as.jaxrs.deployment.JaxrsScanningProcessor) ServiceTarget(org.jboss.msc.service.ServiceTarget) JaxrsSpringProcessor(org.jboss.as.jaxrs.deployment.JaxrsSpringProcessor) JaxrsComponentDeployer(org.jboss.as.jaxrs.deployment.JaxrsComponentDeployer) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) JaxrsDependencyProcessor(org.jboss.as.jaxrs.deployment.JaxrsDependencyProcessor) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) JaxrsCdiIntegrationProcessor(org.jboss.as.jaxrs.deployment.JaxrsCdiIntegrationProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) JaxrsMethodParameterProcessor(org.jboss.as.jaxrs.deployment.JaxrsMethodParameterProcessor)

Example 45 with CapabilityServiceSupport

use of org.jboss.as.controller.capability.CapabilityServiceSupport in project wildfly by wildfly.

the class PersistenceUnitServiceHandler method deployPersistenceUnit.

/**
 * start the persistence unit in one phase
 *
 * @param deploymentUnit
 * @param eeModuleDescription
 * @param serviceTarget
 * @param classLoader
 * @param pu
 * @param provider
 * @param adaptor
 * @param allowCdiBeanManagerAccess
 * @throws DeploymentUnitProcessingException
 */
private static void deployPersistenceUnit(final DeploymentUnit deploymentUnit, final EEModuleDescription eeModuleDescription, final ServiceTarget serviceTarget, final ModuleClassLoader classLoader, final PersistenceUnitMetadata pu, final PersistenceProvider provider, final PersistenceProviderAdaptor adaptor, final boolean allowCdiBeanManagerAccess) throws DeploymentUnitProcessingException {
    pu.setClassLoader(classLoader);
    TransactionManager transactionManager = ContextTransactionManager.getInstance();
    TransactionSynchronizationRegistry transactionSynchronizationRegistry = deploymentUnit.getAttachment(JpaAttachments.TRANSACTION_SYNCHRONIZATION_REGISTRY);
    CapabilityServiceSupport capabilitySupport = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
    try {
        ValidatorFactory validatorFactory = null;
        final HashMap<String, ValidatorFactory> properties = new HashMap<>();
        CapabilityServiceSupport css = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        if (!ValidationMode.NONE.equals(pu.getValidationMode()) && css.hasCapability("org.wildfly.bean-validation")) {
            // Get the Jakarta Contexts and Dependency Injection enabled ValidatorFactory
            validatorFactory = deploymentUnit.getAttachment(BeanValidationAttachments.VALIDATOR_FACTORY);
        }
        BeanManagerAfterDeploymentValidation beanManagerAfterDeploymentValidation = registerJPAEntityListenerRegister(deploymentUnit, capabilitySupport);
        final PersistenceAdaptorRemoval persistenceAdaptorRemoval = new PersistenceAdaptorRemoval(pu, adaptor);
        deploymentUnit.addToAttachmentList(REMOVAL_KEY, persistenceAdaptorRemoval);
        // add persistence provider specific properties
        adaptor.addProviderProperties(properties, pu);
        final ServiceName puServiceName = PersistenceUnitServiceImpl.getPUServiceName(pu);
        deploymentUnit.putAttachment(JpaAttachments.PERSISTENCE_UNIT_SERVICE_KEY, puServiceName);
        deploymentUnit.addToAttachmentList(Attachments.DEPLOYMENT_COMPLETE_SERVICES, puServiceName);
        deploymentUnit.addToAttachmentList(Attachments.WEB_DEPENDENCIES, puServiceName);
        final PersistenceUnitServiceImpl service = new PersistenceUnitServiceImpl(properties, classLoader, pu, adaptor, provider, PersistenceUnitRegistryImpl.INSTANCE, deploymentUnit.getServiceName(), validatorFactory, deploymentUnit.getAttachment(org.jboss.as.ee.naming.Attachments.JAVA_NAMESPACE_SETUP_ACTION), beanManagerAfterDeploymentValidation);
        ServiceBuilder<PersistenceUnitService> builder = serviceTarget.addService(puServiceName, service);
        boolean useDefaultDataSource = Configuration.allowDefaultDataSourceUse(pu);
        final String jtaDataSource = adjustJndi(pu.getJtaDataSourceName());
        final String nonJtaDataSource = adjustJndi(pu.getNonJtaDataSourceName());
        if (jtaDataSource != null && jtaDataSource.length() > 0) {
            if (jtaDataSource.equals(EE_DEFAULT_DATASOURCE)) {
                // explicit use of default datasource
                useDefaultDataSource = true;
            } else {
                builder.addDependency(ContextNames.bindInfoForEnvEntry(eeModuleDescription.getApplicationName(), eeModuleDescription.getModuleName(), eeModuleDescription.getModuleName(), false, jtaDataSource).getBinderServiceName(), ManagedReferenceFactory.class, new ManagedReferenceFactoryInjector(service.getJtaDataSourceInjector()));
                useDefaultDataSource = false;
            }
        }
        if (nonJtaDataSource != null && nonJtaDataSource.length() > 0) {
            builder.addDependency(ContextNames.bindInfoForEnvEntry(eeModuleDescription.getApplicationName(), eeModuleDescription.getModuleName(), eeModuleDescription.getModuleName(), false, nonJtaDataSource).getBinderServiceName(), ManagedReferenceFactory.class, new ManagedReferenceFactoryInjector(service.getNonJtaDataSourceInjector()));
            useDefaultDataSource = false;
        }
        // JPA 2.0 8.2.1.5, container provides default Jakarta Transactions datasource
        if (useDefaultDataSource) {
            // try the default datasource defined in the ee subsystem
            String defaultJtaDataSource = null;
            if (eeModuleDescription != null) {
                defaultJtaDataSource = eeModuleDescription.getDefaultResourceJndiNames().getDataSource();
            }
            if (defaultJtaDataSource == null || defaultJtaDataSource.isEmpty()) {
                // try the datasource defined in the Jakarta Persistence subsystem
                defaultJtaDataSource = adjustJndi(JPAService.getDefaultDataSourceName());
            }
            if (defaultJtaDataSource != null && !defaultJtaDataSource.isEmpty()) {
                builder.addDependency(ContextNames.bindInfoFor(defaultJtaDataSource).getBinderServiceName(), ManagedReferenceFactory.class, new ManagedReferenceFactoryInjector(service.getJtaDataSourceInjector()));
                ROOT_LOGGER.tracef("%s is using the default data source '%s'", puServiceName, defaultJtaDataSource);
            }
        }
        // JPA 2.1 sections 3.5.1 + 9.1 require the Jakarta Contexts and Dependency Injection bean manager to be passed to the peristence provider
        // if the persistence unit is contained in a deployment that is a Jakarta Contexts and Dependency Injection bean archive (has beans.xml).
        final CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        if (support.hasCapability(WELD_CAPABILITY_NAME) && allowCdiBeanManagerAccess) {
            support.getOptionalCapabilityRuntimeAPI(WELD_CAPABILITY_NAME, WeldCapability.class).get().addBeanManagerService(deploymentUnit, builder, service.getBeanManagerInjector());
        }
        try {
            // save a thread local reference to the builder for setting up the second level cache dependencies
            CacheDeploymentListener.setInternalDeploymentSupport(builder, capabilitySupport);
            adaptor.addProviderDependencies(pu);
        } finally {
            CacheDeploymentListener.clearInternalDeploymentSupport();
        }
        /**
         * handle extension that binds a transaction scoped entity manager to specified JNDI location
         */
        entityManagerBind(eeModuleDescription, serviceTarget, pu, puServiceName, transactionManager, transactionSynchronizationRegistry);
        /**
         * handle extension that binds an entity manager factory to specified JNDI location
         */
        entityManagerFactoryBind(eeModuleDescription, serviceTarget, pu, puServiceName);
        // get async executor from Services.addServerExecutorDependency
        addServerExecutorDependency(builder, service.getExecutorInjector());
        builder.install();
        ROOT_LOGGER.tracef("added PersistenceUnitService for '%s'.  PU is ready for injector action.", puServiceName);
        addManagementConsole(deploymentUnit, pu, adaptor, persistenceAdaptorRemoval);
    } catch (ServiceRegistryException e) {
        throw JpaLogger.ROOT_LOGGER.failedToAddPersistenceUnit(e, pu.getPersistenceUnitName());
    }
}
Also used : PhaseOnePersistenceUnitServiceImpl(org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl) PersistenceUnitServiceImpl(org.jboss.as.jpa.service.PersistenceUnitServiceImpl) ValidatorFactory(javax.validation.ValidatorFactory) HashMap(java.util.HashMap) ServiceRegistryException(org.jboss.msc.service.ServiceRegistryException) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) BeanManagerAfterDeploymentValidation(org.jboss.as.jpa.beanmanager.BeanManagerAfterDeploymentValidation) ServiceName(org.jboss.msc.service.ServiceName) ContextTransactionManager(org.wildfly.transaction.client.ContextTransactionManager) TransactionManager(javax.transaction.TransactionManager) TransactionSynchronizationRegistry(javax.transaction.TransactionSynchronizationRegistry) PersistenceUnitService(org.jboss.as.jpa.spi.PersistenceUnitService)

Aggregations

CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)76 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)39 ServiceName (org.jboss.msc.service.ServiceName)38 ServiceTarget (org.jboss.msc.service.ServiceTarget)25 WeldCapability (org.jboss.as.weld.WeldCapability)19 DeploymentUnitProcessingException (org.jboss.as.server.deployment.DeploymentUnitProcessingException)18 Module (org.jboss.modules.Module)16 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)14 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)10 HashMap (java.util.HashMap)9 DeploymentPhaseContext (org.jboss.as.server.deployment.DeploymentPhaseContext)9 ComponentConfiguration (org.jboss.as.ee.component.ComponentConfiguration)8 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)8 ValidatorFactory (javax.validation.ValidatorFactory)7 ModuleSpecification (org.jboss.as.server.deployment.module.ModuleSpecification)7 HashSet (java.util.HashSet)6 TransactionSynchronizationRegistry (javax.transaction.TransactionSynchronizationRegistry)6 ComponentConfigurator (org.jboss.as.ee.component.ComponentConfigurator)6 ModelNode (org.jboss.dmr.ModelNode)6 ModuleLoader (org.jboss.modules.ModuleLoader)6