Java Code Examples for org.jboss.as.controller.PathAddress#EMPTY_ADDRESS
The following examples show how to use
org.jboss.as.controller.PathAddress#EMPTY_ADDRESS .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformersImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public Resource transformRootResource(TransformationInputs transformationInputs, Resource resource, ResourceIgnoredTransformationRegistry ignoredTransformationRegistry) throws OperationFailedException { // Transform the path address final PathAddress original = PathAddress.EMPTY_ADDRESS; final PathAddress transformed = transformAddress(original, target); final ResourceTransformationContext context = ResourceTransformationContextImpl.create(transformationInputs, target, transformed, original, ignoredTransformationRegistry); final ResourceTransformer transformer = target.resolveTransformer(context, original); if(transformer == null) { ControllerLogger.ROOT_LOGGER.tracef("resource %s does not need transformation", resource); return resource; } transformer.transformResource(context, transformed, resource); context.getLogger().flushLogQueue(); return context.getTransformedRoot(); }
Example 2
Source File: SocketBindingResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
static void validateInterfaceReference(final OperationContext context, final ModelNode binding) throws OperationFailedException { ModelNode interfaceNode = binding.get(INTERFACE.getName()); if (interfaceNode.getType() == ModelType.STRING) { // ignore UNDEFINED and EXPRESSION String interfaceName = interfaceNode.asString(); PathAddress operationAddress = context.getCurrentAddress(); //This can be used on both the host and the server, the socket binding group will be a //sibling to the interface in the model PathAddress interfaceAddress = PathAddress.EMPTY_ADDRESS; for (PathElement element : operationAddress) { if (element.getKey().equals(ModelDescriptionConstants.SOCKET_BINDING_GROUP)) { break; } interfaceAddress = interfaceAddress.append(element); } interfaceAddress = interfaceAddress.append(ModelDescriptionConstants.INTERFACE, interfaceName); try { context.readResourceFromRoot(interfaceAddress, false); } catch (RuntimeException e) { throw ControllerLogger.ROOT_LOGGER.nonexistentInterface(interfaceName, INTERFACE.getName()); } } }
Example 3
Source File: CoreModelTestDelegate.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
private void harmonizeModel(ModelVersion modelVersion, ModelNode legacyModel, ModelNode transformed, PathAddress address, ModelHarmonizer harmonizer) { if (address.size() > 0) { PathElement pathElement = address.getElement(0); if (legacyModel.hasDefined(pathElement.getKey()) && transformed.hasDefined(pathElement.getKey())) { ModelNode legacyType = legacyModel.get(pathElement.getKey()); ModelNode transformedType = transformed.get(pathElement.getKey()); PathAddress childAddress = address.size() > 1 ? address.subAddress(1) : PathAddress.EMPTY_ADDRESS; if (pathElement.isWildcard()) { for (String key : legacyType.keys()) { if (transformedType.has(key)) { harmonizeModel(modelVersion, legacyType.get(key), transformedType.get(key), childAddress, harmonizer); } } } else { harmonizeModel(modelVersion, legacyType.get(pathElement.getValue()), transformedType.get(pathElement.getValue()), address, harmonizer); } } } else { harmonizer.harmonizeModel(modelVersion, legacyModel, transformed); } }
Example 4
Source File: TransformerRegistry.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
public static Map<PathAddress, ModelVersion> resolveVersions(final ModelNode subsystems) { final PathAddress base = PathAddress.EMPTY_ADDRESS; final Map<PathAddress, ModelVersion> versions = new HashMap<PathAddress, ModelVersion>(); for(final Property property : subsystems.asPropertyList()) { final String name = property.getName(); final PathAddress address = base.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, name)); versions.put(address, ModelVersion.fromString(property.getValue().asString())); } return versions; }
Example 5
Source File: AbstractResourceRegistration.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void registerAlias(PathElement address, AliasEntry alias) { RootInvocation rootInvocation = parent == null ? null : getRootInvocation(); AbstractResourceRegistration root = rootInvocation == null ? this : rootInvocation.root; PathAddress myaddr = rootInvocation == null ? PathAddress.EMPTY_ADDRESS : rootInvocation.pathAddress; PathAddress targetAddress = alias.getTarget().getPathAddress(); alias.setAddresses(targetAddress, myaddr.append(address)); AbstractResourceRegistration target = (AbstractResourceRegistration)root.getSubModel(alias.getTargetAddress()); if (target == null) { throw ControllerLogger.ROOT_LOGGER.aliasTargetResourceRegistrationNotFound(alias.getTargetAddress()); } registerAlias(address, alias, target); }
Example 6
Source File: ModelTestUtils.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private static String getComparePathAsString(Stack<PathElement> stack) { PathAddress pa = PathAddress.EMPTY_ADDRESS; for (PathElement element : stack) { pa = pa.append(element); } return pa.toModelNode().asString(); }
Example 7
Source File: ResourceTransformationContextImpl.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
static ResourceTransformationContext create(TransformationTarget target, Resource model, ImmutableManagementResourceRegistration registration, RunningMode runningMode, ProcessType type, TransformerOperationAttachment attachment, final Transformers.ResourceIgnoredTransformationRegistry ignoredTransformationRegistry) { final Resource root = Resource.Factory.create(); final OriginalModel originalModel = new OriginalModel(model, runningMode, type, target, registration); return new ResourceTransformationContextImpl(root, PathAddress.EMPTY_ADDRESS, originalModel, attachment, ignoredTransformationRegistry); }
Example 8
Source File: CoreResourceManagementTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
private ModelNode getPropertyAddress(ModelNode basePropAddress, String propName) { PathAddress addr = PathAddress.pathAddress(basePropAddress); PathAddress copy = PathAddress.EMPTY_ADDRESS; for (PathElement element : addr) { if (!element.getKey().equals(SYSTEM_PROPERTY)) { copy = copy.append(element); } else { copy = copy.append(PathElement.pathElement(SYSTEM_PROPERTY, propName)); } } return copy.toModelNode(); }
Example 9
Source File: AbstractResourceRegistration.java From wildfly-core with GNU Lesser General Public License v2.1 | 5 votes |
/** Constructor for a root MRR */ AbstractResourceRegistration(final ProcessType processType) { checkPermission(); this.valueString = null; this.parent = null; this.pathAddress = PathAddress.EMPTY_ADDRESS; this.processType = Assert.checkNotNullParam("processType", processType); }
Example 10
Source File: StandaloneVaultTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public StandaloneVaultTestCase() { super(PathAddress.EMPTY_ADDRESS); }
Example 11
Source File: ValidateAddressOperationHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { ModelNode addr = VALUE_PARAM.validateOperation(operation); final PathAddress pathAddr = PathAddress.pathAddress(addr); Resource model = context.readResource(PathAddress.EMPTY_ADDRESS); final Iterator<PathElement> iterator = pathAddr.iterator(); PathAddress current = PathAddress.EMPTY_ADDRESS; out: while(iterator.hasNext()) { final PathElement next = iterator.next(); current = current.append(next); // Check if the registration is a proxy and dispatch directly final ImmutableManagementResourceRegistration registration = context.getResourceRegistration().getSubModel(current); if(registration != null && registration.isRemote()) { // If the target is a registered proxy return immediately if(! iterator.hasNext()) { break out; } // Create the proxy op final PathAddress newAddress = pathAddr.subAddress(current.size()); final ModelNode newOperation = operation.clone(); newOperation.get(OP_ADDR).set(current.toModelNode()); newOperation.get(VALUE).set(newAddress.toModelNode()); // On the DC the host=master is not a proxy but the validate-address is registered at the root // Otherwise delegate to the proxy handler final OperationStepHandler proxyHandler = registration.getOperationHandler(PathAddress.EMPTY_ADDRESS, OPERATION_NAME); if(proxyHandler != null) { context.addStep(newOperation, proxyHandler, OperationContext.Stage.MODEL, true); return; } } else if (model.hasChild(next)) { model = model.getChild(next); } else { // Invalid context.getResult().get(VALID).set(false); context.getResult().get(PROBLEM).set(ControllerLogger.ROOT_LOGGER.childResourceNotFound(next)); return; } } if (authorize(context, current, operation).getDecision() == Decision.DENY) { context.getResult().get(VALID).set(false); context.getResult().get(PROBLEM).set(ControllerLogger.ROOT_LOGGER.managementResourceNotFoundMessage(current)); } else { context.getResult().get(VALID).set(true); } }
Example 12
Source File: SocketBindingGroupIncludesHandlerTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
public Resource removeResource(PathAddress address) throws UnsupportedOperationException { PathElement element = operationAddress.getLastElement(); PathAddress parentAddress = operationAddress.size() > 1 ? operationAddress.subAddress(0, operationAddress.size() - 1) : PathAddress.EMPTY_ADDRESS; Resource parent = root.navigate(parentAddress); return parent.removeChild(element); }
Example 13
Source File: XmlMarshallingHandler.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
protected PathAddress getBaseAddress() { return PathAddress.EMPTY_ADDRESS; }
Example 14
Source File: ReloadWithConfigTestCase.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
private PathAddress getRootAddress(String host) { return host == null ? PathAddress.EMPTY_ADDRESS : PathAddress.pathAddress(HOST, host); }
Example 15
Source File: HostControllerExecutionSupport.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
/** * Create a HostControllerExecutionSupport for a given operation. * * * @param context * @param operation the operation * @param hostName the name of the host executing the operation * @param domainModelProvider source for the domain model * @param ignoredDomainResourceRegistry registry of resource addresses that should be ignored * @throws OperationFailedException * * @return the HostControllerExecutionSupport */ public static HostControllerExecutionSupport create(OperationContext context, final ModelNode operation, final String hostName, final DomainModelProvider domainModelProvider, final IgnoredDomainResourceRegistry ignoredDomainResourceRegistry, final boolean isRemoteDomainControllerIgnoreUnaffectedConfiguration, final ExtensionRegistry extensionRegistry) throws OperationFailedException { String targetHost = null; PathElement runningServerTarget = null; ModelNode runningServerOp = null; final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); if (address.size() > 0) { PathElement first = address.getElement(0); if (HOST.equals(first.getKey()) && !first.isMultiTarget()) { targetHost = first.getValue(); if (address.size() > 1 && RUNNING_SERVER.equals(address.getElement(1).getKey())) { runningServerTarget = address.getElement(1); ModelNode relativeAddress = new ModelNode().setEmptyList(); for (int i = 2; i < address.size(); i++) { PathElement element = address.getElement(i); relativeAddress.add(element.getKey(), element.getValue()); } runningServerOp = operation.clone(); runningServerOp.get(OP_ADDR).set(relativeAddress); } } } HostControllerExecutionSupport result; if (targetHost != null && !hostName.equals(targetHost)) { // HostControllerExecutionSupport representing another host result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry); } else if (runningServerTarget != null) { // HostControllerExecutionSupport representing a server op final Resource domainModel = domainModelProvider.getDomainModel(); final Resource hostModel = domainModel.getChild(PathElement.pathElement(HOST, targetHost)); if (runningServerTarget.isMultiTarget()) { return new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, PathAddress.EMPTY_ADDRESS); } else { final String serverName = runningServerTarget.getValue(); // TODO prevent NPE final String serverGroup = hostModel.getChild(PathElement.pathElement(SERVER_CONFIG, serverName)).getModel().require(GROUP).asString(); final ServerIdentity serverIdentity = new ServerIdentity(targetHost, serverGroup, serverName); result = new DirectServerOpExecutionSupport(ignoredDomainResourceRegistry, serverIdentity, runningServerOp); } } else if (COMPOSITE.equals(operation.require(OP).asString())) { // Recurse into the steps to see what's required if (operation.hasDefined(STEPS)) { List<HostControllerExecutionSupport> parsedSteps = new ArrayList<HostControllerExecutionSupport>(); for (ModelNode step : operation.get(STEPS).asList()) { // Propagate the caller-type=user header if (operation.hasDefined(OPERATION_HEADERS, CALLER_TYPE) && operation.get(OPERATION_HEADERS, CALLER_TYPE).asString().equals(USER)) { step = step.clone(); step.get(OPERATION_HEADERS, CALLER_TYPE).set(USER); } parsedSteps.add(create(context, step, hostName, domainModelProvider, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, extensionRegistry)); } result = new MultiStepOpExecutionSupport(ignoredDomainResourceRegistry, parsedSteps); } else { // Will fail later result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address); } } else if (targetHost == null && isResourceExcluded(context, ignoredDomainResourceRegistry, isRemoteDomainControllerIgnoreUnaffectedConfiguration, domainModelProvider, hostName, address, extensionRegistry, operation)) { result = new IgnoredOpExecutionSupport(ignoredDomainResourceRegistry); } else { result = new DomainOpExecutionSupport(ignoredDomainResourceRegistry, operation, address); } return result; }
Example 16
Source File: WildflyCompatibilityUtils.java From hawkular-agent with Apache License 2.0 | 4 votes |
private static PathAddress _parseCLIStyleAddress(String address) throws IllegalArgumentException { PathAddress parsedAddress = PathAddress.EMPTY_ADDRESS; if (address == null || address.trim().isEmpty()) { return parsedAddress; } String trimmedAddress = address.trim(); if (trimmedAddress.charAt(0) != '/' || !Character.isAlphabetic(trimmedAddress.charAt(1))) { // https://github.com/wildfly/wildfly-core/blob/588145a00ca5ed3beb0027f8f44be87db6689db3/controller/src/main/java/org/jboss/as/controller/logging/ControllerLogger.java#L3296-L3297 throw new IllegalArgumentException( "Illegal path address '" + address + "' , it is not in a correct CLI format"); } char[] characters = address.toCharArray(); boolean escaped = false; StringBuilder keyBuffer = new StringBuilder(); StringBuilder valueBuffer = new StringBuilder(); StringBuilder currentBuffer = keyBuffer; for (int i = 1; i < characters.length; i++) { switch (characters[i]) { case '/': if (escaped) { escaped = false; currentBuffer.append(characters[i]); } else { parsedAddress = addpathAddressElement(parsedAddress, address, keyBuffer, valueBuffer); keyBuffer = new StringBuilder(); valueBuffer = new StringBuilder(); currentBuffer = keyBuffer; } break; case '\\': if (escaped) { escaped = false; currentBuffer.append(characters[i]); } else { escaped = true; } break; case '=': if (escaped) { escaped = false; currentBuffer.append(characters[i]); } else { currentBuffer = valueBuffer; } break; default: currentBuffer.append(characters[i]); break; } } parsedAddress = addpathAddressElement(parsedAddress, address, keyBuffer, valueBuffer); return parsedAddress; }
Example 17
Source File: AbstractSystemPropertyTransformersTest.java From wildfly-core with GNU Lesser General Public License v2.1 | 4 votes |
@Test public void testSystemPropertyTransformer() throws Exception { KernelServicesBuilder builder = createKernelServicesBuilder(TestModelType.DOMAIN) .setXmlResource(serverGroup ? "domain-servergroup-systemproperties.xml" : "domain-systemproperties.xml"); if (serverGroup) { builder.setModelInitializer(StandardServerGroupInitializers.XML_MODEL_INITIALIZER, StandardServerGroupInitializers.XML_MODEL_WRITE_SANITIZER); } LegacyKernelServicesInitializer legacyInitializer = builder.createLegacyKernelServicesBuilder(modelVersion, testControllerVersion); if (serverGroup) { StandardServerGroupInitializers.addServerGroupInitializers(legacyInitializer); } KernelServices mainServices = builder.build(); Assert.assertTrue(mainServices.isSuccessfulBoot()); KernelServices legacyServices = mainServices.getLegacyServices(modelVersion); Assert.assertTrue(legacyServices.isSuccessfulBoot()); ModelFixer fixer = new StandardServerGroupInitializers.Fixer(modelVersion); ModelNode legacyModel = checkCoreModelTransformation(mainServices, modelVersion, fixer, fixer); ModelNode properties = legacyModel; if (serverGroup) { properties = legacyModel.get(SERVER_GROUP, "test"); } properties = properties.get(SYSTEM_PROPERTY); Assert.assertEquals(expectedUndefined, properties.get("sys.prop.test.one", BOOT_TIME)); Assert.assertEquals(1, properties.get("sys.prop.test.one", VALUE).asInt()); Assert.assertEquals(ModelNode.TRUE, properties.get("sys.prop.test.two", BOOT_TIME)); Assert.assertEquals(2, properties.get("sys.prop.test.two", VALUE).asInt()); Assert.assertEquals(ModelNode.FALSE, properties.get("sys.prop.test.three", BOOT_TIME)); Assert.assertEquals(3, properties.get("sys.prop.test.three", VALUE).asInt()); Assert.assertEquals(expectedUndefined, properties.get("sys.prop.test.four", BOOT_TIME)); Assert.assertFalse(properties.get("sys.prop.test.four", VALUE).isDefined()); //Test the write attribute handler, the 'add' got tested at boot time PathAddress baseAddress = serverGroup ? PathAddress.pathAddress(PathElement.pathElement(SERVER_GROUP, "test")) : PathAddress.EMPTY_ADDRESS; PathAddress propAddress = baseAddress.append(SYSTEM_PROPERTY, "sys.prop.test.two"); //value should just work ModelNode op = Util.getWriteAttributeOperation(propAddress, VALUE, new ModelNode("test12")); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertEquals("test12", ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(VALUE).asString()); //boot time should be 'true' if undefined op = Util.getWriteAttributeOperation(propAddress, BOOT_TIME, new ModelNode()); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertTrue(ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(BOOT_TIME).asBoolean()); op = Util.getUndefineAttributeOperation(propAddress, BOOT_TIME); ModelTestUtils.checkOutcome(mainServices.executeOperation(modelVersion, mainServices.transformOperation(modelVersion, op))); Assert.assertTrue(ModelTestUtils.getSubModel(legacyServices.readWholeModel(), propAddress).get(BOOT_TIME).asBoolean()); }
Example 18
Source File: ObjectNameAddressUtil.java From wildfly-core with GNU Lesser General Public License v2.1 | 3 votes |
/** * Straight conversion from an ObjectName to a PathAddress. * * There may not necessarily be a Resource at this path address (if that correspond to a pattern) but it must * match a model in the registry. * * @param domain the name of the caller's JMX domain * @param registry the root resource for the management model * @param name the ObjectName to convert * * @return the PathAddress, or {@code null} if no address matches the object name */ static PathAddress toPathAddress(String domain, ImmutableManagementResourceRegistration registry, ObjectName name) { if (!name.getDomain().equals(domain)) { return PathAddress.EMPTY_ADDRESS; } if (name.equals(ModelControllerMBeanHelper.createRootObjectName(domain))) { return PathAddress.EMPTY_ADDRESS; } final Hashtable<String, String> properties = name.getKeyPropertyList(); return searchPathAddress(PathAddress.EMPTY_ADDRESS, registry, properties); }
Example 19
Source File: TransformerRegistry.java From wildfly-core with GNU Lesser General Public License v2.1 | 2 votes |
/** * Get the sub registry for the domain. * * @param range the version range * @return the sub registry */ public TransformersSubRegistration getDomainRegistration(final ModelVersionRange range) { final PathAddress address = PathAddress.EMPTY_ADDRESS; return new TransformersSubRegistrationImpl(range, domain, address); }
Example 20
Source File: AbstractBaseSecurityRealmsServerSetupTask.java From wildfly-core with GNU Lesser General Public License v2.1 | 2 votes |
/** * Gets the base address to be used for operations in setup/teardown. * @return */ protected PathAddress getBaseAddress() { return PathAddress.EMPTY_ADDRESS; }