use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ConnectionPropertyAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException {
final String configPropertyValue = CONNECTION_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString();
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String jndiName = path.getElement(path.size() - 2).getValue();
final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
ServiceName serviceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName).append("connection-properties").append(configPropertyName);
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName dataSourceConfigServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(jndiName);
final ServiceController<?> dataSourceConfigController = registry.getService(dataSourceConfigServiceName);
if (dataSourceConfigController == null || !((DataSource) dataSourceConfigController.getValue()).isEnabled()) {
final ServiceTarget serviceTarget = context.getServiceTarget();
final ConnectionPropertiesService service = new ConnectionPropertiesService(configPropertyName, configPropertyValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class XaDataSourcePropertyAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode recoveryEnvModel) throws OperationFailedException {
final String configPropertyValue = XADATASOURCE_PROPERTY_VALUE.resolveModelAttribute(context, recoveryEnvModel).asString();
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String dsName = path.getElement(path.size() - 2).getValue();
final String configPropertyName = PathAddress.pathAddress(address).getLastElement().getValue();
ServiceName serviceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName).append("xa-datasource-properties").append(configPropertyName);
final ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceName dataSourceConfigServiceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName);
final ServiceController<?> dataSourceConfigController = registry.getService(dataSourceConfigServiceName);
if (dataSourceConfigController == null || !((XaDataSource) dataSourceConfigController.getValue()).isEnabled()) {
final ServiceTarget serviceTarget = context.getServiceTarget();
final XaDataSourcePropertiesService service = new XaDataSourcePropertiesService(configPropertyName, configPropertyValue);
ServiceController<?> controller = serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.NEVER).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class BootstrapContextAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
String name = JcaBootstrapContextDefinition.BootstrapCtxParameters.NAME.getAttribute().resolveModelAttribute(context, model).asString();
String workmanager = JcaBootstrapContextDefinition.BootstrapCtxParameters.WORKMANAGER.getAttribute().resolveModelAttribute(context, model).asString();
boolean usingDefaultWm = false;
CloneableBootstrapContext ctx;
if (DEFAULT_NAME.equals(workmanager)) {
usingDefaultWm = true;
ctx = new NamedBootstrapContext(name);
} else {
ctx = new NamedBootstrapContext(name, workmanager);
}
ServiceTarget serviceTarget = context.getServiceTarget();
final BootStrapContextService bootCtxService = new BootStrapContextService(ctx, name, usingDefaultWm);
serviceTarget.addService(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(name), bootCtxService).addDependency(ServiceBuilder.DependencyType.REQUIRED, ConnectorServices.WORKMANAGER_SERVICE.append(workmanager), WorkManager.class, bootCtxService.getWorkManagerValueInjector()).addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, bootCtxService.getXaTerminatorInjector()).addDependency(TxnServices.JBOSS_TXN_ARJUNA_TRANSACTION_MANAGER, com.arjuna.ats.jbossatx.jta.TransactionManagerService.class, bootCtxService.getTxManagerInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, bootCtxService.getJcaConfigInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class JaccEjbDeploymentProcessor method deploy.
@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
boolean securityEnabled = deploymentUnit.hasAttachment(SecurityAttachments.SECURITY_ENABLED);
if (!securityEnabled) {
return;
}
AbstractSecurityDeployer<?> deployer = null;
deployer = new EjbSecurityDeployer();
JaccService<?> service = deployer.deploy(deploymentUnit);
if (service != null) {
final DeploymentUnit parentDU = deploymentUnit.getParent();
// EJBs maybe included directly in war deployment
ServiceName jaccServiceName = getJaccServiceName(deploymentUnit);
final ServiceTarget serviceTarget = phaseContext.getServiceTarget();
ServiceBuilder<?> builder = serviceTarget.addService(jaccServiceName, service);
if (parentDU != null) {
// add dependency to parent policy
builder.addDependency(parentDU.getServiceName().append(JaccService.SERVICE_NAME), PolicyConfiguration.class, service.getParentPolicyInjector());
}
builder.setInitialMode(Mode.ACTIVE).install();
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class JGroupsTransportServiceHandler method installServices.
@Override
public void installServices(OperationContext context, ModelNode model) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
PathAddress containerAddress = address.getParent();
String name = containerAddress.getLastElement().getValue();
ServiceTarget target = context.getServiceTarget();
JGroupsTransportBuilder transportBuilder = new JGroupsTransportBuilder(containerAddress).configure(context, model);
transportBuilder.build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
new SiteBuilder(containerAddress).configure(context, model).build(target).setInitialMode(ServiceController.Mode.PASSIVE).install();
String channel = transportBuilder.getChannel();
for (GroupAliasBuilderProvider provider : ServiceLoader.load(GroupAliasBuilderProvider.class, GroupAliasBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> CLUSTERING_CAPABILITIES.get(requirement).getServiceName(address), name, channel)) {
builder.configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
}
}
}
Aggregations