Search in sources :

Example 1 with AbstractService

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

the class BeanDeploymentTestCase method setupServices.

@Override
protected void setupServices(final ServiceTarget serviceTarget) throws Exception {
    super.setupServices(serviceTarget);
    final DeploymentChain deploymentChain = new DeploymentChainImpl();
    deploymentChain.addProcessor(new ManifestAttachmentProcessor(), Phase.PARSE_MANIFEST);
    deploymentChain.addProcessor(new AnnotationIndexProcessor(), Phase.PARSE_ANNOTATION_INDEX);
    deploymentChain.addProcessor(new ModuleDependencyProcessor(), Phase.DEPENDENCIES_MODULE);
    deploymentChain.addProcessor(new ModuleConfigProcessor(), Phase.MODULARIZE_CONFIG);
    deploymentChain.addProcessor(new DeploymentModuleLoaderProcessor(new DeploymentModuleLoaderImpl(mainModuleLoader)), Phase.MODULARIZE_DEPLOYMENT_MODULE_LOADER);
    deploymentChain.addProcessor(new ModuleDeploymentProcessor(), Phase.MODULARIZE_DEPLOYMENT);
    deploymentChain.addProcessor(new KernelDeploymentParsingProcessor(), Phase.PARSE_MC_BEAN_DEPLOYMENT);
    deploymentChain.addProcessor(new ParsedKernelDeploymentProcessor(), Phase.INSTALL_MC_BEAN_DEPLOYMENT);
    serviceTarget.addService(DeploymentChain.SERVICE_NAME, new DeploymentChainService(deploymentChain));
    Service<Context> ns = new AbstractService<Context>() {

        @Override
        public Context getValue() throws IllegalStateException {
            try {
                return new MockContext();
            } catch (NamingException e) {
                throw new IllegalStateException(e);
            }
        }
    };
    serviceTarget.addService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, ns);
}
Also used : Context(javax.naming.Context) DeploymentModuleLoaderImpl(org.jboss.as.server.deployment.module.DeploymentModuleLoaderImpl) AbstractService(org.jboss.msc.service.AbstractService) ModuleDependencyProcessor(org.jboss.as.server.deployment.module.ModuleDependencyProcessor) ModuleDeploymentProcessor(org.jboss.as.server.deployment.module.ModuleDeploymentProcessor) AnnotationIndexProcessor(org.jboss.as.deployment.processor.AnnotationIndexProcessor) NamingException(javax.naming.NamingException) ManifestAttachmentProcessor(org.jboss.as.server.deployment.module.ManifestAttachmentProcessor)

Example 2 with AbstractService

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

the class CacheDependenciesProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext context) {
    DeploymentUnit unit = context.getDeploymentUnit();
    final ServiceName name = unit.getServiceName();
    EEModuleDescription moduleDescription = unit.getAttachment(Attachments.EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    final CapabilityServiceSupport support = unit.getAttachment(org.jboss.as.server.deployment.Attachments.CAPABILITY_SERVICE_SUPPORT);
    final ServiceTarget target = context.getServiceTarget();
    @SuppressWarnings("rawtypes") Collection<ValueDependency<CacheFactoryBuilder>> cacheDependencies = moduleDescription.getComponentDescriptions().stream().filter(StatefulComponentDescription.class::isInstance).map(description -> new InjectedValueDependency<>(getCacheFactoryBuilderServiceName((StatefulComponentDescription) description), CacheFactoryBuilder.class)).distinct().collect(Collectors.toList());
    Service<Void> service = new AbstractService<Void>() {

        @Override
        public void start(StartContext context) {
            // Install dependencies for each distinct cache factory builder referenced by the deployment
            cacheDependencies.stream().map(Value::getValue).distinct().forEach(builder -> builder.installDeploymentUnitDependencies(support, target, name));
        }
    };
    ServiceBuilder<Void> builder = target.addService(name.append("cache-dependencies-installer"), service);
    cacheDependencies.forEach(dependency -> dependency.register(builder));
    builder.install();
    // Install versioned marshalling configuration
    InjectedValue<ModuleDeployment> deployment = new InjectedValue<>();
    Module module = unit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
    target.addService(MarshallingConfigurationRepositoryValue.getServiceName(name), new ValueService<>(new MarshallingConfigurationRepositoryValue(deployment, new ImmediateValue<>(module)))).addDependency(name.append(ModuleDeployment.SERVICE_NAME), ModuleDeployment.class, deployment).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : InjectedValue(org.jboss.msc.value.InjectedValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) AbstractService(org.jboss.msc.service.AbstractService) ValueDependency(org.wildfly.clustering.service.ValueDependency) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) ValueService(org.jboss.msc.service.ValueService) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) ImmediateValue(org.jboss.msc.value.ImmediateValue) ModuleDeployment(org.jboss.as.ejb3.deployment.ModuleDeployment) StartContext(org.jboss.msc.service.StartContext) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ServiceName(org.jboss.msc.service.ServiceName) Value(org.jboss.msc.value.Value) ImmediateValue(org.jboss.msc.value.ImmediateValue) MarshallingConfigurationRepositoryValue(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue) InjectedValue(org.jboss.msc.value.InjectedValue) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit)

Aggregations

AbstractService (org.jboss.msc.service.AbstractService)2 Context (javax.naming.Context)1 NamingException (javax.naming.NamingException)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 AnnotationIndexProcessor (org.jboss.as.deployment.processor.AnnotationIndexProcessor)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 CacheFactoryBuilder (org.jboss.as.ejb3.cache.CacheFactoryBuilder)1 MarshallingConfigurationRepositoryValue (org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryValue)1 ModuleDeployment (org.jboss.as.ejb3.deployment.ModuleDeployment)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 DeploymentModuleLoaderImpl (org.jboss.as.server.deployment.module.DeploymentModuleLoaderImpl)1 ManifestAttachmentProcessor (org.jboss.as.server.deployment.module.ManifestAttachmentProcessor)1 ModuleDependencyProcessor (org.jboss.as.server.deployment.module.ModuleDependencyProcessor)1 ModuleDeploymentProcessor (org.jboss.as.server.deployment.module.ModuleDeploymentProcessor)1 Module (org.jboss.modules.Module)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 StartContext (org.jboss.msc.service.StartContext)1 ValueService (org.jboss.msc.service.ValueService)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1