Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 76093 invoked from network); 8 Oct 2007 19:02:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Oct 2007 19:02:03 -0000 Received: (qmail 63582 invoked by uid 500); 8 Oct 2007 19:01:39 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 63536 invoked by uid 500); 8 Oct 2007 19:01:39 -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 63526 invoked by uid 99); 8 Oct 2007 19:01:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Oct 2007 12:01:39 -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; Mon, 08 Oct 2007 19:01:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7A77E1A9832; Mon, 8 Oct 2007 12:00:52 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r582939 - in /incubator/cxf/branches/2.0.x-fixes: ./ common/common/src/main/java/org/apache/cxf/common/annotation/ common/common/src/main/java/org/apache/cxf/common/injection/ common/common/src/test/java/org/apache/cxf/common/injection/ rt/... Date: Mon, 08 Oct 2007 19:00:51 -0000 To: cxf-commits@incubator.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071008190052.7A77E1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Mon Oct 8 12:00:50 2007 New Revision: 582939 URL: http://svn.apache.org/viewvc?rev=582939&view=rev Log: Merged revisions 581781 via svnmerge from https://svn.apache.org/repos/asf/incubator/cxf/trunk ........ r581781 | ningjiang | 2007-10-04 01:42:29 -0400 (Thu, 04 Oct 2007) | 1 line CXF-1074 using the spring's AOPUtils.getTargetClass() as the resource injector target class. ........ Modified: incubator/cxf/branches/2.0.x-fixes/ (props changed) incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/pom.xml incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Propchange: incubator/cxf/branches/2.0.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java?rev=582939&r1=582938&r2=582939&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java (original) +++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/annotation/AnnotationProcessor.java Mon Oct 8 12:00:50 2007 @@ -74,9 +74,9 @@ * Visits each of the annotated elements of the object. * * @param visitor a visitor - * + * @param claz the Class of the targe object */ - public void accept(AnnotationVisitor visitor) { + public void accept(AnnotationVisitor visitor, Class claz) { if (visitor == null) { throw new IllegalArgumentException(); @@ -85,10 +85,14 @@ annotationTypes = visitor.getTargetAnnotations(); visitor.setTarget(target); //recursively check annotation in super class - processClass(visitor, target.getClass()); - processFields(visitor, target.getClass()); - processMethods(visitor, target.getClass()); + processClass(visitor, claz); + processFields(visitor, claz); + processMethods(visitor, claz); } + + public void accept(AnnotationVisitor visitor) { + accept(visitor, target.getClass()); + } private void processMethods(AnnotationVisitor visitor, Class targetClass) { Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=582939&r1=582938&r2=582939&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java (original) +++ incubator/cxf/branches/2.0.x-fixes/common/common/src/main/java/org/apache/cxf/common/injection/ResourceInjector.java Mon Oct 8 12:00:50 2007 @@ -52,6 +52,7 @@ private static final List> ANNOTATIONS = new ArrayList>(); + static { ANNOTATIONS.add(Resource.class); ANNOTATIONS.add(Resources.class); @@ -71,11 +72,13 @@ } - public void inject(Object o) { - + public void inject(Object o) { + inject(o, o.getClass()); + } + + public void inject(Object o, Class claz) { AnnotationProcessor processor = new AnnotationProcessor(o); - processor.accept(this); - + processor.accept(this, claz); invokePostConstruct(); } @@ -377,4 +380,5 @@ private Object resolveResource(String resourceName, Class type) { return resourceManager.resolveResource(resourceName, type, resourceResolvers); } + } Modified: incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java?rev=582939&r1=582938&r2=582939&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java (original) +++ incubator/cxf/branches/2.0.x-fixes/common/common/src/test/java/org/apache/cxf/common/injection/ResourceInjectorTest.java Mon Oct 8 12:00:50 2007 @@ -19,7 +19,8 @@ package org.apache.cxf.common.injection; - +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.List; @@ -29,6 +30,10 @@ import javax.annotation.Resource; import javax.annotation.Resources; +import net.sf.cglib.proxy.Enhancer; +import net.sf.cglib.proxy.MethodInterceptor; +import net.sf.cglib.proxy.MethodProxy; + import org.apache.cxf.resource.ResourceManager; import org.apache.cxf.resource.ResourceResolver; @@ -64,6 +69,7 @@ doInjectTest(new FieldTarget()); } + @Test public void testFieldInSuperClassInjection() { setUpResourceManager("org.apache.cxf.common.injection.FieldTarget/"); @@ -81,6 +87,12 @@ setUpResourceManager(SetterTarget.class.getCanonicalName() + "/"); doInjectTest(new SetterTarget()); } + + @Test + public void testProxyInjection() { + setUpResourceManager(FieldTarget.class.getCanonicalName() + "/"); + doInjectTest(getProxyObject()); + } @Test public void testClassLevelInjection() { @@ -111,15 +123,23 @@ assertTrue(target.preDestroyCalled()); } - protected void doInjectTest(Target target) { - - injector.inject(target); + protected void doInjectTest(Target target) { + injector.inject(target); assertNotNull(target.getResource1()); assertEquals(RESOURCE_ONE, target.getResource1()); assertNotNull(target.getResource2()); - assertEquals(RESOURCE_TWO, target.getResource2()); + assertEquals(RESOURCE_TWO, target.getResource2()); + + } + + + private FieldTarget getProxyObject() { + Enhancer e = new Enhancer(); + e.setSuperclass(FieldTarget.class); + e.setCallback(new CallInterceptor()); + return (FieldTarget)e.create(); } } @@ -130,6 +150,17 @@ String getResource2(); } +class CallInterceptor implements MethodInterceptor { + + public Object intercept(Object obj, Method method, Object[] args, MethodProxy proxy) throws Throwable { + Object retValFromSuper = null; + if (!Modifier.isAbstract(method.getModifiers())) { + retValFromSuper = proxy.invokeSuper(obj, args); + } + return retValFromSuper; + } +} + class FieldTarget implements Target { @@ -228,7 +259,8 @@ @Resource(name = "resource1") class ClassTarget implements Target { - @Resource(name = "resource2") public String resource2foo; + @Resource(name = "resource2") + public String resource2foo; private String res1; public final void setResource1(String res) { Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/pom.xml URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/pom.xml?rev=582939&r1=582938&r2=582939&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/pom.xml (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/pom.xml Mon Oct 8 12:00:50 2007 @@ -107,6 +107,11 @@ org.springframework + spring-aop + ${spring.version} + + + org.springframework spring-web test ${spring.version} Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=582939&r1=582938&r2=582939&view=diff ============================================================================== --- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java (original) +++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java Mon Oct 8 12:00:50 2007 @@ -45,6 +45,8 @@ import org.apache.cxf.service.invoker.Invoker; import org.apache.cxf.service.model.BindingInfo; +import org.springframework.aop.support.AopUtils; + /** * Bean to help easily create Server endpoints for JAX-WS. Example: *
@@ -196,7 +198,7 @@
             resourceManager = new DefaultResourceManager(resolvers); 
             resourceManager.addResourceResolver(new WebServiceContextResourceResolver());
             ResourceInjector injector = new ResourceInjector(resourceManager);
-            injector.inject(instance);
+            injector.inject(instance, AopUtils.getTargetClass(instance));
         }
     }  
 }