geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ja...@apache.org
Subject svn commit: r564034 - in /geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean: GAttributeInfo.java GBeanInfo.java GConstructorInfo.java GNotificationInfo.java GOperationInfo.java GReferenceInfo.java
Date Wed, 08 Aug 2007 22:19:24 GMT
Author: jaydm
Date: Wed Aug  8 15:19:22 2007
New Revision: 564034

URL: http://svn.apache.org/viewvc?view=rev&rev=564034
Log:
Added methods to allow gbean info to be returned as xml.
(similar to 'toString' methods)

Modified:
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GNotificationInfo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GOperationInfo.java
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GReferenceInfo.java

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GAttributeInfo.java
Wed Aug  8 15:19:22 2007
@@ -18,6 +18,9 @@
 package org.apache.geronimo.gbean;
 
 import java.io.Serializable;
+import java.util.Arrays;
+
+import org.apache.geronimo.kernel.KernelRegistry;
 
 /**
  * Describes an attibute of a GBean.
@@ -117,13 +120,49 @@
 
     public String toString() {
         return "[GAttributeInfo: name=" + name +
-                " type=" + type +
-                " persistent=" + persistent +
-                " manageable=" + manageable +
-                " readable=" + readable +
-                " writable=" + writable +
-                " getterName=" + getterName +
-                " setterName=" + setterName +
-                "]";
+                 " type=" + type +
+                 " persistent=" + persistent +
+                 " manageable=" + manageable +
+                 " readable=" + readable +
+                 " writable=" + writable +
+                 " getterName=" + getterName +
+                 " setterName=" + setterName +
+                 "]";
+    }
+
+    public String toXML(AbstractName abstractName) {
+        String xml = "";
+        
+        xml += "<gAttributeInfo ";
+        xml += "name='" + name + "' ";
+        xml += "type='" + type + "' ";
+        xml += "persistent='" + persistent + "' ";
+        xml += "manageable='" + manageable + "' ";
+        xml += "readable='" + readable + "' ";
+        xml += "writable='" + writable + "' ";
+        xml += ">";
+        
+        xml += "<getterName>" + getterName + "</getterName>";
+        xml += "<setterName>" + setterName + "</setterName>";
+
+        if (readable) {
+            try {
+                Object value = KernelRegistry.getSingleKernel().getAttribute(abstractName,
name);
+                if (value != null) {
+                    if (value instanceof String[]) {
+                        for (String valueString : Arrays.asList((String[]) value))
+                            xml += "<value>" + valueString + "</value>";    
       
+                    } else {
+                        xml += "<value>" + value + "</value>";
+                    }
+                }
+            } catch (Exception e) {
+                
+            }
+        }
+        
+        xml += "</gAttributeInfo>";
+
+        return xml;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfo.java
Wed Aug  8 15:19:22 2007
@@ -316,4 +316,58 @@
         result.append("]");
         return result.toString();
     }
+    
+    public String toXML(AbstractName abstractName) {
+        String xml = "";
+        
+        xml += "<gBeanInfo ";
+        xml += "id='" + super.toString() + "' ";
+        xml += "sourceClass='" + sourceClass + "' ";
+        xml += "name='" + name + "' ";
+        xml += "className='" + className + "' ";
+        xml += "type='" + j2eeType + "' ";
+        xml += "priority='" + priority + "' ";
+        xml += ">";
+        
+        xml += "<attributes>";
+        
+        for (Iterator loop = attributes.iterator(); loop.hasNext(); ) {
+            xml += ((GAttributeInfo) loop.next()).toXML(abstractName);
+        }
+        
+        xml += "</attributes>";
+        
+        xml += constructor.toXML();
+        
+        xml += "<operations>";
+        
+        for (Iterator loop = operations.iterator(); loop.hasNext(); ) {
+            xml += ((GOperationInfo) loop.next()).toXML();
+        }
+        
+        xml += "</operations>";
+        
+        xml += "<notifications>";
+        
+        // I had expected this to be a set of GNotification Objects
+        // but it was just strings
+        for (Iterator loop = notifications.iterator(); loop.hasNext(); ) {
+            Object note = loop.next();
+            xml += "<notification>" + note + "</notification>";
+        }
+        
+        xml += "</notifications>";
+        
+        xml += "<references>";
+        
+        for (Iterator loop = references.iterator(); loop.hasNext(); ) {
+            xml += ((GReferenceInfo) loop.next()).toXML();
+        }
+        
+        xml += "</references>";
+        
+        xml += "</gBeanInfo>";
+        
+        return xml;
+    }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GConstructorInfo.java
Wed Aug  8 15:19:22 2007
@@ -20,6 +20,7 @@
 import java.io.Serializable;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -46,5 +47,23 @@
 
     public String toString() {
         return "[GConstructorInfo: attributeNames=" + attributeNames + "]";
+    }
+    
+    public String toXML() {
+    	String xml = "";
+    	
+    	xml += "<gConstructorInfo>";
+    	
+    	xml += "<attributes>";
+    	
+    	for (Iterator loop = attributeNames.iterator(); loop.hasNext(); ) {
+    		xml += "<name>" + loop.next().toString() + "</name>";
+    	}
+    	
+    	xml += "</attributes>";
+    	
+    	xml += "</gConstructorInfo>";
+    	
+    	return xml;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GNotificationInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GNotificationInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GNotificationInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GNotificationInfo.java
Wed Aug  8 15:19:22 2007
@@ -19,6 +19,7 @@
 
 import java.io.Serializable;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.Set;
 
 /**
@@ -45,8 +46,24 @@
 
     public String toString() {
         return "[GNotificationInfo:" +
-                " name=" + name +
-                " notificationTypes=" + notificationTypes +
-                "]";
+                 " name=" + name +
+                 " notificationTypes=" + notificationTypes +
+                 "]";
+    }
+
+    public String toXML() {
+        String xml = "";
+
+        xml += "<gNotificationInfo ";
+        xml += "name='" + name + "' ";
+        xml += ">";
+
+        for (Iterator loop = notificationTypes.iterator(); loop.hasNext(); ) {
+            xml += "<notificationType>" + loop.next().toString() + "</notificationType>";
+        }
+
+        xml += "</gNotificationInfo>";
+
+        return xml;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GOperationInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GOperationInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GOperationInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GOperationInfo.java
Wed Aug  8 15:19:22 2007
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -97,5 +98,26 @@
 
     public String toString() {
         return "[GOperationInfo: name=" + name + " parameters=" + parameters + " returnType
=" + returnType + "]";
+    }
+    
+    public String toXML() {
+    	String xml = "";
+    	
+    	xml += "<gOperationInfo ";
+    	xml += "name='" + name + "' ";
+    	xml += "returnType='" + returnType + "' ";
+    	xml += ">";
+    	
+    	xml += "<parameters>";
+    	
+    	for (Iterator loop = parameters.iterator(); loop.hasNext(); ) {
+    		xml += "<parameterType>" + loop.next().toString() + "</parameterType>";
+    	}
+    	
+    	xml += "</parameters>";
+    	
+    	xml += "</gOperationInfo>";
+    	
+    	return xml;
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GReferenceInfo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GReferenceInfo.java?view=diff&rev=564034&r1=564033&r2=564034
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GReferenceInfo.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GReferenceInfo.java
Wed Aug  8 15:19:22 2007
@@ -85,4 +85,18 @@
                 " naming system type name= " + nameTypeName +
                 "]";
     }
+    
+    public String toXML() {
+        String xml = "";
+        
+        xml += "<gReferenceInfo ";
+        xml += "name='" + name + "' ";
+        xml += "referenceType='" + referenceType + "' ";
+        xml += "proxyType='" + proxyType + "' ";
+        xml += "setterName='" + setterName + "' ";
+        xml += "namingSystem='" + nameTypeName + "' ";
+        xml += "/>";
+        
+        return xml;
+    }
 }



Mime
View raw message