/**
  * Validate that there is only 1 DefaultDS ManagedComponent
  *
  * @throws Exception
  */
 public void testJTAComponentCount() throws Exception {
   ManagementView mgtView = getManagementView();
   ComponentType type = new ComponentType("MCBean", "JTA");
   Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
   int count = comps.size();
   assertEquals("There is 1 MCBean:JTA ManagedComponent", 1, 1);
   ManagedComponent comp = comps.iterator().next();
   Map<String, ManagedProperty> props = comp.getProperties();
   for (ManagedProperty prop : props.values()) {
     log.info(prop + ", : " + prop.getValue());
   }
 }
Example #2
0
  /**
   * The plugin container will call this method when it has a new configuration for your managed
   * resource. Your plugin will re-configure the managed resource in your own custom way, setting
   * its configuration based on the new values of the given configuration.
   *
   * @see ConfigurationFacet#updateResourceConfiguration(ConfigurationUpdateReport)
   */
  public void updateResourceConfiguration(ConfigurationUpdateReport report) {

    resourceConfiguration = report.getConfiguration().deepCopy();

    Configuration resourceConfig = report.getConfiguration();

    ManagementView managementView = null;
    ComponentType componentType = null;
    if (this.getComponentType().equals(PluginConstants.ComponentType.VDB.NAME)) {
      componentType =
          new ComponentType(
              PluginConstants.ComponentType.VDB.TYPE, PluginConstants.ComponentType.VDB.SUBTYPE);
    } else {
      report.setStatus(ConfigurationUpdateStatus.FAILURE);
      report.setErrorMessage("Update not implemented for the component type."); // $NON-NLS-1$
    }

    ManagedComponent managedComponent = null;
    report.setStatus(ConfigurationUpdateStatus.SUCCESS);
    try {

      managementView = getConnection().getManagementView();
      managedComponent = managementView.getComponent(this.name, componentType);
      Map<String, ManagedProperty> managedProperties = managedComponent.getProperties();

      ProfileServiceUtil.convertConfigurationToManagedProperties(
          managedProperties, resourceConfig, resourceContext.getResourceType(), null);

      try {
        managementView.updateComponent(managedComponent);
      } catch (Exception e) {
        LOG.error(
            "Unable to update component [" //$NON-NLS-1$
                + managedComponent.getName()
                + "] of type " //$NON-NLS-1$
                + componentType
                + ".",
            e); //$NON-NLS-1$
        report.setStatus(ConfigurationUpdateStatus.FAILURE);
        report.setErrorMessageFromThrowable(e);
      }
    } catch (Exception e) {
      LOG.error("Unable to process update request", e); // $NON-NLS-1$
      report.setStatus(ConfigurationUpdateStatus.FAILURE);
      report.setErrorMessageFromThrowable(e);
    }
  }