Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 13259 invoked from network); 1 Nov 2007 03:23:20 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 Nov 2007 03:23:20 -0000 Received: (qmail 83645 invoked by uid 500); 1 Nov 2007 03:23:08 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 83614 invoked by uid 500); 1 Nov 2007 03:23:08 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 83605 invoked by uid 99); 1 Nov 2007 03:23:08 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 31 Oct 2007 20:23:08 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 01 Nov 2007 03:23:19 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3AD1B1A983A; Wed, 31 Oct 2007 20:22:59 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r590881 - in /incubator/cxf/trunk/integration/jca/src: main/java/org/apache/cxf/jca/cxf/handlers/ main/resources/META-INF/ test/java/org/apache/cxf/jca/cxf/handlers/ test/resources/META-INF/ Date: Thu, 01 Nov 2007 03:22:58 -0000 To: cxf-commits@incubator.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071101032259.3AD1B1A983A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 handlersMap = new TreeMap(); + Enumeration 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 handlersMap, URL url) throws IOException { + Properties p = new Properties(); + p.load(url.openStream()); + Iterator 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