Search in sources :

Example 51 with PathElement

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

the class JChannelFactoryBuilder method configure.

@Override
public Builder<ChannelFactory> configure(OperationContext context, ModelNode model) throws OperationFailedException {
    PathAddress address = context.getCurrentAddress();
    Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS);
    Optional<PathElement> transport = resource.getChildren(TransportResourceDefinition.WILDCARD_PATH.getKey()).stream().map(Resource.ResourceEntry::getPathElement).findFirst();
    if (!transport.isPresent()) {
        throw JGroupsLogger.ROOT_LOGGER.transportNotDefined(this.getName());
    }
    this.transport = new InjectedValueDependency<>(new SingletonProtocolServiceNameProvider(address, transport.get()), TransportConfiguration.class);
    this.protocols = resource.getChildren(ProtocolResourceDefinition.WILDCARD_PATH.getKey()).stream().map(entry -> new InjectedValueDependency<>(new ProtocolServiceNameProvider(address, entry.getPathElement()), ProtocolConfiguration.class)).collect(Collectors.toList());
    this.relay = resource.hasChild(RelayResourceDefinition.PATH) ? new InjectedValueDependency<>(new SingletonProtocolServiceNameProvider(address, RelayResourceDefinition.PATH), RelayConfiguration.class) : null;
    return this;
}
Also used : ProtocolConfiguration(org.wildfly.clustering.jgroups.spi.ProtocolConfiguration) PathElement(org.jboss.as.controller.PathElement) InjectedValueDependency(org.wildfly.clustering.service.InjectedValueDependency) PathAddress(org.jboss.as.controller.PathAddress) Resource(org.jboss.as.controller.registry.Resource) TransportConfiguration(org.wildfly.clustering.jgroups.spi.TransportConfiguration)

Example 52 with PathElement

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

the class ManagedExecutorServiceResourceDefinition method registerTransformers_4_0.

void registerTransformers_4_0(final ResourceTransformationDescriptionBuilder builder) {
    final PathElement pathElement = getPathElement();
    final ResourceTransformationDescriptionBuilder resourceBuilder = builder.addChildResource(pathElement);
    resourceBuilder.getAttributeBuilder().addRejectCheck(RejectAttributeChecker.UNDEFINED, CORE_THREADS_AD).end();
}
Also used : PathElement(org.jboss.as.controller.PathElement) ResourceTransformationDescriptionBuilder(org.jboss.as.controller.transform.description.ResourceTransformationDescriptionBuilder)

Example 53 with PathElement

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

the class JMSDestinationDefinitionInjectionSource method startTopic.

private void startTopic(String topicName, ServiceTarget serviceTarget, ServiceName serverServiceName, ServiceBuilder<?> serviceBuilder, DeploymentUnit deploymentUnit, Injector<ManagedReferenceFactory> injector) {
    ModelNode destination = new ModelNode();
    destination.get(NAME).set(topicName);
    destination.get(ENTRIES).add(jndiName);
    Service<Topic> topicService = JMSTopicService.installService(topicName, serverServiceName, serviceTarget, new String[0]);
    inject(serviceBuilder, injector, topicService);
    //create the management registration
    String serverName = getActiveMQServerName(properties);
    final PathElement serverElement = PathElement.pathElement(SERVER, serverName);
    final PathElement dest = PathElement.pathElement(JMS_TOPIC, topicName);
    final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT);
    deploymentResourceSupport.getDeploymentSubModel(MessagingExtension.SUBSYSTEM_NAME, serverElement);
    PathAddress registration = PathAddress.pathAddress(serverElement, dest);
    MessagingXmlInstallDeploymentUnitProcessor.createDeploymentSubModel(registration, deploymentUnit);
    JMSTopicConfigurationRuntimeHandler.INSTANCE.registerResource(serverName, topicName, destination);
}
Also used : DeploymentResourceSupport(org.jboss.as.server.deployment.DeploymentResourceSupport) PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Topic(javax.jms.Topic)

Example 54 with PathElement

use of org.jboss.as.controller.PathElement 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 55 with PathElement

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

the class JPAService method createManagementStatisticsResource.

/**
     * Create single instance of management statistics resource per managementAdaptor version.
     *
     * ManagementAccess
     *
     * The persistence provider and jipijapa adapters will be in the same classloader,
     * either a static module or included directly in the application.  Those are the two supported use
     * cases for management of deployment persistence units also.
     *
     * From a management point of view, the requirements are:
     *   1.  show management statistics for static persistence provider modules and applications that have
     *       their own persistence provider module.
     *
     *   2.  persistence provider adapters will provide a unique key that identifies the management version of supported
     *       management statistics/operations.  For example, Hibernate 3.x might be 1.0, Hibernate 4.1/4.2 might
     *       be version 2.0 and Hibernate 4.3 could be 2.0 also as long as its compatible (same stats) with 4.1/4.2.
     *       Eventually, a Hibernate (later version) change in statistics is likely to happen, the management version
     *       will be incremented.
     *
     *
     * @param managementAdaptor the management adaptor that will provide statistics
     * @param scopedPersistenceUnitName name of the persistence unit
     * @param deploymentUnit deployment unit for the deployment requesting a resource
     * @return the management resource
     */
public static Resource createManagementStatisticsResource(final ManagementAdaptor managementAdaptor, final String scopedPersistenceUnitName, final DeploymentUnit deploymentUnit) {
    synchronized (existingResourceDescriptionResolver) {
        final EntityManagerFactoryLookup entityManagerFactoryLookup = new EntityManagerFactoryLookup();
        final Statistics statistics = managementAdaptor.getStatistics();
        if (false == existingResourceDescriptionResolver.contains(managementAdaptor.getVersion())) {
            // setup statistics (this used to be part of JPA subsystem startup)
            ResourceDescriptionResolver resourceDescriptionResolver = new StandardResourceDescriptionResolver(statistics.getResourceBundleKeyPrefix(), statistics.getResourceBundleName(), statistics.getClass().getClassLoader()) {

                private ResourceDescriptionResolver fallback = JPAExtension.getResourceDescriptionResolver();

                //add a fallback in case provider doesn't have all properties properly defined
                @Override
                public String getResourceAttributeDescription(String attributeName, Locale locale, ResourceBundle bundle) {
                    if (bundle.containsKey(getBundleKey(attributeName))) {
                        return super.getResourceAttributeDescription(attributeName, locale, bundle);
                    } else {
                        return fallback.getResourceAttributeDescription(attributeName, locale, fallback.getResourceBundle(locale));
                    }
                }
            };
            PathElement subsystemPE = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, JPAExtension.SUBSYSTEM_NAME);
            ManagementResourceRegistration deploymentResourceRegistration = deploymentUnit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
            ManagementResourceRegistration deploymentSubsystemRegistration = deploymentResourceRegistration.getSubModel(PathAddress.pathAddress(subsystemPE));
            ManagementResourceRegistration subdeploymentSubsystemRegistration = deploymentResourceRegistration.getSubModel(PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBDEPLOYMENT), subsystemPE));
            ManagementResourceRegistration providerResource = deploymentSubsystemRegistration.registerSubModel(new ManagementResourceDefinition(PathElement.pathElement(managementAdaptor.getIdentificationLabel()), resourceDescriptionResolver, statistics, entityManagerFactoryLookup));
            providerResource.registerReadOnlyAttribute(PersistenceUnitServiceHandler.SCOPED_UNIT_NAME, null);
            providerResource = subdeploymentSubsystemRegistration.registerSubModel(new ManagementResourceDefinition(PathElement.pathElement(managementAdaptor.getIdentificationLabel()), resourceDescriptionResolver, statistics, entityManagerFactoryLookup));
            providerResource.registerReadOnlyAttribute(PersistenceUnitServiceHandler.SCOPED_UNIT_NAME, null);
            existingResourceDescriptionResolver.add(managementAdaptor.getVersion());
        }
        // create (per deployment) dynamic Resource implementation that can reflect the deployment specific names (e.g. jpa entity classname/Hibernate region name)
        return new DynamicManagementStatisticsResource(statistics, scopedPersistenceUnitName, managementAdaptor.getIdentificationLabel(), entityManagerFactoryLookup);
    }
}
Also used : Locale(java.util.Locale) ManagementResourceDefinition(org.jboss.as.jpa.management.ManagementResourceDefinition) PathElement(org.jboss.as.controller.PathElement) DynamicManagementStatisticsResource(org.jboss.as.jpa.management.DynamicManagementStatisticsResource) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ResourceDescriptionResolver(org.jboss.as.controller.descriptions.ResourceDescriptionResolver) EntityManagerFactoryLookup(org.jboss.as.jpa.management.EntityManagerFactoryLookup) StandardResourceDescriptionResolver(org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver) ResourceBundle(java.util.ResourceBundle) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) Statistics(org.jipijapa.management.spi.Statistics)

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