geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akulshresh...@apache.org
Subject svn commit: r558235 - in /geronimo/server/trunk/modules/geronimo-kernel/src: main/java/org/apache/geronimo/gbean/ main/java/org/apache/geronimo/gbean/runtime/ test/java/org/apache/geronimo/gbean/ test/java/org/apache/geronimo/kernel/
Date Sat, 21 Jul 2007 03:47:45 GMT
Author: akulshreshtha
Date: Fri Jul 20 20:47:45 2007
New Revision: 558235

URL: http://svn.apache.org/viewvc?view=rev&rev=558235
Log:
Retrying rev 499201 with some modifications. The getters/setters must be added explicitly
using addOperation to be able to invoke them using kernel.invoke(...)

Modified:
    geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.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/runtime/GBeanOperation.java
    geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
    geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java?view=diff&rev=558235&r1=558234&r2=558235
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/GBeanInfoBuilder.java
Fri Jul 20 20:47:45 2007
@@ -403,8 +403,10 @@
     
     /**
      * @deprecated
-     */ 
+     */
     public void addOperation(String name) {
+        // FIXME : This is needed because the getters/setters are not being added as operation
+        // i.e. kerenl.invoke("getX") fails.
         addOperation(new GOperationInfo(name, NO_ARGS, ""));
     }
 
@@ -412,13 +414,14 @@
      * @deprecated
      */
     public void addOperation(String name, Class[] paramTypes) {
-        addOperation(new GOperationInfo(name, paramTypes, ""));
+        //addOperation(new GOperationInfo(name, paramTypes, ""));
     }
-    
+   
     public void addOperation(String name, String returnType) {
         addOperation(new GOperationInfo(name, NO_ARGS, returnType));
     }
 
+    // This is redundant because these operations are added automatically; it can be made
private
     public void addOperation(String name, Class[] paramTypes, String returnType) {
         addOperation(new GOperationInfo(name, paramTypes, returnType));
     }

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=558235&r1=558234&r2=558235
==============================================================================
--- 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
Fri Jul 20 20:47:45 2007
@@ -38,7 +38,7 @@
     /**
      * The return type of this method.
      */
-    private final String type;
+    private final String returnType;
     
     /**
      * Parameters of this method.
@@ -54,9 +54,9 @@
         this(name, name, Collections.EMPTY_LIST, type);
     }
 
-    public GOperationInfo(String name, Class[] paramTypes, String type) {
+    public GOperationInfo(String name, Class[] paramTypes, String returnType) {
         this.name = this.methodName = name;
-        this.type = type;
+        this.returnType = returnType;
         String[] args = new String[paramTypes.length];
         for (int i = 0; i < args.length; i++) {
             args[i] = paramTypes[i].getName();
@@ -64,17 +64,17 @@
         this.parameters = Collections.unmodifiableList(Arrays.asList(args));
     }
 
-    public GOperationInfo(String name, String[] paramTypes, String type) {
-        this(name, name, Arrays.asList(paramTypes), type);
+    public GOperationInfo(String name, String[] paramTypes, String returnType) {
+        this(name, name, Arrays.asList(paramTypes), returnType);
     }
     
-    public GOperationInfo(String name, List parameters, String type) {
-        this(name, name, parameters, type);
+    public GOperationInfo(String name, List parameters, String returnType) {
+        this(name, name, parameters, returnType);
     }
     
-    public GOperationInfo(String name, String methodName, List parameters, String type) {
+    public GOperationInfo(String name, String methodName, List parameters, String returnType)
{
         this.name = name;
-        this.type = type;
+        this.returnType = returnType;
         this.methodName = methodName;
         this.parameters = Collections.unmodifiableList(new ArrayList(parameters));
     }
@@ -84,7 +84,7 @@
     }
     
     public String getReturnType() {
-        return type;
+        return returnType;
     }
 
     public String getMethodName() {
@@ -96,6 +96,6 @@
     }
 
     public String toString() {
-        return "[GOperationInfo: name=" + name + " parameters=" + parameters + " type ="
+ type + "]";
+        return "[GOperationInfo: name=" + name + " parameters=" + parameters + " returnType
=" + returnType + "]";
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java?view=diff&rev=558235&r1=558234&r2=558235
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/main/java/org/apache/geronimo/gbean/runtime/GBeanOperation.java
Fri Jul 20 20:47:45 2007
@@ -22,7 +22,6 @@
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
-import java.io.Serializable;
 
 import org.apache.geronimo.gbean.DynamicGBean;
 import org.apache.geronimo.gbean.DynamicGOperationInfo;
@@ -33,9 +32,7 @@
 /**
  * @version $Rev$ $Date$
  */
-public final class GBeanOperation implements Serializable {
-    private static final long serialVersionUID = -5185515581104192977L;
-    
+public final class GBeanOperation {
     private final GBeanInstance gbeanInstance;
     private final String name;
     private final List parameterTypes;
@@ -43,7 +40,6 @@
     private final boolean framework;
     private final GOperationInfo operationInfo;
 
-    // TODO - deprecate this and add returnType
     static GBeanOperation createFrameworkOperation(GBeanInstance gbeanInstance, String name,
List parameterTypes, MethodInvoker methodInvoker) {
         return new GBeanOperation(gbeanInstance, name, parameterTypes, methodInvoker);
     }
@@ -54,6 +50,7 @@
         this.name = name;
         this.parameterTypes = Collections.unmodifiableList(new ArrayList(parameterTypes));
         this.methodInvoker = methodInvoker;
+        // this is not used
         this.operationInfo = new GOperationInfo(this.name, this.parameterTypes, "java.lang.Object");
     }
 

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java?view=diff&rev=558235&r1=558234&r2=558235
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/gbean/GBeanInfoTest.java
Fri Jul 20 20:47:45 2007
@@ -85,7 +85,7 @@
 
     public void testGetOperationsSet() {
         Set gbeanOpSet = gbeanInfo.getOperations();
-        assertEquals(1, gbeanOpSet.size());
+        assertEquals(3, gbeanOpSet.size());
         assertTrue(gbeanOpSet.contains(opInfo));
     }
 
@@ -155,7 +155,9 @@
             infoFactory.addAttribute(persistentAttrInfo);
 
             infoFactory.addOperation(opInfo);
-
+            // These two operations are added automatically
+            infoFactory.addOperation("addSomething", new Class[]{String.class}); // ignored
+            infoFactory.addOperation("removeSomething", new Class[]{String.class}); // ignored
             infoFactory.addReference(refInfo);
 
             infoFactory.addAttribute(CONSTRUCTOR_ARG_0, String.class, true);
@@ -175,6 +177,13 @@
         }
 
         public void setReference(String reference) {
+        }
+        
+        public void addSomething(String something){            
+        }
+        
+        public String removeSomething(String something){
+           return null; 
         }
     }
 }

Modified: geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java?view=diff&rev=558235&r1=558234&r2=558235
==============================================================================
--- geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java
(original)
+++ geronimo/server/trunk/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/SimpleGBeanTest.java
Fri Jul 20 20:47:45 2007
@@ -59,7 +59,9 @@
         // invoke GBean by short name
         assertEquals("1234", kernel.getAttribute("MyBean", "value"));
         assertEquals("1234", kernel.invoke("MyBean", "fetchValue"));
-
+        // this does not work without addOperation
+        assertEquals("1234", kernel.invoke("MyBean", "getValue"));
+        
         // invoke GBean by type
         assertEquals("1234", kernel.getAttribute(TestGBean.class, "value"));
         assertEquals("1234", kernel.invoke(TestGBean.class, "fetchValue"));
@@ -96,6 +98,8 @@
         static {
             GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(TestGBean.class);
             infoBuilder.setConstructor(new String[] {"value"});
+            // FIXME : The getters/setters should have been added as an operation
+            infoBuilder.addOperation("getValue");
             GBEAN_INFO = infoBuilder.getBeanInfo();
         }
         public static GBeanInfo getGBeanInfo() {



Mime
View raw message