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);
}
}
}
}
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);
}
}
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();
}
}
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());
}
}
}
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();
}
Aggregations