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

svn commit: r1442582 - in /stanbol/trunk/commons/web: viewable-ldpath/ viewable-ldpath/src/ viewable-ldpath/src/license/ viewable-ldpath/src/main/ viewable-ldpath/src/main/java/ viewable-ldpath/src/main/java/org/ viewable-ldpath/src/main/java/org/apach...

Author: rwesten
Date: Tue Feb  5 13:44:53 2013
New Revision: 1442582

URL: http://svn.apache.org/viewvc?rev=1442582&view=rev
Log:
STANBOL-910: seperated viewable and ldpath viewable; impl. of BundleTemplateLoader

Added:
    stanbol/trunk/commons/web/viewable-ldpath/   (with props)
    stanbol/trunk/commons/web/viewable-ldpath/README.md
    stanbol/trunk/commons/web/viewable-ldpath/pom.xml   (with props)
    stanbol/trunk/commons/web/viewable-ldpath/src/
    stanbol/trunk/commons/web/viewable-ldpath/src/license/
    stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties   (with props)
    stanbol/trunk/commons/web/viewable-ldpath/src/main/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java   (with props)
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/
    stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java   (with props)
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java   (with props)
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java   (with props)
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java   (with props)
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/Viewable.java
      - copied, changed from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java   (with props)
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/
      - copied from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/ViewableWebFragment.java
      - copied, changed from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/LdViewableWebFragment.java
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/
      - copied from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/mbw/
Removed:
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/ldviewable/mbw/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/ldviewable/webfragment/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/mbw/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/LdViewableWebFragment.java
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/LdViewableWriter.java
Modified:
    stanbol/trunk/commons/web/viewable/pom.xml
    stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/ViewableWriter.java

Propchange: stanbol/trunk/commons/web/viewable-ldpath/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Feb  5 13:44:53 2013
@@ -0,0 +1,7 @@
+.settings
+
+target
+
+.project
+
+.classpath

Added: stanbol/trunk/commons/web/viewable-ldpath/README.md
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/README.md?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/README.md (added)
+++ stanbol/trunk/commons/web/viewable-ldpath/README.md Tue Feb  5 13:44:53 2013
@@ -0,0 +1,21 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+LdViewable
+===========
+
+Allows resource methods to return an instance of LdViewable encapsulating a template path and a GraphNode. The template path is relative to a prefix specific to the target media type, e.g. "html" for "text/html"

Added: stanbol/trunk/commons/web/viewable-ldpath/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/pom.xml?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/pom.xml (added)
+++ stanbol/trunk/commons/web/viewable-ldpath/pom.xml Tue Feb  5 13:44:53 2013
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.stanbol</groupId>
+    <artifactId>stanbol-parent</artifactId>
+    <version>4-SNAPSHOT</version>
+    <relativePath>../../../parent</relativePath>
+  </parent>
+
+  <groupId>org.apache.stanbol</groupId>
+  <artifactId>org.apache.stanbol.commons.web.viewable.ldpath</artifactId>
+  <version>0.12.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <name>Apache Stanbol Commons Web Viewable for LDpath</name>
+  <description>
+    A service providing classes and message body writer for response rendering 
+    allowing to use LDpath based templates over RDF resources.
+  </description>
+  <scm>
+    <connection>
+      scm:svn:http://svn.apache.org/repos/asf/stanbol/trunk/commons/web/viewable-ldpath
+    </connection>
+    <developerConnection>
+      scm:svn:https://svn.apache.org/repos/asf/stanbol/trunk/commons/web/viewable-ldpath
+    </developerConnection>
+    <url>http://stanbol.apache.org/</url>
+  </scm>
+
+  <build>
+    <!-- make it an OSGi bundle -->
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-scr-plugin</artifactId>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.stanbol.commons.web.viewable.ldpath;version=${project.version},
+              org.apache.stanbol.commons.web.viewable.ldpath.writer;version=${project.version}
+            </Export-Package>
+            <Private-Package>
+              org.apache.stanbol.commons.web.viewable.ldpath.webfragment;version=${project.version},
+            </Private-Package>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Import-Package>
+              javax.servlet.*; version="[2.5.0,4.0.0)",
+              javax.ws.rs.*; version="[0,2)",
+              org.apache.stanbol.commons.web.base; provide:=true; version="[0.11,0.13)",
+              *
+            </Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.ldpath.clerezza</artifactId>
+      <version>0.11.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.web.viewable</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.stanbol</groupId>
+      <artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
+      <version>0.12.0-SNAPSHOT</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>rdf.ontologies</artifactId>
+    </dependency>
+   	<dependency>
+      <groupId>org.apache.clerezza</groupId>
+	  <artifactId>rdf.utils</artifactId>
+  	</dependency>
+   
+
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.scr.annotations</artifactId>
+    </dependency>
+    
+  </dependencies>
+
+</project>

Propchange: stanbol/trunk/commons/web/viewable-ldpath/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties (added)
+++ stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties Tue Feb  5 13:44:53 2013
@@ -0,0 +1,28 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Apache Software License
+# - Apache Software License, Version 2.0
+# - BSD License
+# - Common Development And Distribution License (CDDL), Version 1.0
+# - Common Development And Distribution License (CDDL), Version 1.1
+# - Common Public License, Version 1.0
+# - Eclipse Public License, Version 1.0
+# - GNU General Public License (GPL), Version 2 with classpath exception
+# - GNU Lesser General Public License (LGPL)
+# - GNU Lesser General Public License (LGPL), Version 2.1
+# - ICU License
+# - MIT License
+# - New BSD License
+# - Public Domain License
+# - Similar to Apache License but with the acknowledgment clause removed
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Wed Dec 12 16:52:13 CET 2012
+javax.servlet--servlet-api--2.5=Common Development And Distribution License (CDDL), Version 1.0
+org.codehaus.jettison--jettison--1.3=The Apache Software License, Version 2.0
+org.osgi--org.osgi.compendium--4.1.0=The Apache Software License, Version 2.0
+org.osgi--org.osgi.core--4.1.0=The Apache Software License, Version 2.0
+xerces--xercesImpl--2.7.1=The Apache Software License, Version 2.0

Propchange: stanbol/trunk/commons/web/viewable-ldpath/src/license/THIRD-PARTY.properties
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java (added)
+++ stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.stanbol.commons.web.viewable.ldpath.webfragment;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.stanbol.commons.web.base.LinkResource;
+import org.apache.stanbol.commons.web.base.NavigationLink;
+import org.apache.stanbol.commons.web.base.ScriptResource;
+import org.apache.stanbol.commons.web.base.WebFragment;
+import org.apache.stanbol.commons.web.viewable.ldpath.writer.LdViewableWriter;
+import org.apache.stanbol.commons.web.viewable.writer.ViewableWriter;
+import org.osgi.service.component.ComponentContext;
+
+import freemarker.cache.TemplateLoader;
+
+
+/**
+ * Statically define the list of available resources and providers to be
+ * contributed to the the Stanbol JAX-RS Endpoint.
+ */
+@Component(immediate = true, metatype = true)
+@Service
+public class LdViewableWebFragment implements WebFragment {
+
+	private LdViewableWriter ldViewableWriter;
+	
+	@Reference
+	private TemplateLoader templateLoader;
+		
+	private static final String NAME = "ld-viewable";
+
+	@Override
+	public String getName() {
+		return NAME;
+	}
+
+	@Activate
+	protected void activate(ComponentContext ctx) {
+	    ldViewableWriter = new LdViewableWriter(templateLoader);
+	}
+	
+	@Deactivate
+	protected void deactivate(ComponentContext ctx){
+	    ldViewableWriter = null;
+	}
+
+	@Override
+	public Set<Class<?>> getJaxrsResourceClasses() {
+		return Collections.emptySet();
+	}
+
+	@Override
+	public Set<Object> getJaxrsResourceSingletons() {
+		Set<Object> instances = new HashSet<Object>();
+		instances.add(ldViewableWriter);
+		return instances;
+	}
+
+	@Override
+	public List<LinkResource> getLinkResources() {
+		List<LinkResource> resources = new ArrayList<LinkResource>();
+		return resources;
+	}
+
+	@Override
+	public List<ScriptResource> getScriptResources() {
+		return Collections.emptyList();
+	}
+
+	@Override
+	public List<NavigationLink> getNavigationLinks() {
+		return Collections.emptyList();
+	}
+
+}

Propchange: stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/webfragment/LdViewableWebFragment.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java (added)
+++ stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.commons.web.viewable.ldpath.writer;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.stanbol.commons.ldpath.clerezza.ClerezzaBackend;
+import org.apache.stanbol.commons.web.viewable.RdfViewable;
+
+import at.newmedialab.ldpath.api.backend.RDFBackend;
+import at.newmedialab.ldpath.template.engine.TemplateEngine;
+
+import freemarker.cache.TemplateLoader;
+import freemarker.template.TemplateException;
+
+@Produces(MediaType.TEXT_HTML)
+@Provider
+public class LdViewableWriter implements MessageBodyWriter<RdfViewable> {
+
+	private TemplateLoader templateLoader;
+	
+	public LdViewableWriter(TemplateLoader templateLoader) {
+	    if(templateLoader == null){
+	        throw new IllegalArgumentException("The parsed TemplateLoader MUST NOT be NULL!");
+	    }
+        this.templateLoader = templateLoader;
+    }
+
+    @Override
+	public boolean isWriteable(Class<?> type, Type genericType,
+			Annotation[] annotations, MediaType mediaType) {
+		return RdfViewable.class.isAssignableFrom(type);
+	}
+
+	@Override
+	public long getSize(RdfViewable t, Class<?> type, Type genericType,
+			Annotation[] annotations, MediaType mediaType) {
+		return -1;
+	}
+
+	@Override
+	public void writeTo(RdfViewable t, Class<?> type, Type genericType,
+			Annotation[] annotations, MediaType mediaType,
+			MultivaluedMap<String, Object> httpHeaders,
+			OutputStream entityStream) throws IOException,
+			WebApplicationException {
+		Writer out = new OutputStreamWriter(entityStream, "utf-8"); 
+		render(t.getGraphNode(), "html/"+t.getTemplatePath(), out);
+		out.flush();
+	}
+    /**
+     * Renders a GraphNode with a template located in the templates
+     * folder of any active bundle
+     * 
+     * @param node the GraphNode to be rendered
+     * @param templatePath the freemarker path to the template
+     * @param out where the result is written to
+     */
+    private void render(GraphNode node, final String templatePath, Writer out) { 
+        //A GraphNode backend could be graph unspecific, so the same engine could be
+        //reused, possibly being signifantly more performant (caching, etc.)
+        RDFBackend<Resource> backend = new ClerezzaBackend(node.getGraph());
+        Resource context = node.getNode();
+        TemplateEngine<Resource> engine = new TemplateEngine<Resource>(backend);
+        engine.setTemplateLoader(templateLoader);
+        try {
+            engine.processFileTemplate(context, templatePath, null, out);
+            out.flush();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (TemplateException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}

Propchange: stanbol/trunk/commons/web/viewable-ldpath/src/main/java/org/apache/stanbol/commons/web/viewable/ldpath/writer/LdViewableWriter.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: stanbol/trunk/commons/web/viewable/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/pom.xml?rev=1442582&r1=1442581&r2=1442582&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable/pom.xml (original)
+++ stanbol/trunk/commons/web/viewable/pom.xml Tue Feb  5 13:44:53 2013
@@ -53,6 +53,26 @@
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-bundle-plugin</artifactId>
         <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+              org.apache.stanbol.commons.viewable;version=${project.version},
+              org.apache.stanbol.commons.web.viewable;version=${project.version},
+              org.apache.stanbol.commons.web.viewable.writer;version=${project.version}
+            </Export-Package>
+            <Private-Package>
+              org.apache.stanbol.commons.web.viewable.impl;version=${project.version},
+              org.apache.stanbol.commons.web.viewable.webfragment;version=${project.version},
+            </Private-Package>
+            <Embed-Transitive>true</Embed-Transitive>
+            <Import-Package>
+              javax.servlet.*; version="[2.5.0,4.0.0)",
+              javax.ws.rs.*; version="[0,2)",
+              org.apache.stanbol.commons.web.base; provide:=true; version="[0.11,0.13)",
+              *
+            </Import-Package>
+          </instructions>
+        </configuration>
       </plugin>
     </plugins>
   </build>
@@ -77,10 +97,10 @@
       <artifactId>org.apache.stanbol.commons.web.base</artifactId>
       <version>0.11.0</version>
     </dependency>
-	  <dependency>
+    <dependency>
       <groupId>org.apache.stanbol</groupId>
-  		<artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
-  		<version>0.11.0</version>
+  	  <artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
+  	  <version>0.11.0</version>
     </dependency>
   </dependencies>
 

Added: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java (added)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,30 @@
+package org.apache.stanbol.commons.viewable;
+
+import org.apache.clerezza.rdf.utils.GraphNode;
+
+/**
+ * An RdfViewable is a GraphNode associated with a template path. The template 
+ * path will be attempted to be resolved based on the accepted target formats
+ * to create a representation of the GraphNode. 
+ * @deprecated Moved to {@link org.apache.stanbol.commons.web.viewable.RdfViewable}
+ */
+public class RdfViewable extends org.apache.stanbol.commons.web.viewable.RdfViewable {
+
+    /**
+     * 
+     * @param templatePath the templatePath
+     * @param graphNode the graphNode with the actual content
+     */
+    public RdfViewable(final String templatePath, final GraphNode graphNode) {
+        super(templatePath,graphNode);
+    }
+    
+    /**
+     * With this version of the constructor the templatePath is prefixed with
+     * the slash-separated package name of the given Class.
+     * 
+     */
+    public RdfViewable(final String templatePath, final GraphNode graphNode, final Class<?> clazz) {
+        super(templatePath,graphNode,clazz);
+    }
+}

Propchange: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/RdfViewable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java (added)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,37 @@
+package org.apache.stanbol.commons.viewable;
+/**
+ * This is a replacement for the jersey Vieable that allows rendering an 
+ * arbitrary object using a Freemarker template specified by path.
+ * 
+ * Usage of this class promotes a bad programming style where the 
+ * application logic is not clearly separated from the presentation but 
+ * where backend method are called by the presentation layer.
+ * 
+ * Users should consider migrate to RdfViewable instead where instead of
+ * an arbitrary Object a GraphNode representing a node in a graph is passed,
+ * this approach also allows the response to be rendered as RDF.
+ * 
+ * @deprecated Moved to {@link org.apache.stanbol.commons.web.viewable.Viewable}
+ */
+@Deprecated
+public class Viewable extends org.apache.stanbol.commons.web.viewable.Viewable {
+    
+    /**
+     * This uses the class name of Pojo to prefix the template
+     * 
+     * @param templatePath the templatePath
+     * @param graphNode the graphNode with the actual content
+     */
+    public Viewable(String templatePath, Object pojo) {
+        super(templatePath, pojo);
+    }
+
+    /**
+     * With this version of the constructor the templatePath is prefixed with
+     * the slash-separated class name of clazz.
+     * 
+     */
+    public Viewable(final String templatePath, final Object pojo, final Class<?> clazz) {
+        super(templatePath, pojo, clazz);
+    }
+}

Propchange: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java (added)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.commons.web.viewable;
+
+import org.apache.clerezza.rdf.utils.GraphNode;
+
+/**
+ * An RdfViewable is a GraphNode associated with a template path. The template 
+ * path will be attempted to be resolved based on the accepted target formats
+ * to create a representation of the GraphNode. 
+ *
+ */
+public class RdfViewable {
+
+    /**
+     * 
+     * @param templatePath the templatePath
+     * @param graphNode the graphNode with the actual content
+     */
+    public RdfViewable(final String templatePath, final GraphNode graphNode) {
+        this.templatePath = templatePath;
+        this.graphNode = graphNode;
+    }
+    
+    /**
+     * With this version of the constructor the templatePath is prefixed with
+     * the slash-separated package name of the given Class.
+     * 
+     */
+    public RdfViewable(final String templatePath, final GraphNode graphNode, final Class<?> clazz) {
+        final String slahSeparatedPacakgeName = clazz.getPackage().getName().replace('.', '/');
+        if (templatePath.startsWith("/")) {
+            this.templatePath = slahSeparatedPacakgeName+templatePath;
+        } else {
+            this.templatePath = slahSeparatedPacakgeName+'/'+templatePath;
+        }
+        this.graphNode = graphNode;
+    }
+    
+    private String templatePath;
+    private GraphNode graphNode;
+    
+    public String getTemplatePath() {
+        return templatePath;
+    }
+    
+    public GraphNode getGraphNode() {
+        return graphNode;
+    }
+}

Propchange: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/RdfViewable.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/Viewable.java (from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java)
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/Viewable.java?p2=stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/Viewable.java&p1=stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java&r1=1441319&r2=1442582&rev=1442582&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/Viewable.java (original)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/Viewable.java Tue Feb  5 13:44:53 2013
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.stanbol.commons.viewable;
+package org.apache.stanbol.commons.web.viewable;
 
 
 /**
@@ -32,39 +32,39 @@ package org.apache.stanbol.commons.viewa
  */
 public class Viewable {
 
-	/**
-	 * This uses the class name of Pojo to prefix the template
-	 * 
-	 * @param templatePath the templatePath
-	 * @param graphNode the graphNode with the actual content
-	 */
-	public Viewable(final String templatePath, final Object pojo) {
-		this(templatePath, pojo, pojo.getClass());
-	}
-	
-	/**
-	 * With this version of the constructor the templatePath is prefixed with
-	 * the slash-separated class name of clazz.
-	 * 
-	 */
-	public Viewable(final String templatePath, final Object pojo, final Class<?> clazz) {
-		final String slahSeparatedPacakgeName = clazz.getName().replace('.', '/');
-		if (templatePath.startsWith("/")) {
-			this.templatePath = slahSeparatedPacakgeName+templatePath;
-		} else {
-			this.templatePath = slahSeparatedPacakgeName+'/'+templatePath;
-		}
-		this.pojo = pojo;
-	}
-	
-	private String templatePath;
-	private Object pojo;
-	
-	public String getTemplatePath() {
-		return templatePath;
-	}
-	
-	public Object getPojo() {
-		return pojo;
-	}
+    /**
+     * This uses the class name of Pojo to prefix the template
+     * 
+     * @param templatePath the templatePath
+     * @param graphNode the graphNode with the actual content
+     */
+    public Viewable(final String templatePath, final Object pojo) {
+        this(templatePath, pojo, pojo.getClass());
+    }
+    
+    /**
+     * With this version of the constructor the templatePath is prefixed with
+     * the slash-separated class name of clazz.
+     * 
+     */
+    public Viewable(final String templatePath, final Object pojo, final Class<?> clazz) {
+        final String slahSeparatedPacakgeName = clazz.getName().replace('.', '/');
+        if (templatePath.startsWith("/")) {
+            this.templatePath = slahSeparatedPacakgeName+templatePath;
+        } else {
+            this.templatePath = slahSeparatedPacakgeName+'/'+templatePath;
+        }
+        this.pojo = pojo;
+    }
+    
+    private String templatePath;
+    private Object pojo;
+    
+    public String getTemplatePath() {
+        return templatePath;
+    }
+    
+    public Object getPojo() {
+        return pojo;
+    }
 }

Added: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java?rev=1442582&view=auto
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java (added)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java Tue Feb  5 13:44:53 2013
@@ -0,0 +1,128 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.stanbol.commons.web.viewable.impl;
+
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.io.Writer;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashSet;
+
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.utils.GraphNode;
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.BundleListener;
+import org.osgi.service.component.ComponentContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import freemarker.cache.TemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.TemplateException;
+
+/**
+ * This Service provides an {@link TemplateLoader} that provides templates
+ * relative to the {@link #TEMPLATES_PATH_IN_BUNDLES}.
+ */
+@Component
+@Service(TemplateLoader.class)
+public class BundleTemplateLoader implements TemplateLoader{
+	
+	private static final String TEMPLATES_PATH_IN_BUNDLES = "templates/";
+
+	private static final Logger log = LoggerFactory.getLogger(BundleTemplateLoader.class);
+	
+	private final Collection<Bundle> bundles = new HashSet<Bundle>();
+	
+	private BundleListener bundleListener = new BundleListener() {
+		
+		@Override
+		public void bundleChanged(BundleEvent event) {
+			if ((event.getType() == BundleEvent.STARTED) && containsTemplates(event.getBundle())) {
+				bundles.add(event.getBundle());
+			} else {
+				bundles.remove(event.getBundle());
+			}
+		}
+	};
+	
+		
+	@Override
+	public Reader getReader(Object templateSource, String encoding)
+			throws IOException {
+		URL templateUrl = (URL) templateSource;
+		return new InputStreamReader(templateUrl.openStream(), encoding);
+	}
+	
+	@Override
+	public long getLastModified(Object templateSource) {
+		// not known
+		return -1;
+	}
+	
+	@Override
+	public Object findTemplateSource(String name) throws IOException {
+		if (!name.endsWith(".ftl")) {
+			name = name +".ftl";
+		}
+		final String path = TEMPLATES_PATH_IN_BUNDLES+name;
+		for (Bundle bundle : bundles) {
+			URL res = bundle.getResource(path);
+			if (res != null) {
+				return res;
+			}
+		}
+		log.warn("Template "+name+" not known");
+		return null;
+	}
+	
+	@Override
+	public void closeTemplateSource(Object templateSource) throws IOException {
+
+		
+	}
+	
+	@Activate
+	protected void activate(final ComponentContext context) {
+		final Bundle[] registeredBundles = context.getBundleContext().getBundles();
+		for (int i = 0; i < registeredBundles.length; i++) {
+			if ((registeredBundles[i].getState() == Bundle.ACTIVE) 
+					&& containsTemplates(registeredBundles[i])) {
+				bundles.add(registeredBundles[i]);
+			}
+		}	
+		context.getBundleContext().addBundleListener(bundleListener);
+	}
+
+	@Deactivate
+	protected void deactivate(final ComponentContext context) {
+		context.getBundleContext().removeBundleListener(bundleListener);
+	}
+	
+	private boolean containsTemplates(Bundle bundle) {
+		return bundle.getResource(TEMPLATES_PATH_IN_BUNDLES) != null;
+	}
+	
+}

Propchange: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/impl/BundleTemplateLoader.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Copied: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/ViewableWebFragment.java (from r1441319, stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/LdViewableWebFragment.java)
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/ViewableWebFragment.java?p2=stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/ViewableWebFragment.java&p1=stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/LdViewableWebFragment.java&r1=1441319&r2=1442582&rev=1442582&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/viewable/webfragment/LdViewableWebFragment.java (original)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/webfragment/ViewableWebFragment.java Tue Feb  5 13:44:53 2013
@@ -15,26 +15,27 @@
  * limitations under the License.
  */
 
-package org.apache.stanbol.commons.viewable.webfragment;
+package org.apache.stanbol.commons.web.viewable.webfragment;
 
-import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
 import org.apache.felix.scr.annotations.Reference;
 import org.apache.felix.scr.annotations.Service;
-import org.apache.stanbol.commons.viewable.mbw.LdViewableWriter;
-import org.apache.stanbol.commons.viewable.mbw.ViewableWriter;
 import org.apache.stanbol.commons.web.base.LinkResource;
 import org.apache.stanbol.commons.web.base.NavigationLink;
 import org.apache.stanbol.commons.web.base.ScriptResource;
 import org.apache.stanbol.commons.web.base.WebFragment;
-import org.osgi.framework.BundleContext;
+import org.apache.stanbol.commons.web.viewable.writer.ViewableWriter;
 import org.osgi.service.component.ComponentContext;
 
+import freemarker.cache.TemplateLoader;
+
 
 /**
  * Statically define the list of available resources and providers to be
@@ -42,18 +43,18 @@ import org.osgi.service.component.Compon
  */
 @Component(immediate = true, metatype = true)
 @Service
-public class LdViewableWebFragment implements WebFragment {
+public class ViewableWebFragment implements WebFragment {
 
-	@Reference
-	private LdViewableWriter ldViewableWriter;
+	//@Reference
+	//private LdViewableWriter ldViewableWriter;
 	
 	@Reference
+	private TemplateLoader templateLoader;
+	
 	private ViewableWriter viewableWriter;
 	
 	private static final String NAME = "ld-viewable";
 
-	private BundleContext bundleContext;
-
 	@Override
 	public String getName() {
 		return NAME;
@@ -61,39 +62,40 @@ public class LdViewableWebFragment imple
 
 	@Activate
 	protected void activate(ComponentContext ctx) {
-		this.bundleContext = ctx.getBundleContext();
+	    viewableWriter = new ViewableWriter(templateLoader);
+	}
+	
+	@Deactivate
+	protected void deactivate(ComponentContext ctx){
+	    viewableWriter = null;
 	}
 
 	@Override
 	public Set<Class<?>> getJaxrsResourceClasses() {
-		Set<Class<?>> classes = new HashSet<Class<?>>();
-		return classes;
+		return Collections.emptySet();
 	}
 
 	@Override
 	public Set<Object> getJaxrsResourceSingletons() {
 		Set<Object> instances = new HashSet<Object>();
-		instances.add(ldViewableWriter);
+		//instances.add(ldViewableWriter);
 		instances.add(viewableWriter);
 		return instances;
 	}
 
 	@Override
 	public List<LinkResource> getLinkResources() {
-		List<LinkResource> resources = new ArrayList<LinkResource>();
-		return resources;
+		return Collections.emptyList();
 	}
 
 	@Override
 	public List<ScriptResource> getScriptResources() {
-		List<ScriptResource> resources = new ArrayList<ScriptResource>();
-		return resources;
+        return Collections.emptyList();
 	}
 
 	@Override
 	public List<NavigationLink> getNavigationLinks() {
-		List<NavigationLink> links = new ArrayList<NavigationLink>();
-		return links;
+        return Collections.emptyList();
 	}
 
 }

Modified: stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/ViewableWriter.java
URL: http://svn.apache.org/viewvc/stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/ViewableWriter.java?rev=1442582&r1=1441319&r2=1442582&view=diff
==============================================================================
--- stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/ViewableWriter.java (original)
+++ stanbol/trunk/commons/web/viewable/src/main/java/org/apache/stanbol/commons/web/viewable/writer/ViewableWriter.java Tue Feb  5 13:44:53 2013
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.stanbol.commons.viewable.mbw;
+package org.apache.stanbol.commons.web.viewable.writer;
 
 import java.io.IOException;
 import java.io.OutputStream;
@@ -29,20 +29,27 @@ import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.ext.MessageBodyWriter;
 import javax.ws.rs.ext.Provider;
 
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.apache.stanbol.commons.ldpathtemplate.LdRenderer;
-import org.apache.stanbol.commons.viewable.Viewable;
+import org.apache.stanbol.commons.web.viewable.Viewable;
+
+import freemarker.cache.TemplateLoader;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.TemplateException;
 
-@Component
-@Service(ViewableWriter.class)
 @Produces("text/html")
 @Provider
 public class ViewableWriter implements MessageBodyWriter<Viewable> {
 
-	@Reference
-	private LdRenderer ldRenderer;
+    
+    
+	private TemplateLoader templateLoader;
+
+	public ViewableWriter(TemplateLoader templateLoader) {
+	    if(templateLoader == null){
+	        throw new IllegalArgumentException("The parsed templateLoader MUST NOT be NULL");
+	    }
+        this.templateLoader = templateLoader;
+    }
 	
 	@Override
 	public boolean isWriteable(Class<?> type, Type genericType,
@@ -63,9 +70,31 @@ public class ViewableWriter implements M
 			OutputStream entityStream) throws IOException,
 			WebApplicationException {
 		Writer out = new OutputStreamWriter(entityStream, "utf-8"); 
-		ldRenderer.renderPojo(new Wrapper(t.getPojo()), "html/"+t.getTemplatePath(), out);
+		renderPojo(new Wrapper(t.getPojo()), "html/"+t.getTemplatePath(), out);
 		out.flush();
 	}
+	
+	   /**
+     * Old school classical freemarker rendering, no LD here
+     */
+    public void renderPojo(Object pojo, final String templatePath, Writer out) {    
+        Configuration freemarker= new Configuration();
+        freemarker.setDefaultEncoding("utf-8");
+        freemarker.setOutputEncoding("utf-8");
+        freemarker.setLocalizedLookup(false);
+        freemarker.setObjectWrapper(new DefaultObjectWrapper());
+        freemarker.setTemplateLoader(templateLoader);
+        try {
+            //should root be a map instead?
+            freemarker.getTemplate(templatePath).process(pojo, out);
+            out.flush();
+        } catch (IOException e) {
+            throw new RuntimeException(e);
+        } catch (TemplateException e) {
+            throw new RuntimeException(e);
+        }
+    }
+	
 	static public class Wrapper {
 
 		private Object wrapped;