You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by og...@apache.org on 2011/03/29 11:30:44 UTC

svn commit: r1086528 - /incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java

Author: ogrisel
Date: Tue Mar 29 09:30:44 2011
New Revision: 1086528

URL: http://svn.apache.org/viewvc?rev=1086528&view=rev
Log:
STANBOL-120: update the GraphWriter to use ContextHelper#getServiceFromContext to lookup the serializer from the servlet / OSGi bridged contexts

Modified:
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java?rev=1086528&r1=1086527&r2=1086528&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/src/main/java/org/apache/stanbol/commons/web/writers/GraphWriter.java Tue Mar 29 09:30:44 2011
@@ -25,18 +25,18 @@ import javax.ws.rs.ext.Provider;
 
 import org.apache.clerezza.rdf.core.TripleCollection;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.stanbol.commons.web.ContextHelper;
 
 
 @Provider
-@Produces( { TEXT_PLAIN, N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE,
-        RDF_JSON, APPLICATION_JSON })
+@Produces({TEXT_PLAIN, N3, N_TRIPLE, RDF_XML, TURTLE, X_TURTLE, RDF_JSON, APPLICATION_JSON})
 public class GraphWriter implements MessageBodyWriter<TripleCollection> {
 
     @Context
     protected ServletContext servletContext;
 
     protected Serializer getSerializer() {
-        return (Serializer) servletContext.getAttribute(Serializer.class.getName());
+        return ContextHelper.getServiceFromContext(Serializer.class, servletContext);
     }
 
     public boolean isWriteable(Class<?> type, Type genericType,
@@ -56,7 +56,7 @@ public class GraphWriter implements Mess
             WebApplicationException {
 
         if (mediaType == null || mediaType.isWildcardType() || TEXT_PLAIN.equals(mediaType.toString())) {
-           getSerializer().serialize(entityStream, t, APPLICATION_JSON);
+            getSerializer().serialize(entityStream, t, APPLICATION_JSON);
         } else {
             getSerializer().serialize(entityStream, t, mediaType.toString());
         }