cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r884098 - in /cxf/branches/2.2.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/ rt/front...
Date Wed, 25 Nov 2009 13:53:05 GMT
Author: sergeyb
Date: Wed Nov 25 13:53:04 2009
New Revision: 884098

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

........
  r884079 | sergeyb | 2009-11-25 12:48:57 +0000 (Wed, 25 Nov 2009) | 1 line
  
  CXF-2556 and starting with refactoring of Atom providers
........

Added:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
      - copied unchanged from r884079, cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractAtomProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/
      - copied from r884079, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
      - copied unchanged from r884079, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Book.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java
      - copied unchanged from r884079, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/Chapter.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/ObjectFactory.java
      - copied unchanged from r884079, cxf/trunk/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/jaxb/ObjectFactory.java
Removed:
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/Book.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/Chapter.java
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/Description.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
    cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
    cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Nov 25 13:53:04 2009
@@ -1 +1 @@
-/cxf/trunk:881940
+/cxf/trunk:881940,884079

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/Description.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/Description.java
Wed Nov 25 13:53:04 2009
@@ -24,11 +24,29 @@
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
+/**
+ * Can be used to document resource classes and methods
+ * 
+ * See {@link <a href="http://www.w3.org/Submission/wadl/#x3-80002.3">WADL Documentation</a>}.
+ */
 @Target({ElementType.TYPE, ElementType.METHOD })
 @Retention(RetentionPolicy.RUNTIME)
 public @interface Description {
+    /**
+     * This value, if set, will be set as WADL doc content
+     */
     String value() default "";
+    /**
+     * Maps to WADL doc/@xml:lang attribute 
+     **/
     String lang() default "";
+    /**
+     * Maps to WADL doc/@title attribute 
+     **/
     String title() default "";
+    /**
+     * This uri, if set, will be used to retrieve 
+     * the content which will be set as WADL doc content
+     */
     String docuri() default "";
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java
Wed Nov 25 13:53:04 2009
@@ -113,8 +113,9 @@
             Response response = null;
             if (objs.get(0) instanceof Response) {
                 response = (Response)responseObj;
-            } else {    
-                response = Response.ok(responseObj).build();
+            } else {
+                int status = getStatus(message, 200);
+                response = Response.status(status).entity(responseObj).build();
             }
             
             Exchange exchange = message.getExchange();
@@ -137,11 +138,15 @@
             serializeMessage(message, response, ori, true);        
             
         } else {
-            Object customStatus = message.getExchange().get(Message.RESPONSE_CODE);
-            int status = customStatus == null ? 204 : (Integer)customStatus;
+            int status = getStatus(message, 204);
             message.put(Message.RESPONSE_CODE, status);
         }
     }
+
+    private int getStatus(Message message, int defaultValue) {
+        Object customStatus = message.getExchange().get(Message.RESPONSE_CODE);
+        return customStatus == null ? defaultValue : (Integer)customStatus;
+    }
     
     @SuppressWarnings("unchecked")
     private void serializeMessage(Message message, 

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/model/wadl/WadlGenerator.java
Wed Nov 25 13:53:04 2009
@@ -88,7 +88,7 @@
 
     public static final String WADL_QUERY = "_wadl"; 
     public static final MediaType WADL_TYPE = MediaType.valueOf("application/vnd.sun.wadl+xml");

-    public static final String WADL_NS = "http://research.sun.com/wadl/2006/10";    
+    public static final String WADL_NS = "http://wadl.dev.java.net/2009/02";    
     
     private static final Logger LOG = LogUtils.getL7dLogger(WadlGenerator.class);
     private static final String JAXB_DEFAULT_NAMESPACE = "##default";
@@ -495,10 +495,12 @@
         if (classes.isEmpty()) {
             return null;
         }
-        JAXBUtils.scanPackages(classes, null);
+        Set<Class<?>> classesToBeBound = new HashSet<Class<?>>(classes);
+        JAXBUtils.scanPackages(classesToBeBound, null);
+
         JAXBContext ctx;
         try {
-            ctx = JAXBContext.newInstance(classes.toArray(new Class[classes.size()]));
+            ctx = JAXBContext.newInstance(classesToBeBound.toArray(new Class[classes.size()]));
             return ctx;
         } catch (JAXBException ex) {
             LOG.fine("No JAXB context can be created");

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AbstractJAXBProvider.java
Wed Nov 25 13:53:04 2009
@@ -74,7 +74,6 @@
 import org.apache.cxf.jaxb.JAXBContextProxy;
 import org.apache.cxf.jaxb.JAXBUtils;
 import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.impl.MetadataMap;
 import org.apache.cxf.jaxrs.utils.AnnotationUtils;
 import org.apache.cxf.jaxrs.utils.InjectionUtils;
 import org.apache.cxf.jaxrs.utils.JAXRSUtils;
@@ -110,7 +109,6 @@
     protected List<String> inDropElements;
     protected Map<String, String> inElementsMap;
     protected Map<String, String> inAppendMap;
-    protected Map<String, String> inAppendAttributesMap;
     private boolean attributesToElements;
     
     private MessageContext mc;
@@ -569,10 +567,6 @@
         this.inAppendMap = inElements;
     }
     
-    public void setInAppendAttributes(Map<String, String> inElements) {
-        this.inAppendAttributesMap = inElements;
-    }
-    
     public void setInTransformElements(Map<String, String> inElements) {
         this.inElementsMap = inElements;
     }
@@ -606,9 +600,9 @@
             reader = StaxUtils.createFilteredReader(createNewReaderIfNeeded(reader, is),
                                                new StaxStreamFilter(dropElements.toArray(new
QName[]{})));    
         }
-        if (inElementsMap != null || inAppendMap != null || inAppendAttributesMap != null)
{
+        if (inElementsMap != null || inAppendMap != null) {
             reader = new InTransformReader(createNewReaderIfNeeded(reader, is),
-                                           inElementsMap, inAppendMap, inAppendAttributesMap);
+                                           inElementsMap, inAppendMap);
         }
         return reader;
     }
@@ -864,24 +858,6 @@
         }
     }
     
-    private static class AttributeValue {
-        private String name;
-        private String value;
-        
-        public AttributeValue(String n, String v) {
-            this.name = n;
-            this.value = v;
-        }
-        
-        public String getName() {
-            return name;
-        }
-        
-        public String getValue() {
-            return value;
-        }
-    }
-    
     protected static class InTransformReader extends DepthXMLStreamReader {
         
         private static final String INTERN_NAMES = "org.codehaus.stax2.internNames";
@@ -890,64 +866,19 @@
         private Map<QName, QName> inElementsMap = new HashMap<QName, QName>(5);
         private Map<QName, QName> inAppendMap = new HashMap<QName, QName>(5);
         private Map<String, String> nsMap = new HashMap<String, String>(5);
-        private MultivaluedMap<QName, AttributeValue> inAttributes;
         private QName currentQName;
         private QName previousQName;
-        private List<AttributeValue> currentAttributes;
         private int previousDepth = -1;
         
         public InTransformReader(XMLStreamReader reader, 
                                  Map<String, String> inMap,
-                                 Map<String, String> appendMap,
-                                 Map<String, String> appendAttrMap) {
+                                 Map<String, String> appendMap) {
             super(reader);
             convertToMapOfQNames(inMap, inElementsMap, nsMap);
             convertToMapOfQNames(appendMap, inAppendMap, null);
-            convertToMapOfAttributes(appendAttrMap);
-        }
-        
-        private void convertToMapOfAttributes(Map<String, String> map) {
-            if (map != null) {
-                inAttributes = new MetadataMap<QName, AttributeValue>();
-                for (Map.Entry<String, String> entry : map.entrySet()) {
-                    QName lname = convertStringToQName(entry.getKey());
-                    String[] values = entry.getValue().split(":");
-                    inAttributes.add(lname, new AttributeValue(values[0], values[1]));
-                }
-            }
         }
         
-        public int getAttributeCount() {
-            return currentAttributes == null ? super.getAttributeCount() 
-                : currentAttributes.size() + super.getAttributeCount();
-        }
-
-        public String getAttributeLocalName(int ind) {
-            if (currentAttributes == null) {
-                return super.getAttributeLocalName(ind);
-            } else {
-                int count = super.getAttributeCount();
-                return ind < count ? super.getAttributeLocalName(ind) 
-                    : currentAttributes.get(ind - count).getName(); 
-            }
-        }
-
-        public String getAttributeNamespace(int ind) {
-            return currentAttributes == null ? reader.getAttributeNamespace(ind) : "";
-        }
-
-        public String getAttributeValue(int ind) {
-            if (currentAttributes == null) {
-                return super.getAttributeValue(ind);
-            } else {
-                int count = super.getAttributeCount();
-                return ind < count ? super.getAttributeValue(ind) 
-                    : currentAttributes.get(ind - count).getValue(); 
-            }
-        }
-
         public int next() throws XMLStreamException {
-            currentAttributes = null;
             if (currentQName != null) {
                 return XMLStreamConstants.START_ELEMENT;
             } else if (previousDepth != -1 && previousDepth == getDepth() + 1) {
@@ -993,9 +924,6 @@
         public String getNamespaceURI() {
          
             QName theName = readCurrentElement();
-            if (inAttributes != null) {
-                currentAttributes = inAttributes.remove(theName);
-            }
             QName appendQName = inAppendMap.remove(theName);
             if (appendQName != null) {
                 previousDepth = getDepth();

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomEntryProvider.java
Wed Nov 25 13:53:04 2009
@@ -19,63 +19,27 @@
 
 package org.apache.cxf.jaxrs.provider;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 
-import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Entry;
-import org.apache.abdera.writer.Writer;
 
 @Produces({"application/atom+xml", "application/atom+xml;type=entry", "application/json"
})
 @Consumes({"application/atom+xml", "application/atom+xml;type=entry" })
 @Provider
-public class AtomEntryProvider 
-    implements MessageBodyReader<Entry>, MessageBodyWriter<Entry> {
-
-    private static final Abdera ATOM_ENGINE = new Abdera();
-    private static final String JSON_TYPE = "application/json";
+public class AtomEntryProvider extends AbstractAtomProvider<Entry> {
     
-    public long getSize(Entry feed,
-                        Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
-        return -1;
-    }
-
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return Entry.class.isAssignableFrom(type);
     }
-
-    public void writeTo(Entry entry, Class<?> clazz, Type type, Annotation[] a, 
-                        MediaType mt, MultivaluedMap<String, Object> headers, OutputStream
os) 
-        throws IOException {
-        if (JSON_TYPE.equals(mt.toString())) {
-            Writer w = ATOM_ENGINE.getWriterFactory().getWriter("json");
-            entry.writeTo(w, os);   
-        } else {
-            entry.writeTo(os);
-        }
-        
-    }
-
+    
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return Entry.class.isAssignableFrom(type);
     }
-
-    public Entry readFrom(Class<Entry> clazz, Type t, Annotation[] a, MediaType mt,

-                          MultivaluedMap<String, String> headers, InputStream is) 
-        throws IOException {
-        Document<Entry> doc = ATOM_ENGINE.getParser().parse(is);
-        return doc.getRoot();
-    }
+    
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/provider/AtomFeedProvider.java
Wed Nov 25 13:53:04 2009
@@ -19,63 +19,25 @@
 
 package org.apache.cxf.jaxrs.provider;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Type;
 
 import javax.ws.rs.Consumes;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 
-import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Document;
 import org.apache.abdera.model.Feed;
-import org.apache.abdera.writer.Writer;
 
 @Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
 @Consumes({"application/atom+xml", "application/atom+xml;type=feed" })
 @Provider
-public class AtomFeedProvider 
-    implements MessageBodyWriter<Feed>, MessageBodyReader<Feed> {
-
-    private static final String JSON_TYPE = "application/json";
-    private static final Abdera ATOM_ENGINE = new Abdera();
-        
-    public long getSize(Feed feed, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
-        return -1;
-    }
-
+public class AtomFeedProvider extends AbstractAtomProvider<Feed> {
     public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return Feed.class.isAssignableFrom(type);
     }
-
-    public void writeTo(Feed feed, Class<?> clazz, Type type, Annotation[] a, 
-                        MediaType mt, MultivaluedMap<String, Object> headers, OutputStream
os) 
-        throws IOException {
-        if (JSON_TYPE.equals(mt.toString())) {
-            Writer w = ATOM_ENGINE.getWriterFactory().getWriter("json");
-            feed.writeTo(w, os);   
-        } else {
-            feed.writeTo(os);
-        }
-        
-    }
-
+    
     public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
MediaType mt) {
         return Feed.class.isAssignableFrom(type);
     }
-
-    public Feed readFrom(Class<Feed> clazz, Type t, Annotation[] a, MediaType mt, 
-                         MultivaluedMap<String, String> headers, InputStream is) 
-        throws IOException {
-        Document<Feed> doc = ATOM_ENGINE.getParser().parse(is);
-        return doc.getRoot();
-    }
-
 }

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/servlet/CXFNonSpringJaxrsServlet.java
Wed Nov 25 13:53:04 2009
@@ -216,7 +216,7 @@
     }    
     
     
-    private Object createSingletonInstance(Class<?> cls, ServletConfig sc) throws ServletException
{
+    protected Object createSingletonInstance(Class<?> cls, ServletConfig sc) throws
ServletException {
         Constructor c = ResourceUtils.findResourceConstructor(cls, false);
         if (c == null) {
             throw new ServletException("No valid constructor found for " + cls.getName());
@@ -231,7 +231,9 @@
         Object[] values = isDefault ? new Object[]{} 
             : new Object[]{c.getParameterTypes()[0] == ServletConfig.class ? sc : sc.getServletContext()};

         try {
-            return c.newInstance(values);
+            Object instance = c.newInstance(values);
+            configureSingleton(instance);
+            return instance;
         } catch (InstantiationException ex) {
             ex.printStackTrace();
             throw new ServletException("Resource class " + cls.getName()
@@ -247,6 +249,10 @@
         }
     }
     
+    protected void configureSingleton(Object instance) {
+        
+    }
+    
     protected void createServerFromApplication(String cName) throws ServletException {
         Class<?> appClass = loadClass(cName, "Application");
         Application app = null;

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/model/wadl/BookStore.java
Wed Nov 25 13:53:04 2009
@@ -33,6 +33,8 @@
 
 import org.apache.cxf.jaxrs.ext.Description;
 import org.apache.cxf.jaxrs.fortest.jaxb.packageinfo.Book2;
+import org.apache.cxf.jaxrs.model.wadl.jaxb.Book;
+import org.apache.cxf.jaxrs.model.wadl.jaxb.Chapter;
 
 @Path("/bookstore/{id}")
 @Consumes({"application/xml", "application/json" })

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java
Wed Nov 25 13:53:04 2009
@@ -395,25 +395,6 @@
         assertEquals("b", tag.getGroup());
     }
     
-    @Test
-    @SuppressWarnings("unchecked")
-    public void testInAppendAttributes() throws Exception {
-        String data = "<?xml version='1.0' encoding='UTF-8'?>"
-            + "<ns1:tagholder xmlns:ns1=\"http://tags\">"
-            + "<ns1:thetag><group>B</group><name>A</name></ns1:thetag></ns1:tagholder>";
-        JAXBElementProvider provider = new JAXBElementProvider();
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("{http://tags}tagholder", "attr:custom");
-        provider.setInAppendAttributes(map);
-        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        Object o = provider.readFrom((Class)TagVO2Holder.class, TagVO2Holder.class,
-                      new Annotation[0], MediaType.TEXT_XML_TYPE, new MetadataMap<String,
String>(), is);
-        TagVO2Holder holder = (TagVO2Holder)o;
-        assertEquals("custom", holder.getAttribute());
-        TagVO2 tag2 = holder.getTagValue();
-        assertEquals("A", tag2.getName());
-        assertEquals("B", tag2.getGroup());
-    }
     
     @Test
     @SuppressWarnings("unchecked")

Modified: cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JSONProviderTest.java
Wed Nov 25 13:53:04 2009
@@ -54,7 +54,7 @@
 import org.junit.Assert;
 import org.junit.Ignore;
 import org.junit.Test;
-//CHECKSTYLE:OFF
+
 public class JSONProviderTest extends Assert {
 
     @Test
@@ -602,29 +602,6 @@
         readTagVOAfterTransform(data, "{http://bar}thetag2");
     }
     
-    @Test
-    @SuppressWarnings("unchecked")
-    public void testInAppendAttributes() throws Exception {
-        String data = "{t.tagholder:{t.thetag:{\"group\":\"B\",\"name\":\"A\"}}}";
-        JSONProvider provider = new JSONProvider();
-        Map<String, String> nsmap = new HashMap<String, String>();
-        nsmap.put("http://tags", "t");
-        provider.setNamespaceMap(nsmap);
-        Map<String, String> map = new HashMap<String, String>();
-        map.put("{http://tags}tagholder", "attr:custom");
-        provider.setInAppendAttributes(map);
-        ByteArrayInputStream is = new ByteArrayInputStream(data.getBytes());
-        Object o = provider.readFrom((Class)TagVO2Holder.class, TagVO2Holder.class,
-                      new Annotation[0], MediaType.APPLICATION_JSON_TYPE, 
-                      new MetadataMap<String, String>(), is);
-        TagVO2Holder holder = (TagVO2Holder)o;
-        assertEquals("custom", holder.getAttribute());
-        TagVO2 tag2 = holder.getTagValue();
-        assertEquals("A", tag2.getName());
-        assertEquals("B", tag2.getGroup());
-    }
-    
-    
     @SuppressWarnings("unchecked")
     private void readTagVO2AfterTransform(String data, String keyValue) throws Exception
{
         JSONProvider provider = new JSONProvider();
@@ -946,4 +923,3 @@
     }
 
 }
-//CHECKSTYLE:ON
\ No newline at end of file

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerResourceCreatedSpringProviderTest.java
Wed Nov 25 13:53:04 2009
@@ -36,6 +36,7 @@
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.cxf.jaxrs.model.wadl.WadlGenerator;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 
 import org.junit.BeforeClass;
@@ -86,16 +87,16 @@
         WebClient client = WebClient.create(requestURI + "?_wadl&_type=xml");
         Document doc = DOMUtils.readXml(new InputStreamReader(client.get(InputStream.class),
"UTF-8"));
         Element root = doc.getDocumentElement();
-        assertEquals("http://research.sun.com/wadl/2006/10", root.getNamespaceURI());
+        assertEquals(WadlGenerator.WADL_NS, root.getNamespaceURI());
         assertEquals("application", root.getLocalName());
         List<Element> resourcesEls = DOMUtils.getChildrenWithName(root, 
-                                            "http://research.sun.com/wadl/2006/10", "resources");
+                                                                  WadlGenerator.WADL_NS,
"resources");
         assertEquals(1, resourcesEls.size());
         Element resourcesEl =  resourcesEls.get(0);
         assertEquals(baseURI, resourcesEl.getAttribute("base"));
         List<Element> resourceEls = 
             DOMUtils.getChildrenWithName(resourcesEl, 
-                                                "http://research.sun.com/wadl/2006/10", "resource");
+                                         WadlGenerator.WADL_NS, "resource");
         assertEquals(size, resourceEls.size());
         return resourceEls;
     }

Modified: cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml?rev=884098&r1=884097&r2=884098&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
(original)
+++ cxf/branches/2.2.x-fixes/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
Wed Nov 25 13:53:04 2009
@@ -89,7 +89,9 @@
   <bean id="atomstore2" class="org.apache.cxf.systest.jaxrs.AtomBookStore2"/>
   <bean id="atomstore3" class="org.apache.cxf.systest.jaxrs.AtomBookStore3"/>
   
-  <bean id="feed" class="org.apache.cxf.jaxrs.provider.AtomFeedProvider"/>
+  <bean id="feed" class="org.apache.cxf.jaxrs.provider.AtomFeedProvider">
+      <property name="formattedOutput" value="true"/>
+  </bean>
   <bean id="entry" class="org.apache.cxf.jaxrs.provider.AtomEntryProvider"/>
   
 </beans>



Mime
View raw message