cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r892314 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/ rt/frontend...
Date Fri, 18 Dec 2009 17:01:04 GMT
Author: sergeyb
Date: Fri Dec 18 17:01:03 2009
New Revision: 892314

URL: http://svn.apache.org/viewvc?rev=892314&view=rev
Log:
Merged revisions 892307 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r892307 | sergeyb | 2009-12-18 16:33:39 +0000 (Fri, 18 Dec 2009) | 1 line
  
  JAXRS : simplifying AtomElementReader/Writer interfaces and fixing URITemplate to escape
*
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec 18 17:01:03 2009
@@ -1 +1 @@
-/cxf/trunk:891375-891393,891452,891817,891827,891859,891945-891946,892056
+/cxf/trunk:891375-891393,891452,891817,891827,891859,891945-891946,892056,892307

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementReader.java
Fri Dec 18 17:01:03 2009
@@ -19,7 +19,6 @@
 package org.apache.cxf.jaxrs.ext.atom;
 
 import org.apache.abdera.model.Element;
-import org.apache.cxf.jaxrs.ext.MessageContext;
 
 /**
  * A callback-style interface which can be used to deserialize an Atom Feed or Entry into
a custom object
@@ -32,8 +31,7 @@
 public interface AtomElementReader<T extends Element, E> {
     /**
      * @param element Feed or Entry instance 
-     * @param context current MessageContext
      * @return pojoElement 
      */
-    E readFrom(T element, MessageContext mc);
+    E readFrom(T element);
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/atom/AtomElementWriter.java
Fri Dec 18 17:01:03 2009
@@ -19,7 +19,6 @@
 package org.apache.cxf.jaxrs.ext.atom;
 
 import org.apache.abdera.model.Element;
-import org.apache.cxf.jaxrs.ext.MessageContext;
 
 /**
  * A callback-style interface which can be used to map an object to an Atom Feed or Entry
@@ -33,8 +32,6 @@
     /**
      * @param element Feed or Entry instance 
      * @param pojoElement An object which needs to be mapped to the feed or entry
-     * @param context modifiable output headers
-     * @param context MessageContext which can be used for adding properties related to the
current URI, etc
      */
-    void writeTo(T element, E pojoElement, MessageContext mc);
+    void writeTo(T element, E pojoElement);
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/URITemplate.java
Fri Dec 18 17:01:03 2009
@@ -41,7 +41,7 @@
     public static final String LIMITED_REGEX_SUFFIX = "(/.*)?";
     public static final String FINAL_MATCH_GROUP = "FINAL_MATCH_GROUP";
     private static final String DEFAULT_PATH_VARIABLE_REGEX = "([^/]+?)";
-    private static final String CHARACTERS_TO_ESCAPE = ".";
+    private static final String CHARACTERS_TO_ESCAPE = ".*";
 
     private final String template;
     private final List<String> variables = new ArrayList<String>();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomPojoProvider.java
Fri Dec 18 17:01:03 2009
@@ -90,6 +90,23 @@
         for (AbstractAtomElementBuilder builder : atomBuilders.values()) {
             builder.setMessageContext(context);
         }
+        for (AtomElementWriter writer : atomWriters.values()) {
+            tryInjectMessageContext(writer);
+        }
+        for (AtomElementReader reader : atomReaders.values()) {
+            tryInjectMessageContext(reader);
+        }
+    }
+    
+    protected void tryInjectMessageContext(Object handler) {
+        try {
+            Method m = handler.getClass().getMethod("setMessageContext",
+                                                    new Class[]{MessageContext.class});
+            InjectionUtils.injectThroughMethod(handler, m, mc);
+        } catch (Throwable t) {
+            LOG.warning("Message context can not be injected into " + handler.getClass().getName()

+                        + " : " + t.getMessage());
+        }
     }
     
     public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
@@ -199,7 +216,7 @@
     protected boolean buildFeed(Feed feed, Object o) {
         AtomElementWriter<?, ?> builder = atomWriters.get(o.getClass().getName());
         if (builder != null) {
-            ((AtomElementWriter)builder).writeTo(feed, o, mc);
+            ((AtomElementWriter)builder).writeTo(feed, o);
             return true;
         }
         return false;
@@ -313,7 +330,7 @@
     protected boolean buildEntry(Entry entry, Object o) {
         AtomElementWriter<?, ?> builder = atomWriters.get(o.getClass().getName());
         if (builder != null) {
-            ((AtomElementWriter)builder).writeTo(entry, o, mc);
+            ((AtomElementWriter)builder).writeTo(entry, o);
             return true;
         }
         return false;
@@ -466,7 +483,7 @@
         
         AtomElementReader<?, ?> reader = atomReaders.get(cls.getName());
         if (reader != null) {
-            return ((AtomElementReader)reader).readFrom(feed, mc);
+            return ((AtomElementReader)reader).readFrom(feed);
         }
         Object instance = null;
         try {
@@ -493,7 +510,7 @@
         
         AtomElementReader<?, ?> reader = atomReaders.get(cls.getName());
         if (reader != null) {
-            return ((AtomElementReader)reader).readFrom(entry, mc);
+            return ((AtomElementReader)reader).readFrom(entry);
         }
         try {
             Unmarshaller um = 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/client/WebClientTest.java
Fri Dec 18 17:01:03 2009
@@ -34,10 +34,27 @@
     public void testEncoding() {
         URI u = WebClient.create("http://foo").path("bar+ %2B").matrix("a", "value+ ")
             .query("b", "bv+ ").getCurrentURI();
-        System.out.println("'" + u.toString() + "'");
         assertEquals("http://foo/bar+%20%2B;a=value+%20?b=bv%2B+", u.toString());
     }
     
+    @Test
+    public void testExistingAsteriscs() {
+        URI u = WebClient.create("http://foo/*").getCurrentURI();
+        assertEquals("http://foo/*", u.toString());
+    }
+    
+    @Test
+    public void testAsteriscs() {
+        URI u = WebClient.create("http://foo").path("*").getCurrentURI();
+        assertEquals("http://foo/*", u.toString());
+    }
+    
+    @Test
+    public void testDoubleAsteriscs() {
+        URI u = WebClient.create("http://foo").path("**").getCurrentURI();
+        assertEquals("http://foo/**", u.toString());
+    }
+    
     @Test 
     public void testBaseCurrentPath() {
         assertEquals(URI.create("http://foo"), WebClient.create("http://foo").getBaseURI());

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/impl/UriBuilderImplTest.java
Fri Dec 18 17:01:03 2009
@@ -111,6 +111,38 @@
     }
     
     @Test
+    public void testEncodedPathWithAsteriscs() throws Exception {
+        URI uri = new URI("http://bar/foo/");
+        URI newUri = new UriBuilderImpl(uri).path("*").buildFromEncoded();   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/foo/*", newUri.toString());
+    }
+    
+    @Test
+    public void testPathWithAsteriscs() throws Exception {
+        URI uri = new URI("http://bar/foo/");
+        URI newUri = new UriBuilderImpl(uri).path("*").build();   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/foo/*", newUri.toString());
+    }
+    
+    @Test
+    public void testEncodedPathWithTwoAsteriscs() throws Exception {
+        URI uri = new URI("http://bar/foo/");
+        URI newUri = new UriBuilderImpl(uri).path("**").buildFromEncoded();   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/foo/**", newUri.toString());
+    }
+    
+    @Test
+    public void testPathWithTwoAsteriscs() throws Exception {
+        URI uri = new URI("http://bar/foo/");
+        URI newUri = new UriBuilderImpl(uri).path("**").build();   
+        assertEquals("URI is not built correctly", 
+                     "http://bar/foo/**", newUri.toString());
+    }
+    
+    @Test
     public void testEncodedAddedQuery() throws Exception {
         URI uri = new URI("http://bar");
         URI newUri = new UriBuilderImpl(uri).queryParam("q", "a+b%20%2B").buildFromEncoded();
  

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java?rev=892314&r1=892313&r2=892314&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/AtomPojoProviderTest.java
Fri Dec 18 17:01:03 2009
@@ -31,7 +31,6 @@
 
 import org.apache.abdera.model.Entry;
 import org.apache.abdera.model.Feed;
-import org.apache.cxf.jaxrs.ext.MessageContext;
 import org.apache.cxf.jaxrs.ext.atom.AbstractEntryBuilder;
 import org.apache.cxf.jaxrs.ext.atom.AbstractFeedBuilder;
 import org.apache.cxf.jaxrs.ext.atom.AtomElementReader;
@@ -43,7 +42,6 @@
 
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-
 public class AtomPojoProviderTest extends Assert {
 
     private ClassPathXmlApplicationContext ctx;
@@ -165,7 +163,7 @@
  
     public static class CustomFeedWriter implements AtomElementWriter<Feed, Books>
{
 
-        public void writeTo(Feed feed, Books pojoFeed, MessageContext context) {
+        public void writeTo(Feed feed, Books pojoFeed) {
             feed.setTitle("Books");
         }
         
@@ -173,7 +171,7 @@
     
     public static class CustomEntryWriter implements AtomElementWriter<Entry, Book>
{
 
-        public void writeTo(Entry entry, Book pojoEntry, MessageContext context) {
+        public void writeTo(Entry entry, Book pojoEntry) {
             entry.setTitle(pojoEntry.getName());
         }
         
@@ -181,7 +179,7 @@
     
     public static class CustomEntryReader implements AtomElementReader<Entry, Book>
{
 
-        public Book readFrom(Entry element, MessageContext mc) {
+        public Book readFrom(Entry element) {
             try {
                 String s = element.getContent();
                                 
@@ -198,12 +196,12 @@
     
     public static class CustomFeedReader implements AtomElementReader<Feed, Books>
{
 
-        public Books readFrom(Feed element, MessageContext mc) {
+        public Books readFrom(Feed element) {
             Books books = new Books();
             List<Book> list = new ArrayList<Book>();
             CustomEntryReader entryReader = new CustomEntryReader();
             for (Entry e : element.getEntries()) {
-                list.add(entryReader.readFrom(e, mc));
+                list.add(entryReader.readFrom(e));
             }
             books.setBooks(list);
             return books;



Mime
View raw message