tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r984575 - in /openejb/trunk/openejb3/container/openejb-core/src: main/java/org/apache/openejb/util/proxy/ test/java/org/apache/openejb/util/proxy/
Date Wed, 11 Aug 2010 20:49:47 GMT
Author: gawor
Date: Wed Aug 11 20:49:47 2010
New Revision: 984575

URL: http://svn.apache.org/viewvc?rev=984575&view=rev
Log:
proxy all public methods (which includes inherited methods as well)

Added:
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
  (with props)
Modified:
    openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java
    openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/SampleLocalBean.java

Modified: openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java?rev=984575&r1=984574&r2=984575&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImpl.java
Wed Aug 11 20:49:47 2010
@@ -18,6 +18,7 @@ package org.apache.openejb.util.proxy;
 
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
@@ -100,8 +101,12 @@ public class LocalBeanProxyGeneratorImpl
 		mv.visitEnd();
 
 		// loop through public methods, and push something to the class
-		Method[] methods = clsToProxy.getDeclaredMethods();
+		Method[] methods = clsToProxy.getMethods();
 		for (Method method : methods) {
+		    if (Modifier.isFinal(method.getModifiers())) {
+		        // can't proxy final methods
+		        continue;
+		    }
 			processMethod(cw, method, proxyClassName, clsToOverride);
 		}
 		

Added: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java?rev=984575&view=auto
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
(added)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
Wed Aug 11 20:49:47 2010
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.util.proxy;
+
+public class BaseLocalBean {
+
+	public String hello(String name) {
+	    return "Hello " + name;
+	}
+	
+	public final void finalMethod() {	    
+	}
+		
+}

Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/BaseLocalBean.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java?rev=984575&r1=984574&r2=984575&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest.java
Wed Aug 11 20:49:47 2010
@@ -882,7 +882,18 @@ public class LocalBeanProxyGeneratorImpl
         assertEquals("Lorg/apache/openejb/util/proxy/LocalBeanProxyGeneratorImplTest$Color;",
localBeanProxyGenerator.getAsmTypeAsString(Color.class, true));
     }
 
-
+    @Test
+    public void testInheritedMethod() throws Exception {
+        TestInvocationHandler invocationHandler = new TestInvocationHandler(new SampleLocalBean());
+        SampleLocalBean proxy = loadProxy(invocationHandler);
+        String result = proxy.hello("Bob");
+        
+        assertEquals("Hello Bob", result);
+        assertEquals(1, invocationHandler.getCalls().length);
+        Call call = invocationHandler.getCalls()[0];
+        assertEquals("hello", call.getMethodName());
+    }
+    
     public static class EnumParams {
 
         public void someEnumMethod(Color s){

Modified: openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/SampleLocalBean.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/SampleLocalBean.java?rev=984575&r1=984574&r2=984575&view=diff
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/SampleLocalBean.java
(original)
+++ openejb/trunk/openejb3/container/openejb-core/src/test/java/org/apache/openejb/util/proxy/SampleLocalBean.java
Wed Aug 11 20:49:47 2010
@@ -22,9 +22,8 @@ import java.util.List;
 
 import javax.ejb.LocalBean;
 
-
 @LocalBean
-public class SampleLocalBean {
+public class SampleLocalBean extends BaseLocalBean {
 
 	public SampleLocalBean() {
 		super();



Mime
View raw message