Package org.jboss.system

Examples of org.jboss.system.ConfigurationException


      }
      // If class is given, instantiate it
      String code = mbeanElement.getAttribute("code");
      if ( code == null || "".equals(code))
      {
         throw new ConfigurationException("missing 'code' attribute");
      }

      // get the constructor params/sig to use
      ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);

      // Check for xmbean specific attributes
      String xmbeandd = null;
      Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
      if( xmbeanddAttr != null )
         xmbeandd = xmbeanddAttr.getValue();
      String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
      if( xmbeanCode.length() == 0 )
         xmbeanCode = XMBEAN_CODE;

      // Create the mbean instance
      ObjectInstance instance = null;
      try
      {
         if ( xmbeandd == null )
         {
            // Check for the explicit management interface in case of a standard MBean
            Attr itfAttr = mbeanElement.getAttributeNode("interface");
            if (itfAttr != null)
            {
               // Get the good class loader
               ClassLoader classLoader = server.getClassLoader(loaderName);

               // Load interface class
               String itf = itfAttr.getValue();
               Class itfClass = classLoader.loadClass(itf);
               log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
               Object resource = server.instantiate(code,
                                                    loaderName,
                                                    constructor.params,
                                                    constructor.signature);
               //
               log.debug("About to register StandardMBean : " + mbeanName);
               instance = server.createMBean("javax.management.StandardMBean",
                                             mbeanName,
                                             loaderName,
                                             new Object[]{resource,itfClass},
                                             new String[]{Object.class.getName(),Class.class.getName()});
            }
            else
            {
               // This is a standard or dynamic mbean
               log.debug("About to create bean: " + mbeanName + " with code: " + code);
               instance = server.createMBean(code,
                                             mbeanName,
                                             loaderName,
                                             constructor.params,
                                             constructor.signature);
            }
         } // end of if ()
         else if( xmbeandd.length() == 0 )
         {
            // This is an xmbean with an embedded mbean descriptor
            log.debug("About to create xmbean object: " + mbeanName
               + " with code: " + code + " with embedded descriptor");
            //xmbean: construct object first.
            Object resource = server.instantiate(code, loaderName,
                  constructor.params, constructor.signature);

            NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
            if( mbeans.getLength() == 0 )
               throw new ConfigurationException("No nested mbean element given for xmbean");
            Element mbeanDescriptor = (Element) mbeans.item(0);
            Object[] args = {resource, mbeanDescriptor,
                             ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0};
            String[] sig = {Object.class.getName(), Element.class.getName(),
                            String.class.getName()};
View Full Code Here


      {
         ConstructorInfo info = new ConstructorInfo();
         NodeList list = element.getElementsByTagName("constructor");
         if (list.getLength() > 1 && list.item(0).getParentNode() == element)
         {
            throw new ConfigurationException
            ("only one <constructor> element may be defined");
         }
         else if (list.getLength() == 1)
         {
            element = (Element)list.item(0);

            // get all of the "arg" elements
            list = element.getElementsByTagName("arg");
            int length = list.getLength();
            info.params = new Object[length];
            info.signature = new String[length];
            ClassLoader loader = Thread.currentThread().getContextClassLoader();

            // decode the values into params & signature
            for (int j=0; j<length; j++)
            {
               Element arg = (Element)list.item(j);
               String signature = arg.getAttribute("type");
               String value = arg.getAttribute("value");
               // Allow for system property reference replacement
               value = StringPropertyReplacer.replaceProperties(arg.getAttribute("value"));
               Object realValue = value;

               if( signature != null )
               {
                  // See if it is a primitive type first
                  Class typeClass = Classes.getPrimitiveTypeForName(signature);
                  if (typeClass == null)
                  {
                     // Try to load the class
                     try
                     {
                        typeClass = loader.loadClass(signature);
                     }
                     catch (ClassNotFoundException e)
                     {
                        throw new ConfigurationException
                           ("Class not found for type: " + signature, e);
                     }
                  }

                  // Convert the string to the real value
                  PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
                  if (editor == null)
                  {
                     try
                     {
                        // See if there is a ctor(String) for the type
                        Class[] sig = {String.class};
                        Constructor ctor = typeClass.getConstructor(sig);
                        Object[] args = {value};
                        realValue = ctor.newInstance(args);
                     }
                     catch (Exception e)
                     {
                        throw new ConfigurationException("No property editor for type: " + typeClass);
                     }
                  }
                  else
                  {
                     editor.setAsText(value);
View Full Code Here

      }
      // If class is given, instantiate it
      String code = mbeanElement.getAttribute("code");
      if ( code == null || "".equals(code))
      {
         throw new ConfigurationException("missing 'code' attribute");
      }

      // get the constructor params/sig to use
      ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);

      // Check for xmbean specific attributes
      String xmbeandd = null;
      Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
      if( xmbeanddAttr != null )
         xmbeandd = xmbeanddAttr.getValue();
      String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
      if( xmbeanCode.length() == 0 )
         xmbeanCode = XMBEAN_CODE;

      // Create the mbean instance
      ObjectInstance instance = null;
      try
      {
         if ( xmbeandd == null )
         {
            // Check for the explicit management interface in case of a standard MBean
            Attr itfAttr = mbeanElement.getAttributeNode("interface");
            if (itfAttr != null)
            {
               // Get the good class loader
               ClassLoader classLoader = server.getClassLoader(loaderName);

               // Load interface class
               String itf = itfAttr.getValue();
               Class itfClass = classLoader.loadClass(itf);
               log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
               Object resource = server.instantiate(code,
                                                    loaderName,
                                                    constructor.params,
                                                    constructor.signature);
               //
               log.debug("About to register StandardMBean : " + mbeanName);
               instance = server.createMBean("javax.management.StandardMBean",
                                             mbeanName,
                                             loaderName,
                                             new Object[]{resource,itfClass},
                                             new String[]{Object.class.getName(),Class.class.getName()});
            }
            else
            {
               // This is a standard or dynamic mbean
               log.debug("About to create bean: " + mbeanName + " with code: " + code);
               instance = server.createMBean(code,
                                             mbeanName,
                                             loaderName,
                                             constructor.params,
                                             constructor.signature);
            }
         } // end of if ()
         else if( xmbeandd.length() == 0 )
         {
            // This is an xmbean with an embedded mbean descriptor
            log.debug("About to create xmbean object: " + mbeanName
               + " with code: " + code + " with embedded descriptor");
            //xmbean: construct object first.
            Object resource = server.instantiate(code, loaderName,
                  constructor.params, constructor.signature);

            NodeList mbeans = mbeanElement.getElementsByTagName("xmbean");
            if( mbeans.getLength() == 0 )
               throw new ConfigurationException("No nested mbean element given for xmbean");
            Element mbeanDescriptor = (Element) mbeans.item(0);
            Object[] args = {resource, mbeanDescriptor,
                             ServiceConstants.PUBLIC_JBOSSMX_XMBEAN_DTD_1_0};
            String[] sig = {Object.class.getName(), Element.class.getName(),
                            String.class.getName()};
View Full Code Here

      {
         ConstructorInfo info = new ConstructorInfo();
         NodeList list = element.getElementsByTagName("constructor");
         if (list.getLength() > 1 && list.item(0).getParentNode() == element)
         {
            throw new ConfigurationException
            ("only one <constructor> element may be defined");
         }
         else if (list.getLength() == 1)
         {
            element = (Element)list.item(0);

            // get all of the "arg" elements
            list = element.getElementsByTagName("arg");
            int length = list.getLength();
            info.params = new Object[length];
            info.signature = new String[length];
            ClassLoader loader = Thread.currentThread().getContextClassLoader();

            // decode the values into params & signature
            for (int j=0; j<length; j++)
            {
               Element arg = (Element)list.item(j);
               String signature = arg.getAttribute("type");
               String value = arg.getAttribute("value");
               // Allow for system property reference replacement
               value = StringPropertyReplacer.replaceProperties(arg.getAttribute("value"));
               Object realValue = value;

               if( signature != null )
               {
                  // See if it is a primitive type first
                  Class typeClass = Classes.getPrimitiveTypeForName(signature);
                  if (typeClass == null)
                  {
                     // Try to load the class
                     try
                     {
                        typeClass = loader.loadClass(signature);
                     }
                     catch (ClassNotFoundException e)
                     {
                        throw new ConfigurationException
                           ("Class not found for type: " + signature, e);
                     }
                  }

                  // Convert the string to the real value
                  PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
                  if (editor == null)
                  {
                     try
                     {
                        // See if there is a ctor(String) for the type
                        Class[] sig = {String.class};
                        Constructor ctor = typeClass.getConstructor(sig);
                        Object[] args = {value};
                        realValue = ctor.newInstance(args);
                     }
                     catch (Exception e)
                     {
                        throw new ConfigurationException("No property editor for type: " + typeClass);
                     }
                  }
                  else
                  {
                     editor.setAsText(value);
View Full Code Here

   public String[] getSignature() throws ConfigurationException
   {
      for (String string : signature)
      {
         if (string == null || string.trim().length() == 0)
            throw new ConfigurationException("Missing or empty 'type' attribute in constructor arg");
      }
      return signature;
   }
View Full Code Here

     
      Object[] result = new Object[params.length];
      for (int i = 0; i < result.length; ++i)
      {
         if (params[i] == null)
            throw new ConfigurationException("Missing 'value' attribute in constructor arg");
        
         String value = StringPropertyReplacer.replaceProperties(params[i]);
         Object realValue = value;

         if (signature[i] != null)
         {
            // See if it is a primitive type first
            Class typeClass = Classes.getPrimitiveTypeForName(signature[i]);
            if (typeClass == null)
               typeClass = cl.loadClass(signature[i]);

            // Convert the string to the real value
            PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
            if (editor == null)
            {
               try
               {
                  // See if there is a ctor(String) for the type
                  Class[] sig = {String.class};
                  Constructor ctor = typeClass.getConstructor(sig);
                  Object[] args = {value};
                  realValue = ctor.newInstance(args);
               }
               catch (Exception e)
               {
                  throw new ConfigurationException("No property editor for type: " + typeClass);
               }
            }
            else
            {
               editor.setAsText(value);
View Full Code Here

/*     */     throws ConfigurationException
/*     */   {
/*  96 */     for (String string : this.signature)
/*     */     {
/*  98 */       if ((string == null) || (string.trim().length() == 0))
/*  99 */         throw new ConfigurationException("Missing or empty 'type' attribute in constructor arg");
/*     */     }
/* 101 */     return this.signature;
/*     */   }
View Full Code Here

/*     */
/* 133 */     Object[] result = new Object[this.params.length];
/* 134 */     for (int i = 0; i < result.length; i++)
/*     */     {
/* 136 */       if (this.params[i] == null) {
/* 137 */         throw new ConfigurationException("Missing 'value' attribute in constructor arg");
/*     */       }
/* 139 */       String value = StringPropertyReplacer.replaceProperties(this.params[i]);
/* 140 */       Object realValue = value;
/*     */
/* 142 */       if (signature[i] != null)
/*     */       {
/* 145 */         Class typeClass = Classes.getPrimitiveTypeForName(signature[i]);
/* 146 */         if (typeClass == null) {
/* 147 */           typeClass = cl.loadClass(signature[i]);
/*     */         }
/*     */
/* 150 */         PropertyEditor editor = PropertyEditorManager.findEditor(typeClass);
/* 151 */         if (editor == null)
/*     */         {
/*     */           try
/*     */           {
/* 156 */             Class[] sig = { String.class };
/* 157 */             Constructor ctor = typeClass.getConstructor(sig);
/* 158 */             Object[] args = { value };
/* 159 */             realValue = ctor.newInstance(args);
/*     */           }
/*     */           catch (Exception e)
/*     */           {
/* 163 */             throw new ConfigurationException("No property editor for type: " + typeClass);
/*     */           }
/*     */         }
/*     */         else
/*     */         {
/* 168 */           editor.setAsText(value);
View Full Code Here

TOP

Related Classes of org.jboss.system.ConfigurationException

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.