Package org.jboss.mx.metadata

Source Code of org.jboss.mx.metadata.JBossXMBean12

/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.mx.metadata;

import org.jdom.Attribute;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;

import javax.management.Descriptor;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
import javax.management.NotCompliantMBeanException;
import javax.management.modelmbean.DescriptorSupport;
import javax.management.modelmbean.ModelMBeanAttributeInfo;
import javax.management.modelmbean.ModelMBeanConstructorInfo;
import javax.management.modelmbean.ModelMBeanInfo;
import javax.management.modelmbean.ModelMBeanInfoSupport;
import javax.management.modelmbean.ModelMBeanNotificationInfo;
import javax.management.modelmbean.ModelMBeanOperationInfo;

import java.net.MalformedURLException;
import java.net.URL;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.HashSet;

import org.jboss.mx.modelmbean.XMBeanConstants;

/**
* @TODO
*/
public class JBossXMBean12
   extends AbstractBuilder
   implements XMBeanConstants
{

   // Attributes ----------------------------------------------------
  
   /**
    * URL for the XML definition of the management interface
    */
   private URL url                  = null;
  
   /**
    * The class name of the Model MBean implementation class.
    */
   private String mmbClassName      = null;
  
   /**
    * The class name of the resource object represented by this Model MBean.
    */
   private String resourceClassName = null;
   

 
   // Constructors --------------------------------------------------

   /**
    * Initialized a parser for the JBossMX 1.2 XMBean schema.
    *
    * @param   mmbClassName      the name of the Model MBean implementation class
    * @param   resourceClassName the name of the resource class this Model
    *                            MBean represents
    * @param   url               URL to the XMBean management interface definition
    */
   public JBossXMBean12(String mmbClassName, String resourceClassName, URL url)
   {
      super();
     
      this.url               = url;
      this.mmbClassName      = mmbClassName;
      this.resourceClassName = resourceClassName;
   }

   /**
    * Initialized a parser for the JBossMX 1.2 XMBean schema.
    *
    * @param   mmbClassName      the name of the Model MBean implementation class
    * @param   resourceClassName the name of the resource class this Model
    *                            MBean represents
    * @param   url               URL to the XMBean management interface definition
    *
    * @throws MalformedURLException if the given management interface URL cannot
    *         be resolved
    */
   public JBossXMBean12(String mmbClassName, String resourceClassName, String url) throws MalformedURLException
   {
      this(mmbClassName, resourceClassName, new URL(url));
   }

   /**
    * Initialized a parser for the JBossMX 1.2 XMBean schema.
    *
    * @param   mmbClassName      the name of the Model MBean implementation class
    * @param   resourceClassName the name of the resource class this Model
    *                            MBean represents
    * @param   url               URL to the XMBean management interface definition
    */
   public JBossXMBean12(String mmbClassName, String resourceClassName, URL url, Map properties)
   {
      this(mmbClassName, resourceClassName, url);
      setProperties(properties);
   }

   /**
    * Initialized a parser for the JBossMX 1.2 XMBean schema.
    *
    * @param   mmbClassName      the name of the Model MBean implementation class
    * @param   resourceClassName the name of the resource class this Model
    *                            MBean represents
    * @param   url               URL to the XMBean management interface definition
    *
    * @throws MalformedURLException if the given management interface URL cannot
    *         be resolved
    */
   public JBossXMBean12(String mmbClassName, String resourceClassName,
                        String url, Map properties) throws MalformedURLException
   {
      this(mmbClassName, resourceClassName, new URL(url), properties);
   }


   // MetaDataBuilder implementation --------------------------------

   public MBeanInfo build() throws NotCompliantMBeanException
   {
      try
      {
         // by default, let JAXP pick the SAX parser
         SAXBuilder builder = new SAXBuilder();
        
         // check if user wants to override the SAX parser property
         if (properties.get(SAX_PARSER) != null)
            builder = new SAXBuilder(getStringProperty(SAX_PARSER));
            ///*"org.apache.crimson.parser.XMLReaderImpl"*/);

         // by default we validate
         builder.setValidation(true);
        
         // the user can override the validation by setting the VALIDATE property
         try
         {
            boolean validate = getBooleanProperty(XML_VALIDATION);
            builder.setValidation(validate);
         }
         catch (IllegalPropertyException e)
         {
            // FIXME: log the exception (warning)
           
            // fall through, use the default value
         }
        
         // get the root and start parsing...  
         Element root = builder.build(url).getRootElement();
        
         return null;
      }
      catch (JDOMException e)
      {
         // FIXME: log it
         e.printStackTrace();
         throw new NotCompliantMBeanException(
               "Error parsing the XML file: " +
               ((e.getCause() == null) ? e.toString() : e.getCause().toString())
         );
      }
   }

  

}


TOP

Related Classes of org.jboss.mx.metadata.JBossXMBean12

TOP
Copyright © 2018 www.massapi.com. 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.