Search in sources :

Example 61 with ManagementResourceRegistration

use of org.jboss.as.controller.registry.ManagementResourceRegistration 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)

Example 62 with ManagementResourceRegistration

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

the class ACLResourceDefinition method registerChildren.

@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
    super.registerChildren(resourceRegistration);
    ManagementResourceRegistration moduleReg = resourceRegistration.registerSubModel(new LoginModuleResourceDefinition(Constants.ACL_MODULE));
    //https://issues.jboss.org/browse/WFLY-2474 acl-module was wrongly called login-module in 7.2.0
    resourceRegistration.registerAlias(PathElement.pathElement(Constants.LOGIN_MODULE), new AliasEntry(moduleReg) {

        @Override
        public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
            PathElement element = address.getLastElement();
            element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue());
            return address.subAddress(0, address.size() - 1).append(element);
        }
    });
}
Also used : PathElement(org.jboss.as.controller.PathElement) PathAddress(org.jboss.as.controller.PathAddress) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) AliasEntry(org.jboss.as.controller.registry.AliasEntry)

Example 63 with ManagementResourceRegistration

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

the class IIOPExtension method initialize.

@Override
public void initialize(ExtensionContext context) {
    final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
    final ManagementResourceRegistration subsystemRegistration = subsystem.registerSubsystemModel(IIOPRootDefinition.INSTANCE);
    subsystemRegistration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
    subsystem.registerXMLElementWriter(IIOPSubsystemParser_3.INSTANCE);
    if (context.isRegisterTransformers()) {
        IIOPRootDefinition.registerTransformers(subsystem);
    }
}
Also used : ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SubsystemRegistration(org.jboss.as.controller.SubsystemRegistration)

Example 64 with ManagementResourceRegistration

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

the class PojoExtension method initialize.

/**
     * {@inheritDoc}
     */
@Override
public void initialize(ExtensionContext context) {
    final SubsystemRegistration subsystem = context.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
    final ManagementResourceRegistration registration = subsystem.registerSubsystemModel(PojoResource.INSTANCE);
    registration.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE);
    subsystem.registerXMLElementWriter(parser);
}
Also used : ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) SubsystemRegistration(org.jboss.as.controller.SubsystemRegistration)

Example 65 with ManagementResourceRegistration

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

the class CacheResourceDefinition method register.

@Override
public void register(ManagementResourceRegistration parentRegistration) {
    ManagementResourceRegistration registration = parentRegistration.registerSubModel(this);
    ResourceDescriptor descriptor = new ResourceDescriptor(this.getResourceDescriptionResolver());
    this.descriptorConfigurator.accept(descriptor);
    new SimpleResourceRegistration(descriptor, this.handler).register(registration);
    this.registrationConfigurator.accept(registration);
}
Also used : SimpleResourceRegistration(org.jboss.as.clustering.controller.SimpleResourceRegistration) ManagementResourceRegistration(org.jboss.as.controller.registry.ManagementResourceRegistration) 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