geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx GBeanMBean.java CollectionProxy.java
Date Wed, 21 Jan 2004 19:44:29 GMT
djencks     2004/01/21 11:44:29

  Modified:    modules/kernel/src/java/org/apache/geronimo/gbean/jmx
                        GBeanMBean.java CollectionProxy.java
  Log:
  useful info on exceptions
  
  Revision  Changes    Path
  1.4       +12 -7     incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java
  
  Index: GBeanMBean.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBean.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GBeanMBean.java	20 Jan 2004 22:39:05 -0000	1.3
  +++ GBeanMBean.java	21 Jan 2004 19:44:29 -0000	1.4
  @@ -62,6 +62,7 @@
   import java.util.Iterator;
   import java.util.Map;
   import java.util.Set;
  +
   import javax.management.Attribute;
   import javax.management.AttributeList;
   import javax.management.AttributeNotFoundException;
  @@ -78,20 +79,18 @@
   import javax.management.ObjectName;
   import javax.management.ReflectionException;
   
  +import net.sf.cglib.reflect.FastClass;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.geronimo.kernel.jmx.MBeanOperationSignature;
  -import org.apache.geronimo.kernel.management.NotificationType;
   import org.apache.geronimo.gbean.GAttributeInfo;
  +import org.apache.geronimo.gbean.GBean;
   import org.apache.geronimo.gbean.GBeanInfo;
   import org.apache.geronimo.gbean.GConstructorInfo;
   import org.apache.geronimo.gbean.GEndpointInfo;
   import org.apache.geronimo.gbean.GOperationInfo;
   import org.apache.geronimo.gbean.InvalidConfigurationException;
  -import org.apache.geronimo.gbean.GBean;
  -import org.apache.geronimo.gbean.jmx.AbstractManagedObject;
  -
  -import net.sf.cglib.reflect.FastClass;
  +import org.apache.geronimo.kernel.jmx.MBeanOperationSignature;
  +import org.apache.geronimo.kernel.management.NotificationType;
   
   /**
    * A GeronimoMBean is a J2EE Management Managed Object, and is standard base for Geronimo
services.
  @@ -267,6 +266,7 @@
           // create the instance
           Object[] parameters = new Object[parameterTypes.length];
           Iterator names = constructorInfo.getAttributeNames().iterator();
  +        Iterator assertedTypes = constructorInfo.getTypes().iterator();
           for (int i = 0; i < parameters.length; i++) {
               String name = (String) names.next();
               if (attributeMap.containsKey(name)) {
  @@ -278,6 +278,11 @@
               } else {
                   throw new InvalidConfigurationException("Unknown attribute or endpoint
name in constructor: name=" + name);
               }
  +            Class assertedType = (Class) assertedTypes.next();
  +            assert parameters[i] == null || assertedType.isPrimitive() || assertedType.isAssignableFrom(parameters[i].getClass()):
  +                    "Attempting to construct " + objectName + " of type " + gbeanInfo.getClassName()
  +                    + ". Constructor parameter " + i + " should be " + assertedType.getName()
  +                    + " but is " + parameters[i].getClass().getName();
           }
           target = constructor.newInstance(parameters);
   
  
  
  
  1.9       +8 -2      incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CollectionProxy.java
  
  Index: CollectionProxy.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/CollectionProxy.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CollectionProxy.java	20 Jan 2004 22:39:05 -0000	1.8
  +++ CollectionProxy.java	21 Jan 2004 19:44:29 -0000	1.9
  @@ -79,6 +79,7 @@
   import net.sf.cglib.proxy.Enhancer;
   import net.sf.cglib.proxy.Factory;
   import net.sf.cglib.proxy.SimpleCallbacks;
  +import net.sf.cglib.core.CodeGenerationException;
   
   /**
    *
  @@ -140,7 +141,12 @@
           });
           enhancer.setCallbacks(new SimpleCallbacks());
           enhancer.setClassLoader(type.getClassLoader());
  -        factory = enhancer.create();
  +        try {
  +            factory = enhancer.create();
  +        } catch (CodeGenerationException e) {
  +            log.info("Most likely you are enhancing a class rather than an interface and
it lacks a default constructor" +  e.getMessage());
  +            throw e;
  +        }
       }
   
       public synchronized void destroy() {
  
  
  

Mime
View raw message