use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class EJB3RemoteServiceAdd method installRuntimeServices.
void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
final String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
final ServiceName remotingServerInfoServiceName = RemotingConnectorBindingInfoService.serviceName(connectorName);
final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
final ServiceTarget target = context.getServiceTarget();
// Install the client-mapping service for the remoting connector
new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, remotingServerInfoServiceName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
new RegistryInstallerService(clientMappingsClusterName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
// Handle case where no infinispan subsystem exists or does not define an ejb cache-container
Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
PathElement infinispanPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan");
if (!rootResource.hasChild(infinispanPath) || !rootResource.getChild(infinispanPath).hasChild(PathElement.pathElement("cache-container", clientMappingsClusterName))) {
// Install services that would normally be installed by this container/cache
CapabilityServiceSupport support = context.getCapabilityServiceSupport();
for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName), clientMappingsClusterName)) {
builder.configure(support).build(target).install();
}
}
for (CacheBuilderProvider provider : ServiceLoader.load(LocalCacheBuilderProvider.class, LocalCacheBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName, null), clientMappingsClusterName, null)) {
builder.configure(support).build(target).install();
}
}
}
final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
// Install the EJB remoting connector service which will listen for client connections on the remoting channel
// TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions);
ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
builder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector()).addDependency(remotingServerInfoServiceName, RemotingConnectorBindingInfoService.RemotingConnectorInfo.class, ejbRemoteConnectorService.getRemotingConnectorInfoInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addDependency(TxnServices.JBOSS_TXN_REMOTE_TRANSACTION_SERVICE, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, ejbRemoteConnectorService.getControlledProcessStateServiceInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
if (!executeInWorker) {
builder.addDependency(EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName), ExecutorService.class, ejbRemoteConnectorService.getExecutorService());
}
builder.install();
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IronJacamarResourceCreator method addConnectionDefinition.
private void addConnectionDefinition(final Resource parent, ConnectionDefinition connDef) {
final Resource connDefResource = new IronJacamarResource.IronJacamarRuntimeResource();
final ModelNode model = connDefResource.getModel();
setAttribute(model, Constants.JNDINAME, connDef.getJndiName());
if (connDef.getConfigProperties() != null) {
for (Map.Entry<String, String> config : connDef.getConfigProperties().entrySet()) {
addConfigProperties(connDefResource, config.getKey(), config.getValue());
}
}
setAttribute(model, CLASS_NAME, connDef.getClassName());
setAttribute(model, JNDINAME, connDef.getJndiName());
setAttribute(model, USE_JAVA_CONTEXT, connDef.isUseJavaContext());
setAttribute(model, ENABLED, connDef.isEnabled());
setAttribute(model, CONNECTABLE, connDef.isConnectable());
if (connDef.isTracking() != null) {
setAttribute(model, TRACKING, connDef.isTracking());
}
setAttribute(model, USE_CCM, connDef.isUseCcm());
setAttribute(model, SHARABLE, connDef.isSharable());
setAttribute(model, ENLISTMENT, connDef.isEnlistment());
final Pool pool = connDef.getPool();
if (pool != null) {
setAttribute(model, MAX_POOL_SIZE, pool.getMaxPoolSize());
setAttribute(model, MIN_POOL_SIZE, pool.getMinPoolSize());
setAttribute(model, INITIAL_POOL_SIZE, pool.getInitialPoolSize());
if (pool.getCapacity() != null) {
if (pool.getCapacity().getIncrementer() != null) {
setAttribute(model, CAPACITY_INCREMENTER_CLASS, pool.getCapacity().getIncrementer().getClassName());
if (pool.getCapacity().getIncrementer().getConfigPropertiesMap() != null) {
for (Map.Entry<String, String> config : pool.getCapacity().getIncrementer().getConfigPropertiesMap().entrySet()) {
model.get(CAPACITY_INCREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
}
}
}
if (pool.getCapacity().getDecrementer() != null) {
setAttribute(model, CAPACITY_DECREMENTER_CLASS, pool.getCapacity().getDecrementer().getClassName());
if (pool.getCapacity().getDecrementer().getConfigPropertiesMap() != null) {
for (Map.Entry<String, String> config : pool.getCapacity().getDecrementer().getConfigPropertiesMap().entrySet()) {
model.get(CAPACITY_DECREMENTER_PROPERTIES.getName(), config.getKey()).set(config.getValue());
}
}
}
}
setAttribute(model, POOL_USE_STRICT_MIN, pool.isUseStrictMin());
if (pool.getFlushStrategy() != null)
setAttribute(model, POOL_FLUSH_STRATEGY, pool.getFlushStrategy().name());
setAttribute(model, POOL_PREFILL, pool.isPrefill());
setAttribute(model, POOL_FAIR, pool.isFair());
if (connDef.isXa()) {
assert connDef.getPool() instanceof XaPool;
XaPool xaPool = (XaPool) connDef.getPool();
setAttribute(model, WRAP_XA_RESOURCE, xaPool.isWrapXaResource());
setAttribute(model, SAME_RM_OVERRIDE, xaPool.isSameRmOverride());
setAttribute(model, PAD_XID, xaPool.isPadXid());
setAttribute(model, INTERLEAVING, xaPool.isInterleaving());
setAttribute(model, NOTXSEPARATEPOOL, xaPool.isNoTxSeparatePool());
}
}
final Security security = (Security) connDef.getSecurity();
if (security != null) {
setAttribute(model, APPLICATION, security.isApplication());
if (security.isElytronEnabled()) {
setAttribute(model, ELYTRON_ENABLED, true);
setAttribute(model, AUTHENTICATION_CONTEXT, security.getSecurityDomain());
setAttribute(model, AUTHENTICATION_CONTEXT_AND_APPLICATION, security.getSecurityDomainAndApplication());
} else {
setAttribute(model, SECURITY_DOMAIN, security.getSecurityDomain());
setAttribute(model, SECURITY_DOMAIN_AND_APPLICATION, security.getSecurityDomainAndApplication());
}
}
final TimeOut timeOut = connDef.getTimeOut();
if (timeOut != null) {
setAttribute(model, ALLOCATION_RETRY, timeOut.getAllocationRetry());
setAttribute(model, ALLOCATION_RETRY_WAIT_MILLIS, timeOut.getAllocationRetryWaitMillis());
setAttribute(model, BLOCKING_TIMEOUT_WAIT_MILLIS, timeOut.getBlockingTimeoutMillis());
setAttribute(model, IDLETIMEOUTMINUTES, timeOut.getIdleTimeoutMinutes());
setAttribute(model, XA_RESOURCE_TIMEOUT, timeOut.getXaResourceTimeout());
}
final Validation validation = connDef.getValidation();
if (validation != null) {
setAttribute(model, BACKGROUNDVALIDATIONMILLIS, validation.getBackgroundValidationMillis());
setAttribute(model, BACKGROUNDVALIDATION, validation.isBackgroundValidation());
setAttribute(model, USE_FAST_FAIL, validation.isUseFastFail());
setAttribute(model, VALIDATE_ON_MATCH, validation.isValidateOnMatch());
}
final Recovery recovery = connDef.getRecovery();
if (recovery != null) {
setAttribute(model, NO_RECOVERY, recovery.getNoRecovery());
final Extension recoverPlugin = recovery.getRecoverPlugin();
if (recoverPlugin != null) {
setAttribute(model, RECOVERLUGIN_CLASSNAME, recoverPlugin.getClassName());
if (recoverPlugin.getConfigPropertiesMap() != null) {
for (Map.Entry<String, String> config : recoverPlugin.getConfigPropertiesMap().entrySet()) {
model.get(RECOVERLUGIN_PROPERTIES.getName(), config.getKey()).set(config.getValue());
}
}
}
final Credential recoveryCredential = (Credential) recovery.getCredential();
if (recoveryCredential != null) {
setAttribute(model, RECOVERY_PASSWORD, recoveryCredential.getPassword());
if (recoveryCredential.isElytronEnabled()) {
setAttribute(model, RECOVERY_ELYTRON_ENABLED, true);
setAttribute(model, RECOVERY_AUTHENTICATION_CONTEXT, recoveryCredential.getSecurityDomain());
} else {
setAttribute(model, RECOVERY_SECURITY_DOMAIN, recoveryCredential.getSecurityDomain());
}
setAttribute(model, RECOVERY_USERNAME, recoveryCredential.getUserName());
}
}
final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
connDefResource.registerChild(PathElement.pathElement(Constants.STATISTICS_NAME, "local"), statsResource);
final PathElement element = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME, connDef.getJndiName());
parent.registerChild(element, connDefResource);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IronJacamarResourceCreator method execute.
public void execute(Resource parentResource, AS7MetadataRepository mdr, String name) {
// Get the iron-jacamar resource
final IronJacamarResource ironJacamarResource = new IronJacamarResource();
// Replace the current model with an updated one
final Resource storeModel = getIronJacamarResource(mdr, name);
ironJacamarResource.update(storeModel);
PathElement ijPe = PathElement.pathElement(Constants.IRONJACAMAR_NAME, Constants.IRONJACAMAR_NAME);
if (parentResource.getChild(ijPe) == null) {
parentResource.registerChild(ijPe, ironJacamarResource);
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class CachedConnectionManagerAdd method createResource.
@Override
protected Resource createResource(OperationContext context, ModelNode operation) {
// exists, so long as it is configured with the values the parser generates (i.e. no defined attributes)
try {
// will fail in normal case
Resource existing = context.readResourceForUpdate(PathAddress.EMPTY_ADDRESS);
ModelNode model = existing.getModel();
boolean allDefault = true;
for (JcaCachedConnectionManagerDefinition.CcmParameters param : JcaCachedConnectionManagerDefinition.CcmParameters.values()) {
if (param == INSTALL || param == DEBUG || param == ERROR || param == IGNORE_UNKNOWN_CONNECTIONS) {
AttributeDefinition ad = param.getAttribute();
// else someone changed something and we need to account for that
assert !ad.isRequired() : ad.getName();
if (model.hasDefined(ad.getName())) {
allDefault = false;
break;
}
} else {
// Someone added a new param since WFLY-2640/WFLY-8141 and did not account for it above
throw new IllegalStateException();
}
}
if (allDefault) {
// We can use the existing resource as if we just created it
return existing;
}
// else fall through and call super method which will fail due to resource already being present
} catch (Resource.NoSuchResourceException normal) {
// normal case; resource doesn't exist yet so fall through
}
return super.createResource(context, operation);
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class IDMConfigAddStepHandler method configureModelValidators.
private void configureModelValidators(ModelValidationStepHandler[] modelValidators) {
List<AttributeDefinition> alternativeAttributes = new ArrayList<AttributeDefinition>();
for (AttributeDefinition attribute : this.attributes) {
if (attribute.getAlternatives() != null && attribute.getAlternatives().length > 0) {
alternativeAttributes.add(attribute);
}
}
if (!alternativeAttributes.isEmpty()) {
this.modelValidators.add(new AlternativeAttributeValidationStepHandler(alternativeAttributes.toArray(new AttributeDefinition[alternativeAttributes.size()]), isAlternativesRequired()));
}
if (modelValidators != null) {
this.modelValidators.addAll(Arrays.asList(modelValidators));
}
this.modelValidators.add(new ModelValidationStepHandler() {
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
final PathAddress address = getParentAddress(PathAddress.pathAddress(operation.require(OP_ADDR)));
Resource resource = context.readResourceFromRoot(address);
final ModelNode parentModel = Resource.Tools.readModel(resource);
PartitionManagerAddHandler.INSTANCE.validateModel(context, address.getLastElement().getValue(), parentModel);
context.stepCompleted();
}
});
}
Aggregations