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/06/07 12:22:50 UTC

svn commit: r1490567 - in /stanbol/branches/commons-ng: commons/solr/defaults/ commons/stanboltools/offline/ commons/web/base.jersey/ commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/ commons/web/base/src/main/java/org/a...

Author: reto
Date: Fri Jun  7 10:22:50 2013
New Revision: 1490567

URL: http://svn.apache.org/r1490567
Log:
STANBOL-1097: Updates scr to allow injection in superclass. Entry page is now showing up.

Added:
    stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/EditableLayoutConfiguration.java
    stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/LayoutConfiguration.java
Modified:
    stanbol/branches/commons-ng/commons/solr/defaults/pom.xml
    stanbol/branches/commons-ng/commons/stanboltools/offline/pom.xml
    stanbol/branches/commons-ng/commons/web/base.jersey/pom.xml
    stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java
    stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java
    stanbol/branches/commons-ng/commons/web/rdfviewable-writer/pom.xml
    stanbol/branches/commons-ng/parent/pom.xml

Modified: stanbol/branches/commons-ng/commons/solr/defaults/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/solr/defaults/pom.xml?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/solr/defaults/pom.xml (original)
+++ stanbol/branches/commons-ng/commons/solr/defaults/pom.xml Fri Jun  7 10:22:50 2013
@@ -60,10 +60,6 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-scr-plugin</artifactId>
-      </plugin>
-      <plugin>
         <groupId>org.apache.rat</groupId>
         <artifactId>apache-rat-plugin</artifactId>
         <configuration>

Modified: stanbol/branches/commons-ng/commons/stanboltools/offline/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/stanboltools/offline/pom.xml?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/stanboltools/offline/pom.xml (original)
+++ stanbol/branches/commons-ng/commons/stanboltools/offline/pom.xml Fri Jun  7 10:22:50 2013
@@ -47,10 +47,6 @@
     <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>

Modified: stanbol/branches/commons-ng/commons/web/base.jersey/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/base.jersey/pom.xml?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/web/base.jersey/pom.xml (original)
+++ stanbol/branches/commons-ng/commons/web/base.jersey/pom.xml Fri Jun  7 10:22:50 2013
@@ -67,28 +67,13 @@
             <Private-Package>
               org.apache.stanbol.commons.web.base.jersey;version=${project.version}
             </Private-Package>
-            <Import-Package>
-              !javax.servlet.jsp.*,
-              !org.apache.tools.*,
-              !org.mortbay.*,
-              !org.apache.xpath.*,
-              !org.jdom.*,
-              !org.jaxen.*,
-              !org.apache.xml.*,
-              !org.mozilla.javascript.*,
-              !org.python.*,
-              !org.dom4j.*,
-              !org.apache.log.*,
-              !com.sun.org.apache.*,
-              !javax.el,
-              !org.slf4j.spi,
-              !org.zeroturnaround.javarebel,
+            <!-- <Import-Package>
               javax.servlet; version="[2.5.0,4.0.0)",
               javax.servlet.http; version="[2.5.0,4.0.0)",
               org.apache.stanbol.commons.web.base,
               org.apache.stanbol.commons.web.base.*,
               *
-            </Import-Package>
+            </Import-Package> -->
           </instructions>
         </configuration>
       </plugin>

Added: stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/EditableLayoutConfiguration.java
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/EditableLayoutConfiguration.java?rev=1490567&view=auto
==============================================================================
--- stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/EditableLayoutConfiguration.java (added)
+++ stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/EditableLayoutConfiguration.java Fri Jun  7 10:22:50 2013
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed 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.base.jersey;
+
+import java.util.List;
+import javax.ws.rs.core.UriBuilder;
+import org.apache.stanbol.commons.web.base.NavigationLink;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.commons.lang.StringUtils;
+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.NavigationLink;
+import org.apache.stanbol.commons.web.base.ScriptResource;
+import org.apache.stanbol.commons.web.base.resource.LayoutConfiguration;
+
+/**
+ * This class is here for supporting legacy templates
+ *
+ * @deprecated this sets global css-links and script imports, they should be set
+ * specifically in templates
+ */
+@Component
+@Service({LayoutConfiguration.class, EditableLayoutConfiguration.class})
+public class EditableLayoutConfiguration implements LayoutConfiguration {
+
+    private List<NavigationLink> navigationLinks;
+    private String rootUrl;
+    
+    public static final String SYSTEM_CONSOLE = "system/console";
+    private String staticResourcesRootUrl;
+    private List<LinkResource> linkResources;
+    private List<ScriptResource> scriptResources;
+
+    
+    @Override
+    public List<NavigationLink> getNavigationLinks() {
+        return navigationLinks;
+    }
+    
+    
+    @Override
+    public String getRootUrl() {
+        return rootUrl;
+    }
+    
+    void setRootUrl(String rootUrl) {
+        this.rootUrl = rootUrl;
+    }
+
+    @Override
+    public String getStaticResourcesRootUrl() {
+        return staticResourcesRootUrl;
+    }
+
+    @Override
+    public List<LinkResource> getLinkResources() {
+        return linkResources;
+    }
+
+    @Override
+    public List<ScriptResource> getScriptResources() {
+        return scriptResources;
+    }
+
+    void setStaticResourcesRootUrl(String staticResourcesRootUrl) {
+        this.staticResourcesRootUrl = staticResourcesRootUrl;
+    }
+
+    void setLinkResources(List<LinkResource> linkResources) {
+        this.linkResources = linkResources;
+    }
+
+    void setScriptResources(List<ScriptResource> scriptResources) {
+        this.scriptResources = scriptResources;
+    }
+
+    void setNavigationsLinks(List<NavigationLink> navigationLinks) {
+        this.navigationLinks = navigationLinks;
+    }
+}

Modified: stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java (original)
+++ stanbol/branches/commons-ng/commons/web/base.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java Fri Jun  7 10:22:50 2013
@@ -89,6 +89,9 @@ public class JerseyEndpoint {
     
     @Reference
     private Parser parser;
+    
+    @Reference
+    private EditableLayoutConfiguration layoutConfiguration;
 
     /**
      * The origins allowed for multi-host requests
@@ -222,11 +225,16 @@ public class JerseyEndpoint {
         // services
         servletContext = container.getServletContext();
         servletContext.setAttribute(BundleContext.class.getName(), componentContext.getBundleContext());
-        servletContext.setAttribute(BaseStanbolResource.ROOT_URL, applicationAlias);
-        servletContext.setAttribute(BaseStanbolResource.STATIC_RESOURCES_ROOT_URL, staticUrlRoot);
-        servletContext.setAttribute(BaseStanbolResource.LINK_RESOURCES, linkResources);
-        servletContext.setAttribute(BaseStanbolResource.SCRIPT_RESOURCES, scriptResources);
-        servletContext.setAttribute(BaseStanbolResource.NAVIGATION_LINKS, navigationLinks);
+        layoutConfiguration.setRootUrl(applicationAlias);
+        //servletContext.setAttribute(BaseStanbolResource.ROOT_URL, applicationAlias);
+        layoutConfiguration.setStaticResourcesRootUrl(staticUrlRoot);
+        //servletContext.setAttribute(BaseStanbolResource.STATIC_RESOURCES_ROOT_URL, staticUrlRoot);
+        layoutConfiguration.setLinkResources(linkResources);
+        //servletContext.setAttribute(BaseStanbolResource.LINK_RESOURCES, linkResources);
+        layoutConfiguration.setScriptResources(scriptResources);
+        //servletContext.setAttribute(BaseStanbolResource.SCRIPT_RESOURCES, scriptResources);
+        layoutConfiguration.setNavigationsLinks(navigationLinks);
+        //servletContext.setAttribute(BaseStanbolResource.NAVIGATION_LINKS, navigationLinks);
         servletContext.setAttribute(CORS_ORIGIN, corsOrigins);
         servletContext.setAttribute(CORS_ACCESS_CONTROL_EXPOSE_HEADERS, exposedHeaders);
 

Modified: stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java (original)
+++ stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/BaseStanbolResource.java Fri Jun  7 10:22:50 2013
@@ -27,6 +27,8 @@ import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
 import org.apache.stanbol.commons.web.base.LinkResource;
 import org.apache.stanbol.commons.web.base.NavigationLink;
 import org.apache.stanbol.commons.web.base.ScriptResource;
@@ -36,9 +38,13 @@ import org.apache.stanbol.commons.web.ba
  * 
  * TODO: make the list of menu items dynamically contributed by WebFragments from the OSGi runtime.
  */
-public class BaseStanbolResource {
-
-    public static final String LINK_RESOURCES = "org.apache.stanbol.commons.web.base.resource.links";
+//not itself a component but subclasses must be
+//according to http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html
+//"With the annotations the super class is required to have the Component annotation."
+@Component(componentAbstract = true)
+public abstract class BaseStanbolResource {
+    
+    /*public static final String LINK_RESOURCES = "org.apache.stanbol.commons.web.base.resource.links";
 
     public static final String SCRIPT_RESOURCES = "org.apache.stanbol.commons.web.base.resource.scripts";
 
@@ -46,19 +52,25 @@ public class BaseStanbolResource {
 
     public static final String NAVIGATION_LINKS = "org.apache.stanbol.commons.web.base.navigation.link";
 
-    public static final String ROOT_URL = "org.apache.stanbol.commons.web.base.root";
+    public static final String ROOT_URL = "org.apache.stanbol.commons.web.base.root";*/
     
     public static final String SYSTEM_CONSOLE = "system/console";
+    
+   
+    @Reference
+    private LayoutConfiguration layoutConfiguration;
 
     @Context
     protected UriInfo uriInfo;
 
 
     public URI getRequestUri(){
+        if (uriInfo == null) throw new RuntimeException("UriInfo has not been injected");
         return uriInfo.getAbsolutePath();
     }
     
     public URI getPublicBaseUri() {
+        if (uriInfo == null) throw new RuntimeException("UriInfo has not been injected");
         return uriInfo.getBaseUri();
     }
     
@@ -72,7 +84,7 @@ public class BaseStanbolResource {
      * Because of this it will only work with the default {@link #SYSTEM_CONSOLE}.
      * @return The URI for the Apache Felix Webconsole
      */
-    /*public URI getConsoleBaseUri() {
+    public URI getConsoleBaseUri() {
         String root = getRootUrl();
         UriBuilder consolePathBuilder;
         if(StringUtils.isNotBlank(root) && !"/".equals(root)){
@@ -95,26 +107,26 @@ public class BaseStanbolResource {
         }
         
     	return consolePathBuilder.path(SYSTEM_CONSOLE).build();
-    }*/
+    }
 
     /**
      * @return the sorted list of navigation links data transfer objects
      */
-    /*@SuppressWarnings("unchecked")
+    
     public List<NavigationLink> getNavigationLinks() {
-        return (List<NavigationLink>) servletContext.getAttribute(NAVIGATION_LINKS);
-    }*/
+        return layoutConfiguration.getNavigationLinks();
+    }
 
     /**
      * @return menu items with "selected" CSS class for the active link precomputed where applicable
      */
-    /*public List<MenuItem> getMainMenuItems() {
+    public List<MenuItem> getMainMenuItems() {
         List<MenuItem> items = new ArrayList<MenuItem>();
         for (NavigationLink link : getNavigationLinks()) {
             items.add(new MenuItem(link.getLabel(), link.getPath(), uriInfo));
         }
         return items;
-    }*/
+    }
 
     public static class MenuItem {
 
@@ -147,31 +159,24 @@ public class BaseStanbolResource {
 
     }
 
-    /*public String getRootUrl() {
-        return (String) servletContext.getAttribute(ROOT_URL);
+    public String getRootUrl() {
+        return layoutConfiguration.getRootUrl();
     }
 
     public String getStaticRootUrl() {
         String baseURI = getPublicBaseUri().toString();
+        if (layoutConfiguration == null) throw new RuntimeException("layoutConfiguration has not been injected!");
         return baseURI.substring(0, baseURI.length() - 1)
-               + (String) servletContext.getAttribute(STATIC_RESOURCES_ROOT_URL);
+               + layoutConfiguration.getStaticResourcesRootUrl();
     }
 
     @SuppressWarnings("unchecked")
     public List<LinkResource> getRegisteredLinkResources() {
-        if (servletContext != null) {
-            return (List<LinkResource>) servletContext.getAttribute(LINK_RESOURCES);
-        } else {
-            return Collections.emptyList();
-        }
+        return layoutConfiguration.getLinkResources();
     }
 
     @SuppressWarnings("unchecked")
     public List<ScriptResource> getRegisteredScriptResources() {
-        if (servletContext != null) {
-            return (List<ScriptResource>) servletContext.getAttribute(SCRIPT_RESOURCES);
-        } else {
-            return Collections.emptyList();
-        }
-    }*/
+        return layoutConfiguration.getScriptResources();
+    }
 }

Added: stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/LayoutConfiguration.java
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/LayoutConfiguration.java?rev=1490567&view=auto
==============================================================================
--- stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/LayoutConfiguration.java (added)
+++ stanbol/branches/commons-ng/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/resource/LayoutConfiguration.java Fri Jun  7 10:22:50 2013
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2013 The Apache Software Foundation.
+ *
+ * Licensed 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.base.resource;
+
+import java.util.List;
+import org.apache.stanbol.commons.web.base.LinkResource;
+import org.apache.stanbol.commons.web.base.NavigationLink;
+import org.apache.stanbol.commons.web.base.ScriptResource;
+
+/**
+ *
+ * @author Reto
+ */
+public interface LayoutConfiguration {
+
+    List<NavigationLink> getNavigationLinks();
+
+    String getRootUrl();
+
+    public String getStaticResourcesRootUrl();
+
+    public List<LinkResource> getLinkResources();
+
+    public List<ScriptResource> getScriptResources();
+    
+}

Modified: stanbol/branches/commons-ng/commons/web/rdfviewable-writer/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/commons/web/rdfviewable-writer/pom.xml?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/commons/web/rdfviewable-writer/pom.xml (original)
+++ stanbol/branches/commons-ng/commons/web/rdfviewable-writer/pom.xml Fri Jun  7 10:22:50 2013
@@ -72,7 +72,7 @@
     <dependency>
       <groupId>org.apache.stanbol</groupId>
       <artifactId>org.apache.stanbol.commons.ldpathtemplate</artifactId>
-      <version>0.12.0-SNAPSHOT</version>
+      <version>1.0.0-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>

Modified: stanbol/branches/commons-ng/parent/pom.xml
URL: http://svn.apache.org/viewvc/stanbol/branches/commons-ng/parent/pom.xml?rev=1490567&r1=1490566&r2=1490567&view=diff
==============================================================================
--- stanbol/branches/commons-ng/parent/pom.xml (original)
+++ stanbol/branches/commons-ng/parent/pom.xml Fri Jun  7 10:22:50 2013
@@ -181,7 +181,7 @@
       <plugin>
         <groupId>org.apache.felix</groupId>
         <artifactId>maven-scr-plugin</artifactId>
-        <version>1.7.4</version>
+        <version>1.12.0</version>
         <!-- slf4j impl is needed when QDox inspects/loads classes that use a
              static field for the logger, so that those classes can be loaded. -->
           <dependencies>
@@ -553,12 +553,12 @@
       <dependency>
         <groupId>org.apache.felix</groupId>
         <artifactId>org.apache.felix.scr</artifactId>
-        <version>1.6.0</version>
+        <version>1.6.2</version>
       </dependency>
       <dependency>
         <groupId>org.apache.felix</groupId>
         <artifactId>org.apache.felix.scr.annotations</artifactId>
-        <version>1.6.0</version>
+        <version>1.9.2</version>
       </dependency>
       <dependency>
         <groupId>org.apache.felix</groupId>