Search in sources :

Example 91 with Resource

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;
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 92 with Resource

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);
}
Also used : Resource(org.jboss.as.controller.registry.Resource) ModelNode(org.jboss.dmr.ModelNode)

Example 93 with Resource

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;
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) HashSet(java.util.HashSet)

Aggregations

Resource (org.jboss.as.controller.registry.Resource)93 PathAddress (org.jboss.as.controller.PathAddress)52 ModelNode (org.jboss.dmr.ModelNode)52 PathElement (org.jboss.as.controller.PathElement)25 OperationFailedException (org.jboss.as.controller.OperationFailedException)24 OperationContext (org.jboss.as.controller.OperationContext)15 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)12 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)11 Map (java.util.Map)10 ServiceName (org.jboss.msc.service.ServiceName)10 ServiceTarget (org.jboss.msc.service.ServiceTarget)10 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)9 ResourceTransformationContext (org.jboss.as.controller.transform.ResourceTransformationContext)6 ResourceTransformer (org.jboss.as.controller.transform.ResourceTransformer)6 ResourceTransformationDescriptionBuilder (org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)6 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)6 ObjectName (javax.management.ObjectName)5 Activation (org.jboss.jca.common.api.metadata.resourceadapter.Activation)5 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)5 ArrayList (java.util.ArrayList)4