Author: dkulp
Date: Mon Apr  7 06:05:20 2008
New Revision: 645488

URL: http://svn.apache.org/viewvc?rev=645488&view=rev
Log:
[CXF-1494] Support Spring aop beans in jax-rs.  Patch from Sergey B. applied.

Added:
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
   (with props)
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
   (with props)
    
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
   (with props)
    incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/
    incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/
    
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml   
(with props)
    incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml 
  (with props)
Modified:
    
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
    
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
    
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
    
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
    incubator/cxf/trunk/systests/pom.xml

Modified: 
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
 (original)
+++ 
incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/common/util/ClassHelper.java
 Mon Apr  7 06:05:20 2008
@@ -25,7 +25,13 @@
 public class ClassHelper {
     static final ClassHelper HELPER;
     static {
-        HELPER = new ClassHelper();
+        ClassHelper theHelper = null;
+        try {
+            theHelper = new SpringAopClassHelper();
+        } catch (Exception ex) {
+            theHelper = new ClassHelper();
+        }
+        HELPER = theHelper;
     }
     
     

Modified: 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
 Mon Apr  7 06:05:20 2008
@@ -19,7 +19,6 @@
 package org.apache.cxf.jaxrs;
 
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
@@ -238,27 +237,18 @@
     }
     
     /**
-     * Set the backing service bean. If this is set, JAX-RS runtimi will not be
+     * Set the backing service bean. If this is set, JAX-RS runtime will not be
      * responsible for the lifecycle of resource classes.
      * 
      * @return
      */
     public void setServiceBeans(Object... beans) {
-        this.serviceBeans = new ArrayList<Object>(Arrays.asList(beans));
-        Class[] classes = new Class[beans.length];
-        for (int i = 0; i < beans.length; i++) {
-            classes[i] = beans[i].getClass();
-        }
-        serviceFactory.setResourceClasses(classes);
+        setServiceBeans(Arrays.asList(beans));
     }
     
     public void setServiceBeans(List<Object> beans) {
         this.serviceBeans = beans;
-        List<Class> classes = new ArrayList<Class>();
-        for (Object bean : beans) {
-            classes.add(bean.getClass());
-        }
-        serviceFactory.setResourceClasses(classes);
+        serviceFactory.setResourceClassesFromBeans(beans);
     }
     
     public void setResourceProvider(Class c, ResourceProvider rp) {

Modified: 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
 Mon Apr  7 06:05:20 2008
@@ -29,6 +29,7 @@
 
 import javax.ws.rs.Path;
 
+import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.jaxrs.lifecycle.PerRequestResourceProvider;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.jaxrs.model.ClassResourceInfo;
@@ -48,8 +49,8 @@
     //private static final Logger LOG = 
Logger.getLogger(JAXRSServiceFactoryBean.class.getName());
     //private static final ResourceBundle BUNDLE = 
BundleUtils.getBundle(JAXRSServiceFactoryBean.class);
 
-    protected List<ClassResourceInfo> classResourceInfos;
-    protected List<Class> resourceClasses;
+    protected List<ClassResourceInfo> classResourceInfos = 
+        new ArrayList<ClassResourceInfo>();
     protected Map<Class, ResourceProvider> resourceProviders = new 
HashMap<Class, ResourceProvider>();
     
     private Invoker invoker;
@@ -98,29 +99,45 @@
     }
 
     public List<Class> getResourceClasses() {
+        List<Class> resourceClasses = new ArrayList<Class>();
+        for (ClassResourceInfo cri : classResourceInfos) {
+            resourceClasses.add(cri.getResourceClass());
+        }
         return resourceClasses;
     }
 
     public void setResourceClasses(List<Class> classes) {
-        this.resourceClasses = classes;
+        for (Class resourceClass : classes) {
+            ClassResourceInfo classResourceInfo = 
+                createClassResourceInfo(resourceClass, resourceClass, true);
+            classResourceInfos.add(classResourceInfo);
+        }
     }
 
     public void setResourceClasses(Class... classes) {
-        this.resourceClasses = new ArrayList<Class>(Arrays.asList(classes));
+        setResourceClasses(Arrays.asList(classes));
+    }
+    
+    public void setResourceClassesFromBeans(List<Object> beans) {
+        for (Object bean : beans) {
+            
+            ClassResourceInfo classResourceInfo = 
+                createClassResourceInfo(bean.getClass(), 
+                                        ClassHelper.getRealClass(bean),
+                                            true);
+            classResourceInfos.add(classResourceInfo);
+        }
     }
     
     public void setResourceProvider(Class c, ResourceProvider rp) {
         resourceProviders.put(c, rp);
+        updateClassResourceProviders();
     }
     
     protected void initializeServiceModel() {
-        classResourceInfos = new ArrayList<ClassResourceInfo>();
-
-        for (Class resourceClass : resourceClasses) {
-            ClassResourceInfo classResourceInfo = 
createRootClassResourceInfo(resourceClass);
-            classResourceInfos.add(classResourceInfo);
-        }
-
+        
+        updateClassResourceProviders();
+        
         JAXRSServiceImpl service = new JAXRSServiceImpl(classResourceInfos);
 
         setService(service);
@@ -130,28 +147,26 @@
         }
     }
 
-    protected ClassResourceInfo createRootClassResourceInfo(final Class<?> c) {
-        
-        ClassResourceInfo classResourceInfo = createClassResourceInfo(c, true);
-
-        //TODO: Using information from annotation to determine which lifecycle 
provider to use
-        ResourceProvider rp = resourceProviders.get(c);
-        if (rp != null) {
-            classResourceInfo.setResourceProvider(rp);
-        } else {
-            //default lifecycle is per-request
-            rp = new PerRequestResourceProvider(c);
-            classResourceInfo.setResourceProvider(rp);  
+    private void updateClassResourceProviders() {
+        for (ClassResourceInfo cri : classResourceInfos) {
+            //TODO: Using information from annotation to determine which 
lifecycle provider to use
+            ResourceProvider rp = 
resourceProviders.get(cri.getResourceClass());
+            if (rp != null) {
+                cri.setResourceProvider(rp);
+            } else {
+                //default lifecycle is per-request
+                rp = new PerRequestResourceProvider(cri.getResourceClass());
+                cri.setResourceProvider(rp);  
+            }
         }
-        
-        return classResourceInfo;
     }
-
-    protected ClassResourceInfo createClassResourceInfo(final Class<?> c, 
boolean root) {
-        ClassResourceInfo cri  = new ClassResourceInfo(c, root);
+    
+    protected ClassResourceInfo createClassResourceInfo(
+        final Class<?> rClass, final Class<?> sClass, boolean root) {
+        ClassResourceInfo cri  = new ClassResourceInfo(rClass, sClass, root);
 
         if (root) {
-            URITemplate t = URITemplate.createTemplate(cri, 
c.getAnnotation(Path.class));
+            URITemplate t = URITemplate.createTemplate(cri, cri.getPath());
             cri.setURITemplate(t);
         }
         
@@ -162,7 +177,7 @@
 
     protected MethodDispatcher createOperation(ClassResourceInfo cri) {
         MethodDispatcher md = new MethodDispatcher();
-        for (Method m : cri.getResourceClass().getMethods()) {
+        for (Method m : cri.getServiceClass().getMethods()) {
             
                        
             String httpMethod = JAXRSUtils.getHttpMethodValue(m);
@@ -187,7 +202,8 @@
                 ori.setURITemplate(t);
                 md.bind(ori, m);     
                 Class subResourceClass = m.getReturnType();
-                ClassResourceInfo subCri = 
createClassResourceInfo(subResourceClass, false);
+                ClassResourceInfo subCri = createClassResourceInfo(
+                     subResourceClass, subResourceClass, false);
                 cri.addSubClassResourceInfo(subCri);
             } else if (httpMethod != null) {
                 OperationResourceInfo ori = new OperationResourceInfo(m, cri);

Modified: 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
 Mon Apr  7 06:05:20 2008
@@ -57,7 +57,7 @@
     }
 
     public QName getName() {    
-        Class primaryClass = classResourceInfos.get(0).getResourceClass();
+        Class primaryClass = classResourceInfos.get(0).getServiceClass();
         return new QName("jaxrs", primaryClass.getSimpleName());
     }
 

Modified: 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ClassResourceInfo.java
 Mon Apr  7 06:05:20 2008
@@ -25,6 +25,9 @@
 import java.util.List;
 
 import javax.annotation.Resource;
+import javax.ws.rs.ConsumeMime;
+import javax.ws.rs.Path;
+import javax.ws.rs.ProduceMime;
 import javax.ws.rs.core.Context;
 
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
@@ -33,6 +36,7 @@
     
     private boolean root;
     private Class<?> resourceClass;
+    private Class<?> serviceClass;
     private URITemplate uriTemplate;
     private MethodDispatcher methodDispatcher;
     private ResourceProvider resourceProvider;
@@ -45,7 +49,16 @@
     }
     
     public ClassResourceInfo(Class<?> theResourceClass, boolean theRoot) {
+        this(theResourceClass, theResourceClass, theRoot);
+    }
+    
+    public ClassResourceInfo(Class<?> theResourceClass, Class<?> 
theServiceClass) {
+        this(theResourceClass, theServiceClass, false);
+    }
+    
+    public ClassResourceInfo(Class<?> theResourceClass, Class<?> 
theServiceClass, boolean theRoot) {
         resourceClass = theResourceClass;
+        serviceClass = theServiceClass;
         root = theRoot;
         initHttpContexts();
         initResources();
@@ -58,6 +71,10 @@
     public Class<?> getResourceClass() {
         return resourceClass;
     }
+    
+    public Class<?> getServiceClass() {
+        return serviceClass;
+    }
 
     public URITemplate getURITemplate() {
         return uriTemplate;
@@ -100,7 +117,7 @@
             return;
         }
         httpContexts = new ArrayList<Field>();
-        Field[] fields = resourceClass.getDeclaredFields();
+        Field[] fields = getServiceClass().getDeclaredFields();
         
         for (Field f : fields) {
             Context context = f.getAnnotation(Context.class);
@@ -115,7 +132,7 @@
             return;
         }
         resources = new ArrayList<Field>();
-        Field[] fields = resourceClass.getDeclaredFields();
+        Field[] fields = getServiceClass().getDeclaredFields();
         
         for (Field f : fields) {
             Resource resource = f.getAnnotation(Resource.class);
@@ -125,7 +142,20 @@
         }
     }
 
+    //TODO : check supeclass as well
+    public ProduceMime getProduceMime() {
+        return getServiceClass().getAnnotation(ProduceMime.class);
+    }
     
+    //TODO : check supeclass as well
+    public ConsumeMime getConsumeMime() {
+        return getServiceClass().getAnnotation(ConsumeMime.class);
+    }
+    
+    //TODO : check supeclass as well
+    public Path getPath() {
+        return getServiceClass().getAnnotation(Path.class);
+    }
     
     public List<Field> getHttpContexts() {
         List<Field> ret;

Modified: 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
 (original)
+++ 
incubator/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/OperationResourceInfo.java
 Mon Apr  7 06:05:20 2008
@@ -85,8 +85,7 @@
             return JAXRSUtils.getMediaTypes(pm.value());
         }
         
-        return JAXRSUtils.getProduceTypes(classResourceInfo.getResourceClass()
-                                          .getAnnotation(ProduceMime.class));
+        return JAXRSUtils.getProduceTypes(classResourceInfo.getProduceMime());
     }
     
     public List<MediaType> getConsumeTypes() {
@@ -97,7 +96,6 @@
             return JAXRSUtils.getMediaTypes(pm.value());
         }
         
-        return JAXRSUtils.getConsumeTypes(classResourceInfo.getResourceClass()
-                                          .getAnnotation(ConsumeMime.class));
+        return JAXRSUtils.getConsumeTypes(classResourceInfo.getConsumeMime());
     }
 }

Modified: incubator/cxf/trunk/systests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/pom.xml?rev=645488&r1=645487&r2=645488&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/pom.xml (original)
+++ incubator/cxf/trunk/systests/pom.xml Mon Apr  7 06:05:20 2008
@@ -306,6 +306,30 @@
             <scope>test</scope>
         </dependency>
         <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-aop</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>aspectj</groupId>
+            <artifactId>aspectjrt</artifactId>
+            <version>1.5.4</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>aspectj</groupId>
+            <artifactId>aspectjweaver</artifactId>
+            <version>1.5.4</version>
+            <scope>test</scope>
+        </dependency>  
+        <dependency>
+            <groupId>cglib</groupId>
+            <artifactId>cglib-nodep</artifactId>
+            <version>2.1_3</version>
+            <scope>test</scope>
+        </dependency> 
+        <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-j2ee-management_1.1_spec</artifactId>
             <scope>test</scope>

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java?rev=645488&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
 Mon Apr  7 06:05:20 2008
@@ -0,0 +1,89 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+import java.net.URISyntaxException;
+
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+import org.mortbay.jetty.Connector;
+import org.mortbay.jetty.Handler;
+import org.mortbay.jetty.handler.DefaultHandler;
+import org.mortbay.jetty.handler.HandlerCollection;
+import org.mortbay.jetty.nio.SelectChannelConnector;
+import org.mortbay.jetty.webapp.WebAppContext;
+
+
+public class BookServerProxySpring extends AbstractBusTestServerBase {
+
+    private org.mortbay.jetty.Server server;
+    
+    protected void run() {
+        System.out.println("Starting Server");
+
+        server = new org.mortbay.jetty.Server();
+
+        SelectChannelConnector connector = new SelectChannelConnector();
+        connector.setPort(9080);
+        server.setConnectors(new Connector[] {connector});
+
+        WebAppContext webappcontext = new WebAppContext();
+        String contextPath = null;
+        try {
+            contextPath = 
getClass().getResource("/jaxrs_proxy").toURI().getPath();
+        } catch (URISyntaxException e1) {
+            e1.printStackTrace();
+        }
+        webappcontext.setContextPath("/");
+
+        webappcontext.setWar(contextPath);
+
+        HandlerCollection handlers = new HandlerCollection();
+        handlers.setHandlers(new Handler[] {webappcontext, new 
DefaultHandler()});
+
+        server.setHandler(handlers);
+        try {
+            server.start();
+                       
+        } catch (Exception e) {
+            e.printStackTrace();
+        }     
+    }
+    public void tearDown() throws Exception {
+        super.tearDown();
+        if (server != null) {
+            server.stop();
+            server.destroy();
+            server = null;
+        }
+    }    
+    
+    public static void main(String args[]) {
+        try {
+            BookServerProxySpring s = new BookServerProxySpring();
+            s.start();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+            System.exit(-1);
+        } finally {
+            System.out.println("done!");
+        }
+    }
+
+}

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookServerProxySpring.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java?rev=645488&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
 Mon Apr  7 06:05:20 2008
@@ -0,0 +1,65 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.apache.cxf.helpers.IOUtils;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class JAXRSClientServerProxySpringBookTest extends 
AbstractBusClientServerTestBase {
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        assertTrue("server did not launch correctly", 
+                   launchServer(BookServerProxySpring.class));
+    }
+    
+    @Test
+    public void testGetBook123() throws Exception {
+        String endpointAddress =
+            "http://localhost:9080/bookstore/books/123";; 
+        URL url = new URL(endpointAddress);
+        URLConnection connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/json");
+        InputStream in = connect.getInputStream();           
+
+        InputStream expected = getClass()
+            .getResourceAsStream("resources/expected_get_book123json.txt");
+
+        //System.out.println("---" + getStringFromInputStream(in));
+        assertEquals(getStringFromInputStream(expected), 
getStringFromInputStream(in)); 
+    }
+
+    private String getStringFromInputStream(InputStream in) throws Exception { 
       
+        CachedOutputStream bos = new CachedOutputStream();
+        IOUtils.copy(in, bos);
+        in.close();
+        bos.close();
+        //System.out.println(bos.getOut().toString());        
+        return bos.getOut().toString();        
+    }
+
+}

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerProxySpringBookTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java?rev=645488&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
 (added)
+++ 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
 Mon Apr  7 06:05:20 2008
@@ -0,0 +1,32 @@
+/**
+ * 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.
+ */
+
+package org.apache.cxf.systest.jaxrs;
+
+public class SimpleLoggingAspect {
+    
+    public void logBefore() {
+        System.out.println("AOP in before action");
+    }
+    
+    public void logAfter() {
+        System.out.println("AOP in after action");
+    }
+    
+}

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/SimpleLoggingAspect.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml?rev=645488&view=auto
==============================================================================
--- 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml 
(added)
+++ 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml 
Mon Apr  7 06:05:20 2008
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<!-- START SNIPPET: beans -->
+<!--beans xmlns="http://www.springframework.org/schema/beans";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xmlns:simple="http://cxf.apache.org/simple";
+  xsi:schemaLocation="
+  http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+  http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xmlns:jaxrs="http://cxf.apache.org/jaxrs";
+  xmlns:aop="http://www.springframework.org/schema/aop";
+  xsi:schemaLocation="
+http://www.springframework.org/schema/beans 
+http://www.springframework.org/schema/beans/spring-beans.xsd
+http://www.springframework.org/schema/aop 
+http://www.springframework.org/schema/aop/spring-aop.xsd
+http://cxf.apache.org/jaxrs
+http://cxf.apache.org/schemas/jaxrs.xsd";>
+
+  <import resource="classpath:META-INF/cxf/cxf.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-extension-jaxrs-binding.xml" />
+  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
+  
+  <jaxrs:server id="bookservice"
+                       address="/">
+    <jaxrs:serviceBeans>
+      <ref bean="bookstore"/>
+    </jaxrs:serviceBeans>                 
+  </jaxrs:server>
+  <bean id="bookstore" scope="prototype" 
class="org.apache.cxf.systest.jaxrs.BookStore"/>
+  
+  <aop:config>
+               <aop:aspect id="loggingAspect" ref="simpleLogger">
+                       <aop:before
+                             method="logBefore"
+                             pointcut="execution(* 
org.apache.cxf.systest.jaxrs.BookStore.*(..))"/>
+                       <aop:after-returning
+                             method="logAfter"
+                             pointcut="execution(* 
org.apache.cxf.systest.jaxrs.BookStore.*(..))"/>
+               </aop:aspect>
+       </aop:config>
+
+       <bean id="simpleLogger" 
class="org.apache.cxf.systest.jaxrs.SimpleLoggingAspect"/>
+
+</beans>
+<!-- END SNIPPET: beans -->
+

Propchange: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/beans.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml?rev=645488&view=auto
==============================================================================
--- incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml 
(added)
+++ incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml 
Mon Apr  7 06:05:20 2008
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!DOCTYPE web-app
+    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+    "http://java.sun.com/dtd/web-app_2_3.dtd";>
+<!--
+       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.
+-->
+<!-- START SNIPPET: webxml -->
+<web-app>
+       <context-param>
+               <param-name>contextConfigLocation</param-name>
+               <param-value>WEB-INF/beans.xml</param-value>
+       </context-param>
+
+       <listener>
+               <listener-class>
+                       org.springframework.web.context.ContextLoaderListener
+               </listener-class>
+       </listener>
+
+       <servlet>
+               <servlet-name>CXFServlet</servlet-name>
+               <display-name>CXF Servlet</display-name>
+               <servlet-class>
+                       org.apache.cxf.transport.servlet.CXFServlet
+               </servlet-class>
+               <load-on-startup>1</load-on-startup>
+       </servlet>
+
+       <servlet-mapping>
+               <servlet-name>CXFServlet</servlet-name>
+               <url-pattern>/*</url-pattern>
+       </servlet-mapping>
+</web-app>
+<!-- END SNIPPET: webxml -->

Propchange: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
incubator/cxf/trunk/systests/src/test/resources/jaxrs_proxy/WEB-INF/web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to