Search in sources :

Example 66 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 67 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)

Example 68 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class DsXmlDeploymentInstallProcessor method getRegistration.

private ManagementResourceRegistration getRegistration(final boolean xa, final DeploymentUnit unit) {
    final Resource root = unit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
    synchronized (root) {
        ManagementResourceRegistration registration = unit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
        final PathAddress address = xa ? XA_DATASOURCE_ADDRESS : DATASOURCE_ADDRESS;
        ManagementResourceRegistration subModel = registration.getSubModel(address);
        if (subModel == null) {
            throw new IllegalStateException(address.toString());
        }
        return subModel;
    }
}
Also used : PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration)

Example 69 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class DsXmlDeploymentInstallProcessor 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;
}
Also used : PathElement(org.jboss.as.controller.PathElement) Resource(org.jboss.as.controller.registry.Resource)

Example 70 with Resource

use of org.jboss.as.controller.registry.Resource in project wildfly by wildfly.

the class PersistenceUnitServiceHandler method getOrCreateResource.

/**
     * TODO this is a temporary hack into internals until DeploymentUnit exposes a proper Resource-based API
     */
private static Resource getOrCreateResource(final Resource parent, final PathElement element) {
    synchronized (parent) {
        if (parent.hasChild(element)) {
            return parent.requireChild(element);
        } else {
            final Resource resource = Resource.Factory.create();
            parent.registerChild(element, resource);
            return resource;
        }
    }
}
Also used : Resource(org.jboss.as.controller.registry.Resource)

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