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/30 19:12:36 UTC

svn commit: r1087019 - in /incubator/stanbol/branches/http-endpoint-refactoring: commons/ commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/ commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/ commons/web/base/...

Author: ogrisel
Date: Wed Mar 30 17:12:35 2011
New Revision: 1087019

URL: http://svn.apache.org/viewvc?rev=1087019&view=rev
Log:
STANBOL-120: moving the homepage definition in it's dedicated web fragment / bundle

Added:
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/StanbolRootResource.java
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/static/
      - copied from r1087008, incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/resources/META-INF/static/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/
      - copied from r1087008, incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/resources/META-INF/templates/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/base/
      - copied from r1087011, incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/resources/META-INF/templates/org/apache/stanbol/commons/web/base/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/apache/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/apache/stanbol/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/apache/stanbol/commons/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/sparql/src/main/java/org/apache/stanbol/commons/web/sparql/
Removed:
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/StanbolRootResource.java
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/resources/META-INF/static/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/resources/META-INF/templates/
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/org/apache/stanbol/commons/web/resource/
Modified:
    incubator/stanbol/branches/http-endpoint-refactoring/commons/pom.xml
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpoint.java
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpointApplication.java
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/pom.xml
    incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl
    incubator/stanbol/branches/http-endpoint-refactoring/launchers/mini/src/main/bundles/list.xml

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/pom.xml?rev=1087019&r1=1087018&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/pom.xml (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/pom.xml Wed Mar 30 17:12:35 2011
@@ -20,8 +20,8 @@
 
   <modules>
     <module>web/base</module>
-    <!--
     <module>web/home</module>
+    <!--
     <module>web/sparql</module>
     -->
     <module>testing/jarexec</module>

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpoint.java?rev=1087019&r1=1087018&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpoint.java (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpoint.java Wed Mar 30 17:12:35 2011
@@ -27,8 +27,6 @@ import org.slf4j.LoggerFactory;
 
 import com.sun.jersey.spi.container.servlet.ServletContainer;
 
-import freemarker.cache.ClassTemplateLoader;
-
 /**
  * Jersey-based RESTful endpoint for the Stanbol Enhancer engines and store.
  * <p>
@@ -47,12 +45,6 @@ public class JerseyEndpoint {
     @Property(value = "/static")
     public static final String STATIC_RESOURCES_URL_ROOT_PROPERTY = "org.apache.stanbol.commons.web.static.url";
 
-    @Property(value = "/META-INF/static")
-    public static final String STATIC_RESOURCES_CLASSPATH_PROPERTY = "org.apache.stanbol.commons.web.static.classpath";
-
-    @Property(value = "/META-INF/templates")
-    public static final String FREEMARKER_TEMPLATE_CLASSPATH_PROPERTY = "org.apache.stanbol.commons.web.templates.classpath";
-
     @Reference
     HttpService httpService;
 
@@ -81,17 +73,6 @@ public class JerseyEndpoint {
         // prefix
         JerseyEndpointApplication app = new JerseyEndpointApplication();
         String staticUrlRoot = (String) ctx.getProperties().get(STATIC_RESOURCES_URL_ROOT_PROPERTY);
-        String staticClasspath = (String) ctx.getProperties().get(STATIC_RESOURCES_CLASSPATH_PROPERTY);
-        String templateClasspath = (String) ctx.getProperties().get(FREEMARKER_TEMPLATE_CLASSPATH_PROPERTY);
-
-        // register the base template loader
-        templateClasspath = templateClasspath.replaceAll("/$", "");
-        app.contributeTemplateLoader(new ClassTemplateLoader(getClass(), templateClasspath));
-
-        // register the root of static resources (TODO: move me in a dedicated fragment instead)
-        String defaultStaticAlias = staticUrlRoot + "/default";
-        httpService.registerResources(defaultStaticAlias, staticClasspath, null);
-        registeredAliases.add(defaultStaticAlias);
 
         // incrementally contribute fragment resources
         List<LinkResource> linkResources = new ArrayList<LinkResource>();

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpointApplication.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpointApplication.java?rev=1087019&r1=1087018&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpointApplication.java (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/JerseyEndpointApplication.java Wed Mar 30 17:12:35 2011
@@ -8,7 +8,6 @@ import java.util.Set;
 import javax.ws.rs.core.Application;
 
 import org.apache.stanbol.commons.web.base.processor.FreemarkerViewProcessor;
-import org.apache.stanbol.commons.web.base.resource.StanbolRootResource;
 import org.apache.stanbol.commons.web.base.writers.GraphWriter;
 import org.apache.stanbol.commons.web.base.writers.ResultSetWriter;
 import org.slf4j.Logger;
@@ -34,10 +33,6 @@ public class JerseyEndpointApplication e
     @Override
     public Set<Class<?>> getClasses() {
         Set<Class<?>> classes = new HashSet<Class<?>>();
-        // hardcoded root resource class for now (to be externalized into a stanbol.commons.web.home package
-        // for instance)
-        classes.add(StanbolRootResource.class);
-
         // resources contributed buy other bundles
         classes.addAll(contributedClasses);
 

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/pom.xml?rev=1087019&r1=1087018&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/pom.xml (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/pom.xml Wed Mar 30 17:12:35 2011
@@ -63,6 +63,28 @@
       <groupId>commons-lang</groupId>
       <artifactId>commons-lang</artifactId>
     </dependency>
+    
+    <!-- Jersey, servlet and freemarker -->
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-server</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.sun.jersey</groupId>
+      <artifactId>jersey-json</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>javax.servlet</groupId>
+      <artifactId>servlet-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.freemarker</groupId>
+      <artifactId>freemarker</artifactId>
+    </dependency>
 
     <!-- OSGi tax -->
     <dependency>

Added: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java?rev=1087019&view=auto
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java (added)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/HomeWebFragment.java Wed Mar 30 17:12:35 2011
@@ -0,0 +1,88 @@
+package org.apache.stanbol.commons.web.home;
+
+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.Service;
+import org.apache.stanbol.commons.web.base.LinkResource;
+import org.apache.stanbol.commons.web.base.ScriptResource;
+import org.apache.stanbol.commons.web.base.WebFragment;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+
+import freemarker.cache.ClassTemplateLoader;
+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 HomeWebFragment implements WebFragment {
+
+    private static final String NAME = "home";
+
+    private static final String STATIC_RESOURCE_PATH = "/org/apache/stanbol/commons/web/home/static";
+
+    private static final String TEMPLATE_PATH = "/org/apache/stanbol/commons/web/home/templates";
+
+    private BundleContext bundleContext;
+
+    @Override
+    public String getName() {
+        return NAME;
+    }
+
+    @Activate
+    protected void activate(ComponentContext ctx) {
+        this.bundleContext = ctx.getBundleContext();
+    }
+
+    @Override
+    public Set<Class<?>> getJaxrsResourceClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        classes.add(StanbolRootResource.class);
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getJaxrsResourceSingletons() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public String getStaticResourceClassPath() {
+        return STATIC_RESOURCE_PATH;
+    }
+
+    @Override
+    public TemplateLoader getTemplateLoader() {
+        return new ClassTemplateLoader(getClass(), TEMPLATE_PATH);
+    }
+
+    @Override
+    public List<LinkResource> getLinkResources() {
+        List<LinkResource> resources = new ArrayList<LinkResource>();
+        resources.add(new LinkResource("stylesheet", "style/stanbol.css", this));
+        return resources;
+    }
+
+    @Override
+    public List<ScriptResource> getScriptResources() {
+        List<ScriptResource> resources = new ArrayList<ScriptResource>();
+        // resources.add(new ScriptResource("text/javascript", "scripts/jquery-1.4.2.js", this));
+        return resources;
+    }
+
+    @Override
+    public BundleContext getBundleContext() {
+        return bundleContext;
+    }
+
+}

Added: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/StanbolRootResource.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/StanbolRootResource.java?rev=1087019&view=auto
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/StanbolRootResource.java (added)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/java/org/apache/stanbol/commons/web/home/StanbolRootResource.java Wed Mar 30 17:12:35 2011
@@ -0,0 +1,27 @@
+package org.apache.stanbol.commons.web.home;
+
+import static javax.ws.rs.core.MediaType.TEXT_HTML;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Response;
+
+import org.apache.stanbol.commons.web.base.resource.BaseStanbolResource;
+
+import com.sun.jersey.api.view.Viewable;
+
+/**
+ * Root JAX-RS resource. The HTML view is implicitly rendered by a freemarker template to be found in the
+ * META-INF/templates folder.
+ */
+@Path("/")
+public class StanbolRootResource extends BaseStanbolResource {
+
+    @GET
+    @Produces(TEXT_HTML)
+    public Response get() {
+        return Response.ok(new Viewable("index", this), TEXT_HTML).build();
+    }
+
+}

Modified: incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl?rev=1087019&r1=1087008&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/commons/web/home/src/main/resources/org/apache/stanbol/commons/web/home/templates/imports/common.ftl Wed Mar 30 17:12:35 2011
@@ -6,8 +6,8 @@
     <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
 
     <!-- to be moved in the dedicated fragment -->
-    <link rel="stylesheet" href="/static/default/style/stanbol.css" />
-    <link rel="icon" type="image/png" href="/static/default/images/favicon.png" />
+    <link rel="stylesheet" href="/static/base/style/stanbol.css" />
+    <link rel="icon" type="image/png" href="/static/base/images/favicon.png" />
 
     <#list it.registeredLinkResources as link>
     <link rel="${link.rel}" href="${it.staticRootUrl}/${link.fragmentName}/${link.relativePath}" />
@@ -20,7 +20,7 @@
   </head>
 
   <body>
-    <div class="home"><a href="/"><img src="/static/default/images/apache_stanbol_logo_cropped.png" alt="Stanbol Home" /></a></div>
+    <div class="home"><a href="/"><img src="/static/base/images/apache_stanbol_logo_cropped.png" alt="Stanbol Home" /></a></div>
     <div class="header">
       <h1>The RESTful Semantic Engine</h1>
 
@@ -63,9 +63,9 @@ $(".restapitabs a").click(function () {
 
     <div class="column">
       <a href="http://www.w3.org/standards/semanticweb/"><img class="swcube"
-        src="/static/default/images/sw-cube.png"/></a>
+        src="/static/base/images/sw-cube.png"/></a>
       <a href="http://www.iks-project.eu"><img
-        height="60px" alt="IKS Project" src="/static/default/images/iks_project_logo.jpg" /></a>
+        height="60px" alt="IKS Project" src="/static/base/images/iks_project_logo.jpg" /></a>
     </div>
     <div class="column right">
       <em>The research leading to these results has received funding from the European Community's

Modified: incubator/stanbol/branches/http-endpoint-refactoring/launchers/mini/src/main/bundles/list.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/http-endpoint-refactoring/launchers/mini/src/main/bundles/list.xml?rev=1087019&r1=1087018&r2=1087019&view=diff
==============================================================================
--- incubator/stanbol/branches/http-endpoint-refactoring/launchers/mini/src/main/bundles/list.xml (original)
+++ incubator/stanbol/branches/http-endpoint-refactoring/launchers/mini/src/main/bundles/list.xml Wed Mar 30 17:12:35 2011
@@ -150,6 +150,11 @@
 		</bundle>
 		<bundle>
 			<groupId>org.apache.stanbol</groupId>
+			<artifactId>org.apache.stanbol.commons.web.home</artifactId>
+			<version>0.9-SNAPSHOT</version>
+		</bundle>
+		<bundle>
+			<groupId>org.apache.stanbol</groupId>
 			<artifactId>org.apache.stanbol.enhancer.standalone</artifactId>
 			<version>0.9-SNAPSHOT</version>
 		</bundle>