Пример #1
0
 @SuppressWarnings("deprecation")
 @Override
 public void registerMetric(
     String attributeName,
     OperationStepHandler metricHandler,
     EnumSet<AttributeAccess.Flag> flags) {
   deployments.registerMetric(attributeName, metricHandler, flags);
   subdeployments.registerMetric(attributeName, metricHandler, flags);
 }
  @Override
  public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);

    // Metrics
    resourceRegistration.registerMetric(
        BindingMetricHandlers.BoundHandler.ATTRIBUTE_DEFINITION,
        BindingMetricHandlers.BoundHandler.INSTANCE);
    resourceRegistration.registerMetric(
        BindingMetricHandlers.BoundAddressHandler.ATTRIBUTE_DEFINITION,
        BindingMetricHandlers.BoundAddressHandler.INSTANCE);
    resourceRegistration.registerMetric(
        BindingMetricHandlers.BoundPortHandler.ATTRIBUTE_DEFINITION,
        BindingMetricHandlers.BoundPortHandler.INSTANCE);
  }
 @Override
 public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
   MaxRequestsWriteHandler handler = new MaxRequestsWriteHandler(MAX_REQUESTS, requestController);
   resourceRegistration.registerReadWriteAttribute(MAX_REQUESTS, null, handler);
   resourceRegistration.registerMetric(
       ACTIVE_REQUESTS, new ActiveRequestsReadHandler(requestController));
 }
Пример #4
0
  @Override
  public void registerAttributes(ManagementResourceRegistration registry) {
    super.registerAttributes(registry);

    AttributeDefinition[] attributes = deployed ? getDeploymentAttributes() : ATTRIBUTES;
    for (AttributeDefinition attr : attributes) {
      if (registerRuntimeOnly || !attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
        if (deployed) {
          registry.registerReadOnlyAttribute(attr, JMSQueueConfigurationRuntimeHandler.INSTANCE);
        } else {
          if (attr == CommonAttributes.DESTINATION_ENTRIES) {
            registry.registerReadWriteAttribute(
                attr, null, JMSQueueConfigurationWriteHandler.INSTANCE);
          } else {
            registry.registerReadOnlyAttribute(attr, null);
          }
        }
      }
    }

    if (registerRuntimeOnly) {
      for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
        registry.registerReadOnlyAttribute(attr, JMSQueueReadAttributeHandler.INSTANCE);
      }

      for (AttributeDefinition metric : METRICS) {
        registry.registerMetric(metric, JMSQueueReadAttributeHandler.INSTANCE);
      }
    }
  }
  @Override
  public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    resourceRegistration.registerMetric(
        RESOURCE_CLASS,
        new AbstractRestResReadHandler() {
          @Override
          void handleAttribute(
              String className,
              List<JaxrsResourceMethodDescription> methodInvokers,
              List<JaxrsResourceLocatorDescription> locatorIncokers,
              Collection<String> servletMappings,
              ModelNode response) {
            response.set(className);
          }
        });
    resourceRegistration.registerMetric(
        RESOURCE_PATHS,
        new AbstractRestResReadHandler() {
          @Override
          void handleAttribute(
              String className,
              List<JaxrsResourceMethodDescription> methodInvokers,
              List<JaxrsResourceLocatorDescription> locatorIncokers,
              Collection<String> servletMappings,
              ModelNode response) {
            for (JaxrsResourceMethodDescription methodDesc : methodInvokers) {
              response.add(methodDesc.toModelNode());
            }
          }
        });

    resourceRegistration.registerMetric(
        SUB_RESOURCE_LOCATORS,
        new AbstractRestResReadHandler() {
          @Override
          void handleAttribute(
              String className,
              List<JaxrsResourceMethodDescription> methodInvokers,
              List<JaxrsResourceLocatorDescription> locatorIncokers,
              Collection<String> servletMappings,
              ModelNode response) {
            for (JaxrsResourceLocatorDescription methodDesc : locatorIncokers) {
              response.add(methodDesc.toModelNode());
            }
          }
        });
  }
 @Override
 public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
   resourceRegistration.registerReadOnlyAttribute(CONTEXT_ROOT, null);
   resourceRegistration.registerReadOnlyAttribute(VIRTUAL_HOST, null);
   for (SessionStat stat : SessionStat.values()) {
     resourceRegistration.registerMetric(
         stat.definition, SessionManagerStatsHandler.getInstance());
   }
 }
  @Override
  protected void register(ManagementResourceRegistration registration) {

    if (PlatformMBeanUtil.JVM_MAJOR_VERSION > 6) {
      registration.registerReadOnlyAttribute(
          PlatformMBeanConstants.OBJECT_NAME, this, AttributeAccess.Storage.RUNTIME);
    }

    for (String attribute : PlatformMBeanConstants.MEMORY_MANAGER_READ_ATTRIBUTES) {
      registration.registerMetric(attribute, this);
    }
  }
  @Override
  public void registerAttributes(ManagementResourceRegistration registration) {
    super.registerAttributes(registration);
    registration.registerReadOnlyAttribute(
        PlatformMBeanConstants.OBJECT_NAME, CompilationMXBeanAttributeHandler.INSTANCE);

    for (SimpleAttributeDefinition attribute : READ_ATTRIBUTES) {
      registration.registerReadOnlyAttribute(attribute, CompilationMXBeanAttributeHandler.INSTANCE);
    }

    for (SimpleAttributeDefinition attribute : METRICS) {
      registration.registerMetric(attribute, CompilationMXBeanAttributeHandler.INSTANCE);
    }
  }
  @Override
  public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    // the handlers need to take account of alias
    final OperationStepHandler writeHandler =
        new CacheContainerWriteAttributeHandler(CACHE_CONTAINER_ATTRIBUTES);
    for (AttributeDefinition attr : CACHE_CONTAINER_ATTRIBUTES) {
      resourceRegistration.registerReadWriteAttribute(
          attr, CacheContainerReadAttributeHandler.INSTANCE, writeHandler);
    }

    for (AttributeDefinition attr : CACHE_CONTAINER_METRICS) {
      resourceRegistration.registerMetric(attr, CacheContainerMetricsHandler.INSTANCE);
    }
  }
  @Override
  public void registerAttributes(ManagementResourceRegistration resourceRegistration) {
    super.registerAttributes(resourceRegistration);

    // do we really need a special handler here?
    final OperationStepHandler writeHandler =
        new CacheWriteAttributeHandler(CLUSTERED_CACHE_ATTRIBUTES);
    for (AttributeDefinition attr : CLUSTERED_CACHE_ATTRIBUTES) {
      resourceRegistration.registerReadWriteAttribute(
          attr, CacheReadAttributeHandler.INSTANCE, writeHandler);
    }

    // register any metrics
    for (AttributeDefinition attr : CLUSTERED_CACHE_METRICS) {
      resourceRegistration.registerMetric(attr, CacheMetricsHandler.INSTANCE);
    }
  }
Пример #11
0
  @Override
  public void registerAttributes(ManagementResourceRegistration registry) {
    super.registerAttributes(registry);

    for (SimpleAttributeDefinition attr : ATTRIBUTES) {
      if (!attr.getFlags().contains(AttributeAccess.Flag.STORAGE_RUNTIME)) {
        if (runtimeOnly) {
          AttributeDefinition readOnlyRuntimeAttr = create(attr).setStorageRuntime().build();
          registry.registerReadOnlyAttribute(
              readOnlyRuntimeAttr, QueueReadAttributeHandler.RUNTIME_INSTANCE);
        } else {
          registry.registerReadOnlyAttribute(attr, null);
        }
      }
    }

    for (AttributeDefinition attr : READONLY_ATTRIBUTES) {
      registry.registerReadOnlyAttribute(attr, QueueReadAttributeHandler.INSTANCE);
    }

    for (AttributeDefinition metric : METRICS) {
      registry.registerMetric(metric, QueueReadAttributeHandler.INSTANCE);
    }
  }
Пример #12
0
 @Override
 public void registerMetric(AttributeDefinition definition, OperationStepHandler metricHandler) {
   deployments.registerMetric(definition, metricHandler);
   subdeployments.registerMetric(definition, metricHandler);
 }
Пример #13
0
 @SuppressWarnings("deprecation")
 @Override
 public void registerMetric(String attributeName, OperationStepHandler metricHandler) {
   deployments.registerMetric(attributeName, metricHandler);
   subdeployments.registerMetric(attributeName, metricHandler);
 }
  public void transition(
      final ServiceController<? extends Object> controller,
      final ServiceController.Transition transition) {
    switch (transition) {
      case STARTING_to_UP:
        {
          CommonDeployment deploymentMD = getDeploymentMetadata(controller);

          if (deploymentMD.getConnectionManagers() != null) {
            for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
              if (cm.getPool() != null) {
                StatisticsPlugin poolStats = cm.getPool().getStatistics();

                if (poolStats.getNames().size() != 0) {
                  DescriptionProvider statsResourceDescriptionProvider =
                      new StatisticsDescriptionProvider(
                          ResourceAdaptersSubsystemProviders.RESOURCE_NAME,
                          "statistics",
                          poolStats);
                  PathElement pe =
                      PathElement.pathElement(
                          ModelDescriptionConstants.SUBSYSTEM,
                          ResourceAdaptersExtension.SUBSYSTEM_NAME);
                  PathElement peStats =
                      PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
                  PathElement peCD =
                      PathElement.pathElement(
                          Constants.CONNECTIONDEFINITIONS_NAME, cm.getJndiName());
                  ManagementResourceRegistration overrideRegistration = registration;
                  // when you are in deploy you have a registration pointing to deployment=*
                  // when you are in re-deploy it points to specific deploymentUnit
                  synchronized (this) {
                    if (registration.isAllowsOverride()
                        && registration.getOverrideModel(deploymentUnitName) == null) {
                      overrideRegistration =
                          registration.registerOverrideModel(
                              deploymentUnitName,
                              new OverrideDescriptionProvider() {
                                @Override
                                public Map<String, ModelNode> getAttributeOverrideDescriptions(
                                    Locale locale) {
                                  return Collections.emptyMap();
                                }

                                @Override
                                public Map<String, ModelNode> getChildTypeOverrideDescriptions(
                                    Locale locale) {
                                  return Collections.emptyMap();
                                }
                              });
                    } else {
                      overrideRegistration = registration.getOverrideModel(deploymentUnitName);
                    }

                    ManagementResourceRegistration subRegistration =
                        overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
                    if (subRegistration == null) {
                      subRegistration =
                          overrideRegistration.registerSubModel(
                              pe,
                              new SubSystemExtensionDescriptionProvider(
                                  ResourceAdaptersSubsystemProviders.RESOURCE_NAME,
                                  "deployment-subsystem"));
                    }
                    Resource subsystemResource;

                    if (!deploymentResource.hasChild(pe)) {
                      subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
                      deploymentResource.registerChild(pe, subsystemResource);
                    } else {
                      subsystemResource = deploymentResource.getChild(pe);
                    }

                    ManagementResourceRegistration statsRegistration =
                        subRegistration.getSubModel(PathAddress.pathAddress(peStats));
                    if (statsRegistration == null) {
                      statsRegistration =
                          subRegistration.registerSubModel(
                              peStats,
                              new StatisticsElementDescriptionProvider(
                                  ResourceAdaptersSubsystemProviders.RESOURCE_NAME, "statistics"));
                    }
                    Resource statisticsResource;

                    if (!subsystemResource.hasChild(peStats)) {
                      statisticsResource = new IronJacamarResource.IronJacamarRuntimeResource();
                      subsystemResource.registerChild(peStats, statisticsResource);
                    } else {
                      statisticsResource = subsystemResource.getChild(peStats);
                    }

                    if (statsRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
                      ManagementResourceRegistration cdSubRegistration =
                          statsRegistration.registerSubModel(
                              peCD, statsResourceDescriptionProvider);
                      final Resource cdResource =
                          new IronJacamarResource.IronJacamarRuntimeResource();

                      if (!statisticsResource.hasChild(peCD))
                        statisticsResource.registerChild(peCD, cdResource);

                      for (String statName : poolStats.getNames()) {
                        cdSubRegistration.registerMetric(
                            statName, new PoolMetrics.ParametrizedPoolMetricsHandler(poolStats));
                      }
                      cdSubRegistration.registerOperationHandler(
                          "clear-statistics",
                          new ClearStatisticsHandler(poolStats),
                          ResourceAdaptersSubsystemProviders.CLEAR_STATISTICS_DESC,
                          false);
                    }

                    registerIronjacamar(controller, subRegistration, subsystemResource);
                  }
                }
              }
            }
          }
          break;
        }
      case UP_to_STOP_REQUESTED:
        {
          PathElement pe =
              PathElement.pathElement(
                  ModelDescriptionConstants.SUBSYSTEM, ResourceAdaptersExtension.SUBSYSTEM_NAME);
          PathElement ijPe =
              PathElement.pathElement(Constants.IRONJACAMAR_NAME, Constants.IRONJACAMAR_NAME);
          PathElement peStats =
              PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
          PathElement peCD = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME);

          ManagementResourceRegistration overrideRegistration = registration;
          // when you are in deploy you have a registration pointing to deployment=*
          // when you are in re-deploy it points to specific deploymentUnit
          if (registration.isAllowsOverride()
              && registration.getOverrideModel(deploymentUnitName) != null) {
            overrideRegistration = registration.getOverrideModel(deploymentUnitName);
          }
          ManagementResourceRegistration subsystemReg =
              overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
          if (subsystemReg != null) {
            if (subsystemReg.getSubModel(PathAddress.pathAddress(ijPe)) != null) {
              subsystemReg.unregisterSubModel(ijPe);
            }
            ManagementResourceRegistration statsReg =
                subsystemReg.getSubModel(PathAddress.pathAddress(peStats));
            if (statsReg != null) {
              if (statsReg.getSubModel(PathAddress.pathAddress(peCD)) != null) {
                statsReg.unregisterSubModel(peCD);
              }
              subsystemReg.unregisterSubModel(peStats);
            }
            overrideRegistration.unregisterSubModel(pe);
          }

          deploymentResource.removeChild(pe);
        }
    }
  }
  @Override
  public void initialize(final ExtensionContext context) {
    SUBSYSTEM_RA_LOGGER.debugf("Initializing ResourceAdapters Extension");
    // Register the remoting subsystem
    final SubsystemRegistration registration = context.registerSubsystem(SUBSYSTEM_NAME);

    ReloadRequiredWriteAttributeHandler reloadRequiredWriteAttributeHandler =
        new ReloadRequiredWriteAttributeHandler();

    registration.registerXMLElementWriter(ResourceAdapterSubsystemParser.INSTANCE);

    // Remoting subsystem description and operation handlers
    final ManagementResourceRegistration subsystem = registration.registerSubsystemModel(SUBSYSTEM);
    subsystem.registerOperationHandler(
        ADD, ResourceAdaptersSubSystemAdd.INSTANCE, SUBSYSTEM_ADD_DESC, false);
    subsystem.registerOperationHandler(
        DESCRIBE,
        GenericSubsystemDescribeHandler.INSTANCE,
        GenericSubsystemDescribeHandler.INSTANCE,
        false,
        OperationEntry.EntryType.PRIVATE);

    final ManagementResourceRegistration resourceadapter =
        subsystem.registerSubModel(
            PathElement.pathElement(RESOURCEADAPTER_NAME), RESOURCEADAPTER_DESC);
    resourceadapter.registerOperationHandler(ADD, RaAdd.INSTANCE, ADD_RESOURCEADAPTER_DESC, false);
    resourceadapter.registerOperationHandler(
        REMOVE, RaRemove.INSTANCE, REMOVE_RESOURCEADAPTER_DESC, false);
    for (final String attribute : ResourceAdaptersSubsystemProviders.RESOURCEADAPTER_ATTRIBUTE) {
      resourceadapter.registerReadWriteAttribute(
          attribute, null, reloadRequiredWriteAttributeHandler, Storage.CONFIGURATION);
    }

    final ManagementResourceRegistration configAdapter =
        resourceadapter.registerSubModel(
            PathElement.pathElement(CONFIG_PROPERTIES.getName()), CONFIG_PROPERTIES_DESC);
    configAdapter.registerOperationHandler(
        ADD, ConfigPropertyAdd.INSTANCE, ADD_CONFIG_PROPERTIES_DESC, false);
    configAdapter.registerOperationHandler(
        REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, REMOVE_CONFIG_PROPERTIES_DESC, false);

    final ManagementResourceRegistration connectionDefinition =
        resourceadapter.registerSubModel(
            PathElement.pathElement(CONNECTIONDEFINITIONS_NAME), CONNECTION_DEFINITION_DESC);
    connectionDefinition.registerOperationHandler(
        ADD, ConnectionDefinitionAdd.INSTANCE, ADD_CONNECTION_DEFINITION_DESC, false);
    connectionDefinition.registerOperationHandler(
        REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, REMOVE_CONNECTION_DEFINITION_DESC, false);

    final ManagementResourceRegistration configCF =
        connectionDefinition.registerSubModel(
            PathElement.pathElement(CONFIG_PROPERTIES.getName()), CONFIG_PROPERTIES_DESC);
    configCF.registerOperationHandler(
        ADD, CDConfigPropertyAdd.INSTANCE, ADD_CONFIG_PROPERTIES_DESC, false);
    configCF.registerOperationHandler(
        REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, REMOVE_CONFIG_PROPERTIES_DESC, false);
    for (final SimpleAttributeDefinition attribute :
        ResourceAdaptersSubsystemProviders.CONNECTIONDEFINITIONS_NODEATTRIBUTE) {
      connectionDefinition.registerReadWriteAttribute(
          attribute.getName(), null, reloadRequiredWriteAttributeHandler, Storage.CONFIGURATION);
    }

    final ManagementResourceRegistration adminObject =
        resourceadapter.registerSubModel(
            PathElement.pathElement(ADMIN_OBJECTS_NAME), ADMIN_OBJECT_DESC);
    adminObject.registerOperationHandler(
        ADD, AdminObjectAdd.INSTANCE, ADD_ADMIN_OBJECT_DESC, false);
    adminObject.registerOperationHandler(
        REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, REMOVE_ADMIN_OBJECT_DESC, false);

    final ManagementResourceRegistration configAO =
        adminObject.registerSubModel(
            PathElement.pathElement(CONFIG_PROPERTIES.getName()), CONFIG_PROPERTIES_DESC);
    configAO.registerOperationHandler(
        ADD, AOConfigPropertyAdd.INSTANCE, ADD_CONFIG_PROPERTIES_DESC, false);
    configAO.registerOperationHandler(
        REMOVE, ReloadRequiredRemoveStepHandler.INSTANCE, REMOVE_CONFIG_PROPERTIES_DESC, false);
    for (final SimpleAttributeDefinition attribute :
        ResourceAdaptersSubsystemProviders.ADMIN_OBJECTS_NODEATTRIBUTE) {
      adminObject.registerReadWriteAttribute(
          attribute.getName(), null, reloadRequiredWriteAttributeHandler, Storage.CONFIGURATION);
    }

    resourceadapter.registerOperationHandler(
        "flush-idle-connection-in-pool",
        PoolOperations.FlushIdleConnectionInPool.RA_INSTANCE,
        FLUSH_IDLE_CONNECTION_DESC,
        false);
    resourceadapter.registerOperationHandler(
        "flush-all-connection-in-pool",
        PoolOperations.FlushAllConnectionInPool.RA_INSTANCE,
        FLUSH_ALL_CONNECTION_DESC,
        false);
    resourceadapter.registerOperationHandler(
        "test-connection-in-pool",
        PoolOperations.TestConnectionInPool.RA_INSTANCE,
        TEST_CONNECTION_DESC,
        false);

    for (final String attributeName : PoolMetrics.ATTRIBUTES) {
      resourceadapter.registerMetric(attributeName, PoolMetrics.RaPoolMetricsHandler.INSTANCE);
    }
  }
  public void transition(
      final ServiceController<? extends Object> controller,
      final ServiceController.Transition transition) {
    switch (transition) {
      case STARTING_to_UP:
        {
          CommonDeployment deploymentMD = getDeploymentMetadata(controller);

          if (deploymentMD.getConnectionManagers() != null) {
            for (ConnectionManager cm : deploymentMD.getConnectionManagers()) {
              if (cm.getPool() != null) {
                StatisticsPlugin poolStats = cm.getPool().getStatistics();
                poolStats.setEnabled(false);
                final ServiceController<?> bootstrapContextController =
                    controller
                        .getServiceContainer()
                        .getService(
                            ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootstrapCtx));
                WorkManager wm = null;
                if (bootstrapContextController != null) {
                  wm =
                      (WorkManager)
                          ((CloneableBootstrapContext) bootstrapContextController.getValue())
                              .getWorkManager();
                }
                if ((wm != null && wm.getStatistics() != null)
                    || poolStats.getNames().size() != 0) {

                  PathElement pe =
                      PathElement.pathElement(
                          ModelDescriptionConstants.SUBSYSTEM,
                          ResourceAdaptersExtension.SUBSYSTEM_NAME);
                  PathElement peStats =
                      PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
                  PathElement peRa =
                      PathElement.pathElement(Constants.RESOURCEADAPTER_NAME, raName);
                  PathElement peWm =
                      PathElement.pathElement(Constants.WORKMANAGER_NAME, wm.getName());
                  PathElement peDistributedWm =
                      PathElement.pathElement(Constants.DISTRIBUTED_WORKMANAGER_NAME, wm.getName());
                  PathElement peCD =
                      PathElement.pathElement(
                          Constants.CONNECTIONDEFINITIONS_NAME, cm.getJndiName());
                  ManagementResourceRegistration overrideRegistration = registration;
                  // when you are in deploy you have a registration pointing to deployment=*
                  // when you are in re-deploy it points to specific deploymentUnit
                  synchronized (this) {
                    if (registration.isAllowsOverride()) {

                      if (registration.getOverrideModel(deploymentUnitName) != null) {
                        overrideRegistration = registration.getOverrideModel(deploymentUnitName);
                      } else {
                        overrideRegistration =
                            registration.registerOverrideModel(
                                deploymentUnitName,
                                new OverrideDescriptionProvider() {
                                  @Override
                                  public Map<String, ModelNode> getAttributeOverrideDescriptions(
                                      Locale locale) {
                                    return Collections.emptyMap();
                                  }

                                  @Override
                                  public Map<String, ModelNode> getChildTypeOverrideDescriptions(
                                      Locale locale) {
                                    return Collections.emptyMap();
                                  }
                                });
                      }
                    }

                    ManagementResourceRegistration subRegistration;
                    try {
                      ResourceBuilder resourceBuilder =
                          ResourceBuilder.Factory.create(
                              pe,
                              new StandardResourceDescriptionResolver(
                                  Constants.STATISTICS_NAME,
                                  CommonAttributes.RESOURCE_NAME,
                                  CommonAttributes.class.getClassLoader()));
                      subRegistration =
                          overrideRegistration.registerSubModel(resourceBuilder.build());

                    } catch (IllegalArgumentException iae) {
                      subRegistration =
                          overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
                    }
                    Resource subsystemResource;

                    if (!deploymentResource.hasChild(pe)) {
                      subsystemResource = new IronJacamarResource.IronJacamarRuntimeResource();
                      deploymentResource.registerChild(pe, subsystemResource);
                    } else {
                      subsystemResource = deploymentResource.getChild(pe);
                    }

                    ManagementResourceRegistration statsRegistration;
                    try {
                      ResourceBuilder resourceBuilder =
                          ResourceBuilder.Factory.create(
                              peStats,
                              new StandardResourceDescriptionResolver(
                                  Constants.STATISTICS_NAME,
                                  CommonAttributes.RESOURCE_NAME,
                                  CommonAttributes.class.getClassLoader()));

                      statsRegistration = subRegistration.registerSubModel(resourceBuilder.build());
                    } catch (IllegalArgumentException iae) {
                      statsRegistration =
                          subRegistration.getSubModel(PathAddress.pathAddress(peStats));
                    }
                    Resource statisticsResource;

                    if (!subsystemResource.hasChild(peStats)) {
                      statisticsResource = new IronJacamarResource.IronJacamarRuntimeResource();
                      subsystemResource.registerChild(peStats, statisticsResource);
                    } else {
                      statisticsResource = subsystemResource.getChild(peStats);
                    }

                    ManagementResourceRegistration raRegistration;
                    try {
                      ResourceBuilder resourceBuilder =
                          ResourceBuilder.Factory.create(
                              peRa,
                              new StandardResourceDescriptionResolver(
                                  Constants.STATISTICS_NAME,
                                  CommonAttributes.RESOURCE_NAME,
                                  CommonAttributes.class.getClassLoader()));

                      raRegistration = statsRegistration.registerSubModel(resourceBuilder.build());
                    } catch (IllegalArgumentException iae) {
                      raRegistration = statsRegistration.getSubModel(PathAddress.pathAddress(peRa));
                    }
                    Resource raResource;

                    if (!statisticsResource.hasChild(peRa)) {
                      raResource = new IronJacamarResource.IronJacamarRuntimeResource();
                      statisticsResource.registerChild(peRa, raResource);
                    } else {
                      raResource = statisticsResource.getChild(peRa);
                    }
                    if (deploymentMD.getConnector() != null
                        && deploymentMD.getConnector().getResourceAdapter() != null
                        && deploymentMD.getConnector().getResourceAdapter().getStatistics()
                            != null) {
                      StatisticsPlugin raStats =
                          deploymentMD.getConnector().getResourceAdapter().getStatistics();
                      raStats.setEnabled(false);
                      PoolMetrics.ParametrizedPoolMetricsHandler handler =
                          new PoolMetrics.ParametrizedPoolMetricsHandler(raStats);
                      for (AttributeDefinition attribute :
                          StatisticsResourceDefinition.getAttributesFromPlugin(raStats)) {
                        raRegistration.registerMetric(attribute, handler);
                      }
                      // adding enable/disable for pool stats
                      OperationStepHandler readHandler =
                          new PoolStatisticsRuntimeAttributeReadHandler(raStats);
                      OperationStepHandler writeHandler =
                          new PoolStatisticsRuntimeAttributeWriteHandler(raStats);
                      raRegistration.registerReadWriteAttribute(
                          org.jboss.as.connector.subsystems.common.pool.Constants
                              .POOL_STATISTICS_ENABLED,
                          readHandler,
                          writeHandler);
                    }
                    if (poolStats.getNames().size() != 0
                        && raRegistration.getSubModel(PathAddress.pathAddress(peCD)) == null) {
                      ManagementResourceRegistration cdSubRegistration =
                          raRegistration.registerSubModel(
                              new StatisticsResourceDefinition(
                                  peCD, CommonAttributes.RESOURCE_NAME, poolStats));
                      final Resource cdResource =
                          new IronJacamarResource.IronJacamarRuntimeResource();

                      if (!raResource.hasChild(peCD)) raResource.registerChild(peCD, cdResource);
                    }

                    if (wm.getStatistics() != null) {
                      if (wm instanceof DistributedWorkManager
                          && ((DistributedWorkManager) wm).getDistributedStatistics() != null
                          && raRegistration.getSubModel(PathAddress.pathAddress(peDistributedWm))
                              == null) {
                        ResourceBuilder resourceBuilder =
                            ResourceBuilder.Factory.create(
                                peDistributedWm,
                                new StandardResourceDescriptionResolver(
                                    Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME,
                                    CommonAttributes.RESOURCE_NAME,
                                    CommonAttributes.class.getClassLoader()));

                        ManagementResourceRegistration dwmSubRegistration =
                            raRegistration.registerSubModel(resourceBuilder.build());
                        final Resource dwmResource =
                            new IronJacamarResource.IronJacamarRuntimeResource();

                        if (!raResource.hasChild(peDistributedWm))
                          raResource.registerChild(peDistributedWm, dwmResource);

                        OperationStepHandler metricsHandler =
                            new WorkManagerRuntimeAttributeReadHandler(
                                wm,
                                ((DistributedWorkManager) wm).getDistributedStatistics(),
                                false);
                        for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                          dwmSubRegistration.registerMetric(metric, metricsHandler);
                        }

                        OperationStepHandler readHandler =
                            new WorkManagerRuntimeAttributeReadHandler(
                                wm, ((DistributedWorkManager) wm).getDistributedStatistics(), true);
                        OperationStepHandler writeHandler =
                            new WorkManagerRuntimeAttributeWriteHandler(
                                wm, true, Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES);
                        for (SimpleAttributeDefinition attribute :
                            Constants.DISTRIBUTED_WORKMANAGER_RW_ATTRIBUTES) {
                          dwmSubRegistration.registerReadWriteAttribute(
                              attribute, readHandler, writeHandler);
                        }

                        dwmSubRegistration.registerOperationHandler(
                            ClearWorkManagerStatisticsHandler.DEFINITION,
                            new ClearWorkManagerStatisticsHandler(wm));
                      }
                      if (raRegistration.getSubModel(PathAddress.pathAddress(peWm)) == null) {
                        ResourceBuilder resourceBuilder =
                            ResourceBuilder.Factory.create(
                                peWm,
                                new StandardResourceDescriptionResolver(
                                    Constants.STATISTICS_NAME + "." + Constants.WORKMANAGER_NAME,
                                    CommonAttributes.RESOURCE_NAME,
                                    CommonAttributes.class.getClassLoader()));

                        ManagementResourceRegistration wmSubRegistration =
                            raRegistration.registerSubModel(resourceBuilder.build());
                        final Resource wmResource =
                            new IronJacamarResource.IronJacamarRuntimeResource();

                        if (!raResource.hasChild(peWm)) raResource.registerChild(peWm, wmResource);

                        OperationStepHandler metricHandler =
                            new WorkManagerRuntimeAttributeReadHandler(
                                wm, wm.getStatistics(), false);
                        for (SimpleAttributeDefinition metric : Constants.WORKMANAGER_METRICS) {
                          wmSubRegistration.registerMetric(metric, metricHandler);
                        }

                        OperationStepHandler readHandler =
                            new WorkManagerRuntimeAttributeReadHandler(
                                wm, wm.getStatistics(), false);
                        OperationStepHandler writeHandler =
                            new WorkManagerRuntimeAttributeWriteHandler(
                                wm, false, Constants.WORKMANAGER_RW_ATTRIBUTES);
                        for (SimpleAttributeDefinition attribute :
                            Constants.WORKMANAGER_RW_ATTRIBUTES) {
                          wmSubRegistration.registerReadWriteAttribute(
                              attribute, readHandler, writeHandler);
                        }

                        wmSubRegistration.registerOperationHandler(
                            ClearWorkManagerStatisticsHandler.DEFINITION,
                            new ClearWorkManagerStatisticsHandler(wm));
                      }
                    }

                    registerIronjacamar(controller, subRegistration, subsystemResource);
                  }
                }
              }
            }
          }
          break;
        }
      case UP_to_STOP_REQUESTED:
        {
          PathElement pe =
              PathElement.pathElement(
                  ModelDescriptionConstants.SUBSYSTEM, ResourceAdaptersExtension.SUBSYSTEM_NAME);
          PathElement ijPe =
              PathElement.pathElement(Constants.IRONJACAMAR_NAME, Constants.IRONJACAMAR_NAME);
          PathElement peStats =
              PathElement.pathElement(Constants.STATISTICS_NAME, Constants.STATISTICS_NAME);
          PathElement peCD = PathElement.pathElement(Constants.CONNECTIONDEFINITIONS_NAME);

          ManagementResourceRegistration overrideRegistration = registration;
          // when you are in deploy you have a registration pointing to deployment=*
          // when you are in re-deploy it points to specific deploymentUnit
          if (registration.isAllowsOverride()
              && registration.getOverrideModel(deploymentUnitName) != null) {
            overrideRegistration = registration.getOverrideModel(deploymentUnitName);
          }
          ManagementResourceRegistration subsystemReg =
              overrideRegistration.getSubModel(PathAddress.pathAddress(pe));
          if (subsystemReg != null) {
            if (subsystemReg.getSubModel(PathAddress.pathAddress(ijPe)) != null) {
              subsystemReg.unregisterSubModel(ijPe);
            }
            ManagementResourceRegistration statsReg =
                subsystemReg.getSubModel(PathAddress.pathAddress(peStats));
            if (statsReg != null) {
              if (statsReg.getSubModel(PathAddress.pathAddress(peCD)) != null) {
                statsReg.unregisterSubModel(peCD);
              }
              subsystemReg.unregisterSubModel(peStats);
            }
            overrideRegistration.unregisterSubModel(pe);
          }

          deploymentResource.removeChild(pe);
        }
    }
  }