You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/11/02 03:29:53 UTC
svn commit: r591195 - in /incubator/cxf/branches/2.0.x-fixes: ./
integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/
integration/jca/src/main/resources/META-INF/
integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/
integration/jca/...
Author: dkulp
Date: Thu Nov 1 19:29:52 2007
New Revision: 591195
URL: http://svn.apache.org/viewvc?rev=591195&view=rev
Log:
Merged revisions 590881 via svnmerge from
https://svn.apache.org/repos/asf/incubator/cxf/trunk
........
r590881 | ningjiang | 2007-10-31 23:22:58 -0400 (Wed, 31 Oct 2007) | 1 line
CXF-1147 applied the patch ,thanks Jeff
........
Added:
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/resources/META-INF/
- copied from r590881, incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
- copied unchanged from r590881, incubator/cxf/trunk/integration/jca/src/main/resources/META-INF/cxf-jca-handlers.properties
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/resources/META-INF/
- copied from r590881, incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
- copied unchanged from r590881, incubator/cxf/trunk/integration/jca/src/test/resources/META-INF/cxf-jca-handlers.properties
Modified:
incubator/cxf/branches/2.0.x-fixes/ (props changed)
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java?rev=591195&r1=591194&r2=591195&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/main/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactory.java Thu Nov 1 19:29:52 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;
}
}
Modified: incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java?rev=591195&r1=591194&r2=591195&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java (original)
+++ incubator/cxf/branches/2.0.x-fixes/integration/jca/src/test/java/org/apache/cxf/jca/cxf/handlers/InvocationHandlerFactoryTest.java Thu Nov 1 19:29:52 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);
+ }
+
+ }
}