Return-Path: Delivered-To: apmail-incubator-cxf-dev-archive@locus.apache.org Received: (qmail 56017 invoked from network); 4 Oct 2007 12:44:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 4 Oct 2007 12:44:18 -0000 Received: (qmail 17366 invoked by uid 500); 4 Oct 2007 12:44:07 -0000 Delivered-To: apmail-incubator-cxf-dev-archive@incubator.apache.org Received: (qmail 17318 invoked by uid 500); 4 Oct 2007 12:44:07 -0000 Mailing-List: contact cxf-dev-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-dev@incubator.apache.org Received: (qmail 17295 invoked by uid 99); 4 Oct 2007 12:44:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 05:44:07 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 Oct 2007 12:44:07 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1IdQ3O-0006TQ-DW for cxf-dev@incubator.apache.org; Thu, 04 Oct 2007 05:43:46 -0700 Message-ID: <13039052.post@talk.nabble.com> Date: Thu, 4 Oct 2007 05:43:46 -0700 (PDT) From: Willem2 To: cxf-dev@incubator.apache.org Subject: Re: svn commit: r581781 - in /incubator/cxf/trunk: 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/frontend/jaxws/ r In-Reply-To: <200710040659.40165.dkulp@apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: ning.jiang@iona.com References: <200710040659.40165.dkulp@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Hi Dan, The jaxws frond end already has the spring jar dependency. Do we really need to create a sub jaxws module which contains all the spring stuff ? If so we need do the same thing in the simple front end. Willem. dkulp wrote: > > > > This commit makes using jaxws 100% dependent on having the Spring jars. > Thus, I'm -1 on this. The Spring stuff must be localized to the > spring subpackage and the rest needs to work without spring. > > Dan > > > > > On Thursday 04 October 2007, ningjiang@apache.org wrote: >> Author: ningjiang >> Date: Wed Oct 3 22:42:29 2007 >> New Revision: 581781 >> >> URL: http://svn.apache.org/viewvc?rev=581781&view=rev >> Log: >> CXF-1074 using the spring's AOPUtils.getTargetClass() as the resource >> injector target class. >> >> Modified: >> >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>annotation/AnnotationProcessor.java >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>injection/ResourceInjector.java >> incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/ >>injection/ResourceInjectorTest.java >> incubator/cxf/trunk/rt/frontend/jaxws/pom.xml >> >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jax >>ws/JaxWsServerFactoryBean.java >> >> Modified: >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>annotation/AnnotationProcessor.java URL: >> http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/mai >>n/java/org/apache/cxf/common/annotation/AnnotationProcessor.java?rev=58 >>1781&r1=581780&r2=581781&view=diff >> ====================================================================== >>======== --- >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>annotation/AnnotationProcessor.java (original) +++ >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>annotation/AnnotationProcessor.java Wed Oct 3 22:42:29 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> extends Object> targetClass) { >> >> Modified: >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>injection/ResourceInjector.java URL: >> http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/mai >>n/java/org/apache/cxf/common/injection/ResourceInjector.java?rev=581781 >>&r1=581780&r2=581781&view=diff >> ====================================================================== >>======== --- >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>injection/ResourceInjector.java (original) +++ >> incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/ >>injection/ResourceInjector.java Wed Oct 3 22:42:29 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/trunk/common/common/src/test/java/org/apache/cxf/common/ >>injection/ResourceInjectorTest.java URL: >> http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/tes >>t/java/org/apache/cxf/common/injection/ResourceInjectorTest.java?rev=58 >>1781&r1=581780&r2=581781&view=diff >> ====================================================================== >>======== --- >> incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/ >>injection/ResourceInjectorTest.java (original) +++ >> incubator/cxf/trunk/common/common/src/test/java/org/apache/cxf/common/ >>injection/ResourceInjectorTest.java Wed Oct 3 22:42:29 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/trunk/rt/frontend/jaxws/pom.xml >> URL: >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/pom >>.xml?rev=581781&r1=581780&r2=581781&view=diff >> ====================================================================== >>======== --- incubator/cxf/trunk/rt/frontend/jaxws/pom.xml (original) >> +++ incubator/cxf/trunk/rt/frontend/jaxws/pom.xml Wed Oct 3 22:42:29 >> 2007 @@ -107,6 +107,11 @@ >> >> >> org.springframework >> + spring-aop >> + ${spring.version} >> + >> + >> + org.springframework >> spring-web >> test >> ${spring.version} >> >> Modified: >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jax >>ws/JaxWsServerFactoryBean.java URL: >> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src >>/main/java/org/apache/cxf/jaxws/JaxWsServerFactoryBean.java?rev=581781& >>r1=581780&r2=581781&view=diff >> ====================================================================== >>======== --- >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jax >>ws/JaxWsServerFactoryBean.java (original) +++ >> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jax >>ws/JaxWsServerFactoryBean.java Wed Oct 3 22:42:29 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)); }
>>      }
>>  }
> 
> 
> 
> -- 
> J. Daniel Kulp
> Principal Engineer
> IONA
> P: 781-902-8727    C: 508-380-7194
> daniel.kulp@iona.com
> http://www.dankulp.com/blog
> 
> 

-- 
View this message in context: http://www.nabble.com/Re%3A-svn-commit%3A-r581781---in--incubator-cxf-trunk%3A-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-frontend-jaxws--r-tf4568099.html#a13039052
Sent from the cxf-dev mailing list archive at Nabble.com.