Java Code Examples for org.jboss.as.controller.PathElement#pathElement()

The following examples show how to use org.jboss.as.controller.PathElement#pathElement() . 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: DeploymentResourceSupport.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Registers the provided resource as the resource for the {@link org.jboss.as.controller.PathAddress#getLastElement()
 * last element} of the address. Operations, metrics and descriptions have to be registered as part of the
 * subsystem registration {@link org.jboss.as.controller.ExtensionContext} and {@link
 * org.jboss.as.controller.SubsystemRegistration#registerDeploymentModel(org.jboss.as.controller.ResourceDefinition)}.
 *
 * <p>
 * The subsystem resource as well as each {@link org.jboss.as.controller.PathAddress#getParent()} parent element}
 * from the address will be created if it does not already exist.
 * </p>
 *
 * @param subsystemName the subsystem name the model was registered
 * @param address       the path address this sub-model should be created in
 * @param resource      the resource to be registered as sub-module
 *
 * @return the {@link org.jboss.as.controller.registry.Resource#getModel() model} from the resource parameter
 *
 * @throws java.lang.IllegalStateException if the {@link org.jboss.as.controller.PathAddress#getLastElement() last}
 *                                         resource already exists
 */
public ModelNode registerDeploymentSubResource(final String subsystemName, final PathAddress address, final Resource resource) {
    final Resource root = deploymentUnit.getAttachment(DEPLOYMENT_RESOURCE);
    synchronized (root) {
        final ImmutableManagementResourceRegistration registration = deploymentUnit.getAttachment(REGISTRATION_ATTACHMENT);
        final PathElement subsystemPath = PathElement.pathElement(SUBSYSTEM, subsystemName);
        if (address == PathAddress.EMPTY_ADDRESS) {
            return register(root, subsystemPath, resource).getModel();
        }
        Resource parent = getOrCreate(root, subsystemPath);
        int count = address.size() - 1;
        for (int index = 0; index < count; index++) {
            parent = getOrCreate(parent, address.getElement(index));
        }
        final ImmutableManagementResourceRegistration subModel = registration.getSubModel(getSubsystemAddress(subsystemName, address));
        if (subModel == null) {
            throw new IllegalStateException(address.toString());
        }
        return register(parent, address.getLastElement(), resource).getModel();
    }
}
 
Example 2
Source File: AbstractResourceRegistration.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/** {@inheritDoc} */
    @Override
    public final ManagementResourceRegistration getOverrideModel(String name) {

        Assert.checkNotNullParam("name", name);

        if (parent == null) {
            throw ControllerLogger.ROOT_LOGGER.cannotOverrideRootRegistration();
        }

        if (!PathElement.WILDCARD_VALUE.equals(valueString)) {
            throw ControllerLogger.ROOT_LOGGER.cannotOverrideNonWildCardRegistration(valueString);
        }
        PathElement pe = PathElement.pathElement(parent.getKeyName(),name);

        // TODO https://issues.jboss.org/browse/WFLY-2883
//        ManagementResourceRegistration candidate = parent.getParent().getSubModel(PathAddress.pathAddress(pe));
//        // We may have gotten back the wildcard reg; detect this by checking for allowing override
//        return candidate.isAllowsOverride() ? null : candidate;
        return parent.getParent().getSubModel(PathAddress.pathAddress(pe));
    }
 
Example 3
Source File: HandlerUtil.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static void checkNoOtherHandlerWithTheSameName(OperationContext context) throws OperationFailedException {
    final PathAddress address = context.getCurrentAddress();
    final PathAddress parentAddress = address.subAddress(0, address.size() - 1);
    final Resource resource = context.readResourceFromRoot(parentAddress);

    final PathElement element = address.getLastElement();
    final String handlerType = element.getKey();
    final String handlerName = element.getValue();

    for (String otherHandler: HANDLER_TYPES) {
        if (handlerType.equals(otherHandler)) {
            // we need to check other handler types for the same name
            continue;
        }
        final PathElement check = PathElement.pathElement(otherHandler, handlerName);
        if (resource.hasChild(check)) {
            throw DomainManagementLogger.ROOT_LOGGER.handlerAlreadyExists(check.getValue(), parentAddress.append(check));
        }
    }
}
 
Example 4
Source File: GarbageCollectorMXBeanResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
ResourceEntry getChildEntry(String name) {
    for (GarbageCollectorMXBean mbean : ManagementFactory.getGarbageCollectorMXBeans()) {
        if (name.equals(escapeMBeanName(mbean.getName()))) {
            return new LeafPlatformMBeanResource(PathElement.pathElement(ModelDescriptionConstants.NAME, name));
        }
    }
    return null;
}
 
Example 5
Source File: LocalDestinationOutboundSocketBindingResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private LocalDestinationOutboundSocketBindingResourceDefinition() {
    super(PathElement.pathElement(ModelDescriptionConstants.LOCAL_DESTINATION_OUTBOUND_SOCKET_BINDING),
            ControllerResolver.getResolver(ModelDescriptionConstants.LOCAL_DESTINATION_OUTBOUND_SOCKET_BINDING),
            LocalDestinationOutboundSocketBindingAddHandler.INSTANCE,
            new ServiceRemoveStepHandler(LocalDestinationOutboundSocketBindingAddHandler.INSTANCE,
                    OUTBOUND_SOCKET_BINDING_CAPABILITY));
}
 
Example 6
Source File: AbstractResourceRegistration.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void unregisterOverrideModel(String name) {
    Assert.checkNotNullParam("name", name);
    if (PathElement.WILDCARD_VALUE.equals(name)) {
        throw ControllerLogger.ROOT_LOGGER.wildcardRegistrationIsNotAnOverride();
    }
    if (parent == null) {
        throw ControllerLogger.ROOT_LOGGER.rootRegistrationIsNotOverridable();
    }
    PathElement pe = PathElement.pathElement(parent.getKeyName(), name);
    parent.getParent().unregisterSubModel(pe);
}
 
Example 7
Source File: SyncModelOperationHandlerWrapper.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static void processProfile(final Resource domain, String profile, Set<String> profiles) {
    if (!profiles.contains(profile)) {
        profiles.add(profile);
        final PathElement pathElement = PathElement.pathElement(PROFILE, profile);
        if (domain.hasChild(pathElement)) {
            final Resource resource = domain.getChild(pathElement);
            final ModelNode model = resource.getModel();
            if (model.hasDefined(INCLUDES)) {
                for (final ModelNode include : model.get(INCLUDES).asList()) {
                    processProfile(domain, include.asString(), profiles);
                }
            }
        }
    }
}
 
Example 8
Source File: BaseLdapUserSearchResource.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected BaseLdapUserSearchResource(final UserSearchType searchType,
        final ResourceDescriptionResolver descriptionResolver, final OperationStepHandler addHandler,
        final OperationStepHandler removeHandler) {
    super(PathElement.pathElement(ModelDescriptionConstants.USERNAME_TO_DN, searchType.getModelValue()),
            descriptionResolver, addHandler, removeHandler, OperationEntry.Flag.RESTART_NONE,
            OperationEntry.Flag.RESTART_RESOURCE_SERVICES);
}
 
Example 9
Source File: RevertReloadRequiredTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public TestResource() {
    super(PathElement.pathElement("test"),
            new NonResolvingResourceDescriptionResolver(),
            new TestResourceAddHandler(),
            new AbstractRemoveStepHandler() {
            });
}
 
Example 10
Source File: PatchIntegrationFactory.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void initializeHost(final ServiceTarget serviceTarget, final ManagementModel managementModel, String hostName) {
    final PathElement host = PathElement.pathElement(HOST, hostName);
    final ManagementResourceRegistration hostRegistration = managementModel.getRootResourceRegistration().getSubModel(PathAddress.EMPTY_ADDRESS.append(host));
    final Resource hostResource = managementModel.getRootResource().getChild(host);
    if (hostResource == null) {
        // this is generally only the case when an embedded HC has been started with an empty config, but /host=foo:add() has not yet been invoked, so we have no
        // real hostname yet.
        return;
    }
    initializeCoreServices(serviceTarget, hostRegistration, hostResource);
}
 
Example 11
Source File: SensitivityResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static ResourceEntry createSensitivityClassificationResource(AbstractSensitivity classification, String classificationType, String name,
                                                             AccessConstraintUtilizationRegistry registry) {
    return new SensitivityClassificationResource(PathElement.pathElement(ModelDescriptionConstants.CLASSIFICATION, name), classification, classificationType, registry);
}
 
Example 12
Source File: AccessConstraintAppliesToResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
private AccessConstraintAppliesToResource(AccessConstraintUtilization constraintUtilization) {
    super(PathElement.pathElement(ModelDescriptionConstants.APPLIES_TO,
            constraintUtilization.getPathAddress().toCLIStyleString()));
    this.constraintUtilization = constraintUtilization;
}
 
Example 13
Source File: SecureDeploymentDefinition.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private SecureDeploymentDefinition() {
    super(PathElement.pathElement(Constants.Model.SECURE_DEPLOYMENT),
            KeycloakSamlExtension.getResourceDescriptionResolver(Constants.Model.SECURE_DEPLOYMENT),
            SecureDeploymentAddHandler.INSTANCE,
            ReloadRequiredRemoveStepHandler.INSTANCE);
}
 
Example 14
Source File: RealmDefinition.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public RealmDefinition() {
    super(PathElement.pathElement("realm"),
            KeycloakExtension.getResourceDescriptionResolver("realm"),
            RealmAddHandler.INSTANCE,
            RealmRemoveHandler.INSTANCE);
}
 
Example 15
Source File: ApplicationClassificationTypeResourceDefinition.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static ResourceEntry createResource(Map<String, ApplicationTypeConfig> classificationsByType,
                                    String name, AccessConstraintUtilizationRegistry registry) {
    return new ApplicationTypeResource(PathElement.pathElement(ModelDescriptionConstants.TYPE, name),
            classificationsByType, registry);
}
 
Example 16
Source File: SecureDeploymentDefinition.java    From keycloak with Apache License 2.0 4 votes vote down vote up
private SecureDeploymentDefinition() {
    super(PathElement.pathElement(Constants.Model.SECURE_DEPLOYMENT),
            KeycloakSamlExtension.getResourceDescriptionResolver(Constants.Model.SECURE_DEPLOYMENT),
            SecureDeploymentAddHandler.INSTANCE,
            ReloadRequiredRemoveStepHandler.INSTANCE);
}
 
Example 17
Source File: ChainedOperationBuilderTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Test
public void testOperationsTransformationHierarchy() throws Exception {
    final PathElement common = PathElement.pathElement("child", "common");
    final PathElement one = PathElement.pathElement("child", "one");
    final PathElement two = PathElement.pathElement("child", "two");
    final PathElement three = PathElement.pathElement("child", "three");
    ChainedTransformationDescriptionBuilder chainedBuilder = TransformationDescriptionBuilder.Factory.createChainedInstance(PATH, V4_0_0);
    ResourceTransformationDescriptionBuilder builder = chainedBuilder.createBuilder(V4_0_0, V3_0_0);
    builder.addChildResource(common).getAttributeBuilder()
        .setValueConverter(new SimpleAttributeConverter("old", "one"), "attr")
        .end();
    builder.addChildResource(one).addOperationTransformationOverride("test")
        .setValueConverter(new NewAttributeConverter("a"), "attr-1");

    builder = chainedBuilder.createBuilder(V3_0_0, V2_0_0);
    builder.addChildResource(common).getAttributeBuilder()
        .setValueConverter(new SimpleAttributeConverter("one", "two"), "attr");
    builder.addChildResource(two).addOperationTransformationOverride("test")
        .setValueConverter(new NewAttributeConverter("b"), "attr-2");

    builder = chainedBuilder.createBuilder(V2_0_0, V1_0_0);
    builder.addChildResource(common).getAttributeBuilder()
        .setValueConverter(new SimpleAttributeConverter("two", "three"), "attr");
    builder.addChildResource(three).addOperationTransformationOverride("test")
        .setValueConverter(new NewAttributeConverter("c"), "attr-3");


    TransformationDescription.Tools.register(chainedBuilder.build(V1_0_0, V2_0_0, V3_0_0).get(V1_0_0), transformersSubRegistration);

    //Although tested elsewhere test that the root operation gets (not) transformed as expected
    final PathAddress address = PathAddress.EMPTY_ADDRESS.append(PATH);
    ModelNode original = Util.createAddOperation(address);
    original.get("attr").set("old");
    assertNotRejectedOperation(original, original);

    //Add ops on the common child should have the 'common' transformation
    original = Util.createAddOperation(address.append(common));
    original.get("attr").set("old");
    ModelNode expected = original.clone();
    expected.get("attr").set("three");
    assertNotRejectedOperation(original, expected);

    //Add ops on the one, two and three children should not be transformed
    original = Util.createAddOperation(address.append(one));
    assertNotRejectedOperation(original, original);

    original = Util.createAddOperation(address.append(two));
    assertNotRejectedOperation(original, original);

    original = Util.createAddOperation(address.append(three));
    assertNotRejectedOperation(original, original);

    //The overridden ops on the children should have basic transformation
    original = Util.createEmptyOperation("test", address.append(one));
    expected = original.clone();
    expected.get("attr-1").set("a");
    assertNotRejectedOperation(original, expected);

    original = Util.createEmptyOperation("test", address.append(two));
    expected = original.clone();
    expected.get("attr-2").set("b");
    assertNotRejectedOperation(original, expected);

    original = Util.createEmptyOperation("test", address.append(three));
    expected = original.clone();
    expected.get("attr-3").set("c");
    assertNotRejectedOperation(original, expected);
}
 
Example 18
Source File: CredentialDefinition.java    From keycloak with Apache License 2.0 4 votes vote down vote up
public CredentialDefinition() {
    super(PathElement.pathElement(TAG_NAME),
            KeycloakExtension.getResourceDescriptionResolver(TAG_NAME),
            new CredentialAddHandler(VALUE),
            CredentialRemoveHandler.INSTANCE);
}
 
Example 19
Source File: OldExtension.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected PropertyResourceDefinition() {
    super(PathElement.pathElement("property"),
            new NonResolvingResourceDescriptionResolver(),
            new ModelOnlyAddStepHandler(VALUE),
            ModelOnlyRemoveStepHandler.INSTANCE);
}
 
Example 20
Source File: DefaultAttributeTestCase.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public TestResource() {
    super(PathElement.pathElement("test"), new NonResolvingResourceDescriptionResolver(), new TestResourceAddHandler(), new AbstractRemoveStepHandler() {});
}