Package javax.management

Examples of javax.management.Attribute


   public AttributeList setAttributes(AttributeList attributeList)
   {
      AttributeList list = new AttributeList();
      for(int n = 0; n < attributeList.size(); n ++)
      {
         Attribute attr = (Attribute) attributeList.get(n);
         try
         {
            setAttribute(attr);
            list.add(attr);
         }
View Full Code Here


            outcome = "Expected " + refCl + " got " + testCl;
        
         MBeanServer server = MBeanServerLocator.locateJBoss();
         ObjectName testFromDD = new ObjectName("jboss.test:service=LegacyWebClassLoader");
         System.out.println(getClass().getName() + " " + test + " ==> " + outcome);
         server.setAttribute(testFromDD, new Attribute(test, outcome));
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

   /**
    * {@inheritDoc}
    */
   protected void set(Object name, String setter, Object value) throws Throwable
   {
      mbeanServer.setAttribute(new ObjectName(name.toString()), new Attribute(setter, value));  
   }
View Full Code Here

      // remember original BaseDir
      String basedir = (String)getServer().getAttribute(target, "BaseDir");
      try
      {
         // Should throw an IllegalArgumentException
         getServer().setAttribute(target, new Attribute("BaseDir", ".."));
         // Should throw an IllegalArgumentException
         getServer().setAttribute(target, new Attribute("BaseDir", "/"));
        
         // Restore the original dir and fail the test
         getServer().setAttribute(target, new Attribute("BaseDir", basedir));
         fail("Managed to set BaseDir outside ServerHomeDir for service: " + target);
      }
      catch (RuntimeMBeanException e)
      {
         // expected
View Full Code Here

        }
        // TODO do more mumbo jumbo for type casting / changing
       
        if (val != null)
            {
          Attribute at = new Attribute(be.attr.getName(), val);
          server.setAttribute(be.mbean, at);
          if (trace)
            log.trace("setValueFor: set attribute in mbean-Server");
        }
        else
View Full Code Here

      this.mName = mbName;
      this.aName = attrName;
      try
         {
         mbean = new ObjectName(mbName);
        attr = new Attribute(attrName, null);

      }
         catch (Exception e)
         {
            log.warn(e.toString());
View Full Code Here

         return "setting " + target.getCanonicalName() + ":" + attribute + " to " + value.getArg();
      }

      public Object execute(MBeanServerConnection server, Task parent) throws Exception
      {
         Attribute att = new Attribute(attribute, value.getValue());
         server.setAttribute(target, att);
         return null;
      }
View Full Code Here

         if (value.equals("null") && server.getAttribute(objName, attrName) == null) {
            log.trace("ignoring 'null' for " + attrName);
            continue;
         }
         String attrType = attrInfo.getType();
         Attribute attr = null;
         try
         {
            Object realValue = PropertyEditors.convertValue(value, attrType);
            attr = new Attribute(attrName, realValue);
         }
         catch(ClassNotFoundException e)
         {
            String s = (attr != null) ? attr.getName() : attrType;
            log.trace("Failed to load class for attribute: " + s, e);
            throw new ReflectionException(e, "Failed to load class for attribute: " + s);
         }
         catch(IntrospectionException e)
         {
View Full Code Here

                  value = parseJbxbSerialData(attr, cl, element, replace, trim);
               else
                  value = parseTextSerialData(attr, cl, element, replace, trim);
              
               log.debug(attributeName + " set to " + value + " in " + objectName);
               setAttribute(objectName, new Attribute(attributeName, value));
            }//if has children

         }
         //end of "attribute
         else if (element.getTagName().equals("depends"))
         {
            if (!element.hasChildNodes())
            {
               throw new DeploymentException("No ObjectName supplied for depends in  " + objectName);
            }

            String mbeanRefName = element.getAttribute("optional-attribute-name");
            if ("".equals(mbeanRefName))
               mbeanRefName = null;
            else
               mbeanRefName = StringPropertyReplacer.replaceProperties(mbeanRefName);

            String proxyType = element.getAttribute("proxy-type");
            if ("".equals(proxyType))
               proxyType = null;
            else
               proxyType = StringPropertyReplacer.replaceProperties(proxyType);

            // Get the mbeanRef value
            ObjectName dependsObjectName = processDependency(objectName, loaderName, element, mbeans, replace);
            log.debug("considering " + ((mbeanRefName == null) ? "<anonymous>" : mbeanRefName.toString()) + " with object name " + dependsObjectName);

            if (mbeanRefName != null)
            {
               Object attribute = dependsObjectName;
               if (proxyType != null)
               {
                  if (mbeanRefName == null)
                     throw new DeploymentException("You cannot use a proxy-type without an optional-attribute-name");
                  if (proxyType.equals("attribute"))
                  {
                     MBeanAttributeInfo attr = attributeMap.get(mbeanRefName);
                     if (attr == null)
                        throw new DeploymentException("No Attribute found with name: " + mbeanRefName);
                     proxyType = attr.getType();
                  }
                  Class proxyClass = cl.loadClass(proxyType);
                  attribute = MBeanProxyExt.create(proxyClass, dependsObjectName,
                     server, true);
               }

               //if if doesn't exist or has wrong type, we'll get an exception
               setAttribute(objectName, new Attribute(mbeanRefName, attribute));
            } // end of if ()
         }
         //end of depends
         else if (element.getTagName().equals("depends-list"))
         {
            String dependsListName = element.getAttribute("optional-attribute-name");
            if ("".equals(dependsListName))
            {
               dependsListName = null;
            } // end of if ()

            NodeList dependsList = element.getChildNodes();
            ArrayList<ObjectName> dependsListNames = new ArrayList<ObjectName>();
            for (int l = 0; l < dependsList.getLength(); l++)
            {
               if (dependsList.item(l).getNodeType() != Node.ELEMENT_NODE)
               {
                  continue;
               }

               Element dependsElement = (Element) dependsList.item(l);
               if (dependsElement.getTagName().equals("depends-list-element"))
               {
                  if (!dependsElement.hasChildNodes())
                  {
                     throw new DeploymentException("Empty depends-list-element!");
                  } // end of if ()

                  // Get the depends value
                  ObjectName dependsObjectName = processDependency(objectName, loaderName, dependsElement, mbeans, replace);
                  if (!dependsListNames.contains(dependsObjectName))
                  {
                     dependsListNames.add(dependsObjectName);
                  } // end of if ()
               }

            } // end of for ()
            if (dependsListName != null)
            {
               setAttribute(objectName, new Attribute(dependsListName, dependsListNames));
            } // end of if ()
         }//end of depends-list
      }
   }
View Full Code Here

   {
      if (objectName.equals(sampleServiceObjectName))
      {
         String value = getServiceBindingManager().getStringBinding(objectName.getCanonicalName(), null, "socket://${host}:${port}", "localhost", 9999);
         MBeanServer server = getServer();
         server.setAttribute(objectName, new Attribute("TestAttribute", value));
      }
   }
View Full Code Here

TOP

Related Classes of javax.management.Attribute

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.