Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedComponent


    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);
          report.setErrorMessageFromThrowable(e);
        }
      }
View Full Code Here


  @Override
  public Configuration loadResourceConfiguration() {

    VDBComponent parentComponent = (VDBComponent) this.resourceContext
        .getParentResourceComponent();
    ManagedComponent mcVdb = null;
    Configuration configuration = resourceContext.getPluginConfiguration();
    try {
      mcVdb = ProfileServiceUtil.getManagedComponent(getConnection(),
          new ComponentType(PluginConstants.ComponentType.VDB.TYPE,
              PluginConstants.ComponentType.VDB.SUBTYPE),
          parentComponent.name);
    } catch (NamingException e) {
      final String msg = "NamingException in loadResourceConfiguration(): " + e.getMessage(); //$NON-NLS-1$
      LOG.error(msg, e);
    } catch (Exception e) {
      final String msg = "Exception in loadResourceConfiguration(): " + e.getMessage(); //$NON-NLS-1$
      LOG.error(msg, e);
    }

    // Get data roles from VDB
    ManagedProperty property = mcVdb.getProperty("dataPolicies"); //$NON-NLS-1$
    if (property != null) {
      CollectionValueSupport valueSupport = (CollectionValueSupport) property
          .getValue();
      MetaValue[] metaValues = valueSupport.getElements();
View Full Code Here

      ProfileServiceConnection connection, String name,
      ComponentType componentType) {
    boolean isDeployed = false;
    if (name != null) {
      try {
        ManagedComponent component = getManagedComponent(connection,
            componentType, name);
        if (component != null)
          isDeployed = true;
      } catch (Exception e) {
        // Setting it to true to be safe than sorry, since there might
View Full Code Here

   * @throws Exception
   */
  public static ManagedComponent getManagedComponent(
      ProfileServiceConnection connection, ComponentType componentType,
      String componentName) throws NamingException, Exception {
    ManagedComponent mc = connection.getManagementView().getComponent(
        componentName, componentType);

    return mc;
  }
View Full Code Here

    Set<DiscoveredResourceDetails> discoveredResources = new HashSet<DiscoveredResourceDetails>();
    VDBComponent parenComponent = (VDBComponent) discoveryContext
        .getParentResourceComponent();
    ProfileServiceConnection connection = parenComponent.getConnection();

    ManagedComponent mcVdb = ProfileServiceUtil.getManagedComponent(
        connection, new ComponentType(
            PluginConstants.ComponentType.VDB.TYPE,
            PluginConstants.ComponentType.VDB.SUBTYPE),
        parenComponent.name);

    // Get data roles from VDB
    ManagedProperty property = mcVdb.getProperty("dataPolicies");
    if (property != null) {
      CollectionValueSupport valueSupport = (CollectionValueSupport) property
          .getValue();
      MetaValue[] metaValues = valueSupport.getElements();
View Full Code Here

   {
      log.info("+++ testListDataSourceComponents");

      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("DataSource", "LocalTx");
      ManagedComponent ds = getManagedComponent(mgtView, type, "DefaultDS");
      assertNotNull("hsqldb-ds.xml ManagedComponent", ds);
      Map<String,ManagedProperty> props = ds.getProperties();
      log.info("hsqldb-ds.props: "+props);
      // Validate the property names
      ManagedProperty p = props.get("jndi-name");
      assertEquals("jndi-name", SimpleValueSupport.wrap("DefaultDS"), p.getValue());
      p = props.get("driver-class");
View Full Code Here

      throws Exception
   {
      log.info("+++ testUpdateDefaultDS");
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("DataSource", "LocalTx");
      ManagedComponent hsqldb = mgtView.getComponent("DefaultDS", type);
      Map<String,ManagedProperty> props = hsqldb.getProperties();
      log.info("hsqldb.props: "+props);
      // Update properties
      ManagedProperty minSize = props.get("min-pool-size");
      minSize.setValue(SimpleValueSupport.wrap(new Integer(13)));
      ManagedProperty maxSize = props.get("max-pool-size");
View Full Code Here

   public void testDefaultDSPropertiesAreMetaValues()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("DataSource", "LocalTx");
      ManagedComponent hsqldb = mgtView.getComponent("DefaultDS", type);
      Map<String,ManagedProperty> props = hsqldb.getProperties();
      validatePropertyMetaValues(props);

      // Validate the config-property
      ManagedProperty configProperty = hsqldb.getProperty("config-property");
      assertNotNull(configProperty);
      MetaValue value = configProperty.getValue();
      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
      log.debug("config-property: "+configProperty);
      assertTrue(value instanceof CompositeValue);
View Full Code Here

   public void testDefaultDSStats()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("DataSource", "LocalTx");
      ManagedComponent hsqldb = mgtView.getComponent("DefaultDS", type);
      Map<String,ManagedProperty> props = hsqldb.getProperties();
      ArrayList<ManagedProperty> stats = new ArrayList<ManagedProperty>();
      for(ManagedProperty prop : props.values())
      {
         if(prop.hasViewUse(ViewUse.STATISTIC))
         {
            log.info("STATISTIC: "+prop+", value: "+prop.getValue());
            stats.add(prop);
         }
      }
      assertTrue("Saw ManagedProperty(ViewUse.STATISTIC)", stats.size() > 0);
      HashSet<String> nullStats = new HashSet<String>();
      // These should also have non-null values
      for(ManagedProperty stat : stats)
      {
         Object value = stat.getValue();
         if(value == null)
            nullStats.add(stat.getName());
      }
      assertTrue("There are no null stats: "+nullStats, nullStats.size() == 0);

      // Validate the component run state
      RunState state = hsqldb.getRunState();
      assertEquals("DefaultDS is running", RunState.RUNNING, state);
   }
View Full Code Here

   public void testDefaultDSOps()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("DataSource", "LocalTx");
      ManagedComponent hsqldb = mgtView.getComponent("DefaultDS", type);
      Set<ManagedOperation> ops = hsqldb.getOperations();
      log.info("DefaultDS ops: "+ops);
      assertNotNull("Set<ManagedOperation>", ops);
      assertTrue("Set<ManagedOperation> > 0", ops.size() > 0);
      ManagedOperation listFormattedSubPoolStatistics = null;
      HashMap<String, ManagedOperation> opsByName = new HashMap<String, ManagedOperation>();
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.ManagedComponent

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.