geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r594105 - in /geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main: java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java xsd/geronimo-javabean-xmlattribute-1.0.xsd
Date Mon, 12 Nov 2007 13:16:53 GMT
Author: gdamour
Date: Mon Nov 12 05:16:53 2007
New Revision: 594105

URL: http://svn.apache.org/viewvc?rev=594105&view=rev
Log:
Add optional class attribute so that it is possible to specify the class name of the JavaBean
to be configured instead of relying on the GBeanAttribute type. This allows the declaration
of interfaces as GBean attributes and hence improve testability

Modified:
    geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java
    geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/xsd/geronimo-javabean-xmlattribute-1.0.xsd

Modified: geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java?rev=594105&r1=594104&r2=594105&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/java/org/apache/geronimo/deployment/service/JavaBeanXmlAttributeBuilder.java
Mon Nov 12 05:16:53 2007
@@ -48,10 +48,17 @@
         return getValue(javabean, type, cl);
     }
 
-    private Object getValue(JavabeanType javabean, String className, ClassLoader cl) throws
DeploymentException {
+    private Object getValue(JavabeanType javabean, String type, ClassLoader cl) throws DeploymentException
{
+        String className = type;
+        if (javabean.isSetClass1()) {
+            className = javabean.getClass1();
+        }
         Class clazz = null;
         try {
             clazz = cl.loadClass(className);
+            if (!type.equals(className) && !cl.loadClass(type).isAssignableFrom(clazz))
{
+                throw new DeploymentException("javabean class " + className + " is not of
the expected type " + type);
+            }
         } catch (ClassNotFoundException e) {
             throw new DeploymentException("Could not load alleged javabean class " + className,
e);
         }
@@ -61,6 +68,7 @@
         } catch (Exception e) {
             throw new DeploymentException("Could not create java bean instance", e);
         }
+        
         PropertyDescriptor[] propertyDescriptors;
         try {
             BeanInfo beanInfo = Introspector.getBeanInfo(clazz);
@@ -77,15 +85,15 @@
             for (int j = 0; j < propertyDescriptors.length; j++) {
                 PropertyDescriptor propertyDescriptor = propertyDescriptors[j];
                 if (propertyName.equals(propertyDescriptor.getName())) {
-                    String type = propertyDescriptor.getPropertyType().getName();
+                    String protertyType = propertyDescriptor.getPropertyType().getName();
                     PropertyEditor propertyEditor = null;
                     try {
-                        propertyEditor = PropertyEditors.findEditor(type, cl);
+                        propertyEditor = PropertyEditors.findEditor(protertyType, cl);
                     } catch (ClassNotFoundException e) {
-                        throw new DeploymentException("Could not load editor for type " +
type, e);
+                        throw new DeploymentException("Could not load editor for type " +
protertyType, e);
                     }
                     if (propertyEditor == null) {
-                        throw new DeploymentException("Unable to find PropertyEditor for
" + type);
+                        throw new DeploymentException("Unable to find PropertyEditor for
" + protertyType);
                     }
                     propertyEditor.setAsText(propertyString);
                     Object value = propertyEditor.getValue();

Modified: geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/xsd/geronimo-javabean-xmlattribute-1.0.xsd
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/xsd/geronimo-javabean-xmlattribute-1.0.xsd?rev=594105&r1=594104&r2=594105&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/xsd/geronimo-javabean-xmlattribute-1.0.xsd
(original)
+++ geronimo/server/trunk/framework/modules/geronimo-service-builder/src/main/xsd/geronimo-javabean-xmlattribute-1.0.xsd
Mon Nov 12 05:16:53 2007
@@ -39,6 +39,7 @@
             <xs:element name="property" type="javabean:propertyType" minOccurs="0" maxOccurs="unbounded"/>
             <xs:element name="bean-property" type="javabean:bean-propertyType" minOccurs="0"
maxOccurs="unbounded"/>
         </xs:sequence>
+        <xs:attribute name="class" type="xs:string" use="optional"/>
     </xs:complexType>
 
     <xs:complexType name="propertyType">



Mime
View raw message