Package org.jboss.msc.service

Examples of org.jboss.msc.service.ServiceTarget


        if (deploymentUnit.getParent() != null) {
            return;
        }
        EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);

        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();

        final ServiceName applicationContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
        final NamingStoreService contextService = new NamingStoreService();
        serviceTarget.addService(applicationContextServiceName, contextService).install();

        final BinderService applicationNameBinder = new BinderService("AppName");
        serviceTarget.addService(applicationContextServiceName.append("AppName"), applicationNameBinder)
                .addDependency(applicationContextServiceName, ServiceBasedNamingStore.class, applicationNameBinder.getNamingStoreInjector())
                .addInjection(applicationNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getApplicationName())))
                .install();

        deploymentUnit.putAttachment(Attachments.APPLICATION_CONTEXT_CONFIG, applicationContextServiceName);
View Full Code Here


    }

    protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model, ServiceVerificationHandler verificationHandler, List<ServiceController<?>> newControllers) {
        ROOT_LOGGER.activatingSubsystem();

        ServiceTarget target = context.getServiceTarget();
        newControllers.add(target.addService(ProtocolDefaultsService.SERVICE_NAME, new ProtocolDefaultsService())
                .setInitialMode(ServiceController.Mode.ON_DEMAND)
                .install());
        String stack = operation.require(ModelKeys.DEFAULT_STACK).asString();
        InjectedValue<ChannelFactory> factory = new InjectedValue<ChannelFactory>();
        ValueService<ChannelFactory> service = new ValueService<ChannelFactory>(factory);
        newControllers.add(target.addService(ChannelFactoryService.getServiceName(null), service)
                .addDependency(ChannelFactoryService.getServiceName(stack), ChannelFactory.class, factory)
                .setInitialMode(ServiceController.Mode.ON_DEMAND)
                .install());

    }
View Full Code Here

        final JSSESecurityDomain jsseSecurityDomain = createJSSESecurityDomain(securityDomain, operation);
        final String cacheType = getAuthenticationCacheType(operation);

        final SecurityDomainService securityDomainService = new SecurityDomainService(securityDomain,
                applicationPolicy, jsseSecurityDomain, cacheType);
        final ServiceTarget target = context.getServiceTarget();
        // some login modules may require the TransactionManager
        final Injector<TransactionManager> transactionManagerInjector = new Injector<TransactionManager>() {
            public void inject(final TransactionManager value) throws InjectionException {
                TransactionManagerLocator.setTransactionManager(value);
            }

            public void uninject() {
            }
        };
        ServiceBuilder<SecurityDomainContext> builder = target
                .addService(SecurityDomainService.SERVICE_NAME.append(securityDomain), securityDomainService)
                .addDependency(SecurityManagementService.SERVICE_NAME, ISecurityManagement.class,
                        securityDomainService.getSecurityManagementInjector())
                .addDependency(JaasConfigurationService.SERVICE_NAME, Configuration.class,
                        securityDomainService.getConfigurationInjector())
View Full Code Here

    private static ModelControllerClient client;

    @BeforeClass
    public static void setupController() throws InterruptedException {
        container = ServiceContainer.Factory.create("test");
        ServiceTarget target = container.subTarget();
        ControlledProcessState processState = new ControlledProcessState(true);
        PlatformMBeanTestModelControllerService svc = new PlatformMBeanTestModelControllerService(processState);
        ServiceBuilder<ModelController> builder = target.addService(ServiceName.of("ModelController"), svc);
        builder.install();
        svc.latch.await();
        controller = svc.getValue();
        ModelNode setup = Util.getEmptyOperation("setup", new ModelNode());
        controller.execute(setup, null, null, null);
View Full Code Here

public final class EndpointServiceDeploymentAspect extends EndpointLifecycleDeploymentAspect {

    @Override
    public void start(final Deployment dep) {
        super.start(dep);
        final ServiceTarget target = getOptionalAttachment(dep, ServiceTarget.class);
        if (target != null) {
            final DeploymentUnit unit = getRequiredAttachment(dep, DeploymentUnit.class);
            for (final Endpoint ep : dep.getService().getEndpoints()) {
                EndpointService.install(target, ep, unit);
            }
View Full Code Here

    }

    protected void deployComponent(final DeploymentPhaseContext phaseContext, final ComponentConfiguration configuration, final Set<ServiceName> dependencies, final ServiceName bindingDependencyService) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();

        final String applicationName = configuration.getApplicationName();
        final String moduleName = configuration.getModuleName();
        final String componentName = configuration.getComponentName();
        final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
        final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);

        //create additional injectors

        final ServiceName createServiceName = configuration.getComponentDescription().getCreateServiceName();
        final ServiceName startServiceName = configuration.getComponentDescription().getStartServiceName();
        final BasicComponentCreateService createService = configuration.getComponentCreateServiceFactory().constructService(configuration);
        final ServiceBuilder<Component> createBuilder = serviceTarget.addService(createServiceName, createService);
        // inject the DU
        createBuilder.addDependency(deploymentUnit.getServiceName(), DeploymentUnit.class, createService.getDeploymentUnitInjector());

        final ComponentStartService startService = new ComponentStartService();
        final ServiceBuilder<Component> startBuilder = serviceTarget.addService(startServiceName, startService);
        final EEModuleConfiguration moduleConfiguration = deploymentUnit.getAttachment(Attachments.EE_MODULE_CONFIGURATION);

        if (moduleConfiguration == null) {
            return;
        }
        // Add all service dependencies
        for (DependencyConfigurator configurator : configuration.getCreateDependencies()) {
            configurator.configureDependency(createBuilder, createService);
        }
        for (DependencyConfigurator configurator : configuration.getStartDependencies()) {
            configurator.configureDependency(startBuilder, startService);
        }

        // START depends on CREATE
        startBuilder.addDependency(createServiceName, BasicComponent.class, startService.getComponentInjector());

        //don't start components until all bindings are up
        startBuilder.addDependency(bindingDependencyService);
        final ServiceName contextServiceName;
        //set up the naming context if necessary
        if (configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE) {
            final NamingStoreService contextService = new NamingStoreService();
            contextServiceName = configuration.getComponentDescription().getContextServiceName();
            serviceTarget.addService(contextServiceName, contextService).install();
        } else {
            contextServiceName = configuration.getComponentDescription().getContextServiceName();
        }

        final InjectionSource.ResolutionContext resolutionContext = new InjectionSource.ResolutionContext(
                configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.USE_MODULE,
                configuration.getComponentName(),
                configuration.getModuleName(),
                configuration.getApplicationName()
        );

        // Iterate through each view, creating the services for each
        for (ViewConfiguration viewConfiguration : configuration.getViews()) {
            final ServiceName serviceName = viewConfiguration.getViewServiceName();
            final ViewService viewService = new ViewService(viewConfiguration);
            serviceTarget.addService(serviceName, viewService)
                    .addDependency(createServiceName, Component.class, viewService.getComponentInjector())
                    .install();
            startBuilder.addDependency(serviceName);
            // The bindings for the view
            for (BindingConfiguration bindingConfiguration : viewConfiguration.getBindingConfigurations()) {
                final String bindingName = bindingConfiguration.getName();
                final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(applicationName, moduleName, componentName, bindingName);
                final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource());

                //these bindings should never be merged, if a view binding is duplicated it is an error
                dependencies.add(bindInfo.getBinderServiceName());

                ServiceBuilder<ManagedReferenceFactory> serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), service);
                bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector());
                serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector());
                serviceBuilder.install();
            }
        }
View Full Code Here

            stopWebApp(deployment.getAttachment(StandardContext.class));
        } finally {
            ClassLoader origClassLoader = SecurityActions.getContextClassLoader();
            try {
                SecurityActions.setContextClassLoader(ClassLoaderProvider.getDefaultProvider().getServerIntegrationClassLoader());
                final ServiceTarget target = deployment.getAttachment(ServiceTarget.class);
                // TODO: [JBWS-3426] fix this. START workaround
                if (target == null) {
                    SPIProvider spiProvider = SPIProviderResolver.getInstance().getProvider();
                    EndpointRegistryFactory factory = spiProvider.getSPI(EndpointRegistryFactory.class);
                    EndpointRegistry registry = factory.getEndpointRegistry();
View Full Code Here

                context.addStep(new OperationStepHandler() {
                    public void execute(OperationContext context, ModelNode operation) {
                        final ServiceVerificationHandler verificationHandler = new ServiceVerificationHandler();
                        log.info("Activating Security Subsystem");

                        final ServiceTarget target = context.getServiceTarget();

                        // add bootstrap service
                        final SecurityBootstrapService bootstrapService = new SecurityBootstrapService();
                        if (securityPropertiesStr != null && !securityPropertiesStr.isEmpty())
                            bootstrapService.setSecurityProperties(securityPropertiesStr);

                        target.addService(SecurityBootstrapService.SERVICE_NAME, bootstrapService)
                                .setInitialMode(ServiceController.Mode.ACTIVE).install();

                        // add service to bind SecurityDomainJndiInjectable to JNDI
                        final SecurityDomainJndiInjectable securityDomainJndiInjectable = new SecurityDomainJndiInjectable();
                        final BinderService binderService = new BinderService("jaas");
                        target.addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append("jboss", "jaas"), binderService)
                                .addInjection(binderService.getManagedObjectInjector(), securityDomainJndiInjectable)
                                .addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append("jboss"), NamingStore.class,
                                        binderService.getNamingStoreInjector())
                                .addDependency(SecurityManagementService.SERVICE_NAME, ISecurityManagement.class,
                                        securityDomainJndiInjectable.getSecurityManagementInjector())
                                .setInitialMode(ServiceController.Mode.ACTIVE).install();

                        // add security management service
                        final SecurityManagementService securityManagementService = new SecurityManagementService(
                                resolvedAuthenticationManagerClassName, deepCopySubject, resolvedCallbackHandlerClassName,
                                resolvedAuthorizationManagerClassName, resolvedAuditManagerClassName,
                                resolvedIdentityTrustManagerClassName, resolvedMappingManagerClassName);
                        target.addService(SecurityManagementService.SERVICE_NAME, securityManagementService)
                                .setInitialMode(ServiceController.Mode.ACTIVE).install();

                        // add subject factory service
                        final SubjectFactoryService subjectFactoryService = new SubjectFactoryService(
                                resolvedSubjectFactoryClassName);
                        target.addService(SubjectFactoryService.SERVICE_NAME, subjectFactoryService)
                                .addDependency(SecurityManagementService.SERVICE_NAME, ISecurityManagement.class,
                                        subjectFactoryService.getSecurityManagementInjector())
                                .setInitialMode(ServiceController.Mode.ACTIVE).install();

                        // add jaas configuration service
                        Configuration loginConfig = XMLLoginConfigImpl.getInstance();
                        final JaasConfigurationService jaasConfigurationService = new JaasConfigurationService(loginConfig);
                        target.addService(JaasConfigurationService.SERVICE_NAME, jaasConfigurationService)
                                .addListener(verificationHandler)
                                .setInitialMode(ServiceController.Mode.ACTIVE)
                                .install();

                        target.addService(SimpleSecurityManagerService.SERVICE_NAME, new SimpleSecurityManagerService())
                                .addListener(verificationHandler)
                                .install();

                        context.addStep(verificationHandler, OperationContext.Stage.VERIFY);
View Full Code Here

    @Override
    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {

        final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        final DeploymentUnit topLevelDeployment = deploymentUnit.getParent() == null ? deploymentUnit : deploymentUnit.getParent();
        final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
        if (!WeldDeploymentMarker.isPartOfWeldDeployment(topLevelDeployment)) {
            return;
        }

        final Set<ServiceName> dependencies = deploymentUnit.getAttachment(Attachments.JNDI_DEPENDENCIES);


        BeanDeploymentArchiveImpl rootBda = deploymentUnit
                .getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);
        if (rootBda == null) {
            // this archive is not actually a bean archive.
            // then use the top level root bda
            rootBda = topLevelDeployment.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE);
        }
        if (rootBda == null) {
            WeldLogger.ROOT_LOGGER.couldNotFindBeanManagerForDeployment(deploymentUnit.getName());
            return;
        }

        final ServiceName weldServiceName = topLevelDeployment.getServiceName().append(WeldService.SERVICE_NAME);

        // add the BeanManager service
        final ServiceName beanManagerServiceName = BeanManagerService.serviceName(deploymentUnit);
        BeanManagerService beanManagerService = new BeanManagerService(rootBda.getId());
        serviceTarget.addService(beanManagerServiceName, beanManagerService).addDependency(weldServiceName,
                WeldContainer.class, beanManagerService.getWeldContainer()).install();


        final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
View Full Code Here

            }
        }, OperationContext.Stage.RUNTIME);

        final ModelNode defaultDSNode = operation.require(CommonAttributes.DEFAULT_DATASOURCE);
        final String dataSourceName = defaultDSNode.resolve().asString();
        final ServiceTarget target = context.getServiceTarget();
        newControllers.add(JPAService.addService(target, dataSourceName, verificationHandler));
        newControllers.add(JPAUserTransactionListenerService.addService(target, verificationHandler));
    }
View Full Code Here

TOP

Related Classes of org.jboss.msc.service.ServiceTarget

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.