use of org.jboss.as.naming.service.NamingStoreService in project wildfly by wildfly.
the class ComponentInstallProcessor method deployComponent.
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void deployComponent(final DeploymentPhaseContext phaseContext, final ComponentConfiguration configuration, final List<ServiceName> jndiDependencies, final ServiceName bindingDependencyService) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final String applicationName = configuration.getApplicationName();
final String moduleName = configuration.getModuleName();
final String componentName = configuration.getComponentName();
final EEApplicationClasses applicationClasses = deploymentUnit.getAttachment(Attachments.EE_APPLICATION_CLASSES_DESCRIPTION);
final Module module = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.MODULE);
//create additional injectors
final ServiceName createServiceName = configuration.getComponentDescription().getCreateServiceName();
final ServiceName startServiceName = configuration.getComponentDescription().getStartServiceName();
final BasicComponentCreateService createService = configuration.getComponentCreateServiceFactory().constructService(configuration);
final ServiceBuilder<Component> createBuilder = serviceTarget.addService(createServiceName, createService);
// inject the DU
createBuilder.addDependency(deploymentUnit.getServiceName(), DeploymentUnit.class, createService.getDeploymentUnitInjector());
final ComponentStartService startService = new ComponentStartService();
final ServiceBuilder<Component> startBuilder = serviceTarget.addService(startServiceName, startService);
deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_COMPLETE_SERVICES, startServiceName);
//WFLY-1402 we don't add the bindings to the jndi dependencies list directly, instead
//the bindings depend on the this artificial service
ServiceName jndiDepServiceName = configuration.getComponentDescription().getServiceName().append(JNDI_BINDINGS_SERVICE);
final ServiceBuilder<Void> jndiDepServiceBuilder = serviceTarget.addService(jndiDepServiceName, Service.NULL);
jndiDependencies.add(jndiDepServiceName);
// Add all service dependencies
for (DependencyConfigurator configurator : configuration.getCreateDependencies()) {
configurator.configureDependency(createBuilder, createService);
}
for (DependencyConfigurator configurator : configuration.getStartDependencies()) {
configurator.configureDependency(startBuilder, startService);
}
// START depends on CREATE
startBuilder.addDependency(createServiceName, BasicComponent.class, startService.getComponentInjector());
Services.addServerExecutorDependency(startBuilder, startService.getExecutorInjector(), false);
//don't start components until all bindings are up
startBuilder.addDependency(bindingDependencyService);
final ServiceName contextServiceName;
//set up the naming context if necessary
if (configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE) {
final NamingStoreService contextService = new NamingStoreService(true);
serviceTarget.addService(configuration.getComponentDescription().getContextServiceName(), contextService).install();
}
final InjectionSource.ResolutionContext resolutionContext = new InjectionSource.ResolutionContext(configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.USE_MODULE, configuration.getComponentName(), configuration.getModuleName(), configuration.getApplicationName());
// Iterate through each view, creating the services for each
for (ViewConfiguration viewConfiguration : configuration.getViews()) {
final ServiceName serviceName = viewConfiguration.getViewServiceName();
final ViewService viewService = new ViewService(viewConfiguration);
final ServiceBuilder<ComponentView> componentViewServiceBuilder = serviceTarget.addService(serviceName, viewService);
componentViewServiceBuilder.addDependency(createServiceName, Component.class, viewService.getComponentInjector());
for (final DependencyConfigurator<ViewService> depConfig : viewConfiguration.getDependencies()) {
depConfig.configureDependency(componentViewServiceBuilder, viewService);
}
componentViewServiceBuilder.install();
startBuilder.addDependency(serviceName);
// The bindings for the view
for (BindingConfiguration bindingConfiguration : viewConfiguration.getBindingConfigurations()) {
final String bindingName = bindingConfiguration.getName();
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(applicationName, moduleName, componentName, bindingName);
final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource());
//these bindings should never be merged, if a view binding is duplicated it is an error
jndiDepServiceBuilder.addDependency(bindInfo.getBinderServiceName());
ServiceBuilder<ManagedReferenceFactory> serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), service);
bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector());
serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector());
serviceBuilder.install();
}
}
if (configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE) {
// The bindings for the component
final Set<ServiceName> bound = new HashSet<ServiceName>();
processBindings(phaseContext, configuration, serviceTarget, resolutionContext, configuration.getComponentDescription().getBindingConfigurations(), jndiDepServiceBuilder, bound);
//class level bindings should be ignored if the deployment is metadata complete
if (!MetadataCompleteMarker.isMetadataComplete(phaseContext.getDeploymentUnit())) {
// The bindings for the component class
new ClassDescriptionTraversal(configuration.getComponentClass(), applicationClasses) {
@Override
protected void handle(final Class<?> clazz, final EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException {
if (classDescription != null) {
processBindings(phaseContext, configuration, serviceTarget, resolutionContext, classDescription.getBindingConfigurations(), jndiDepServiceBuilder, bound);
}
}
}.run();
for (InterceptorDescription interceptor : configuration.getComponentDescription().getAllInterceptors()) {
final Class<?> interceptorClass;
try {
interceptorClass = module.getClassLoader().loadClass(interceptor.getInterceptorClassName());
} catch (ClassNotFoundException e) {
throw EeLogger.ROOT_LOGGER.cannotLoadInterceptor(e, interceptor.getInterceptorClassName(), configuration.getComponentClass());
}
if (interceptorClass != null) {
new ClassDescriptionTraversal(interceptorClass, applicationClasses) {
@Override
protected void handle(final Class<?> clazz, final EEModuleClassDescription classDescription) throws DeploymentUnitProcessingException {
if (classDescription != null) {
processBindings(phaseContext, configuration, serviceTarget, resolutionContext, classDescription.getBindingConfigurations(), jndiDepServiceBuilder, bound);
}
}
}.run();
}
}
}
}
createBuilder.install();
startBuilder.install();
jndiDepServiceBuilder.install();
}
use of org.jboss.as.naming.service.NamingStoreService in project wildfly by wildfly.
the class NamingSubsystemAdd method performBoottime.
@SuppressWarnings("deprecation")
@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) {
ROOT_LOGGER.activatingSubsystem();
NamingContext.initializeNamingManager();
final ServiceTarget target = context.getServiceTarget();
// Create the java: namespace
target.addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME, new NamingStoreService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// Create the Naming Service
final NamingService namingService = new NamingService();
target.addService(Capability.NAMING_STORE.getDefinition().getCapabilityServiceName(), namingService).addAliases(NamingService.SERVICE_NAME).addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, NamingStore.class, namingService.getNamingStore()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// Create the java:global namespace
target.addService(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, new NamingStoreService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// Create the java:jboss vendor namespace
target.addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, new NamingStoreService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// Setup remote naming store
//we always install the naming store, but we don't install the server unless it has been explicitly enabled
target.addService(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, new NamingStoreService()).setInitialMode(ServiceController.Mode.ACTIVE).install();
// add the default namespace context selector service
DefaultNamespaceContextSelectorService defaultNamespaceContextSelectorService = new DefaultNamespaceContextSelectorService();
target.addService(DefaultNamespaceContextSelectorService.SERVICE_NAME, defaultNamespaceContextSelectorService).addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, NamingStore.class, defaultNamespaceContextSelectorService.getGlobalNamingStore()).addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, NamingStore.class, defaultNamespaceContextSelectorService.getJbossNamingStore()).addDependency(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, NamingStore.class, defaultNamespaceContextSelectorService.getRemoteExposedNamingStore()).setInitialMode(ServiceController.Mode.ACTIVE).install();
target.addService(JndiViewExtensionRegistry.SERVICE_NAME, new JndiViewExtensionRegistry()).install();
// create the subsystem's external context instance, and install related Service and DUP
final ExternalContexts externalContexts = new ExternalContextsNavigableSet();
target.addService(ExternalContextsService.SERVICE_NAME, new ExternalContextsService(externalContexts)).install();
context.addStep(new AbstractDeploymentChainStep() {
@Override
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(NamingExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_NAMING_EXTERNAL_CONTEXTS, new ExternalContextsProcessor(externalContexts));
processorTarget.addDeploymentProcessor(NamingExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_JNDI_DEPENDENCIES, new JndiNamingDependencyProcessor());
}
}, OperationContext.Stage.RUNTIME);
if (context.hasOptionalCapability(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, NamingService.CAPABILITY_NAME, null)) {
HttpRemoteNamingServerService httpRemoteNamingServerService = new HttpRemoteNamingServerService();
context.getServiceTarget().addService(HttpRemoteNamingServerService.SERVICE_NAME, httpRemoteNamingServerService).addDependency(context.getCapabilityServiceName(UNDERTOW_HTTP_INVOKER_CAPABILITY_NAME, PathHandler.class), PathHandler.class, httpRemoteNamingServerService.getPathHandlerInjectedValue()).addDependency(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, NamingStore.class, httpRemoteNamingServerService.getNamingStore()).install();
}
}
use of org.jboss.as.naming.service.NamingStoreService in project wildfly by wildfly.
the class WritableServiceBasedNamingStoreTestCase method setup.
@Before
public void setup() throws Exception {
container = ServiceContainer.Factory.create();
installOwnerService(OWNER_FOO);
installOwnerService(OWNER_BAR);
final CountDownLatch latch2 = new CountDownLatch(1);
final NamingStoreService namingStoreService = new NamingStoreService();
container.addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME, namingStoreService).setInitialMode(ServiceController.Mode.ACTIVE).addListener(new AbstractServiceListener<NamingStore>() {
public void transition(ServiceController<? extends NamingStore> controller, ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
latch2.countDown();
break;
}
case STARTING_to_START_FAILED:
{
latch2.countDown();
fail("Did not install store service - " + controller.getStartException().getMessage());
break;
}
default:
break;
}
}
}).install();
latch2.await(10, TimeUnit.SECONDS);
store = (WritableServiceBasedNamingStore) namingStoreService.getValue();
}
use of org.jboss.as.naming.service.NamingStoreService in project wildfly by wildfly.
the class ApplicationContextProcessor method deploy.
/**
* Add a ContextService for this module.
*
* @param phaseContext the deployment unit context
* @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (deploymentUnit.getParent() != null) {
return;
}
EEModuleDescription moduleDescription = deploymentUnit.getAttachment(org.jboss.as.ee.component.Attachments.EE_MODULE_DESCRIPTION);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final ServiceName applicationContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
final NamingStoreService contextService = new NamingStoreService(true);
serviceTarget.addService(applicationContextServiceName, contextService).install();
final BinderService applicationNameBinder = new BinderService("AppName");
final ServiceName appNameServiceName = applicationContextServiceName.append("AppName");
serviceTarget.addService(appNameServiceName, applicationNameBinder).addDependency(applicationContextServiceName, ServiceBasedNamingStore.class, applicationNameBinder.getNamingStoreInjector()).addInjection(applicationNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getApplicationName()))).install();
deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, appNameServiceName);
deploymentUnit.putAttachment(Attachments.APPLICATION_CONTEXT_CONFIG, applicationContextServiceName);
}
use of org.jboss.as.naming.service.NamingStoreService in project wildfly by wildfly.
the class ModuleContextProcessor method deploy.
/**
* Add a ContextService for this module.
*
* @param phaseContext the deployment unit context
* @throws org.jboss.as.server.deployment.DeploymentUnitProcessingException
*/
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
return;
}
EEModuleDescription moduleDescription = deploymentUnit.getAttachment(EE_MODULE_DESCRIPTION);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
final ServiceName appContextServiceName = ContextNames.contextServiceNameOfApplication(moduleDescription.getApplicationName());
final ServiceName moduleContextServiceName = ContextNames.contextServiceNameOfModule(moduleDescription.getApplicationName(), moduleDescription.getModuleName());
final NamingStoreService contextService = new NamingStoreService(true);
serviceTarget.addService(moduleContextServiceName, contextService).install();
final BinderService moduleNameBinder = new BinderService("ModuleName");
final ServiceName moduleNameServiceName = moduleContextServiceName.append("ModuleName");
serviceTarget.addService(moduleNameServiceName, moduleNameBinder).addInjection(moduleNameBinder.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(moduleDescription.getModuleName()))).addDependency(moduleContextServiceName, ServiceBasedNamingStore.class, moduleNameBinder.getNamingStoreInjector()).install();
deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES, moduleNameServiceName);
deploymentUnit.putAttachment(MODULE_CONTEXT_CONFIG, moduleContextServiceName);
final InjectedEENamespaceContextSelector selector = new InjectedEENamespaceContextSelector();
phaseContext.addDependency(appContextServiceName, NamingStore.class, selector.getAppContextInjector());
phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getModuleContextInjector());
phaseContext.addDependency(moduleContextServiceName, NamingStore.class, selector.getCompContextInjector());
phaseContext.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getJbossContextInjector());
phaseContext.addDependency(ContextNames.EXPORTED_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getExportedContextInjector());
phaseContext.addDependency(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME, NamingStore.class, selector.getGlobalContextInjector());
moduleDescription.setNamespaceContextSelector(selector);
final Set<ServiceName> serviceNames = new HashSet<ServiceName>();
serviceNames.add(appContextServiceName);
serviceNames.add(moduleContextServiceName);
serviceNames.add(ContextNames.JBOSS_CONTEXT_SERVICE_NAME);
serviceNames.add(ContextNames.GLOBAL_CONTEXT_SERVICE_NAME);
// add the arquillian setup action, so the module namespace is available in arquillian tests
final JavaNamespaceSetup setupAction = new JavaNamespaceSetup(selector, deploymentUnit.getServiceName());
deploymentUnit.addToAttachmentList(SETUP_ACTIONS, setupAction);
deploymentUnit.addToAttachmentList(org.jboss.as.ee.component.Attachments.WEB_SETUP_ACTIONS, setupAction);
deploymentUnit.putAttachment(Attachments.JAVA_NAMESPACE_SETUP_ACTION, setupAction);
}
Aggregations