Package org.jboss.deployers.spi.management

Examples of org.jboss.deployers.spi.management.ManagementView


            }
        }
    }

    private File getServerTempDirectory() {
        ManagementView managementView = getProfileServiceConnection().getManagementView();
        ManagedComponent serverConfigComponent = ManagedComponentUtils.getSingletonManagedComponent(managementView,
            new ComponentType("MCBean", "ServerConfig"));
        String serverTempDir = (String) ManagedComponentUtils.getSimplePropertyValue(serverConfigComponent,
            "serverTempDir");
View Full Code Here


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

    Configuration resourceConfig = report.getConfiguration();

    ManagementView managementView = null;
    ComponentType componentType = new ComponentType(
        PluginConstants.ComponentType.Platform.TEIID_TYPE,
        PluginConstants.ComponentType.Platform.TEIID_SUB_TYPE);

    report.setStatus(ConfigurationUpdateStatus.SUCCESS);
    try {

      managementView = getConnection().getManagementView();
      Set<ManagedComponent> allComponents = managementView.getComponentsForType(componentType);
     
      for (ManagedComponent managedComponent : allComponents) {
       
        Map<String, ManagedProperty> managedProperties = managedComponent.getProperties();

       
        ProfileServiceUtil.convertConfigurationToManagedProperties(managedProperties, resourceConfig, resourceContext.getResourceType(), managedComponent.getName());

        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);
    }
   
    managementView.load();

  }
View Full Code Here

    // First update simple properties
    super.updateResourceConfiguration(report);

    // Then update models
    ManagementView managementView = null;
    ComponentType componentType = new ComponentType(
        PluginConstants.ComponentType.VDB.TYPE,
        PluginConstants.ComponentType.VDB.SUBTYPE);

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

      managementView = getConnection().getManagementView();
      managedComponent = managementView.getComponent(this.name,
          componentType);
      modelsMetaValue = (CollectionValueSupport) managedComponent
          .getProperty("models").getValue();
      GenericValue[] models = (GenericValue[]) modelsMetaValue
          .getElements();
      List<Property> multiSourceModelsPropertyList = resourceConfiguration
          .getList("multiSourceModels").getList();
      List<Property> singleSourceModelsPropertyList = resourceConfiguration
          .getList("singleSourceModels").getList();
      ArrayList<List<Property>> sourceMappingList = new ArrayList<List<Property>>();
      sourceMappingList.add(singleSourceModelsPropertyList);
      sourceMappingList.add(multiSourceModelsPropertyList);
      PropertyMap model = null;
      Iterator<List<Property>> sourceMappingListIterator = sourceMappingList
          .iterator();
      while (sourceMappingListIterator.hasNext()) {
        List<Property> sourceList = sourceMappingListIterator.next();
        for (int i = 0; i < sourceList.size(); i++) {
          model = (PropertyMap) sourceList.get(i);
          String sourceName = ((PropertySimple) model
              .get("sourceName")).getStringValue(); //$NON-NLS-1$
          if (sourceName.equals("See below"))
            continue; // This is a multisource model which we will
                  // handle separately
          String modelName = ((PropertySimple) model.get("name")) //$NON-NLS-1$
              .getStringValue();
          String dsName = ((PropertySimple) model.get("jndiName")) //$NON-NLS-1$
              .getStringValue();

          ManagedObject managedModel = null;
          if (models != null && models.length != 0) {
            for (GenericValue genValue : models) {
              ManagedObject mo = (ManagedObject) ((GenericValueSupport) genValue)
                  .getValue();
              String name = ProfileServiceUtil.getSimpleValue(mo,
                  "name", String.class); //$NON-NLS-1$
              if (modelName.equals(name)) {
                managedModel = mo;
                break;
              }
            }
          }

          ManagedProperty sourceMappings = null;
          if (managedModel != null) {

            sourceMappings = managedModel
                .getProperty("sourceMappings");//$NON-NLS-1$

            if (sourceMappings != null) {
              CollectionValueSupport mappings = (CollectionValueSupport) sourceMappings
                  .getValue();
              GenericValue[] mappingsArray = (GenericValue[]) mappings
                  .getElements();
              for (GenericValue sourceGenValue : mappingsArray) {
                ManagedObject sourceMo = (ManagedObject) ((GenericValueSupport) sourceGenValue)
                    .getValue();
                String sName = ProfileServiceUtil
                    .getSimpleValue(sourceMo,
                        "name", String.class);//$NON-NLS-1$
                if (sName.equals(sourceName)) {
                  // set the jndi name for the ds.
                  ManagedProperty jndiProperty = sourceMo
                      .getProperty("connectionJndiName"); //$NON-NLS-1$
                  jndiProperty
                      .setValue(ProfileServiceUtil.wrap(
                          SimpleMetaType.STRING,
                          dsName));
                  break;
                }
              }
            }
          }
        }
      }

      try {
        managementView.updateComponent(managedComponent);
        managementView.load();
      } catch (Exception e) {
        LOG.error("Unable to update component ["
            + managedComponent.getName() + "] of type "
            + componentType + ".", e);
        report.setStatus(ConfigurationUpdateStatus.FAILURE);
View Full Code Here

    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);
View Full Code Here

   */
  protected void updateComponent(ManagedComponent managedComponent)
      throws Exception {
    log.trace("Updating " + this.name + " with component " //$NON-NLS-1$ //$NON-NLS-2$
        + managedComponent.toString() + "..."); //$NON-NLS-1$
    ManagementView managementView = getConnection().getManagementView();
    managementView.updateComponent(managedComponent);

  }
View Full Code Here

        .getResourceConfiguration();
    String resourceName = getResourceName(defaultPluginConfig,
        resourceConfig);
    ComponentType componentType = ProfileServiceUtil
        .getComponentType(resourceType);
    ManagementView managementView = null;
    ;
    managementView = getConnection().getManagementView();

    if (ProfileServiceUtil.isManagedComponent(getConnection(),
        resourceName, componentType)) {
      createResourceReport.setStatus(CreateResourceStatus.FAILURE);
      createResourceReport.setErrorMessage("A " + resourceType.getName() //$NON-NLS-1$
          + " named '" + resourceName + "' already exists."); //$NON-NLS-1$ //$NON-NLS-2$
      return createResourceReport;
    }

    createResourceReport.setResourceName(resourceName);
    String resourceKey = getResourceKey(resourceType, resourceName);
    createResourceReport.setResourceKey(resourceKey);

    PropertySimple templateNameProperty = resourceConfig
        .getSimple(TranslatorComponent.Config.TEMPLATE_NAME);
    String templateName = templateNameProperty.getStringValue();

    DeploymentTemplateInfo template;
    try {
      template = managementView.getTemplate(templateName);
      Map<String, ManagedProperty> managedProperties = template.getProperties();

      ProfileServiceUtil.convertConfigurationToManagedProperties(managedProperties, resourceConfig, resourceType, null);

      LOG.debug("Applying template [" + templateName //$NON-NLS-1$
          + "] to create ManagedComponent of type [" + componentType //$NON-NLS-1$
          + "]..."); //$NON-NLS-1$
      try {
        managementView.applyTemplate(resourceName, template);
        managementView.process();
        createResourceReport.setStatus(CreateResourceStatus.SUCCESS);
      } catch (Exception e) {
        LOG.error("Unable to apply template [" + templateName //$NON-NLS-1$
            + "] to create ManagedComponent of type " //$NON-NLS-1$
            + componentType + ".", e); //$NON-NLS-1$
View Full Code Here

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

    // Get the vdb and update date role anyAuthenticated and MappedRoleNames
    ManagementView managementView = null;
    ComponentType componentType = new ComponentType(
        PluginConstants.ComponentType.VDB.TYPE,
        PluginConstants.ComponentType.VDB.SUBTYPE);

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

      managementView = getConnection().getManagementView();
      managedComponent = managementView.getComponent(
          ((VDBComponent) this.resourceContext
              .getParentResourceComponent()).name, componentType);
      ManagedProperty mp = managedComponent.getProperty("dataPolicies");//$NON-NLS-1$
      CollectionValueSupport dataRolesListMp = (CollectionValueSupport) mp
          .getValue();
      String name = resourceConfiguration.getSimpleValue("name", null); //$NON-NLS-1$
      String anyAuthenticated = resourceConfiguration.getSimpleValue(
          "anyAuthenticated", null); //$NON-NLS-1$

      for (MetaValue val : dataRolesListMp.getElements()) {
        GenericValueSupport genValueSupport = (GenericValueSupport) val;
        ManagedObjectImpl managedObject = (ManagedObjectImpl) genValueSupport
            .getValue();

        for (String dataRolesProp : managedObject.getPropertyNames()) {
          ManagedProperty property = managedObject
              .getProperty(dataRolesProp);

          String pname = ProfileServiceUtil.stringValue(managedObject
              .getProperty("name").getValue()); //$NON-NLS-1$
          if (!pname.equals(name)) {
            continue;
          }

          anyAuthenticatedMp = managedObject
              .getProperty("anyAuthenticated"); //$NON-NLS-1$
          anyAuthenticatedMp.setValue(ProfileServiceUtil.wrap(
              SimpleMetaType.BOOLEAN, anyAuthenticated));
          List<Property> mappedRoleNamePropertyList = resourceConfiguration.getList("mappedRoleNameList").getList(); //$NON-NLS-1$
          List<String> mappedRoleNameList = new ArrayList<String>();
         
          for (Property mappedRoleNameProperty : mappedRoleNamePropertyList){
            String mappedRoleNameString = ((PropertyMap)mappedRoleNameProperty).getSimpleValue("name", null); //$NON-NLS-1$
            mappedRoleNameList.add(mappedRoleNameString);
          }
          ManagedProperty mappedRoleNameMp = managedObject.getProperty("mappedRoleNames"); //$NON-NLS-1$
          mappedRoleNameMp.setValue(convertListOfStringsToMetaValue(mappedRoleNameList));
        }

        try {
          managementView.updateComponent(managedComponent);
          managementView.load();
        } 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);
View Full Code Here

   * @param {@link ManagementView}
   * @return
   */
  public static ManagementView getManagementView(ProfileService ps,
      boolean load) {
    ManagementView mv = ps.getViewManager();
    if (load) {
      mv.load();
    }
    return mv;
  }
View Full Code Here

    * Test the ManagedObject for the ManagementFactory.CLASS_LOADING_MXBEAN_NAME
    */
   public void testClassLoadingMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent clMC = mgtView.getComponent(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, type);
      assertEquals(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, clMC.getName());

      Map<String, ManagedProperty> props = clMC.getProperties();
      assertNotNull(props);
      // totalLoadedClassCount
View Full Code Here

   }

   public void testMemoryMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent mo = mgtView.getComponent(ManagementFactory.MEMORY_MXBEAN_NAME, type);
      assertNotNull(mo);
      assertEquals(ManagementFactory.MEMORY_MXBEAN_NAME, mo.getName());

      Map<String, ManagedProperty> props = mo.getProperties();
      assertNotNull(props);
View Full Code Here

TOP

Related Classes of org.jboss.deployers.spi.management.ManagementView

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.