cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r892664 - in /cxf/trunk/rt/frontend/jaxrs/src: main/java/org/apache/cxf/jaxrs/ main/java/org/apache/cxf/jaxrs/client/ main/java/org/apache/cxf/jaxrs/interceptor/ main/java/org/apache/cxf/jaxrs/spring/ main/resources/schemas/ test/java/org/a...
Date Sun, 20 Dec 2009 21:29:51 GMT
Author: sergeyb
Date: Sun Dec 20 21:29:50 2009
New Revision: 892664

URL: http://svn.apache.org/viewvc?rev=892664&view=rev
Log:
JAX-RS : support for serviceName attributes

Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanDefinitionParser.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
    cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml
    cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
Sun Dec 20 21:29:50 2009
@@ -84,6 +84,7 @@
         try {
             checkResources(true);
             if (serviceFactory.getService() == null) {
+                serviceFactory.setServiceName(getServiceName());
                 serviceFactory.create();
                 updateClassResourceProviders();
             }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Sun Dec 20 21:29:50 2009
@@ -28,6 +28,7 @@
 import java.util.concurrent.Executor;
 
 import javax.ws.rs.Path;
+import javax.xml.namespace.QName;
 
 import org.apache.cxf.common.util.ClassHelper;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
@@ -53,10 +54,14 @@
     private Executor executor;
     private Map<String, Object> properties;
     private boolean enableStatic;
+    private QName serviceName;
     
     public JAXRSServiceFactoryBean() {
     }
 
+    public void setServiceName(QName name) {
+        this.serviceName = name;
+    }
     
     public void setEnableStaticResolution(boolean staticResolution) {
         this.enableStatic = staticResolution;
@@ -222,7 +227,7 @@
     
     protected void initializeServiceModel() {
         
-        JAXRSServiceImpl service = new JAXRSServiceImpl(classResourceInfos);
+        JAXRSServiceImpl service = new JAXRSServiceImpl(classResourceInfos, serviceName);
 
         setService(service);
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceImpl.java Sun
Dec 20 21:29:50 2009
@@ -59,22 +59,26 @@
     private Map<QName, Endpoint> endpoints = new HashMap<QName, Endpoint>();
     private String address;
     private boolean createServiceModel;
+    private QName serviceName;
     
-    public JAXRSServiceImpl() {
-    }
-    
-    public JAXRSServiceImpl(String address) {
+    public JAXRSServiceImpl(String address, QName qname) {
         this.address = address;
+        this.serviceName = qname;
     }
 
-    public JAXRSServiceImpl(List<ClassResourceInfo> cri) {
+    public JAXRSServiceImpl(List<ClassResourceInfo> cri, QName qname) {
         this.classResourceInfos = cri;
         executor = SynchronousExecutor.getInstance();    
+        this.serviceName = qname;
     }
     
-    public JAXRSServiceImpl(List<ClassResourceInfo> cri, boolean createModel) {
-        this(cri);
-        this.createServiceModel = createModel;
+    public JAXRSServiceImpl(List<ClassResourceInfo> cri) {
+        this(cri, null);
+    }
+    
+    public JAXRSServiceImpl(List<ClassResourceInfo> cri, boolean create) {
+        this(cri, null);
+        createServiceModel = true;
     }
     
     public void setCreateServiceModel(boolean create) {
@@ -86,6 +90,9 @@
     }
 
     public QName getName() {
+        if (serviceName != null) {
+            return serviceName;
+        }
         if (address == null) {
             Class primaryClass = classResourceInfos.get(0).getServiceClass();
             String ns = PackageUtils.getNamespace(PackageUtils.getPackageName(primaryClass));

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/JAXRSClientFactoryBean.java
Sun Dec 20 21:29:50 2009
@@ -103,7 +103,7 @@
     
     public WebClient createWebClient() {
         
-        Service service = new JAXRSServiceImpl(getAddress());
+        Service service = new JAXRSServiceImpl(getAddress(), getServiceName());
         getServiceFactory().setService(service);
         
         try {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Sun Dec 20 21:29:50 2009
@@ -148,7 +148,7 @@
                     ori = JAXRSUtils.findTargetMethod(resource, 
                         message, httpMethod, values, 
                         requestContentType, acceptContentTypes, false);
-                    setMessageProperties(message, ori, values);
+                    setMessageProperties(message, ori, values, resources.size());
                 } catch (WebApplicationException ex) {
                     operChecked = true;
                 }
@@ -178,7 +178,7 @@
             try {                
                 ori = JAXRSUtils.findTargetMethod(resource, message, 
                                             httpMethod, values, requestContentType, acceptContentTypes,
true);
-                setMessageProperties(message, ori, values);
+                setMessageProperties(message, ori, values, resources.size());
             } catch (WebApplicationException ex) {
                 if (ex.getResponse() != null && ex.getResponse().getStatus() == 405

                     && "OPTIONS".equalsIgnoreCase(httpMethod)) {
@@ -198,7 +198,7 @@
         LOG.fine("Accept contentType is: " + acceptTypes);
         
         LOG.fine("Found operation: " + ori.getMethodToInvoke().getName());
-        setMessageProperties(message, ori, values);  
+        setMessageProperties(message, ori, values, resources.size());  
       
         //Process parameters
         List<Object> params = JAXRSUtils.processParameters(ori, values, message);
@@ -206,10 +206,16 @@
     }
     
     private void setMessageProperties(Message message, OperationResourceInfo ori, 
-                                      MultivaluedMap<String, String> values) {
+                                      MultivaluedMap<String, String> values,
+                                      int numberOfResources) {
         message.getExchange().put(OperationResourceInfo.class, ori);
         message.put(URITemplate.TEMPLATE_PARAMETERS, values);
-        message.getExchange().put("org.apache.cxf.resource.operation.name", 
-                                  ori.getMethodToInvoke().getName());
+        
+        String plainOperationName = ori.getMethodToInvoke().getName();
+        if (numberOfResources > 1) {
+            plainOperationName = ori.getClassResourceInfo().getServiceClass().getSimpleName()
+                + "#" + plainOperationName;
+        }
+        message.getExchange().put("org.apache.cxf.resource.operation.name", plainOperationName);
   
     }
 }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanDefinitionParser.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanDefinitionParser.java
Sun Dec 20 21:29:50 2009
@@ -21,6 +21,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
@@ -63,7 +65,12 @@
     
     @Override
     protected void mapAttribute(BeanDefinitionBuilder bean, Element e, String name, String
val) {
-        mapToProperty(bean, name, val);
+        if ("serviceName".equals(name)) {
+            QName q = parseQName(e, val);
+            bean.addPropertyValue(name, q);
+        } else { 
+            mapToProperty(bean, name, val);
+        }
     }
 
     @Override

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
Sun Dec 20 21:29:50 2009
@@ -22,6 +22,8 @@
 import java.util.List;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
 import org.w3c.dom.Element;
 
 import org.apache.cxf.Bus;
@@ -63,6 +65,9 @@
                 }
             }
             bean.addPropertyValue("tempResourceProviders", tempFactories);
+        } else if ("serviceName".equals(name)) {
+            QName q = parseQName(e, val);
+            bean.addPropertyValue(name, q);
         } else {
             mapToProperty(bean, name, val);
         }

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/resources/schemas/jaxrs.xsd Sun Dec 20 21:29:50 2009
@@ -64,6 +64,7 @@
           <xsd:attribute name="bindingId" type="xsd:string" />          
           <xsd:attribute name="staticSubresourceResolution" type="xsd:boolean"/>  
       
           <xsd:attribute name="beanNames" type="xsd:string"/>
+          <xsd:attribute name="serviceName" type="xsd:QName"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>
@@ -99,6 +100,7 @@
           <xsd:attribute name="modelRef" type="xsd:string" />
           <xsd:attribute name="username" type="xsd:string"/>
           <xsd:attribute name="password" type="xsd:string"/>
+          <xsd:attribute name="serviceName" type="xsd:QName"/>
         </xsd:extension>
       </xsd:complexContent>
     </xsd:complexType>

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSClientFactoryBeanTest.java
Sun Dec 20 21:29:50 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.spring;
 
+import javax.xml.namespace.QName;
+
 import junit.framework.Assert;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
@@ -49,6 +51,8 @@
         assertEquals("Get a wrong map size", cfb.getHeaders().size(), 1);
         assertEquals("Get a wrong username", cfb.getUsername(), "username");
         assertEquals("Get a wrong password", cfb.getPassword(), "password");
+        assertEquals(new QName("http://books.com", "BookService"), 
+                     cfb.getServiceName());
         
         bean = ctx.getBean("ModelClient.proxyFactory");
         assertNotNull(bean);

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanTest.java
Sun Dec 20 21:29:50 2009
@@ -18,6 +18,8 @@
  */
 package org.apache.cxf.jaxrs.spring;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.resources.BookStore;
@@ -49,6 +51,8 @@
         assertEquals("Get a wrong address", "http://localhost:8080/rs", sfb.getAddress());
         assertNotNull("The resource classes should not be null", sfb.getResourceClasses());
         assertEquals("Get a wrong resource class", BookStore.class, sfb.getResourceClasses().get(0));
+        assertEquals(new QName("http://books.com", "BookService"), 
+                     sfb.getServiceName());
         
         sfb = (JAXRSServerFactoryBean)ctx.getBean("inlineServiceBeans");
         assertNotNull("The resource classes should not be null", sfb.getResourceClasses());

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/clients.xml Sun
Dec 20 21:29:50 2009
@@ -50,6 +50,7 @@
     </jaxrs:client>
    
   <jaxrs:client id="setHeaderClient" 
+    xmlns:s="http://books.com" serviceName="s:BookService"
     serviceClass="org.apache.cxf.jaxrs.resources.BookStore"
     address="http://localhost:8080/simpleWithAddress"
     username="username"

Modified: cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml?rev=892664&r1=892663&r2=892664&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/spring/servers.xml Sun
Dec 20 21:29:50 2009
@@ -38,7 +38,9 @@
       </property>
   </bean>
   
-  <jaxrs:server id="simple" serviceClass="org.apache.cxf.jaxrs.resources.BookStore"  
      
+  <jaxrs:server xmlns:s="http://books.com" serviceName="s:BookService" 
+        id="simple" 
+        serviceClass="org.apache.cxf.jaxrs.resources.BookStore"         
         address="http://localhost:8080/rs"/>
   
   <jaxrs:server id="inlineServiceBeans" address="http://localhost:8080/simpleWithAddress10">



Mime
View raw message