Author: ningjiang
Date: Wed Oct 31 20:22:58 2007
New Revision: 590881
URL: http://svn.apache.org/viewvc?rev=590881&view=rev
Log:
CXF-1147 applied the patch ,thanks Jeff
Added:
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
(with props)
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
(with props)
Modified:
incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
Modified:
incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java?rev=590881&r1=590880&r2=590881&view=diff
==============================================================================
---
incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
(original)
+++
incubator/cxf/trunk/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
Wed Oct 31 20:22:58 2007
@@ -20,6 +20,12 @@
import java.io.IOException;
import java.lang.reflect.Constructor;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeMap;
import java.util.logging.Logger;
import javax.security.auth.Subject;
@@ -33,7 +39,9 @@
public class InvocationHandlerFactory {
-
+
+ public static final String JCA_HANDLERS_RESOURCE =
"META-INF/cxf-jca-handlers.properties";
+
private static final Logger LOG =
LogUtils.getL7dLogger(InvocationHandlerFactory.class);
final Class<?>[] handlerChainTypes;
@@ -99,19 +107,33 @@
private Class<?>[] getHandlerChainDefinition() throws IOException,
ClassNotFoundException {
- String[] classNames =
{"org.apache.cxf.jca.cxf.handlers.ProxyInvocationHandler",
-
"org.apache.cxf.jca.cxf.handlers.ObjectMethodInvocationHandler",
-
//"org.apache.cxf.jca.cxf.handlers.SecurityInvocationHandler",
-
//"org.apache.cxf.jca.cxf.handlers.TransactionHandler",
-
"org.apache.cxf.jca.cxf.handlers.InvokingInvocationHandler"};
-
- Class[] classes = new Class[classNames.length];
-
- for (int i = 0; i < classNames.length; i++) {
- LOG.fine("reading handler class: " + classNames[i]);
- classes[i] = getClass().getClassLoader().loadClass(classNames[i]);
+ Map<Long, String> handlersMap = new TreeMap<Long, String>();
+ Enumeration<URL> urls = Thread.currentThread().getContextClassLoader().
+
getResources(JCA_HANDLERS_RESOURCE);
+ while (urls.hasMoreElements()) {
+ URL url = urls.nextElement();
+ loadProperties(handlersMap, url);
+ }
+
+ Class[] handlers = new Class[handlersMap.size()];
+ String[] handlerClasses = new String[handlersMap.size()];
+ handlersMap.values().toArray(handlerClasses);
+ for (int i = 0; i < handlerClasses.length; i++) {
+ LOG.fine("reading handler class: " + handlerClasses[i]);
+ handlers[i] =
getClass().getClassLoader().loadClass(handlerClasses[i]);
+ }
+ return handlers;
+ }
+
+
+ private void loadProperties(Map<Long, String> handlersMap, URL url) throws
IOException {
+ Properties p = new Properties();
+ p.load(url.openStream());
+ Iterator<Object> keys = p.keySet().iterator();
+ while (keys.hasNext()) {
+ String key = (String)keys.next();
+ handlersMap.put(Long.valueOf(key), p.getProperty(key));
}
- return classes;
}
}
Added:
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties?rev=590881&view=auto
==============================================================================
---
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
(added)
+++
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
Wed Oct 31 20:22:58 2007
@@ -0,0 +1,23 @@
+#
+#
+# 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.
+#
+#
+10=org.apache.cxf.jca.cxf.handlers.ProxyInvocationHandler
+20=org.apache.cxf.jca.cxf.handlers.ObjectMethodInvocationHandler
+1000=org.apache.cxf.jca.cxf.handlers.InvokingInvocationHandler
Propchange:
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified:
incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java?rev=590881&r1=590880&r2=590881&view=diff
==============================================================================
---
incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
(original)
+++
incubator/cxf/trunk/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
Wed Oct 31 20:22:58 2007
@@ -18,6 +18,7 @@
*/
package org.apache.cxf.jca.cxf.handlers;
+import java.lang.reflect.Method;
import java.util.HashSet;
import java.util.Set;
@@ -26,10 +27,16 @@
import org.apache.cxf.jca.cxf.CXFInvocationHandler;
+import org.apache.cxf.jca.cxf.CXFInvocationHandlerData;
+import org.junit.Before;
import org.junit.Test;
public class InvocationHandlerFactoryTest extends HandlerTestBase {
+ private CXFInvocationHandler handler;
+
+ private Subject testSubject;
+
public InvocationHandlerFactoryTest() {
super();
}
@@ -38,18 +45,21 @@
super(name);
}
+ @Before
+ public void setUp() {
+ super.setUp();
+ testSubject = new Subject();
+ try {
+ InvocationHandlerFactory factory = new
InvocationHandlerFactory(mockBus, mci);
+ handler = factory.createHandlers(target, testSubject);
+ } catch (ResourceAdapterInternalException e) {
+ fail();
+ }
+ }
+
@Test
- public void testCreateHandlerChain()
- throws ResourceAdapterInternalException {
-
- Subject testSubject = new Subject();
-
- InvocationHandlerFactory factory =
- new InvocationHandlerFactory(
- mockBus,
- mci);
-
- CXFInvocationHandler handler = factory.createHandlers(target,
testSubject);
+ public void testCreateHandlerChain() throws
ResourceAdapterInternalException {
+
CXFInvocationHandler first = handler;
CXFInvocationHandler last = null;
@@ -72,7 +82,7 @@
}
assertNotNull(last);
- assertEquals("must create correct number of handlers", 3, count);
+ assertEquals("must create correct number of handlers", count, 4);
assertTrue("first handler must a ProxyInvocationHandler", first
instanceof ProxyInvocationHandler);
assertTrue("last handler must be an InvokingInvocationHandler",
@@ -87,7 +97,25 @@
}
}
+ @Test
+ public void testOrderedHandlerChain() throws Exception {
+ assertEquals(ProxyInvocationHandler.class, handler.getClass());
+ assertEquals(ObjectMethodInvocationHandler.class,
handler.getNext().getClass());
+ assertEquals(SecurityTestHandler.class,
handler.getNext().getNext().getClass());
+ }
+
+ public static class SecurityTestHandler extends CXFInvocationHandlerBase {
+ public SecurityTestHandler(CXFInvocationHandlerData data) {
+ super(data);
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
+
+ return invokeNext(proxy, method, args);
+ }
+
+ }
}
Added:
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
URL:
http://svn.apache.org/viewvc/incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties?rev=590881&view=auto
==============================================================================
---
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
(added)
+++
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
Wed Oct 31 20:22:58 2007
@@ -0,0 +1,21 @@
+#
+#
+# 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.
+#
+#
+30=org.apache.cxf.jca.cxf.handlers.InvocationHandlerFactoryTest$SecurityTestHandler
\ No newline at end of file
Propchange:
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain