Search in sources :

Example 46 with ManagementResourceRegistration

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

the class PooledConnectionFactoryStatisticsService method start.

@Override
public void start(StartContext context) throws StartException {
    ROOT_LOGGER.debugf("start PooledConnectionFactoryStatisticsService");
    synchronized (POOL_STATISTICS) {
        ResourceAdapterDeployment raDeployment = injectedRADeployment.getValue();
        CommonDeployment deployment = raDeployment.getDeployment();
        StatisticsPlugin poolStats = deployment.getConnectionManagers()[0].getPool().getStatistics();
        poolStats.setEnabled(statsEnabled);
        int poolStatsSize = poolStats.getNames().size();
        if (poolStatsSize > 0) {
            if (registration != null) {
                if (poolStatsSize > 0) {
                    if (registration.getSubModel(PathAddress.pathAddress(POOL_STATISTICS)) == null) {
                        // TODO WFLY-5285 get rid of redundant .setRuntimeOnly once WFCORE-959 is integrated
                        ManagementResourceRegistration poolRegistration = registration.registerSubModel(new StatisticsResourceDefinition(POOL_STATISTICS, DataSourcesSubsystemProviders.RESOURCE_NAME, poolStats));
                        poolRegistration.setRuntimeOnly(true);
                    }
                }
            }
        }
    }
}
Also used : ResourceAdapterDeployment(org.jboss.as.connector.metadata.deployment.ResourceAdapterDeployment) CommonDeployment(org.jboss.jca.deployers.common.CommonDeployment) StatisticsResourceDefinition(org.jboss.as.connector.dynamicresource.StatisticsResourceDefinition) StatisticsPlugin(org.jboss.jca.core.spi.statistics.StatisticsPlugin) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration)

Example 47 with ManagementResourceRegistration

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

the class MessagingXmlInstallDeploymentUnitProcessor method createDeploymentSubModel.

static ManagementResourceRegistration createDeploymentSubModel(final PathAddress address, final DeploymentUnit unit) {
    final Resource root = unit.getAttachment(DeploymentModelUtils.DEPLOYMENT_RESOURCE);
    synchronized (root) {
        final ManagementResourceRegistration registration = unit.getAttachment(DeploymentModelUtils.MUTABLE_REGISTRATION_ATTACHMENT);
        final PathAddress subsystemAddress = PathAddress.pathAddress(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, MessagingExtension.SUBSYSTEM_NAME));
        final Resource subsystem = getOrCreate(root, subsystemAddress);
        Set<String> childTypes = subsystem.getChildTypes();
        final ManagementResourceRegistration subModel = registration.getSubModel(subsystemAddress.append(address));
        if (subModel == null) {
            throw new IllegalStateException(address.toString());
        }
        getOrCreate(subsystem, address);
        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 48 with ManagementResourceRegistration

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

the class ModClusterExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    ROOT_LOGGER.debugf("Activating mod_cluster extension");
    final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, ModClusterModel.CURRENT.getVersion());
    final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(new ModClusterSubsystemResourceDefinition(context.isRuntimeOnlyRegistrationValid()));
    final ManagementResourceRegistration configuration = registration.registerSubModel(new ModClusterConfigResourceDefinition());
    configuration.registerSubModel(new ModClusterSSLResourceDefinition());
    final ManagementResourceRegistration dynamicLoadProvider = configuration.registerSubModel(DynamicLoadProviderDefinition.INSTANCE);
    dynamicLoadProvider.registerSubModel(LoadMetricDefinition.INSTANCE);
    dynamicLoadProvider.registerSubModel(CustomLoadMetricDefinition.INSTANCE);
    subsystem.registerXMLElementWriter(new ModClusterSubsystemXMLWriter());
}
Also used : ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SubsystemRegistration(org.jboss.as.controller.SubsystemRegistration)

Example 49 with ManagementResourceRegistration

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

the class AbstractProtocolResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parent) {
    ManagementResourceRegistration registration = parent.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver());
    this.descriptorConfigurator.accept(descriptor);
    new RestartParentResourceRegistration<>(this.parentBuilderFactory, descriptor, this.handler).register(registration);
    this.registrationConfigurator.accept(parent, registration);
}
Also used : ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Example 50 with ManagementResourceRegistration

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

the class ChannelResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver()).addAttributes(Attribute.class).addCapabilities(Capability.class).addCapabilities(CLUSTERING_CAPABILITIES.values()).addAlias(DeprecatedAttribute.STATS_ENABLED, Attribute.STATISTICS_ENABLED).addOperationTranslator(new OperationStepHandler() {

        @SuppressWarnings("deprecation")
        @Override
        public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
            // Handle recipe for version < 4.0 where stack was not required and the stack attribute would use default-stack for a default value
            if (!operation.hasDefined(Attribute.STACK.getName())) {
                ModelNode parentModel = context.readResourceFromRoot(context.getCurrentAddress().getParent()).getModel();
                // If default-stack is not defined either, then recipe must be for version >= 4.0 and so this really is an invalid operation
                if (parentModel.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName())) {
                    operation.get(Attribute.STACK.getName()).set(parentModel.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName()));
                }
            }
        }
    }).addRuntimeResourceRegistration(new ProtocolResourceRegistrationHandler());
    ResourceServiceHandler handler = new ChannelServiceHandler();
    new SimpleResourceRegistration(descriptor, handler).register(registration);
    if (this.allowRuntimeOnlyRegistration) {
        new MetricHandler<>(new ChannelMetricExecutor(), ChannelMetric.class).register(registration);
    }
    new ForkResourceDefinition().register(registration);
}
Also used : OperationContext(org.jboss.as.controller.OperationContext) OperationStepHandler(org.jboss.as.controller.OperationStepHandler) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ModelNode(org.jboss.dmr.ModelNode) ResourceServiceHandler(org.jboss.as.clustering.controller.ResourceServiceHandler) ResourceDescriptor(org.jboss.as.clustering.controller.ResourceDescriptor)

Aggregations

ManagementResourceRegistration (org.jboss.as.controller.registry.ManagementResourceRegistration)79 SubsystemRegistration (org.jboss.as.controller.SubsystemRegistration)32 ResourceDescriptor (org.jboss.as.clustering.controller.ResourceDescriptor)30 ResourceServiceHandler (org.jboss.as.clustering.controller.ResourceServiceHandler)26 SimpleResourceRegistration (org.jboss.as.clustering.controller.SimpleResourceRegistration)25 SimpleResourceServiceHandler (org.jboss.as.clustering.controller.SimpleResourceServiceHandler)16 PathElement (org.jboss.as.controller.PathElement)12 SimpleAliasEntry (org.jboss.as.clustering.controller.SimpleAliasEntry)9 PathAddress (org.jboss.as.controller.PathAddress)9 ModelNode (org.jboss.dmr.ModelNode)8 OperationStepHandler (org.jboss.as.controller.OperationStepHandler)7 Resource (org.jboss.as.controller.registry.Resource)7 Map (java.util.Map)6 Locale (java.util.Locale)5 UnaryRequirementCapability (org.jboss.as.clustering.controller.UnaryRequirementCapability)5 OperationContext (org.jboss.as.controller.OperationContext)5 EnumMap (java.util.EnumMap)4 EnumSet (java.util.EnumSet)4 AttributeDefinition (org.jboss.as.controller.AttributeDefinition)4 SimpleAttributeDefinitionBuilder (org.jboss.as.controller.SimpleAttributeDefinitionBuilder)4