use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class QueueDefinition method forwardToRuntimeQueue.
/**
* [AS7-5850] Core queues created with ActiveMQ API does not create WildFly resources
*
* For backwards compatibility if an operation is invoked on a queue that has no corresponding resources,
* we forward the operation to the corresponding runtime-queue resource (which *does* exist).
*
* @return true if the operation is forwarded to the corresponding runtime-queue resource, false else.
*/
static boolean forwardToRuntimeQueue(OperationContext context, ModelNode operation, OperationStepHandler handler) {
PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR));
// do not forward if the current operation is for a runtime-queue already:
if (RUNTIME_QUEUE.equals(address.getLastElement().getKey())) {
return false;
}
String queueName = address.getLastElement().getValue();
PathAddress activeMQPathAddress = MessagingServices.getActiveMQServerPathAddress(address);
Resource serverResource = context.readResourceFromRoot(activeMQPathAddress);
boolean hasChild = serverResource.hasChild(address.getLastElement());
if (hasChild) {
return false;
} else {
// there is no registered queue resource, forward to the runtime-queue address instead
ModelNode forwardOperation = operation.clone();
forwardOperation.get(ModelDescriptionConstants.OP_ADDR).set(activeMQPathAddress.append(RUNTIME_QUEUE, queueName).toModelNode());
context.addStep(forwardOperation, handler, OperationContext.Stage.RUNTIME, true);
return true;
}
}
use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.
the class ExportJournalOperation method resolvePath.
private static String resolvePath(OperationContext context, PathManager pathManager, PathElement pathElement) throws OperationFailedException {
Resource serverResource = context.readResource(EMPTY_ADDRESS);
// if the path resource does not exist, resolve its attributes against an empty ModelNode to get its default values
final ModelNode model = serverResource.hasChild(pathElement) ? serverResource.getChild(pathElement).getModel() : new ModelNode();
final String path = PathDefinition.PATHS.get(pathElement.getValue()).resolveModelAttribute(context, model).asString();
final String relativeToPath = PathDefinition.RELATIVE_TO.resolveModelAttribute(context, model).asString();
final String relativeTo = AbsolutePathService.isAbsoluteUnixOrWindowsPath(path) ? null : relativeToPath;
return pathManager.resolveRelativePathEntry(path, relativeTo);
}
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 address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR));
PathAddress active = MessagingServices.getActiveMQServerPathAddress(address);
Resource activeMQServerResource = context.readResourceFromRoot(active);
Set<String> availableConnectors = new HashSet<String>();
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.HTTP_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.IN_VM_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.REMOTE_CONNECTOR));
availableConnectors.addAll(activeMQServerResource.getChildrenNames(CommonAttributes.CONNECTOR));
return availableConnectors;
}
Aggregations