use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class AbstractDataSourceAdd method firstRuntimeStep.
void firstRuntimeStep(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String jndiName = JNDI_NAME.resolveModelAttribute(context, model).asString();
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final boolean jta = JTA.resolveModelAttribute(context, operation).asBoolean();
// The STATISTICS_ENABLED.resolveModelAttribute(context, model) call should remain as it serves to validate that any
final String dsName = context.getCurrentAddressValue();
// expression in the model can be resolved to a correct value.
@SuppressWarnings("unused") final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
final ServiceTarget serviceTarget = context.getServiceTarget();
ModelNode node = DATASOURCE_DRIVER.resolveModelAttribute(context, model);
final String driverName = node.asString();
final ServiceName driverServiceName = ServiceName.JBOSS.append("jdbc-driver", driverName.replaceAll("\\.", "_"));
ValueInjectionService<Driver> driverDemanderService = new ValueInjectionService<Driver>();
final ServiceName driverDemanderServiceName = ServiceName.JBOSS.append("driver-demander").append(jndiName);
final ServiceBuilder<?> driverDemanderBuilder = serviceTarget.addService(driverDemanderServiceName, driverDemanderService).addDependency(driverServiceName, Driver.class, driverDemanderService.getInjector());
driverDemanderBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
AbstractDataSourceService dataSourceService = createDataSourceService(dsName, jndiName);
final ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate();
final ServiceName dataSourceServiceNameAlias = AbstractDataSourceService.getServiceName(bindInfo);
final ServiceName dataSourceServiceName = context.getCapabilityServiceName(Capabilities.DATA_SOURCE_CAPABILITY_NAME, dsName, DataSource.class);
final ServiceBuilder<?> dataSourceServiceBuilder = Services.addServerExecutorDependency(serviceTarget.addService(dataSourceServiceName, dataSourceService), dataSourceService.getExecutorServiceInjector(), false).addAliases(dataSourceServiceNameAlias).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, dataSourceService.getManagementRepositoryInjector()).addDependency(ConnectorServices.JDBC_DRIVER_REGISTRY_SERVICE, DriverRegistry.class, dataSourceService.getDriverRegistryInjector()).addDependency(ConnectorServices.IDLE_REMOVER_SERVICE).addDependency(ConnectorServices.CONNECTION_VALIDATOR_SERVICE).addDependency(ConnectorServices.IRONJACAMAR_MDR, MetadataRepository.class, dataSourceService.getMdrInjector()).addDependency(NamingService.SERVICE_NAME);
if (jta) {
dataSourceServiceBuilder.addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, dataSourceService.getTransactionIntegrationInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, dataSourceService.getCcmInjector()).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(DEFAULT_NAME)).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, dataSourceService.getRaRepositoryInjector());
} else {
dataSourceServiceBuilder.addDependency(ConnectorServices.NON_JTA_DS_RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, dataSourceService.getRaRepositoryInjector()).addDependency(ConnectorServices.NON_TX_CCM_SERVICE, CachedConnectionManager.class, dataSourceService.getCcmInjector());
}
//Register an empty override model regardless of we're enabled or not - the statistics listener will add the relevant childresources
if (registration.isAllowsOverride()) {
registration.registerOverrideModel(dsName, DataSourcesSubsystemProviders.OVERRIDE_DS_DESC);
}
startConfigAndAddDependency(dataSourceServiceBuilder, dataSourceService, dsName, serviceTarget, operation);
dataSourceServiceBuilder.addDependency(driverServiceName, Driver.class, dataSourceService.getDriverInjector());
// If the authentication context is defined, add the capability
boolean requireLegacySecurity = false;
if (ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) {
if (model.hasDefined(AUTHENTICATION_CONTEXT.getName())) {
dataSourceServiceBuilder.addDependency(context.getCapabilityServiceName(Capabilities.AUTHENTICATION_CONTEXT_CAPABILITY, AUTHENTICATION_CONTEXT.resolveModelAttribute(context, model).asString(), AuthenticationContext.class), AuthenticationContext.class, dataSourceService.getAuthenticationContext());
}
} else {
String secDomain = SECURITY_DOMAIN.resolveModelAttribute(context, model).asStringOrNull();
requireLegacySecurity = (secDomain != null && secDomain.length() > 0);
}
if (isXa()) {
if (RECOVERY_ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) {
if (model.hasDefined(RECOVERY_AUTHENTICATION_CONTEXT.getName())) {
dataSourceServiceBuilder.addDependency(context.getCapabilityServiceName(Capabilities.AUTHENTICATION_CONTEXT_CAPABILITY, RECOVERY_AUTHENTICATION_CONTEXT.resolveModelAttribute(context, model).asString(), AuthenticationContext.class), AuthenticationContext.class, dataSourceService.getRecoveryAuthenticationContext());
}
} else if (!requireLegacySecurity) {
String secDomain = RECOVERY_SECURITY_DOMAIN.resolveModelAttribute(context, model).asStringOrNull();
requireLegacySecurity = (secDomain != null && secDomain.length() > 0);
}
}
if (requireLegacySecurity) {
dataSourceServiceBuilder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, dataSourceService.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, dataSourceService.getServerSecurityManager());
}
ModelNode credentialReference = Constants.CREDENTIAL_REFERENCE.resolveModelAttribute(context, model);
if (credentialReference.isDefined()) {
dataSourceService.getCredentialSourceSupplierInjector().inject(CredentialReference.getCredentialSourceSupplier(context, Constants.CREDENTIAL_REFERENCE, model, dataSourceServiceBuilder));
}
ModelNode recoveryCredentialReference = Constants.RECOVERY_CREDENTIAL_REFERENCE.resolveModelAttribute(context, model);
if (recoveryCredentialReference.isDefined()) {
dataSourceService.getRecoveryCredentialSourceSupplierInjector().inject(CredentialReference.getCredentialSourceSupplier(context, Constants.RECOVERY_CREDENTIAL_REFERENCE, model, dataSourceServiceBuilder));
}
dataSourceServiceBuilder.setInitialMode(ServiceController.Mode.NEVER);
dataSourceServiceBuilder.install();
driverDemanderBuilder.install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class AbstractDataSourceAdd method secondRuntimeStep.
static void secondRuntimeStep(OperationContext context, ModelNode operation, ManagementResourceRegistration datasourceRegistration, ModelNode model, boolean isXa) throws OperationFailedException {
final ServiceTarget serviceTarget = context.getServiceTarget();
final ModelNode address = operation.require(OP_ADDR);
final String dsName = PathAddress.pathAddress(address).getLastElement().getValue();
final String jndiName = JNDI_NAME.resolveModelAttribute(context, model).asString();
final ServiceRegistry registry = context.getServiceRegistry(true);
final List<ServiceName> serviceNames = registry.getServiceNames();
final boolean elytronEnabled = ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean();
final ServiceName dataSourceServiceName = context.getCapabilityServiceName(Capabilities.DATA_SOURCE_CAPABILITY_NAME, dsName, DataSource.class);
final ServiceController<?> dataSourceController = registry.getService(dataSourceServiceName);
final ExceptionSupplier<CredentialSource, Exception> credentialSourceExceptionExceptionSupplier = dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService) dataSourceController.getService()).getCredentialSourceSupplierInjector().getOptionalValue() : null;
final ExceptionSupplier<CredentialSource, Exception> recoveryCredentialSourceExceptionExceptionSupplier = dataSourceController.getService() instanceof AbstractDataSourceService ? ((AbstractDataSourceService) dataSourceController.getService()).getRecoveryCredentialSourceSupplierInjector().getOptionalValue() : null;
final boolean jta;
if (isXa) {
jta = true;
final ModifiableXaDataSource dataSourceConfig;
try {
dataSourceConfig = xaFrom(context, model, dsName, credentialSourceExceptionExceptionSupplier, recoveryCredentialSourceExceptionExceptionSupplier);
} catch (ValidateException e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToCreate("XaDataSource", operation, e.getLocalizedMessage()));
}
final ServiceName xaDataSourceConfigServiceName = XADataSourceConfigService.SERVICE_NAME_BASE.append(dsName);
final XADataSourceConfigService xaDataSourceConfigService = new XADataSourceConfigService(dataSourceConfig);
final ServiceBuilder<?> builder = serviceTarget.addService(xaDataSourceConfigServiceName, xaDataSourceConfigService);
// add dependency on security domain service if applicable
final DsSecurity dsSecurityConfig = dataSourceConfig.getSecurity();
if (dsSecurityConfig != null) {
final String securityDomainName = dsSecurityConfig.getSecurityDomain();
if (!elytronEnabled && securityDomainName != null) {
builder.addDependency(SecurityDomainService.SERVICE_NAME.append(securityDomainName));
}
}
// add dependency on security domain service if applicable for recovery config
if (dataSourceConfig.getRecovery() != null) {
final Credential credential = dataSourceConfig.getRecovery().getCredential();
if (credential != null) {
final String securityDomainName = credential.getSecurityDomain();
if (!RECOVERY_ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean() && securityDomainName != null) {
builder.addDependency(SecurityDomainService.SERVICE_NAME.append(securityDomainName));
}
}
}
int propertiesCount = 0;
for (ServiceName name : serviceNames) {
if (xaDataSourceConfigServiceName.append("xa-datasource-properties").isParentOf(name)) {
final ServiceController<?> xaConfigPropertyController = registry.getService(name);
XaDataSourcePropertiesService xaPropService = (XaDataSourcePropertiesService) xaConfigPropertyController.getService();
if (!ServiceController.State.UP.equals(xaConfigPropertyController.getState())) {
propertiesCount++;
xaConfigPropertyController.setMode(ServiceController.Mode.ACTIVE);
builder.addDependency(name, String.class, xaDataSourceConfigService.getXaDataSourcePropertyInjector(xaPropService.getName()));
} else {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceAlreadyStarted("Data-source.xa-config-property", name));
}
}
}
if (propertiesCount == 0) {
throw ConnectorLogger.ROOT_LOGGER.xaDataSourcePropertiesNotPresent();
}
builder.install();
} else {
final ModifiableDataSource dataSourceConfig;
try {
dataSourceConfig = from(context, model, dsName, credentialSourceExceptionExceptionSupplier);
} catch (ValidateException e) {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.failedToCreate("DataSource", operation, e.getLocalizedMessage()));
}
jta = dataSourceConfig.isJTA();
final ServiceName dataSourceCongServiceName = DataSourceConfigService.SERVICE_NAME_BASE.append(dsName);
final DataSourceConfigService configService = new DataSourceConfigService(dataSourceConfig);
final ServiceBuilder<?> builder = serviceTarget.addService(dataSourceCongServiceName, configService);
// add dependency on security domain service if applicable
final DsSecurity dsSecurityConfig = dataSourceConfig.getSecurity();
if (dsSecurityConfig != null) {
final String securityDomainName = dsSecurityConfig.getSecurityDomain();
if (!elytronEnabled && securityDomainName != null) {
builder.addDependency(SecurityDomainService.SERVICE_NAME.append(securityDomainName));
}
}
for (ServiceName name : serviceNames) {
if (dataSourceCongServiceName.append("connection-properties").isParentOf(name)) {
final ServiceController<?> connPropServiceController = registry.getService(name);
ConnectionPropertiesService connPropService = (ConnectionPropertiesService) connPropServiceController.getService();
if (!ServiceController.State.UP.equals(connPropServiceController.getState())) {
connPropServiceController.setMode(ServiceController.Mode.ACTIVE);
builder.addDependency(name, String.class, configService.getConnectionPropertyInjector(connPropService.getName()));
} else {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceAlreadyStarted("Data-source.connectionProperty", name));
}
}
}
builder.install();
}
final ServiceName dataSourceServiceNameAlias = AbstractDataSourceService.SERVICE_NAME_BASE.append(jndiName).append(Constants.STATISTICS);
if (dataSourceController != null) {
if (!ServiceController.State.UP.equals(dataSourceController.getState())) {
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
DataSourceStatisticsService statsService = new DataSourceStatisticsService(datasourceRegistration, statsEnabled);
serviceTarget.addService(dataSourceServiceName.append(Constants.STATISTICS), statsService).addAliases(dataSourceServiceNameAlias).addDependency(dataSourceServiceName).addDependency(CommonDeploymentService.getServiceName(ContextNames.bindInfoFor(jndiName)), CommonDeployment.class, statsService.getCommonDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
dataSourceController.setMode(ServiceController.Mode.ACTIVE);
} else {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceAlreadyStarted("Data-source", dsName));
}
} else {
throw new OperationFailedException(ConnectorLogger.ROOT_LOGGER.serviceNotAvailable("Data-source", dsName));
}
final DataSourceReferenceFactoryService referenceFactoryService = new DataSourceReferenceFactoryService();
final ServiceName referenceFactoryServiceName = DataSourceReferenceFactoryService.SERVICE_NAME_BASE.append(dsName);
final ServiceBuilder<?> referenceBuilder = serviceTarget.addService(referenceFactoryServiceName, referenceFactoryService).addDependency(dataSourceServiceName, DataSource.class, referenceFactoryService.getDataSourceInjector());
referenceBuilder.install();
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final BinderService binderService = new BinderService(bindInfo.getBindName());
final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(referenceFactoryServiceName, ManagedReferenceFactory.class, binderService.getManagedObjectInjector()).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
if (jta) {
SUBSYSTEM_DATASOURCES_LOGGER.boundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.boundNonJTADataSource(jndiName);
}
break;
}
case STOPPING_to_DOWN:
{
if (jta) {
SUBSYSTEM_DATASOURCES_LOGGER.unboundDataSource(jndiName);
} else {
SUBSYSTEM_DATASOURCES_LOGGER.unBoundNonJTADataSource(jndiName);
}
break;
}
case REMOVING_to_REMOVED:
{
SUBSYSTEM_DATASOURCES_LOGGER.debugf("Removed JDBC Data-source [%s]", jndiName);
break;
}
}
}
});
binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
binderBuilder.install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ResourceAdapterDeploymentService method start.
@Override
public void start(StartContext context) throws StartException {
final URL url = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getUrl();
deploymentName = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getDeploymentName();
connectorServicesRegistrationName = deploymentName;
final File root = connectorXmlDescriptor == null ? null : connectorXmlDescriptor.getRoot();
DEPLOYMENT_CONNECTOR_LOGGER.debugf("DEPLOYMENT name = %s", deploymentName);
final boolean fromModule = duServiceName.getParent().equals(RaOperationUtil.RAR_MODULE);
final WildFLyRaDeployer raDeployer = new WildFLyRaDeployer(context.getChildTarget(), url, deploymentName, root, classLoader, cmd, activation, deploymentServiceName, fromModule);
raDeployer.setConfiguration(config.getValue());
ClassLoader old = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged();
try {
try {
WritableServiceBasedNamingStore.pushOwner(duServiceName);
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(classLoader);
raDeployment = raDeployer.doDeploy();
deploymentName = raDeployment.getDeploymentName();
} finally {
WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(old);
WritableServiceBasedNamingStore.popOwner();
}
if (raDeployer.checkActivation(cmd, activation)) {
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Activating: %s", deploymentName);
ServiceName raServiceName = ConnectorServices.getResourceAdapterServiceName(deploymentName);
value = new ResourceAdapterDeployment(raDeployment, deploymentName, raServiceName);
managementRepository.getValue().getConnectors().add(value.getDeployment().getConnector());
registry.getValue().registerResourceAdapterDeployment(value);
ServiceTarget serviceTarget = context.getChildTarget();
serviceTarget.addService(raServiceName, new ResourceAdapterService(raServiceName, value.getDeployment().getResourceAdapter())).setInitialMode(Mode.ACTIVE).install();
final ServiceName deployerServiceName = ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName());
IronJacamarActivationResourceService ijResourceService = new IronJacamarActivationResourceService(registration, deploymentResource, false);
serviceTarget.addService(deployerServiceName.append(ConnectorServices.IRONJACAMAR_RESOURCE), ijResourceService).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, ijResourceService.getMdrInjector()).addDependency(deployerServiceName, ResourceAdapterDeployment.class, ijResourceService.getResourceAdapterDeploymentInjector()).setInitialMode(Mode.PASSIVE).install();
} else {
DEPLOYMENT_CONNECTOR_LOGGER.debugf("Not activating: %s", deploymentName);
}
} catch (Throwable t) {
cleanupStartAsync(context, deploymentName, t, duServiceName, classLoader);
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class CachedConnectionManagerAdd method performBoottime.
@Override
protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
final boolean debug = JcaCachedConnectionManagerDefinition.CcmParameters.DEBUG.getAttribute().resolveModelAttribute(context, model).asBoolean();
final boolean error = JcaCachedConnectionManagerDefinition.CcmParameters.ERROR.getAttribute().resolveModelAttribute(context, model).asBoolean();
final boolean ignoreUnknownConnections = JcaCachedConnectionManagerDefinition.CcmParameters.IGNORE_UNKNOWN_CONNECTIONS.getAttribute().resolveModelAttribute(context, model).asBoolean();
final boolean install = JcaCachedConnectionManagerDefinition.CcmParameters.INSTALL.getAttribute().resolveModelAttribute(context, model).asBoolean();
final ServiceTarget serviceTarget = context.getServiceTarget();
if (install) {
ROOT_LOGGER.debug("Enabling the Cache Connection Manager valve and interceptor...");
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(JcaExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_CACHED_CONNECTION_MANAGER, new CachedConnectionManagerSetupProcessor());
}
}, OperationContext.Stage.RUNTIME);
} else {
ROOT_LOGGER.debug("Disabling the Cache Connection Manager valve and interceptor...");
}
CachedConnectionManagerService ccmService = new CachedConnectionManagerService(debug, error, ignoreUnknownConnections);
serviceTarget.addService(ConnectorServices.CCM_SERVICE, ccmService).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, ccmService.getTransactionIntegrationInjector()).install();
NonTxCachedConnectionManagerService noTxCcm = new NonTxCachedConnectionManagerService(debug, error, ignoreUnknownConnections);
serviceTarget.addService(ConnectorServices.NON_TX_CCM_SERVICE, noTxCcm).install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class DistributedWorkManagerAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
String name = JcaDistributedWorkManagerDefinition.DWmParameters.NAME.getAttribute().resolveModelAttribute(context, model).asString();
boolean elytronEnabled = JcaWorkManagerDefinition.WmParameters.ELYTRON_ENABLED.getAttribute().resolveModelAttribute(context, resource.getModel()).asBoolean();
String policy = JcaDistributedWorkManagerDefinition.DWmParameters.POLICY.getAttribute().resolveModelAttribute(context, model).asString();
String selector = JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR.getAttribute().resolveModelAttribute(context, model).asString();
ServiceTarget serviceTarget = context.getServiceTarget();
NamedDistributedWorkManager namedDistributedWorkManager = new NamedDistributedWorkManager(name, elytronEnabled);
if (policy != null && !policy.trim().isEmpty()) {
switch(JcaDistributedWorkManagerDefinition.PolicyValue.valueOf(policy)) {
case NEVER:
{
namedDistributedWorkManager.setPolicy(new Never());
break;
}
case ALWAYS:
{
namedDistributedWorkManager.setPolicy(new Always());
break;
}
case WATERMARK:
{
namedDistributedWorkManager.setPolicy(new WaterMark());
break;
}
default:
throw ROOT_LOGGER.unsupportedPolicy(policy);
}
Injection injector = new Injection();
for (Map.Entry<String, String> entry : ((PropertiesAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.POLICY_OPTIONS.getAttribute()).unwrap(context, model).entrySet()) {
try {
injector.inject(namedDistributedWorkManager.getPolicy(), entry.getKey(), entry.getValue());
} catch (Exception e) {
ROOT_LOGGER.unsupportedPolicyOption(entry.getKey());
}
}
} else {
namedDistributedWorkManager.setPolicy(new WaterMark());
}
if (selector != null && !selector.trim().isEmpty()) {
switch(JcaDistributedWorkManagerDefinition.SelectorValue.valueOf(selector)) {
case FIRST_AVAILABLE:
{
namedDistributedWorkManager.setSelector(new FirstAvailable());
break;
}
case MAX_FREE_THREADS:
{
namedDistributedWorkManager.setSelector(new MaxFreeThreads());
break;
}
case PING_TIME:
{
namedDistributedWorkManager.setSelector(new PingTime());
break;
}
default:
throw ROOT_LOGGER.unsupportedSelector(selector);
}
Injection injector = new Injection();
for (Map.Entry<String, String> entry : ((PropertiesAttributeDefinition) JcaDistributedWorkManagerDefinition.DWmParameters.SELECTOR_OPTIONS.getAttribute()).unwrap(context, model).entrySet()) {
try {
injector.inject(namedDistributedWorkManager.getSelector(), entry.getKey(), entry.getValue());
} catch (Exception e) {
ROOT_LOGGER.unsupportedSelectorOption(entry.getKey());
}
}
} else {
namedDistributedWorkManager.setSelector(new PingTime());
}
DistributedWorkManagerService wmService = new DistributedWorkManagerService(namedDistributedWorkManager);
ServiceBuilder<NamedDistributedWorkManager> builder = serviceTarget.addService(ConnectorServices.WORKMANAGER_SERVICE.append(name), wmService);
builder.addDependency(JGroupsDefaultRequirement.CHANNEL_FACTORY.getServiceName(context), ChannelFactory.class, wmService.getJGroupsChannelFactoryInjector());
builder.addDependency(ServiceBuilder.DependencyType.OPTIONAL, ThreadsServices.EXECUTOR.append(WORKMANAGER_LONG_RUNNING).append(name), Executor.class, wmService.getExecutorLongInjector());
builder.addDependency(ThreadsServices.EXECUTOR.append(WORKMANAGER_SHORT_RUNNING).append(name), Executor.class, wmService.getExecutorShortInjector());
builder.addDependency(TxnServices.JBOSS_TXN_CONTEXT_XA_TERMINATOR, JBossContextXATerminator.class, wmService.getXaTerminatorInjector()).setInitialMode(ServiceController.Mode.ACTIVE).install();
WorkManagerStatisticsService wmStatsService = new WorkManagerStatisticsService(context.getResourceRegistrationForUpdate(), name, true);
serviceTarget.addService(ConnectorServices.WORKMANAGER_STATS_SERVICE.append(name), wmStatsService).addDependency(ConnectorServices.WORKMANAGER_SERVICE.append(name), WorkManager.class, wmStatsService.getWorkManagerInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
DistributedWorkManagerStatisticsService dwmStatsService = new DistributedWorkManagerStatisticsService(context.getResourceRegistrationForUpdate(), name, true);
serviceTarget.addService(ConnectorServices.DISTRIBUTED_WORKMANAGER_STATS_SERVICE.append(name), dwmStatsService).addDependency(ConnectorServices.WORKMANAGER_SERVICE.append(name), DistributedWorkManager.class, dwmStatsService.getDistributedWorkManagerInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peDistributedWm = PathElement.pathElement(org.jboss.as.connector.subsystems.resourceadapters.Constants.STATISTICS_NAME, "distributed");
PathElement peLocaldWm = PathElement.pathElement(org.jboss.as.connector.subsystems.resourceadapters.Constants.STATISTICS_NAME, "local");
final Resource wmResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!resource.hasChild(peLocaldWm))
resource.registerChild(peLocaldWm, wmResource);
final Resource dwmResource = new IronJacamarResource.IronJacamarRuntimeResource();
if (!resource.hasChild(peDistributedWm))
resource.registerChild(peDistributedWm, dwmResource);
}
Aggregations