Search in sources :

Example 1 with MarshallingConfigurationRepositoryServiceConfigurator

use of org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryServiceConfigurator 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();
    Set<SupplierDependency<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>>> dependencies = new HashSet<>();
    for (ComponentDescription description : moduleDescription.getComponentDescriptions()) {
        if (description instanceof StatefulComponentDescription) {
            StatefulComponentDescription statefulDescription = (StatefulComponentDescription) description;
            dependencies.add(new ServiceSupplierDependency<>(getCacheFactoryBuilderServiceName(statefulDescription)));
        }
    }
    Service service = new ChildTargetService(new Consumer<ServiceTarget>() {

        @Override
        public void accept(ServiceTarget target) {
            // Cache factory builder dependencies might still contain duplicates (if referenced via alias), so ensure we collect only distinct instances.
            Set<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> builders = new HashSet<>(dependencies.size());
            for (Supplier<CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance>> dependency : dependencies) {
                builders.add(dependency.get());
            }
            for (CacheFactoryBuilder<SessionID, StatefulSessionComponentInstance> builder : builders) {
                for (CapabilityServiceConfigurator configurator : builder.getDeploymentServiceConfigurators(unit)) {
                    configurator.configure(support).build(target).install();
                }
            }
        }
    });
    ServiceBuilder<?> builder = target.addService(name.append("cache-dependencies-installer"));
    for (Dependency dependency : dependencies) {
        dependency.register(builder);
    }
    builder.setInstance(service).install();
    // Install versioned marshalling configuration
    new MarshallingConfigurationRepositoryServiceConfigurator(unit).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
Also used : StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) HashSet(java.util.HashSet) Set(java.util.Set) StatefulSessionComponentInstance(org.jboss.as.ejb3.component.stateful.StatefulSessionComponentInstance) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) CacheFactoryBuilder(org.jboss.as.ejb3.cache.CacheFactoryBuilder) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) StatefulComponentDescription(org.jboss.as.ejb3.component.stateful.StatefulComponentDescription) Supplier(java.util.function.Supplier) HashSet(java.util.HashSet) CapabilityServiceConfigurator(org.jboss.as.clustering.controller.CapabilityServiceConfigurator) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) ServiceTarget(org.jboss.msc.service.ServiceTarget) MarshallingConfigurationRepositoryServiceConfigurator(org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryServiceConfigurator) Service(org.jboss.msc.Service) ChildTargetService(org.wildfly.clustering.service.ChildTargetService) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) Dependency(org.wildfly.clustering.service.Dependency) SupplierDependency(org.wildfly.clustering.service.SupplierDependency) ServiceSupplierDependency(org.wildfly.clustering.service.ServiceSupplierDependency) ServiceName(org.jboss.msc.service.ServiceName) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) SessionID(org.jboss.ejb.client.SessionID)

Aggregations

HashSet (java.util.HashSet)1 Set (java.util.Set)1 Supplier (java.util.function.Supplier)1 CapabilityServiceConfigurator (org.jboss.as.clustering.controller.CapabilityServiceConfigurator)1 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)1 ComponentDescription (org.jboss.as.ee.component.ComponentDescription)1 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)1 CacheFactoryBuilder (org.jboss.as.ejb3.cache.CacheFactoryBuilder)1 MarshallingConfigurationRepositoryServiceConfigurator (org.jboss.as.ejb3.component.stateful.MarshallingConfigurationRepositoryServiceConfigurator)1 StatefulComponentDescription (org.jboss.as.ejb3.component.stateful.StatefulComponentDescription)1 StatefulSessionComponentInstance (org.jboss.as.ejb3.component.stateful.StatefulSessionComponentInstance)1 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)1 SessionID (org.jboss.ejb.client.SessionID)1 Service (org.jboss.msc.Service)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1 ChildTargetService (org.wildfly.clustering.service.ChildTargetService)1 Dependency (org.wildfly.clustering.service.Dependency)1 ServiceSupplierDependency (org.wildfly.clustering.service.ServiceSupplierDependency)1 SupplierDependency (org.wildfly.clustering.service.SupplierDependency)1