You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/02/26 23:09:58 UTC
svn commit: r381178 - in
/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation:
MethodHashMap.java jdk/JDKProxyFactory.java
Author: jsdelfino
Date: Sun Feb 26 14:09:54 2006
New Revision: 381178
URL: http://svn.apache.org/viewcvs?rev=381178&view=rev
Log:
added an implementation of a Map keyed by method which uses JavaIntrospectionHelper to find a matching method - this is a temporary solution to allow methods to be matched based on their signatures instead of strict equality, we'll probably need to change all these maps later to a more specific class that doesn't implement java.util.Map
Added:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java (with props)
Modified:
incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
Added: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java?rev=381178&view=auto
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java (added)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java Sun Feb 26 14:09:54 2006
@@ -0,0 +1,53 @@
+/**
+ *
+ * Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
+ *
+ * Licensed 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.tuscany.core.invocation;
+
+import java.lang.reflect.Method;
+import java.util.HashMap;
+
+import org.apache.tuscany.core.config.JavaIntrospectionHelper;
+
+/**
+ * A HashMap keyed by method
+ */
+public class MethodHashMap extends HashMap {
+
+ /**
+ * Constructs a new MethodHashMap.
+ */
+ public MethodHashMap() {
+ super();
+ }
+
+ /**
+ * Constructs a new MethodHashMap.
+ */
+ public MethodHashMap(int size) {
+ super(size);
+ }
+
+ /**
+ * @see java.util.HashMap#get(java.lang.Object)
+ */
+ public Object get(Object key) {
+ Method method=(Method)key;
+ //FIXME find a more efficient way to find a matching method
+ Method closestMethod=JavaIntrospectionHelper.findClosestMatchingMethod(method.getName(), method.getParameterTypes(), super.keySet());
+ return super.get(closestMethod);
+ }
+
+}
Propchange: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/MethodHashMap.java
------------------------------------------------------------------------------
svn:keywords = Rev,Date
Modified: incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java
URL: http://svn.apache.org/viewcvs/incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java?rev=381178&r1=381177&r2=381178&view=diff
==============================================================================
--- incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java (original)
+++ incubator/tuscany/java/sca/core/src/main/java/org/apache/tuscany/core/invocation/jdk/JDKProxyFactory.java Sun Feb 26 14:09:54 2006
@@ -19,10 +19,10 @@
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.HashMap;
import java.util.Map;
import org.apache.tuscany.core.invocation.InvocationConfiguration;
+import org.apache.tuscany.core.invocation.MethodHashMap;
import org.apache.tuscany.core.invocation.ProxyConfiguration;
import org.apache.tuscany.core.invocation.spi.ProxyFactory;
import org.apache.tuscany.core.invocation.spi.ProxyInitializationException;
@@ -53,7 +53,7 @@
throw new IllegalStateException("Proxy factory in wrong state [" + state + "]");
}
Map<Method, InvocationConfiguration> invocationConfigs = configuration.getInvocationConfigurations();
- methodToInvocationConfig = new HashMap(invocationConfigs.size());
+ methodToInvocationConfig = new MethodHashMap(invocationConfigs.size());
for (Map.Entry entry : invocationConfigs.entrySet()) {
Method method = (Method) entry.getKey();
methodToInvocationConfig.put(method, (InvocationConfiguration) entry.getValue());