Search in sources :

Example 56 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class NamingBindingAdd method installLookup.

void installLookup(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString();
    final ServiceTarget serviceTarget = context.getServiceTarget();
    final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
    final BinderService binderService = new BinderService(name);
    binderService.getManagedObjectInjector().inject(new MutableManagedReferenceFactory(new LookupManagedReferenceFactory(lookup)));
    serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).install();
}
Also used : ExternalContextBinderService(org.jboss.as.naming.service.ExternalContextBinderService) BinderService(org.jboss.as.naming.service.BinderService) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ServiceTarget(org.jboss.msc.service.ServiceTarget) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 57 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class ParsedKernelDeploymentProcessor method deploy.

/**
     * Process a deployment for KernelDeployment configuration.
     * Will install a {@code POJO} for each configured bean.
     *
     * @param phaseContext the deployment unit context
     * @throws DeploymentUnitProcessingException
     *
     */
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit unit = phaseContext.getDeploymentUnit();
    final List<KernelDeploymentXmlDescriptor> kdXmlDescriptors = unit.getAttachment(KernelDeploymentXmlDescriptor.ATTACHMENT_KEY);
    if (kdXmlDescriptors == null || kdXmlDescriptors.isEmpty())
        return;
    final Module module = unit.getAttachment(Attachments.MODULE);
    if (module == null)
        throw PojoLogger.ROOT_LOGGER.noModuleFound(unit);
    final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
    final DeploymentReflectionIndex index = unit.getAttachment(Attachments.REFLECTION_INDEX);
    if (index == null)
        throw PojoLogger.ROOT_LOGGER.missingReflectionIndex(unit);
    for (KernelDeploymentXmlDescriptor kdXmlDescriptor : kdXmlDescriptors) {
        final List<BeanMetaDataConfig> beanConfigs = kdXmlDescriptor.getBeans();
        for (final BeanMetaDataConfig beanConfig : beanConfigs) {
            describeBean(module, serviceTarget, index, beanConfig);
        }
    // TODO -- KD::classloader, KD::aliases
    }
}
Also used : BeanMetaDataConfig(org.jboss.as.pojo.descriptor.BeanMetaDataConfig) ServiceTarget(org.jboss.msc.service.ServiceTarget) KernelDeploymentXmlDescriptor(org.jboss.as.pojo.descriptor.KernelDeploymentXmlDescriptor) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) DeploymentReflectionIndex(org.jboss.as.server.deployment.reflect.DeploymentReflectionIndex)

Example 58 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class JaccEarDeploymentProcessor method deploy.

/**
     * {@inheritDoc}
     */
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    AbstractSecurityDeployer<?> deployer = null;
    if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
        deployer = new EarSecurityDeployer();
        JaccService<?> service = deployer.deploy(deploymentUnit);
        if (service != null) {
            final ServiceName jaccServiceName = deploymentUnit.getServiceName().append(JaccService.SERVICE_NAME);
            final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
            ServiceBuilder<?> builder = serviceTarget.addService(jaccServiceName, service);
            if (deploymentUnit.getParent() != null) {
                // add dependency to parent policy
                final DeploymentUnit parentDU = deploymentUnit.getParent();
                builder.addDependency(parentDU.getServiceName().append(JaccService.SERVICE_NAME), PolicyConfiguration.class, service.getParentPolicyInjector());
            }
            builder.setInitialMode(Mode.ACTIVE).install();
        }
    }
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Example 59 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class BasicAddHandler method performRuntime.

@Override
protected final void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
    String address = context.getCurrentAddressValue();
    ServiceName mainName = runtimeCapabilities[0].fromBaseCapability(address).getCapabilityServiceName();
    ServiceTarget serviceTarget = context.getServiceTarget();
    BasicService<T> basicService = new BasicService<T>();
    ServiceBuilder<T> serviceBuilder = serviceTarget.addService(mainName, basicService);
    for (int i = 1; i < runtimeCapabilities.length; i++) {
        serviceBuilder.addAliases(runtimeCapabilities[i].fromBaseCapability(address).getCapabilityServiceName());
    }
    basicService.setValueSupplier(getValueSupplier(serviceBuilder, context, resource.getModel()));
    serviceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Also used : ServiceName(org.jboss.msc.service.ServiceName) ServiceTarget(org.jboss.msc.service.ServiceTarget)

Example 60 with ServiceTarget

use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.

the class JPASubSystemAdd method performBoottime.

protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    runtimeValidator.validate(operation.resolve());
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            // set Hibernate persistence provider as the default provider
            javax.persistence.spi.PersistenceProviderResolverHolder.setPersistenceProviderResolver(PersistenceProviderResolverImpl.getInstance());
            final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
            PlatformImpl platform;
            if (appclient) {
                // we do not yet support a second level cache in the client container
                platform = new PlatformImpl(Classification.NONE);
            } else {
                // Infinispan can be used in server container
                platform = new PlatformImpl(Classification.INFINISPAN, Classification.INFINISPAN);
            }
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_JPA, new JBossAllXmlParserRegisteringProcessor<>(JPAJarJBossAllParser.ROOT_ELEMENT, JpaAttachments.DEPLOYMENT_SETTINGS_KEY, new JPAJarJBossAllParser()));
            // handles parsing of persistence.xml
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PERSISTENCE_UNIT, new PersistenceUnitParseProcessor(appclient));
            // handles persistence unit / context annotations in components
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_PERSISTENCE_ANNOTATION, new JPAAnnotationProcessor());
            // injects JPA dependencies into an application
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JPA, new JPADependencyProcessor());
            // Inject Hibernate Search dependencies into an application
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_HIBERNATE_SEARCH, new HibernateSearchProcessor());
            // handle ClassFileTransformer
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_PERSISTENCE_CLASS_FILE_TRANSFORMER, new JPAClassFileTransformerProcessor());
            // registers listeners/interceptors on session beans
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_INTERCEPTORS, new JPAInterceptorProcessor());
            // begin pu service install and deploying a persistence provider
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_PERSISTENCE_PREPARE, new PersistenceBeginInstallProcessor(platform));
            // handles persistence unit / context references from deployment descriptors
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_PERSISTENCE_REF, new PersistenceRefProcessor());
            // handles pu deployment (completes pu service installation)
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_PERSISTENTUNIT, new PersistenceCompleteInstallProcessor(platform));
        }
    }, OperationContext.Stage.RUNTIME);
    final ModelNode defaultDSNode = operation.require(CommonAttributes.DEFAULT_DATASOURCE);
    final String dataSourceName = defaultDSNode.resolve().asString();
    ExtendedPersistenceInheritance defaultExtendedPersistenceInheritance = ExtendedPersistenceInheritance.DEEP;
    if (operation.hasDefined(CommonAttributes.DEFAULT_EXTENDEDPERSISTENCE_INHERITANCE)) {
        final ModelNode defaultExtendedPersistenceInheritanceNode = operation.get(CommonAttributes.DEFAULT_EXTENDEDPERSISTENCE_INHERITANCE);
        defaultExtendedPersistenceInheritance = ExtendedPersistenceInheritance.valueOf(defaultExtendedPersistenceInheritanceNode.resolve().asString());
    }
    final ServiceTarget target = context.getServiceTarget();
    JPAService.addService(target, dataSourceName, defaultExtendedPersistenceInheritance);
    JPAUserTransactionListenerService.addService(target);
}
Also used : JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) ServiceTarget(org.jboss.msc.service.ServiceTarget) PersistenceRefProcessor(org.jboss.as.jpa.processor.PersistenceRefProcessor) JPAInterceptorProcessor(org.jboss.as.jpa.processor.JPAInterceptorProcessor) PersistenceCompleteInstallProcessor(org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor) JPADependencyProcessor(org.jboss.as.jpa.processor.JPADependencyProcessor) ExtendedPersistenceInheritance(org.jboss.as.jpa.config.ExtendedPersistenceInheritance) JPAJarJBossAllParser(org.jboss.as.jpa.processor.JPAJarJBossAllParser) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) PersistenceUnitParseProcessor(org.jboss.as.jpa.processor.PersistenceUnitParseProcessor) JPAClassFileTransformerProcessor(org.jboss.as.jpa.processor.JPAClassFileTransformerProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) HibernateSearchProcessor(org.jboss.as.jpa.processor.HibernateSearchProcessor) ModelNode(org.jboss.dmr.ModelNode) JPAAnnotationProcessor(org.jboss.as.jpa.processor.JPAAnnotationProcessor) PersistenceBeginInstallProcessor(org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor) PlatformImpl(org.jboss.as.jpa.platform.PlatformImpl)

Aggregations

ServiceTarget (org.jboss.msc.service.ServiceTarget)108 ServiceName (org.jboss.msc.service.ServiceName)57 PathAddress (org.jboss.as.controller.PathAddress)30 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)26 ModelNode (org.jboss.dmr.ModelNode)26 Module (org.jboss.modules.Module)18 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)15 OperationFailedException (org.jboss.as.controller.OperationFailedException)12 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)11 ContextNames (org.jboss.as.naming.deployment.ContextNames)11 Resource (org.jboss.as.controller.registry.Resource)10 BinderService (org.jboss.as.naming.service.BinderService)10 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)10 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)10 PathElement (org.jboss.as.controller.PathElement)9 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)9 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)9 ServiceController (org.jboss.msc.service.ServiceController)8 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5