Search in sources :

Example 46 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class TimerServiceResource method timerCreated.

public void timerCreated(String id) {
    PathElement address = PathElement.pathElement(EJB3SubsystemModel.TIMER, id);
    this.delegate.registerChild(address, Resource.Factory.create());
}
Also used : PathElement(org.jboss.as.controller.PathElement)

Example 47 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class AbstractEJBComponentRuntimeHandler method getComponentConfiguration.

private ServiceName getComponentConfiguration(final OperationContext context, final PathAddress operationAddress) throws OperationFailedException {
    final List<PathElement> relativeAddress = new ArrayList<PathElement>();
    final String typeKey = this.componentType.getResourceType();
    boolean skip = true;
    for (int i = operationAddress.size() - 1; i >= 0; i--) {
        PathElement pe = operationAddress.getElement(i);
        if (skip && !pe.getKey().equals(typeKey)) {
            continue;
        } else {
            skip = false;
        }
        if (ModelDescriptionConstants.DEPLOYMENT.equals(pe.getKey())) {
            final String runtimName = resolveRuntimeName(context, pe);
            PathElement realPe = PathElement.pathElement(pe.getKey(), runtimName);
            relativeAddress.add(0, realPe);
            break;
        } else {
            relativeAddress.add(0, pe);
        }
    }
    final PathAddress pa = PathAddress.pathAddress(relativeAddress);
    final ServiceName config = componentConfigs.get(pa);
    if (config == null) {
        String exceptionMessage = EjbLogger.ROOT_LOGGER.noComponentRegisteredForAddress(operationAddress);
        throw new OperationFailedException(exceptionMessage);
    }
    return config;
}
Also used : PathElement(org.jboss.as.controller.PathElement) ServiceName(org.jboss.msc.service.ServiceName) PathAddress(org.jboss.as.controller.PathAddress) ArrayList(java.util.ArrayList) OperationFailedException(org.jboss.as.controller.OperationFailedException)

Example 48 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class TimerServiceResourceDefinition method registerDataStoreTransformers.

private static void registerDataStoreTransformers(ResourceTransformationDescriptionBuilder timerService) {
    DataStoreTransformer dataStoreTransformer = new DataStoreTransformer();
    timerService.getAttributeBuilder().setDiscard(DiscardAttributeChecker.ALWAYS, //this is ok, as default-data-store only has any sense with new model, but it is always set!
    EJB3SubsystemModel.DEFAULT_DATA_STORE).end();
    timerService.discardOperations(ModelDescriptionConstants.ADD);
    timerService.setCustomResourceTransformer(dataStoreTransformer);
    timerService.rejectChildResource(EJB3SubsystemModel.DATABASE_DATA_STORE_PATH);
    ResourceTransformationDescriptionBuilder fileDataStore = timerService.addChildRedirection(EJB3SubsystemModel.FILE_DATA_STORE_PATH, new PathAddressTransformer() {

        @Override
        public PathAddress transform(PathElement current, Builder builder) {
            return builder.getCurrent();
        }
    });
    fileDataStore.addOperationTransformationOverride(ModelDescriptionConstants.ADD).inheritResourceAttributeDefinitions().setCustomOperationTransformer(dataStoreTransformer).end();
}
Also used : PathElement(org.jboss.as.controller.PathElement) SimpleAttributeDefinitionBuilder(org.jboss.as.controller.SimpleAttributeDefinitionBuilder) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) PathAddress(org.jboss.as.controller.PathAddress) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder) PathAddressTransformer(org.jboss.as.controller.transform.PathAddressTransformer)

Example 49 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class ModClusterSubsystemXMLReader_1_0 method parseCustomLoadMetric.

void parseCustomLoadMetric(XMLExtendedStreamReader reader, List<ModelNode> list, PathAddress address) throws XMLStreamException {
    final ModelNode customMetric = new ModelNode();
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case CAPACITY:
                LoadMetricDefinition.CAPACITY.parseAndSetParameter(value, customMetric, reader);
                break;
            case WEIGHT:
                LoadMetricDefinition.WEIGHT.parseAndSetParameter(value, customMetric, reader);
                break;
            case CLASS:
                CustomLoadMetricDefinition.CLASS.parseAndSetParameter(value, customMetric, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    PathElement pe = PathElement.pathElement(CustomLoadMetricDefinition.PATH.getKey(), customMetric.get(CommonAttributes.CLASS).asString());
    customMetric.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    customMetric.get(ModelDescriptionConstants.OP_ADDR).set(address.append(pe).toModelNode());
    readProperties(reader, customMetric);
    list.add(customMetric);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Example 50 with PathElement

use of org.jboss.as.controller.PathElement in project wildfly by wildfly.

the class ModClusterSubsystemXMLReader_1_0 method parseLoadMetric.

void parseLoadMetric(XMLExtendedStreamReader reader, List<ModelNode> list, PathAddress address) throws XMLStreamException {
    final ModelNode metric = new ModelNode();
    final int count = reader.getAttributeCount();
    for (int i = 0; i < count; i++) {
        requireNoNamespaceAttribute(reader, i);
        final String value = reader.getAttributeValue(i);
        final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
        switch(attribute) {
            case TYPE:
                LoadMetricDefinition.TYPE.parseAndSetParameter(value, metric, reader);
                break;
            case CAPACITY:
                LoadMetricDefinition.CAPACITY.parseAndSetParameter(value, metric, reader);
                break;
            case WEIGHT:
                LoadMetricDefinition.WEIGHT.parseAndSetParameter(value, metric, reader);
                break;
            default:
                throw unexpectedAttribute(reader, i);
        }
    }
    PathElement pe = PathElement.pathElement(LoadMetricDefinition.PATH.getKey(), metric.get(CommonAttributes.TYPE).asString());
    metric.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.ADD);
    metric.get(ModelDescriptionConstants.OP_ADDR).set(address.append(pe).toModelNode());
    readProperties(reader, metric);
    list.add(metric);
}
Also used : PathElement(org.jboss.as.controller.PathElement) ParseUtils.unexpectedAttribute(org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute) ParseUtils.requireNoNamespaceAttribute(org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

PathElement (org.jboss.as.controller.PathElement)70 PathAddress (org.jboss.as.controller.PathAddress)35 ModelNode (org.jboss.dmr.ModelNode)32 Resource (org.jboss.as.controller.registry.Resource)24 OperationFailedException (org.jboss.as.controller.OperationFailedException)10 ServiceName (org.jboss.msc.service.ServiceName)10 Map (java.util.Map)9 ServiceTarget (org.jboss.msc.service.ServiceTarget)9 ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)7 ParseUtils.requireNoNamespaceAttribute (org.jboss.as.controller.parsing.ParseUtils.requireNoNamespaceAttribute)5 ParseUtils.unexpectedAttribute (org.jboss.as.controller.parsing.ParseUtils.unexpectedAttribute)5 AbstractSubsystemBaseTest (org.jboss.as.subsystem.test.AbstractSubsystemBaseTest)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 StatisticsResourceDefinition (org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition)4 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)4 OperationContext (org.jboss.as.controller.OperationContext)4 StandardResourceDescriptionResolver (org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver)4 StatisticsPlugin (org.jboss.jca.core.spi.statistics.StatisticsPlugin)4