use of org.jboss.as.naming.ValueManagedReferenceFactory in project wildfly by wildfly.
the class PartitionManagerAddHandler method configureJPAIdentityStore.
private JPAStoreSubsystemConfigurationBuilder configureJPAIdentityStore(OperationContext context, ServiceBuilder<PartitionManager> serviceBuilder, PartitionManagerService partitionManagerService, final ModelNode identityStore, String configurationName, final NamedIdentityConfigurationBuilder builder) throws OperationFailedException {
JPAStoreSubsystemConfigurationBuilder storeConfig = builder.stores().add(JPAStoreSubsystemConfiguration.class, JPAStoreSubsystemConfigurationBuilder.class);
ModelNode jpaDataSourceNode = JPAStoreResourceDefinition.DATA_SOURCE.resolveModelAttribute(context, identityStore);
ModelNode jpaEntityModule = JPAStoreResourceDefinition.ENTITY_MODULE.resolveModelAttribute(context, identityStore);
ModelNode jpaEntityModuleUnitName = JPAStoreResourceDefinition.ENTITY_MODULE_UNIT_NAME.resolveModelAttribute(context, identityStore);
ModelNode jpaEntityManagerFactoryNode = JPAStoreResourceDefinition.ENTITY_MANAGER_FACTORY.resolveModelAttribute(context, identityStore);
if (jpaEntityModule.isDefined()) {
storeConfig.entityModule(jpaEntityModule.asString());
}
storeConfig.entityModuleUnitName(jpaEntityModuleUnitName.asString());
if (serviceBuilder != null) {
JPAIdentityStoreService storeService = new JPAIdentityStoreService(storeConfig);
ServiceName storeServiceName = PartitionManagerService.createIdentityStoreServiceName(partitionManagerService.getName(), configurationName, ModelElement.JPA_STORE.getName());
ServiceBuilder<JPAIdentityStoreService> storeServiceBuilder = context.getServiceTarget().addService(storeServiceName, storeService);
storeServiceBuilder.addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, storeService.getTransactionManager());
storeServiceBuilder.addDependency(TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY, TransactionSynchronizationRegistry.class, storeService.getTransactionSynchronizationRegistry());
if (jpaDataSourceNode.isDefined()) {
storeConfig.dataSourceJndiUrl(toJndiName(jpaDataSourceNode.asString()));
storeServiceBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(toJndiName(jpaDataSourceNode.asString()).split("/")));
}
if (jpaEntityManagerFactoryNode.isDefined()) {
storeConfig.entityManagerFactoryJndiName(jpaEntityManagerFactoryNode.asString());
storeServiceBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jpaEntityManagerFactoryNode.asString().split("/")), ValueManagedReferenceFactory.class, new InjectedValue<ValueManagedReferenceFactory>());
}
serviceBuilder.addDependency(storeServiceName);
ServiceController<JPAIdentityStoreService> controller = storeServiceBuilder.setInitialMode(Mode.PASSIVE).install();
}
return storeConfig;
}
use of org.jboss.as.naming.ValueManagedReferenceFactory in project wildfly by wildfly.
the class TransactionSubsystemAdd method performBoottime.
@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
checkIfNodeIdentifierIsDefault(context, model);
boolean jts = model.hasDefined(JTS) && model.get(JTS).asBoolean();
final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(TransactionExtension.SUBSYSTEM_PATH));
final List<ServiceName> deps = new LinkedList<>();
for (Resource.ResourceEntry re : subsystemResource.getChildren(CM_RESOURCE)) {
deps.add(TxnServices.JBOSS_TXN_CMR.append(re.getName()));
}
//recovery environment
performRecoveryEnvBoottime(context, model, jts, deps);
//core environment
performCoreEnvironmentBootTime(context, model);
//coordinator environment
performCoordinatorEnvBoottime(context, model, jts);
//object store
performObjectStoreBoottime(context, model);
//always propagate the transaction context
//TODO: need a better way to do this, but this value gets cached in a static
//so we need to make sure we set it before anything tries to read it
jtsPropertyManager.getJTSEnvironmentBean().setAlwaysPropagateContext(true);
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(final DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_TRANSACTION_ROLLBACK_ACTION, new TransactionLeakRollbackProcessor());
processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_TRANSACTIONS_EE_CONCURRENCY, new EEConcurrencyContextHandleFactoryProcessor());
processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_TRANSACTION_BINDINGS, new TransactionJndiBindingProcessor());
processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_TRANSACTIONS, new TransactionDependenciesProcessor());
processorTarget.addDeploymentProcessor(TransactionExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_TRANSACTIONS, new CompensationsDependenciesDeploymentProcessor());
}
}, OperationContext.Stage.RUNTIME);
//bind the TransactionManger and the TSR into JNDI
final BinderService tmBinderService = new BinderService("TransactionManager");
final ServiceBuilder<ManagedReferenceFactory> tmBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("TransactionManager"), tmBinderService);
tmBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tmBinderService.getNamingStoreInjector());
tmBuilder.addDependency(TransactionManagerService.SERVICE_NAME, javax.transaction.TransactionManager.class, new Injector<javax.transaction.TransactionManager>() {
@Override
public void inject(final javax.transaction.TransactionManager value) throws InjectionException {
tmBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
}
@Override
public void uninject() {
tmBinderService.getManagedObjectInjector().uninject();
}
});
tmBuilder.install();
final BinderService tmLegacyBinderService = new BinderService("TransactionManager");
final ServiceBuilder<ManagedReferenceFactory> tmLegacyBuilder = context.getServiceTarget().addService(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append("TransactionManager"), tmLegacyBinderService);
tmLegacyBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tmLegacyBinderService.getNamingStoreInjector());
tmLegacyBuilder.addDependency(TransactionManagerService.SERVICE_NAME, javax.transaction.TransactionManager.class, new Injector<javax.transaction.TransactionManager>() {
@Override
public void inject(final javax.transaction.TransactionManager value) throws InjectionException {
tmLegacyBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
}
@Override
public void uninject() {
tmLegacyBinderService.getManagedObjectInjector().uninject();
}
});
tmLegacyBuilder.install();
final BinderService tsrBinderService = new BinderService("TransactionSynchronizationRegistry");
final ServiceBuilder<ManagedReferenceFactory> tsrBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("TransactionSynchronizationRegistry"), tsrBinderService);
tsrBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, tsrBinderService.getNamingStoreInjector());
tsrBuilder.addDependency(TransactionSynchronizationRegistryService.SERVICE_NAME, TransactionSynchronizationRegistry.class, new Injector<TransactionSynchronizationRegistry>() {
@Override
public void inject(final TransactionSynchronizationRegistry value) throws InjectionException {
tsrBinderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
}
@Override
public void uninject() {
tsrBinderService.getManagedObjectInjector().uninject();
}
});
tsrBuilder.install();
// Install the UserTransactionAccessControlService
final UserTransactionAccessControlService lookupControlService = new UserTransactionAccessControlService();
context.getServiceTarget().addService(UserTransactionAccessControlService.SERVICE_NAME, lookupControlService).install();
// Bind the UserTransaction into JNDI
final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction");
final ServiceBuilder<ManagedReferenceFactory> utBuilder = context.getServiceTarget().addService(ContextNames.JBOSS_CONTEXT_SERVICE_NAME.append("UserTransaction"), userTransactionBindingService);
utBuilder.addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()).addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class, userTransactionBindingService.getUserTransactionAccessControlServiceInjector()).addDependency(UserTransactionService.SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector()));
utBuilder.install();
// install the EE Concurrency transaction setup provider's service
final TransactionSetupProviderService transactionSetupProviderService = new TransactionSetupProviderService();
context.getServiceTarget().addService(ConcurrentServiceNames.TRANSACTION_SETUP_PROVIDER_SERVICE_NAME, transactionSetupProviderService).addDependency(TransactionManagerService.SERVICE_NAME, TransactionManager.class, transactionSetupProviderService.getTransactionManagerInjectedValue()).install();
}
use of org.jboss.as.naming.ValueManagedReferenceFactory 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.ValueManagedReferenceFactory 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);
}
use of org.jboss.as.naming.ValueManagedReferenceFactory in project wildfly by wildfly.
the class BinderServiceUtil method installBinderService.
/**
* Install a binder service to bind the value of the {@code service} using the binding {@code name}.
* @param serviceTarget
* @param name the binding name
* @param service the service whose value must be bound
*/
public static void installBinderService(final ServiceTarget serviceTarget, final String name, final Service<?> service, final ServiceName... dependencies) {
final BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(bindInfo.getBindName());
final ServiceBuilder serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addInjection(binderService.getManagedObjectInjector(), new ValueManagedReferenceFactory(service)).setInitialMode(ServiceController.Mode.PASSIVE);
if (dependencies != null && dependencies.length > 0) {
serviceBuilder.addDependencies(dependencies);
}
serviceBuilder.install();
}
Aggregations