dain 2004/01/25 22:50:47
Modified: modules/core project.xml
modules/deployment project.xml
modules/jetty project.xml
modules/kernel project.xml
modules/kernel/src/java/org/apache/geronimo/gbean/jmx
CollectionProxy.java GBeanMBeanReference.java
ProxyMethodInterceptor.java SingleProxy.java
modules/kernel/src/java/org/apache/geronimo/kernel/jmx
InterfaceCallbackFilter.java MBeanProxyFactory.java
modules/maven-plugin project.xml
modules/remoting project.xml
modules/remoting/src/java/org/apache/geronimo/remoting/router
JMXRouter.java
Added: modules/kernel/src/java/org/apache/geronimo/gbean/jmx
ProxyFactory.java
Log:
Updated cglib to 2.0 beta 2
Revision Changes Path
1.41 +3 -3 incubator-geronimo/modules/core/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/core/project.xml,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- project.xml 23 Jan 2004 19:04:48 -0000 1.40
+++ project.xml 26 Jan 2004 06:50:46 -0000 1.41
@@ -172,8 +172,8 @@
</dependency>
<dependency>
- <id>cglib</id>
- <version>HEAD-20031109</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sourceforge.net</url>
<properties>
<runtime>true</runtime>
1.5 +3 -3 incubator-geronimo/modules/deployment/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/deployment/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- project.xml 21 Jan 2004 20:37:39 -0000 1.4
+++ project.xml 26 Jan 2004 06:50:46 -0000 1.5
@@ -44,8 +44,8 @@
</dependency>
<dependency>
- <id>cglib</id>
- <version>HEAD-20031111</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sf.net/</url>
<properties>
<runtime>true</runtime>
1.8 +3 -3 incubator-geronimo/modules/jetty/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/jetty/project.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- project.xml 25 Jan 2004 17:47:37 -0000 1.7
+++ project.xml 26 Jan 2004 06:50:46 -0000 1.8
@@ -190,8 +190,8 @@
</dependency>
<dependency>
- <id>cglib</id>
- <version>HEAD-20031111</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sf.net/</url>
<properties>
<runtime>true</runtime>
1.15 +3 -3 incubator-geronimo/modules/kernel/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/project.xml,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- project.xml 23 Jan 2004 01:00:18 -0000 1.14
+++ project.xml 26 Jan 2004 06:50:46 -0000 1.15
@@ -48,8 +48,8 @@
<!-- Thirdparty -->
<dependency>
- <id>cglib</id>
- <version>HEAD-20031111</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sf.net/</url>
<properties>
<runtime>true</runtime>
1.11 +15 -37
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.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- CollectionProxy.java 25 Jan 2004 21:07:04 -0000 1.10
+++ CollectionProxy.java 26 Jan 2004 06:50:46 -0000 1.11
@@ -55,7 +55,7 @@
*/
package org.apache.geronimo.gbean.jmx;
-import java.lang.reflect.Method;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -74,13 +74,6 @@
import org.apache.geronimo.gbean.ReferenceCollectionListener;
import org.apache.geronimo.gbean.WaitingException;
-import net.sf.cglib.proxy.CallbackFilter;
-import net.sf.cglib.proxy.Callbacks;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.Factory;
-import net.sf.cglib.proxy.SimpleCallbacks;
-import net.sf.cglib.core.CodeGenerationException;
-
/**
*
*
@@ -117,7 +110,7 @@
/**
* Facotry for proxy instances.
*/
- private Factory factory;
+ private ProxyFactory factory;
/**
* Is this proxy currently stopped?
@@ -127,26 +120,7 @@
public CollectionProxy(GBeanMBean gmbean, String name, Class type) {
this.gmbean = gmbean;
this.name = name;
- Enhancer enhancer = new Enhancer();
- if (type.isInterface()) {
- enhancer.setSuperclass(Object.class);
- enhancer.setInterfaces(new Class[]{type});
- } else {
- enhancer.setSuperclass(type);
- }
- enhancer.setCallbackFilter(new CallbackFilter() {
- public int accept(Method method) {
- return Callbacks.INTERCEPT;
- }
- });
- enhancer.setCallbacks(new SimpleCallbacks());
- enhancer.setClassLoader(type.getClassLoader());
- 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;
- }
+ factory = new ProxyFactory(type);
}
public synchronized void destroy() {
@@ -175,13 +149,17 @@
public synchronized void addTarget(ObjectName target) {
// if this is a new target...
if (!proxies.containsKey(target)) {
- ProxyMethodInterceptor interceptor = new
ProxyMethodInterceptor(factory.getClass());
- interceptor.connect(gmbean.getServer(), target,
proxy.isStopped());
- interceptors.put(target, interceptor);
- Factory targetProxy = factory.newInstance(interceptor);
- proxies.put(target, targetProxy);
- if (!stopped) {
- proxy.fireMemberAdddedEvent(targetProxy);
+ try {
+ ProxyMethodInterceptor interceptor = new
ProxyMethodInterceptor(factory.getType());
+ interceptor.connect(gmbean.getServer(), target,
proxy.isStopped());
+ interceptors.put(target, interceptor);
+ proxies.put(target, factory.create(interceptor));
+ if (!stopped) {
+ proxy.fireMemberAdddedEvent(target);
+ }
+ } catch (InvocationTargetException e) {
+ log.info("Could not create optional proxy to mbean:
objectName=" + target);
+
}
}
}
1.2 +5 -9
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanReference.java
Index: GBeanMBeanReference.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/GBeanMBeanReference.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- GBeanMBeanReference.java 25 Jan 2004 21:07:04 -0000 1.1
+++ GBeanMBeanReference.java 26 Jan 2004 06:50:46 -0000 1.2
@@ -55,7 +55,6 @@
*/
package org.apache.geronimo.gbean.jmx;
-import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collection;
@@ -71,14 +70,13 @@
import javax.management.NotificationFilterSupport;
import javax.management.NotificationListener;
import javax.management.ObjectName;
-import javax.management.ReflectionException;
-import org.apache.geronimo.kernel.jmx.JMXUtil;
-import org.apache.geronimo.kernel.management.NotificationType;
-import org.apache.geronimo.kernel.management.State;
import org.apache.geronimo.gbean.GReferenceInfo;
import org.apache.geronimo.gbean.InvalidConfigurationException;
import org.apache.geronimo.gbean.WaitingException;
+import org.apache.geronimo.kernel.jmx.JMXUtil;
+import org.apache.geronimo.kernel.management.NotificationType;
+import org.apache.geronimo.kernel.management.State;
/**
*
@@ -188,7 +186,7 @@
}
}
- public synchronized void online() throws ReflectionException {
+ public synchronized void online() throws Exception {
// create the proxy
if (singleValued) {
proxy = new SingleProxy(gmbean, name, type, patterns);
@@ -237,8 +235,6 @@
try {
Thread.currentThread().setContextClassLoader(gmbean.getClassLoader());
setInvoker.invoke(gmbean.getTarget(), new
Object[]{proxy.getProxy()});
- } catch (Throwable throwable) {
- throw new ReflectionException(new
InvocationTargetException(throwable));
} finally {
Thread.currentThread().setContextClassLoader(oldClassLoader);
}
1.5 +17 -37
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyMethodInterceptor.java
Index: ProxyMethodInterceptor.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyMethodInterceptor.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ProxyMethodInterceptor.java 23 Jan 2004 16:43:39 -0000 1.4
+++ ProxyMethodInterceptor.java 26 Jan 2004 06:50:46 -0000 1.5
@@ -56,7 +56,6 @@
package org.apache.geronimo.gbean.jmx;
import java.lang.reflect.Method;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.management.MBeanAttributeInfo;
@@ -68,9 +67,11 @@
import org.apache.geronimo.kernel.jmx.InvokeMBean;
import org.apache.geronimo.kernel.jmx.MBeanOperationSignature;
+import net.sf.cglib.core.Signature;
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import net.sf.cglib.reflect.FastClass;
+import org.objectweb.asm.Type;
/**
*
@@ -156,7 +157,7 @@
}
InvokeMBean invoker = methodTable[proxy.getSuperIndex()];
if (invoker == null) {
- throw new NoSuchOperationError("No implementation method for
"+method);
+ throw new NoSuchOperationError("No implementation method for " +
method);
}
return invoker.invoke(server, objectName, args);
}
@@ -191,7 +192,7 @@
Method[] methods = proxyType.getMethods();
for (int i = 0; i < methods.length; i++) {
Method method = methods[i];
- int index = getSuperIndex(fastClass, method);
+ int index = getSuperIndex(proxyType, method);
if (index >= 0) {
if (operations.containsKey(new
MBeanOperationSignature(method))) {
methodTable[index] = new InvokeMBean(method, false,
false);
@@ -207,9 +208,9 @@
// handle equals, hashCode and toString directly here
try {
- methodTable[getSuperIndex(fastClass,
proxyType.getMethod("equals", new Class[]{Object.class}))] = new EqualsInvoke();
- methodTable[getSuperIndex(fastClass,
proxyType.getMethod("hashCode", null))] = new HashCodeInvoke();
- methodTable[getSuperIndex(fastClass,
proxyType.getMethod("toString", null))] = new
ToStringInvoke(proxyType.getName());
+ methodTable[getSuperIndex(proxyType,
proxyType.getMethod("equals", new Class[]{Object.class}))] = new EqualsInvoke();
+ methodTable[getSuperIndex(proxyType,
proxyType.getMethod("hashCode", null))] = new HashCodeInvoke();
+ methodTable[getSuperIndex(proxyType,
proxyType.getMethod("toString", null))] = new
ToStringInvoke(proxyType.getName());
} catch (Exception e) {
System.out.println("Missing method for " + proxyType + " object
name " + objectName);
// this can not happen... all classes must implement equals,
hashCode and toString
@@ -219,6 +220,15 @@
return methodTable;
}
+ private static int getSuperIndex(Class proxyType, Method method) {
+ Signature signature = new Signature(method.getName(),
Type.getReturnType(method), Type.getArgumentTypes(method));
+ MethodProxy methodProxy = MethodProxy.find(proxyType, signature);
+ if (methodProxy != null) {
+ return methodProxy.getSuperIndex();
+ }
+ return -1;
+ }
+
private static final class HashCodeInvoke extends InvokeMBean {
public HashCodeInvoke() {
super("hashCode", new String[0], new Class[0], false, false, 0);
@@ -250,35 +260,5 @@
public Object invoke(MBeanServer server, ObjectName objectName,
Object[] arguments) throws Throwable {
return interfaceName + objectName + "]";
}
- }
-
-
- private static String ACCESS_PREFIX = "CGLIB$$ACCESS_";
-
- /**
- * Returns the name of the synthetic method created by CGLIB which is
- * used by invokesuper to invoke the superclass
- * (non-intercepted) method implementation. The parameter types are
- * guaranteed to be the same.
- * @param enhancedClass the class generated by Enhancer
- * @param method the original method; only the name and parameter types
are used.
- * @return the name of the synthetic proxy method, or null if no
matching method can be found
- */
- private static int getSuperIndex(FastClass enhancedClass, Method method)
{
- String prefix = ACCESS_PREFIX + method.getName() + "_";
- int lastUnderscore = prefix.length() - 1;
- Class[] params = method.getParameterTypes();
-
- Method[] methods = enhancedClass.getJavaClass().getDeclaredMethods();
- for (int i = 0; i < methods.length; i++) {
- String name = methods[i].getName();
- Class[] parameterTypes = methods[i].getParameterTypes();
- if (name.startsWith(prefix) &&
- name.lastIndexOf('_') == lastUnderscore &&
- Arrays.equals(parameterTypes, params)) {
- return enhancedClass.getIndex(name, parameterTypes);
- }
- }
- return -1;
}
}
1.8 +6 -33
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/SingleProxy.java
Index: SingleProxy.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/SingleProxy.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- SingleProxy.java 25 Jan 2004 21:07:04 -0000 1.7
+++ SingleProxy.java 26 Jan 2004 06:50:46 -0000 1.8
@@ -55,7 +55,6 @@
*/
package org.apache.geronimo.gbean.jmx;
-import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
import javax.management.ObjectName;
@@ -65,13 +64,6 @@
import org.apache.geronimo.gbean.WaitingException;
import org.apache.geronimo.kernel.management.State;
-import net.sf.cglib.proxy.CallbackFilter;
-import net.sf.cglib.proxy.Callbacks;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.Factory;
-import net.sf.cglib.proxy.SimpleCallbacks;
-import net.sf.cglib.core.CodeGenerationException;
-
/**
*
*
@@ -79,6 +71,7 @@
*/
public class SingleProxy implements Proxy {
private static final Log log = LogFactory.getLog(SingleProxy.class);
+
/**
* The GBeanMBean to which this proxy belongs.
*/
@@ -116,33 +109,13 @@
*/
private ProxyMethodInterceptor methodInterceptor;
- public SingleProxy(GBeanMBean gmbean, String name, Class type, Set
patterns) {
+ public SingleProxy(GBeanMBean gmbean, String name, Class type, Set
patterns) throws Exception {
this.gmbean = gmbean;
this.name = name;
this.patterns = patterns;
- Enhancer enhancer = new Enhancer();
- if (type.isInterface()) {
- enhancer.setSuperclass(Object.class);
- enhancer.setInterfaces(new Class[]{type});
- } else {
- enhancer.setSuperclass(type);
- }
- enhancer.setCallbackFilter(new CallbackFilter() {
- public int accept(Method method) {
- return Callbacks.INTERCEPT;
- }
- });
- enhancer.setCallbacks(new SimpleCallbacks());
- enhancer.setClassLoader(type.getClassLoader());
- Factory factory = null;
- 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;
- }
- methodInterceptor = new ProxyMethodInterceptor(factory.getClass());
- proxy = factory.newInstance(methodInterceptor);
+ ProxyFactory factory = new ProxyFactory(type);
+ methodInterceptor = new ProxyMethodInterceptor(factory.getType());
+ proxy = factory.create(methodInterceptor);
}
public synchronized void destroy() {
1.1
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/gbean/jmx/ProxyFactory.java
Index: ProxyFactory.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.gbean.jmx;
import java.lang.reflect.InvocationTargetException;
import net.sf.cglib.proxy.Callback;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.MethodInterceptor;
/**
*
*
* @version $Revision: 1.1 $ $Date: 2004/01/26 06:50:46 $
*/
public class ProxyFactory {
private final Class type;
private final Enhancer enhancer;
public ProxyFactory(Class type) {
enhancer = new Enhancer();
enhancer.setSuperclass(type);
enhancer.setCallbackType(MethodInterceptor.class);
enhancer.setUseFactory(false);
this.type = enhancer.createClass();
}
public Class getType() {
return type;
}
public Object create(MethodInterceptor methodInterceptor) throws
InvocationTargetException {
return create(methodInterceptor, new Class[0], new Object[0]);
}
public synchronized Object create(MethodInterceptor methodInterceptor,
Class[] types, Object[] arguments) throws InvocationTargetException {
enhancer.setCallbacks(new Callback[]{methodInterceptor});
return enhancer.create(types, arguments);
}
}
1.3 +5 -7
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/InterfaceCallbackFilter.java
Index: InterfaceCallbackFilter.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/InterfaceCallbackFilter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- InterfaceCallbackFilter.java 9 Nov 2003 19:56:55 -0000 1.2
+++ InterfaceCallbackFilter.java 26 Jan 2004 06:50:47 -0000 1.3
@@ -59,18 +59,16 @@
import java.util.HashSet;
import java.util.Set;
-import net.sf.cglib.proxy.Callbacks;
-import net.sf.cglib.proxy.SimpleFilter;
+import net.sf.cglib.proxy.CallbackFilter;
/**
*
*
* @version $Revision$ $Date$
*/
-public final class InterfaceCallbackFilter extends SimpleFilter {
+public final class InterfaceCallbackFilter implements CallbackFilter {
private final Set methodSet;
public InterfaceCallbackFilter(Class iface) {
- super(Callbacks.INTERCEPT);
Method[] methods = iface.getMethods();
methodSet = new HashSet(methods.length);
for (int i = 0; i < methods.length; i++) {
@@ -81,9 +79,9 @@
public int accept(Method method) {
if(methodSet.contains(new MBeanOperationSignature(method))) {
- return Callbacks.INTERCEPT;
+ return 1;
}
- return Callbacks.NO_OP;
+ return 0;
}
}
1.6 +11 -70
incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java
Index: MBeanProxyFactory.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/jmx/MBeanProxyFactory.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- MBeanProxyFactory.java 11 Nov 2003 20:22:36 -0000 1.5
+++ MBeanProxyFactory.java 26 Jan 2004 06:50:47 -0000 1.6
@@ -55,23 +55,12 @@
*/
package org.apache.geronimo.kernel.jmx;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
import java.util.Set;
-import javax.management.MBeanAttributeInfo;
-import javax.management.MBeanInfo;
-import javax.management.MBeanOperationInfo;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.Factory;
-import net.sf.cglib.proxy.SimpleCallbacks;
-import net.sf.cglib.proxy.MethodProxy;
-import net.sf.cglib.proxy.CallbackFilter;
-import net.sf.cglib.proxy.Callbacks;
-import net.sf.cglib.reflect.FastClass;
+import org.apache.geronimo.gbean.jmx.ProxyFactory;
+import org.apache.geronimo.gbean.jmx.ProxyMethodInterceptor;
/**
* MBeanProxyFactory creates a dynamic proxy to an MBean by ObjectName.
@@ -84,27 +73,16 @@
/**
* Creates an MBean proxy using the specified interface to the
objectName.
*
- * @param iface the interface to implement for this proxy
+ * @param type the interface to implement for this proxy
* @param server the MBeanServer in which the object is registered
* @param objectName the objectName of the MBean to proxy
* @return the new MBean proxy, which implemnts the specified interface
*/
- public static Object getProxy(Class iface, MBeanServer server,
ObjectName objectName) {
- assert iface != null;
- assert iface.isInterface();
+ public static Object getProxy(Class type, MBeanServer server, ObjectName
objectName) throws Exception {
+ assert type != null;
+ assert type.isInterface();
assert server != null;
- // get the factory
- Enhancer enhancer = new Enhancer();
- enhancer.setSuperclass(Object.class);
- enhancer.setInterfaces(new Class[]{iface});
- enhancer.setCallbackFilter(new InterfaceCallbackFilter(iface));
- enhancer.setCallbacks(new SimpleCallbacks());
- enhancer.setClassLoader(iface.getClassLoader());
-
- Factory factory = enhancer.create();
-
- // build the method table
if (objectName.isPattern()) {
Set names = server.queryNames(objectName, null);
if (names.isEmpty()) {
@@ -113,46 +91,9 @@
objectName = (ObjectName) names.iterator().next();
}
- MBeanInfo info = null;
- try {
- info = server.getMBeanInfo(objectName);
- } catch (Exception e) {
- throw new IllegalArgumentException("Could not get MBeanInfo for
target object: " + objectName);
- }
-
- MBeanAttributeInfo[] attributeInfos = info.getAttributes();
- Map attributes = new HashMap(attributeInfos.length);
- for (int i = 0; i < attributeInfos.length; i++) {
- MBeanAttributeInfo attributeInfo = attributeInfos[i];
- attributes.put(attributeInfo.getName(), attributeInfo);
- }
-
- MBeanOperationInfo[] operationInfos = info.getOperations();
- Map operations = new HashMap(operationInfos.length);
- for (int i = 0; i < operationInfos.length; i++) {
- MBeanOperationInfo operationInfo = operationInfos[i];
- operations.put(new MBeanOperationSignature(operationInfo),
operationInfo);
- }
-
- FastClass fastClass = FastClass.create(factory.newInstance(new
SimpleCallbacks()).getClass());
- InvokeMBean[] methodTable = new InvokeMBean[fastClass.getMaxIndex()
+ 1];
- Method[] methods = fastClass.getJavaClass().getMethods();
- for (int i = 0; i < methods.length; i++) {
- Method method = methods[i];
- String superName =
MethodProxy.getSuperName(fastClass.getJavaClass(), method);
- if (superName != null) {
- int index = fastClass.getIndex(superName,
method.getParameterTypes());
- if (operations.containsKey(new
MBeanOperationSignature(method))) {
- methodTable[index] = new InvokeMBean(method, false,
false);
- } else if (method.getName().startsWith("get") &&
attributes.containsKey(method.getName().substring(3))) {
- methodTable[index] = new InvokeMBean(method, true, true);
- } else if (method.getName().startsWith("is") &&
attributes.containsKey(method.getName().substring(2))) {
- methodTable[index] = new InvokeMBean(method, true, true);
- } else if (method.getName().startsWith("set") &&
attributes.containsKey(method.getName().substring(3))) {
- methodTable[index] = new InvokeMBean(method, true,
false);
- }
- }
- }
- return factory.newInstance(new MBeanProxyCallback(methodTable,
server, objectName));
+ ProxyFactory factory = new ProxyFactory(type);
+ ProxyMethodInterceptor methodInterceptor = new
ProxyMethodInterceptor(factory.getType());
+ methodInterceptor.connect(server, objectName);
+ return factory.create(methodInterceptor);
}
}
1.2 +2 -2 incubator-geronimo/modules/maven-plugin/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/maven-plugin/project.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- project.xml 24 Jan 2004 19:50:04 -0000 1.1
+++ project.xml 26 Jan 2004 06:50:47 -0000 1.2
@@ -79,8 +79,8 @@
</dependency>
<dependency>
- <id>cglib</id>
- <version>HEAD-20031109</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sourceforge.net</url>
<properties>
<classloader>root</classloader>
1.5 +3 -3 incubator-geronimo/modules/remoting/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/remoting/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- project.xml 23 Jan 2004 01:23:26 -0000 1.4
+++ project.xml 26 Jan 2004 06:50:47 -0000 1.5
@@ -93,8 +93,8 @@
</dependency>
<dependency>
- <id>cglib</id>
- <version>HEAD-20031111</version>
+ <id>cglib+full</id>
+ <version>2.0-RC2</version>
<url>http://cglib.sf.net/</url>
<properties>
<runtime>true</runtime>
1.7 +2 -2
incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/router/JMXRouter.java
Index: JMXRouter.java
===================================================================
RCS file:
/home/cvs/incubator-geronimo/modules/remoting/src/java/org/apache/geronimo/remoting/router/JMXRouter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- JMXRouter.java 25 Jan 2004 21:07:04 -0000 1.6
+++ JMXRouter.java 26 Jan 2004 06:50:47 -0000 1.7
@@ -87,7 +87,7 @@
this.subsystemRouter = subsystemRouter;
}
- protected Interceptor lookupInterceptorFrom(URI to) throws
MalformedObjectNameException {
+ protected Interceptor lookupInterceptorFrom(URI to) throws Exception {
ObjectName on = new ObjectName(to.getFragment());
JMXTarget bean = (JMXTarget)
MBeanProxyFactory.getProxy(JMXTarget.class, context.getServer(), on);
return bean.getRemotingEndpointInterceptor();