use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class WebMigrateOperation method addExtension.
/**
* It's possible that the extension is already present. In that case, this method does nothing.
*/
private void addExtension(OperationContext context, Map<PathAddress, ModelNode> migrationOperations, boolean describe, String extension) {
Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false);
if (root.getChildrenNames(EXTENSION).contains(extension)) {
// extension is already added, do nothing
return;
}
PathAddress extensionAddress = pathAddress(EXTENSION, extension);
OperationEntry addEntry = context.getRootResourceRegistration().getOperationEntry(extensionAddress, ADD);
ModelNode addOperation = createAddOperation(extensionAddress);
addOperation.get(MODULE).set(extension);
if (describe) {
migrationOperations.put(extensionAddress, addOperation);
} else {
context.addStep(context.getResult().get(extensionAddress.toString()), addOperation, addEntry.getOperationHandler(), MODEL);
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class MigrateOperation method connectionFactoryIsUsingInVMConnectors.
private boolean connectionFactoryIsUsingInVMConnectors(OperationContext context, ModelNode connectionFactoryAddOp) {
ModelNode connector = connectionFactoryAddOp.get(CONNECTOR);
if (connector.isDefined()) {
PathAddress connectionFactoryAddress = pathAddress(connectionFactoryAddOp.get(OP_ADDR));
PathElement relativeLegacyServerAddress = connectionFactoryAddress.getParent().getLastElement();
// read the server resource related to the context current address (which is the messaging subsystem address).
Resource serverResource = context.readResource(pathAddress(relativeLegacyServerAddress), false);
Set<String> definedInVMConnectors = serverResource.getChildrenNames("in-vm-connector");
// legacy connector is a property list where the name is the connector and the value is undefined
List<Property> connectorProps = connector.asPropertyList();
for (Property connectorProp : connectorProps) {
String connectorName = connectorProp.getName();
if (definedInVMConnectors.contains(connectorName)) {
return true;
}
}
}
return false;
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class MigrateOperation method addMessagingActiveMQExtension.
/**
* It's possible that the extension is already present. In that case, this method does nothing.
*/
private void addMessagingActiveMQExtension(OperationContext context, Map<PathAddress, ModelNode> migrationOperations, boolean describe) {
Resource root = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false);
if (root.getChildrenNames(EXTENSION).contains(MESSAGING_ACTIVEMQ_EXTENSION)) {
// extension is already added, do nothing
return;
}
PathAddress extensionAddress = pathAddress(EXTENSION, MESSAGING_ACTIVEMQ_EXTENSION);
OperationEntry addEntry = context.getRootResourceRegistration().getOperationEntry(extensionAddress, ADD);
ModelNode addOperation = createAddOperation(extensionAddress);
addOperation.get(MODULE).set(MESSAGING_ACTIVEMQ_MODULE);
if (describe) {
migrationOperations.put(extensionAddress, addOperation);
} else {
context.addStep(context.getResult().get(extensionAddress.toString()), addOperation, addEntry.getOperationHandler(), MODEL);
}
}
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);
}
}
Aggregations