Search in sources :

Example 1 with ImmediateValue

use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.

the class ParsedServiceDeploymentProcessor method addDependencyLists.

private void addDependencyLists(final JBossServiceDependencyListConfig[] dependencyListConfigs, final List<ClassReflectionIndex> mBeanClassHierarchy, final MBeanServices mBeanServices) throws DeploymentUnitProcessingException {
    if (dependencyListConfigs != null) {
        final Service<Object> createDestroyService = mBeanServices.getCreateDestroyService();
        for (final JBossServiceDependencyListConfig dependencyListConfig : dependencyListConfigs) {
            final List<ObjectName> dependencyObjectNames = new ArrayList<ObjectName>(dependencyListConfig.getDependencyConfigs().length);
            for (final JBossServiceDependencyConfig dependencyConfig : dependencyListConfig.getDependencyConfigs()) {
                final String dependencyName = dependencyConfig.getDependencyName();
                mBeanServices.addDependency(dependencyName);
                final ObjectName dependencyObjectName = createDependencyObjectName(dependencyName);
                dependencyObjectNames.add(dependencyObjectName);
            }
            final String optionalAttributeName = dependencyListConfig.getOptionalAttributeName();
            if (optionalAttributeName != null) {
                final Injector<Object> injector = getOptionalAttributeInjector(optionalAttributeName, mBeanClassHierarchy, createDestroyService);
                final ImmediateValue<List<ObjectName>> dependencyNamesValue = new ImmediateValue<List<ObjectName>>(dependencyObjectNames);
                mBeanServices.addInjectionValue(injector, dependencyNamesValue);
            }
        }
    }
}
Also used : JBossServiceDependencyListConfig(org.jboss.as.service.descriptor.JBossServiceDependencyListConfig) ArrayList(java.util.ArrayList) JBossServiceDependencyConfig(org.jboss.as.service.descriptor.JBossServiceDependencyConfig) ArrayList(java.util.ArrayList) List(java.util.List) ObjectName(javax.management.ObjectName) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Example 2 with ImmediateValue

use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.

the class ValueServiceActivator method activate.

@Override
public void activate(ServiceActivatorContext context) throws ServiceRegistryException {
    try {
        SingletonPolicy policy = (SingletonPolicy) context.getServiceRegistry().getRequiredService(ServiceName.parse(SingletonDefaultRequirement.SINGLETON_POLICY.getName())).awaitValue();
        policy.createSingletonServiceBuilder(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(Boolean.TRUE)), new ValueService<>(new ImmediateValue<>(Boolean.FALSE))).build(context.getServiceTarget()).install();
    } catch (InterruptedException e) {
        throw new ServiceRegistryException(e);
    }
}
Also used : SingletonPolicy(org.wildfly.clustering.singleton.SingletonPolicy) ServiceRegistryException(org.jboss.msc.service.ServiceRegistryException) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Example 3 with ImmediateValue

use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.

the class SharedSessionManagerDeploymentProcessor method deploy.

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    SharedSessionManagerConfig sharedConfig = deploymentUnit.getAttachment(UndertowAttachments.SHARED_SESSION_MANAGER_CONFIG);
    if (sharedConfig == null) {
        return;
    }
    ServiceTarget target = phaseContext.getServiceTarget();
    ServiceName deploymentServiceName = deploymentUnit.getServiceName();
    ServiceName managerServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_MANAGER_SERVICE_NAME);
    DistributableSessionManagerFactoryBuilder builder = new DistributableSessionManagerFactoryBuilderValue().getValue();
    if (builder != null) {
        CapabilityServiceSupport support = deploymentUnit.getAttachment(Attachments.CAPABILITY_SERVICE_SUPPORT);
        Module module = deploymentUnit.getAttachment(Attachments.MODULE);
        builder.build(support, target, managerServiceName, new SimpleDistributableSessionManagerConfiguration(sharedConfig, deploymentUnit.getName(), module)).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        InMemorySessionManager manager = new InMemorySessionManager(deploymentUnit.getName(), sharedConfig.getMaxActiveSessions());
        if (sharedConfig.getSessionConfig() != null) {
            if (sharedConfig.getSessionConfig().getSessionTimeoutSet()) {
                manager.setDefaultSessionTimeout(sharedConfig.getSessionConfig().getSessionTimeout());
            }
        }
        SessionManagerFactory factory = new ImmediateSessionManagerFactory(manager);
        target.addService(managerServiceName, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
    }
    ServiceName codecServiceName = deploymentServiceName.append(SharedSessionManagerConfig.SHARED_SESSION_IDENTIFIER_CODEC_SERVICE_NAME);
    DistributableSessionIdentifierCodecBuilder sessionIdentifierCodecBuilder = new DistributableSessionIdentifierCodecBuilderValue().getValue();
    if (sessionIdentifierCodecBuilder != null) {
        sessionIdentifierCodecBuilder.build(target, codecServiceName, deploymentUnit.getName()).setInitialMode(Mode.ON_DEMAND).install();
    } else {
        // Fallback to simple codec if server does not support clustering
        SimpleSessionIdentifierCodecService.build(target, codecServiceName).setInitialMode(Mode.ON_DEMAND).install();
    }
}
Also used : DistributableSessionIdentifierCodecBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilderValue) ServiceTarget(org.jboss.msc.service.ServiceTarget) DistributableSessionManagerFactoryBuilderValue(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilderValue) CapabilityServiceSupport(org.jboss.as.controller.capability.CapabilityServiceSupport) ImmediateValue(org.jboss.msc.value.ImmediateValue) DistributableSessionIdentifierCodecBuilder(org.wildfly.extension.undertow.session.DistributableSessionIdentifierCodecBuilder) SharedSessionManagerConfig(org.wildfly.extension.undertow.session.SharedSessionManagerConfig) SimpleDistributableSessionManagerConfiguration(org.wildfly.extension.undertow.session.SimpleDistributableSessionManagerConfiguration) DistributableSessionManagerFactoryBuilder(org.wildfly.extension.undertow.session.DistributableSessionManagerFactoryBuilder) ServiceName(org.jboss.msc.service.ServiceName) SessionManagerFactory(io.undertow.servlet.api.SessionManagerFactory) Module(org.jboss.modules.Module) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) InMemorySessionManager(io.undertow.server.session.InMemorySessionManager)

Example 4 with ImmediateValue

use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.

the class ComponentAggregationProcessor method deploy.

public void deploy(final DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
    DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
    final ComponentRegistry componentRegistry = new ComponentRegistry(phaseContext.getServiceRegistry());
    final EEModuleDescription moduleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
    if (moduleDescription == null) {
        return;
    }
    phaseContext.getServiceTarget().addService(ComponentRegistry.serviceName(deploymentUnit), new ValueService<>(new ImmediateValue<Object>(componentRegistry))).addDependency(moduleDescription.getDefaultClassIntrospectorServiceName(), EEClassIntrospector.class, componentRegistry.getClassIntrospectorInjectedValue()).install();
    deploymentUnit.putAttachment(COMPONENT_REGISTRY, componentRegistry);
    if (deploymentUnit.getAttachment(Attachments.DEPLOYMENT_TYPE) == DeploymentType.EAR) {
        final EEApplicationDescription applicationDescription = new EEApplicationDescription();
        deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_DESCRIPTION, applicationDescription);
        for (final Map.Entry<String, String> messageDestination : moduleDescription.getMessageDestinations().entrySet()) {
            applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT).getRoot());
        }
        /*
            * We are an EAR, so we must inspect all of our subdeployments and aggregate all their component views
            * into a single index, so that inter-module resolution will work.
            */
        // Add the application description
        final List<DeploymentUnit> subdeployments = deploymentUnit.getAttachmentList(SUB_DEPLOYMENTS);
        for (final DeploymentUnit subdeployment : subdeployments) {
            final EEModuleDescription subDeploymentModuleDescription = subdeployment.getAttachment(EE_MODULE_DESCRIPTION);
            final ResourceRoot deploymentRoot = subdeployment.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
            if (subDeploymentModuleDescription == null) {
                // Not an EE deployment.
                continue;
            }
            for (final ComponentDescription componentDescription : subDeploymentModuleDescription.getComponentDescriptions()) {
                applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
            }
            for (final Map.Entry<String, String> messageDestination : subDeploymentModuleDescription.getMessageDestinations().entrySet()) {
                applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentRoot.getRoot());
            }
            for (final ComponentDescription componentDescription : subdeployment.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
                applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
            }
            subdeployment.putAttachment(EE_APPLICATION_DESCRIPTION, applicationDescription);
        }
    } else if (deploymentUnit.getParent() == null) {
        final EEApplicationDescription applicationDescription = new EEApplicationDescription();
        deploymentUnit.putAttachment(org.jboss.as.ee.component.Attachments.EE_APPLICATION_DESCRIPTION, applicationDescription);
        /*
             * We are a top-level EE deployment, or a non-EE deployment.  Our "aggregate" index is just a copy of
             * our local EE module index.
             */
        final ResourceRoot deploymentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
        for (final ComponentDescription componentDescription : moduleDescription.getComponentDescriptions()) {
            applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
        }
        for (final Map.Entry<String, String> messageDestination : moduleDescription.getMessageDestinations().entrySet()) {
            applicationDescription.addMessageDestination(messageDestination.getKey(), messageDestination.getValue(), deploymentRoot.getRoot());
        }
        for (final ComponentDescription componentDescription : deploymentUnit.getAttachmentList(org.jboss.as.ee.component.Attachments.ADDITIONAL_RESOLVABLE_COMPONENTS)) {
            applicationDescription.addComponent(componentDescription, deploymentRoot.getRoot());
        }
    }
}
Also used : EEApplicationDescription(org.jboss.as.ee.component.EEApplicationDescription) ComponentDescription(org.jboss.as.ee.component.ComponentDescription) ImmediateValue(org.jboss.msc.value.ImmediateValue) ResourceRoot(org.jboss.as.server.deployment.module.ResourceRoot) EEModuleDescription(org.jboss.as.ee.component.EEModuleDescription) ComponentRegistry(org.jboss.as.ee.component.ComponentRegistry) DeploymentUnit(org.jboss.as.server.deployment.DeploymentUnit) Map(java.util.Map) EEClassIntrospector(org.jboss.as.ee.component.EEClassIntrospector)

Example 5 with ImmediateValue

use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.

the class IIOPJndiBindingProcessor method bindService.

/**
     * Binds java:comp/ORB
     *
     * @param serviceTarget      The service target
     * @param contextServiceName The service name of the context to bind to
     */
private void bindService(final ServiceTarget serviceTarget, final ServiceName contextServiceName, final Module module) {
    final ServiceName orbServiceName = contextServiceName.append("ORB");
    final BinderService orbService = new BinderService("ORB");
    serviceTarget.addService(orbServiceName, orbService).addDependency(CorbaORBService.SERVICE_NAME, ORB.class, new ManagedReferenceInjector<ORB>(orbService.getManagedObjectInjector())).addDependency(contextServiceName, ServiceBasedNamingStore.class, orbService.getNamingStoreInjector()).install();
    final ServiceName handleDelegateServiceName = contextServiceName.append("HandleDelegate");
    final BinderService handleDelegateBindingService = new BinderService("HandleDelegate");
    handleDelegateBindingService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue(new HandleDelegateImpl(module.getClassLoader()))));
    serviceTarget.addService(handleDelegateServiceName, handleDelegateBindingService).addDependency(contextServiceName, ServiceBasedNamingStore.class, handleDelegateBindingService.getNamingStoreInjector()).install();
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) HandleDelegateImpl(org.jboss.as.ejb3.iiop.handle.HandleDelegateImpl) ServiceName(org.jboss.msc.service.ServiceName) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ORB(org.omg.CORBA.ORB) ImmediateValue(org.jboss.msc.value.ImmediateValue)

Aggregations

ImmediateValue (org.jboss.msc.value.ImmediateValue)20 BinderService (org.jboss.as.naming.service.BinderService)6 ServiceName (org.jboss.msc.service.ServiceName)6 ValueManagedReferenceFactory (org.jboss.as.naming.ValueManagedReferenceFactory)5 Method (java.lang.reflect.Method)3 ContextNames (org.jboss.as.naming.deployment.ContextNames)3 DeploymentUnit (org.jboss.as.server.deployment.DeploymentUnit)3 ServiceTarget (org.jboss.msc.service.ServiceTarget)3 ArrayList (java.util.ArrayList)2 ObjectName (javax.management.ObjectName)2 ClassLoaderThreadFactory (org.jboss.as.clustering.jgroups.ClassLoaderThreadFactory)2 CapabilityServiceSupport (org.jboss.as.controller.capability.CapabilityServiceSupport)2 EEModuleDescription (org.jboss.as.ee.component.EEModuleDescription)2 PersistenceUnitServiceImpl (org.jboss.as.jpa.service.PersistenceUnitServiceImpl)2 PhaseOnePersistenceUnitServiceImpl (org.jboss.as.jpa.service.PhaseOnePersistenceUnitServiceImpl)2 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)2 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)2 JBossServiceDependencyConfig (org.jboss.as.service.descriptor.JBossServiceDependencyConfig)2 Module (org.jboss.modules.Module)2 CastingInjector (org.jboss.msc.inject.CastingInjector)2