You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by re...@apache.org on 2013/02/18 15:14:31 UTC

svn commit: r1447265 - /stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java

Author: reto
Date: Mon Feb 18 14:14:31 2013
New Revision: 1447265

URL: http://svn.apache.org/r1447265
Log:
STANBOL-936: added MBW for rdf formats

Added:
    stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java
      - copied, changed from r1443638, incubator/clerezza/trunk/jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/GraphNodeWriter.java

Copied: stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java (from r1443638, incubator/clerezza/trunk/jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/GraphNodeWriter.java)
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java?p2=stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java&p1=incubator/clerezza/trunk/jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/GraphNodeWriter.java&r1=1443638&r2=1447265&rev=1447265&view=diff
==============================================================================
--- incubator/clerezza/trunk/jaxrs.rdf.providers/src/main/java/org/apache/clerezza/jaxrs/rdf/providers/GraphNodeWriter.java (original)
+++ stanbol/trunk/commons/web/rdfviewable-writer/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/impl/RdfSerializingWriter.java Mon Feb 18 14:14:31 2013
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.clerezza.jaxrs.rdf.providers;
+package org.apache.stanbol.commons.web.viewable.ldpath.writer.impl;
 
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
 import org.apache.clerezza.rdf.core.serializedform.SupportedFormat;
@@ -44,52 +44,57 @@ import org.apache.clerezza.rdf.core.Trip
 import org.apache.clerezza.rdf.core.UriRef;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.web.viewable.RdfViewable;
 
 /**
- * By default this returns a serialization of the context of the GraphNode.
+ * By default this returns a serialization of the context of the GraphNode. The
+ * template path of the RdfViewable is ignored.
  *
- * The expansion can be widened by using the query parameters xPropObj and
+ * Same as with <code>org.apache.clerezza.jaxrs.rdf.providers</code> the 
+ * expansion can be widened by using the query parameters xPropObj and
  * xProSubj. These parameters specify property uris (both parameters might be
  * repeated). For the specified properties their objects respectively subjects
  * are expanded as if they were bnodes.
- *
- * @scr.component
- * @scr.service interface="java.lang.Object"
- * @scr.property name="javax.ws.rs" type="Boolean" value="true"
  * 
- * @author reto
  */
+@Component
+@Service(Object.class)
+@Property(name="javax.ws.rs", boolValue=true)
 @Provider
 @Produces({SupportedFormat.N3, SupportedFormat.N_TRIPLE,
 	SupportedFormat.RDF_XML, SupportedFormat.TURTLE,
 	SupportedFormat.X_TURTLE, SupportedFormat.RDF_JSON})
-public class GraphNodeWriter implements MessageBodyWriter<GraphNode> {
+public class RdfSerializingWriter implements MessageBodyWriter<RdfViewable> {
 
 	public static final String OBJ_EXP_PARAM = "xPropObj";
 	public static final String SUBJ_EXP_PARAM = "xPropSubj";
-	/**
-	 * @scr.reference
-	 */
+	
+    @Reference
 	private Serializer serializer;
 	private UriInfo uriInfo;
 
 	@Override
 	public boolean isWriteable(Class<?> type, Type genericType,
 			Annotation[] annotations, MediaType mediaType) {
-		return GraphNode.class.isAssignableFrom(type);
+		return RdfViewable.class.isAssignableFrom(type);
 	}
 
 	@Override
-	public long getSize(GraphNode n, Class<?> type, Type genericType,
+	public long getSize(RdfViewable n, Class<?> type, Type genericType,
 			Annotation[] annotations, MediaType mediaType) {
 		return -1;
 	}
 
 	@Override
-	public void writeTo(GraphNode node, Class<?> type, Type genericType,
+	public void writeTo(RdfViewable v, Class<?> type, Type genericType,
 			Annotation[] annotations, MediaType mediaType,
 			MultivaluedMap<String, Object> httpHeaders,
 			OutputStream entityStream) throws IOException, WebApplicationException {
+        GraphNode node = v.getGraphNode();
 		serializer.serialize(entityStream, getExpandedContext(node), mediaType.toString());
 	}