use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class BroadcastGroupDefinition method getAvailableConnectors.
private static Set<String> getAvailableConnectors(final OperationContext context, final ModelNode operation) throws OperationFailedException {
PathAddress hornetqServer = context.getCurrentAddress().getParent();
Resource hornetQServerResource = context.readResourceFromRoot(hornetqServer);
Set<String> availableConnectors = new HashSet<String>();
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
availableConnectors.addAll(hornetQServerResource.getChildrenNames(CommonAttributes.CONNECTOR));
return availableConnectors;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class PooledConnectionFactoryAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, Resource resource) throws OperationFailedException {
ModelNode model = resource.getModel();
PathAddress address = context.getCurrentAddress();
final String name = context.getCurrentAddressValue();
final ModelNode resolvedModel = model.clone();
for (final AttributeDefinition attribute : getDefinitions(PooledConnectionFactoryDefinition.ATTRIBUTES)) {
resolvedModel.get(attribute.getName()).set(attribute.resolveModelAttribute(context, resolvedModel));
}
// We validated that jndiName part of the model in populateModel
final List<String> jndiNames = new ArrayList<String>();
for (ModelNode node : resolvedModel.get(Common.ENTRIES.getName()).asList()) {
jndiNames.add(node.asString());
}
String managedConnectionPoolClassName = null;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName())) {
managedConnectionPoolClassName = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MANAGED_CONNECTION_POOL.getName()).asString();
}
final int minPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MIN_POOL_SIZE.getName()).asInt();
final int maxPoolSize = resolvedModel.get(ConnectionFactoryAttributes.Pooled.MAX_POOL_SIZE.getName()).asInt();
Boolean enlistmentTrace = null;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName())) {
enlistmentTrace = resolvedModel.get(ConnectionFactoryAttributes.Pooled.ENLISTMENT_TRACE.getName()).asBoolean();
}
final String txSupport;
if (resolvedModel.hasDefined(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName())) {
String txType = resolvedModel.get(ConnectionFactoryAttributes.Pooled.TRANSACTION.getName()).asString();
if (LOCAL.equals(txType)) {
txSupport = LOCAL_TX;
} else if (NONE.equals(txType)) {
txSupport = NO_TX;
} else {
txSupport = XA_TX;
}
} else {
txSupport = XA_TX;
}
ServiceTarget serviceTarget = context.getServiceTarget();
List<String> connectors = Common.CONNECTORS.unwrap(context, model);
String discoveryGroupName = getDiscoveryGroup(resolvedModel);
String jgroupsChannelName = null;
if (discoveryGroupName != null) {
Resource dgResource = context.readResourceFromRoot(MessagingServices.getActiveMQServerPathAddress(address).append(CommonAttributes.DISCOVERY_GROUP, discoveryGroupName));
ModelNode dgModel = dgResource.getModel();
jgroupsChannelName = JGROUPS_CHANNEL.resolveModelAttribute(context, dgModel).asString();
}
List<PooledConnectionFactoryConfigProperties> adapterParams = getAdapterParams(resolvedModel, context);
final PathAddress serverAddress = MessagingServices.getActiveMQServerPathAddress(address);
PooledConnectionFactoryService.installService(serviceTarget, name, serverAddress.getLastElement().getValue(), connectors, discoveryGroupName, jgroupsChannelName, adapterParams, jndiNames, txSupport, minPoolSize, maxPoolSize, managedConnectionPoolClassName, enlistmentTrace);
boolean statsEnabled = ConnectionFactoryAttributes.Pooled.STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
if (statsEnabled) {
installStatistics(context, name);
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class MessagingXmlInstallDeploymentUnitProcessor method getOrCreate.
static Resource getOrCreate(final Resource parent, final PathAddress address) {
Resource current = parent;
for (final PathElement element : address) {
synchronized (current) {
if (current.hasChild(element)) {
current = current.requireChild(element);
} else {
final Resource resource = Resource.Factory.create();
current.registerChild(element, resource);
current = resource;
}
}
}
return current;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class SecurityRoleAttributeHandler method applyUpdateToRuntime.
@Override
protected boolean applyUpdateToRuntime(OperationContext context, ModelNode operation, String attributeName, ModelNode newValue, ModelNode currentValue, HandbackHolder<Set<Role>> handbackHolder) throws OperationFailedException {
final ActiveMQServer server = getActiveMQServer(context, operation);
if (server != null) {
final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
final String match = address.getElement(address.size() - 2).getValue();
final String roleName = address.getLastElement().getValue();
final Set<Role> newRoles = new HashSet<Role>();
final Set<Role> roles = server.getSecurityRepository().getMatch(match);
handbackHolder.setHandback(roles);
for (final Role role : roles) {
if (!roleName.equals(role.getName())) {
newRoles.add(role);
}
}
final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
final ModelNode subModel = resource.getModel();
final Role updatedRole = SecurityRoleDefinition.transform(context, roleName, subModel);
newRoles.add(updatedRole);
server.getSecurityRepository().addMatch(match, newRoles);
}
return false;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class NotEmptyResourceValidationStepHandler method validateChildren.
protected void validateChildren(OperationContext context, ModelNode operation) throws OperationFailedException {
Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
PathAddress pathAddress = PathAddress.pathAddress(operation.get(OP_ADDR));
if (resource.getChildTypes().isEmpty()) {
throw ROOT_LOGGER.emptyResource(pathAddress.getLastElement().toString());
}
}
Aggregations