You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@clerezza.apache.org by re...@apache.org on 2015/09/05 12:06:45 UTC

clerezza git commit: renamed package

Repository: clerezza
Updated Branches:
  refs/heads/master ea0996014 -> c3676000e


renamed package

Project: http://git-wip-us.apache.org/repos/asf/clerezza/repo
Commit: http://git-wip-us.apache.org/repos/asf/clerezza/commit/c3676000
Tree: http://git-wip-us.apache.org/repos/asf/clerezza/tree/c3676000
Diff: http://git-wip-us.apache.org/repos/asf/clerezza/diff/c3676000

Branch: refs/heads/master
Commit: c3676000e7874cc3285c01f1b7b10c4c369be12d
Parents: ea09960
Author: Reto Gmür <re...@apache.org>
Authored: Sat Sep 5 12:01:53 2015 +0200
Committer: Reto Gmür <re...@apache.org>
Committed: Sat Sep 5 12:01:53 2015 +0200

----------------------------------------------------------------------
 jaxrs.whiteboard.jersey/pom.xml                 |   9 +-
 .../whiteboard/jersey/DefaultApplication.java   |  69 +++++++++
 .../jaxrs/whiteboard/jersey/JerseyEndpoint.java | 148 +++++++++++++++++++
 .../web/base/jersey/DefaultApplication.java     |  69 ---------
 .../commons/web/base/jersey/JerseyEndpoint.java | 148 -------------------
 5 files changed, 218 insertions(+), 225 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/clerezza/blob/c3676000/jaxrs.whiteboard.jersey/pom.xml
----------------------------------------------------------------------
diff --git a/jaxrs.whiteboard.jersey/pom.xml b/jaxrs.whiteboard.jersey/pom.xml
index 432d87d..b0181f8 100644
--- a/jaxrs.whiteboard.jersey/pom.xml
+++ b/jaxrs.whiteboard.jersey/pom.xml
@@ -56,15 +56,8 @@
                 <configuration>
                     <instructions>
                         <Private-Package>
-                            org.apache.stanbol.commons.web.base.jersey;version=${project.version}
+                            org.apache.clerezza.jaxrs.whiteboard.jersey;version=${project.version}
                         </Private-Package>
-                        <!-- <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> -->
                     </instructions>
                 </configuration>
             </plugin>

http://git-wip-us.apache.org/repos/asf/clerezza/blob/c3676000/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/DefaultApplication.java
----------------------------------------------------------------------
diff --git a/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/DefaultApplication.java b/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/DefaultApplication.java
new file mode 100644
index 0000000..535fdeb
--- /dev/null
+++ b/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/DefaultApplication.java
@@ -0,0 +1,69 @@
+/*
+* 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.clerezza.jaxrs.whiteboard.jersey;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.ws.rs.core.Application;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Define the list of available resources and providers to be used by the Stanbol JAX-RS Endpoint.
+ */
+public class DefaultApplication extends Application {
+
+    @SuppressWarnings("unused")
+    private static final Logger log = LoggerFactory.getLogger(DefaultApplication.class);
+
+    protected final Set<Class<?>> contributedClasses = new HashSet<Class<?>>();
+
+    protected final Set<Object> contributedSingletons = new HashSet<Object>();
+
+
+    @Override
+    public Set<Class<?>> getClasses() {
+        Set<Class<?>> classes = new HashSet<Class<?>>();
+        // resources contributed buy other bundles
+        classes.addAll(contributedClasses);
+        //TODO check if clerezza rdf.jaxrs prvoder fits the purpose
+        // message body writers, hard-coded for now
+        //classes.add(GraphWriter.class);
+        //classes.add(JenaModelWriter.class);
+        //classes.add(ResultSetWriter.class);
+        return classes;
+    }
+
+    @Override
+    public Set<Object> getSingletons() {
+        Set<Object> singletons = new HashSet<Object>();
+        singletons.addAll(contributedSingletons);
+        return singletons;
+    }
+
+    public void contributeClasses(Set<Class<?>> classes) {
+        contributedClasses.addAll(classes);
+    }
+
+    public void contributeSingletons(Set<Object> singletons) {
+        contributedSingletons.addAll(singletons);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/c3676000/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/JerseyEndpoint.java
----------------------------------------------------------------------
diff --git a/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/JerseyEndpoint.java b/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/JerseyEndpoint.java
new file mode 100644
index 0000000..b0364a5
--- /dev/null
+++ b/jaxrs.whiteboard.jersey/src/main/java/org/apache/clerezza/jaxrs/whiteboard/jersey/JerseyEndpoint.java
@@ -0,0 +1,148 @@
+/*
+ * 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.clerezza.jaxrs.whiteboard.jersey;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+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.Property;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.apache.felix.scr.annotations.ReferencePolicy;
+import org.apache.felix.scr.annotations.ReferencePolicyOption;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import org.apache.felix.scr.annotations.References;
+import org.glassfish.jersey.server.ResourceConfig;
+import org.glassfish.jersey.servlet.ServletContainer;
+
+/**
+ * Jersey-based JAXRS whiteboard implementation.
+ * 
+ * This exposes JAX-RS resources available as services exposing Object with the property javax.ws.rs=true
+ */
+@Component(immediate = true, metatype = true)
+@References({
+    @Reference(name="component", referenceInterface=Object.class, 
+        target="(javax.ws.rs=true)", 
+		cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, 
+        policy=ReferencePolicy.STATIC,
+        policyOption=ReferencePolicyOption.GREEDY)})
+public class JerseyEndpoint {
+
+    private final Logger log = LoggerFactory.getLogger(getClass());
+
+    @Property(value = "/")
+    public static final String ALIAS_PROPERTY = "org.apache.stanbol.commons.web.alias";
+
+    @Property(value = "/static")
+    public static final String STATIC_RESOURCES_URL_ROOT_PROPERTY = "org.apache.stanbol.commons.web.static.url";
+    
+    @Reference
+    HttpService httpService;
+
+    protected ComponentContext componentContext;
+
+    protected ServletContext servletContext;
+
+
+    protected final List<String> registeredAliases = new ArrayList<String>();
+
+    protected Set<String> exposedHeaders;
+    private Set<Object> components = new HashSet<Object>();
+
+    public Dictionary<String,String> getInitParams() {
+        Dictionary<String,String> initParams = new Hashtable<String,String>();
+        // make jersey automatically turn resources into Viewable models and
+        // hence lookup matching freemarker templates
+        initParams.put("com.sun.jersey.config.feature.ImplicitViewables", "true");
+        return initParams;
+    }
+
+    @Activate
+    protected void activate(ComponentContext componentContext) throws IOException,
+                                                 ServletException,
+                                                 NamespaceException,
+                                                 ConfigurationException {
+
+        log.info("Activating Jersey subsystem");
+
+        // register all the JAX-RS resources into a a JAX-RS application and bind it to a configurable URL
+        // prefix
+        DefaultApplication app = new DefaultApplication();
+        String applicationAlias = (String) componentContext.getProperties().get(ALIAS_PROPERTY);
+
+        app.contributeSingletons(components);
+
+        // bind the aggregate JAX-RS application to a dedicated servlet
+        ServletContainer container = new ServletContainer(
+                ResourceConfig.forApplication(app));
+        httpService.registerServlet(applicationAlias, container, getInitParams(), null);
+        registeredAliases.add(applicationAlias);
+
+        // forward the main Stanbol OSGi runtime context so that JAX-RS resources can lookup arbitrary
+        // services
+        servletContext = container.getServletContext();
+        servletContext.setAttribute(BundleContext.class.getName(), componentContext.getBundleContext());
+        log.info("JerseyEndpoint servlet registered at {}", applicationAlias);
+    }
+
+    /** Shutdown Jersey, if there's anything to do */
+    private synchronized void shutdownJersey() {
+        log.debug("Unregistering aliases {}", registeredAliases);
+        for (String alias : registeredAliases) {
+            httpService.unregister(alias);
+        }
+        registeredAliases.clear();
+    }
+
+    @Deactivate
+    protected void deactivate(ComponentContext ctx) {
+        shutdownJersey();
+        servletContext = null;
+    }
+    
+    protected void bindComponent(Object component) throws IOException,
+                                                          ServletException,
+                                                          NamespaceException  {
+        components.add(component);
+    }
+
+    protected void unbindComponent(Object component) throws IOException,
+                                                          ServletException,
+                                                          NamespaceException  {
+        components.remove(component);
+    }    
+}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/c3676000/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/DefaultApplication.java
----------------------------------------------------------------------
diff --git a/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/DefaultApplication.java b/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/DefaultApplication.java
deleted file mode 100644
index 6d1c292..0000000
--- a/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/DefaultApplication.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* 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.base.jersey;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.ws.rs.core.Application;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * Define the list of available resources and providers to be used by the Stanbol JAX-RS Endpoint.
- */
-public class DefaultApplication extends Application {
-
-    @SuppressWarnings("unused")
-    private static final Logger log = LoggerFactory.getLogger(DefaultApplication.class);
-
-    protected final Set<Class<?>> contributedClasses = new HashSet<Class<?>>();
-
-    protected final Set<Object> contributedSingletons = new HashSet<Object>();
-
-
-    @Override
-    public Set<Class<?>> getClasses() {
-        Set<Class<?>> classes = new HashSet<Class<?>>();
-        // resources contributed buy other bundles
-        classes.addAll(contributedClasses);
-        //TODO check if clerezza rdf.jaxrs prvoder fits the purpose
-        // message body writers, hard-coded for now
-        //classes.add(GraphWriter.class);
-        //classes.add(JenaModelWriter.class);
-        //classes.add(ResultSetWriter.class);
-        return classes;
-    }
-
-    @Override
-    public Set<Object> getSingletons() {
-        Set<Object> singletons = new HashSet<Object>();
-        singletons.addAll(contributedSingletons);
-        return singletons;
-    }
-
-    public void contributeClasses(Set<Class<?>> classes) {
-        contributedClasses.addAll(classes);
-    }
-
-    public void contributeSingletons(Set<Object> singletons) {
-        contributedSingletons.addAll(singletons);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/clerezza/blob/c3676000/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java
----------------------------------------------------------------------
diff --git a/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java b/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java
deleted file mode 100644
index e98ab04..0000000
--- a/jaxrs.whiteboard.jersey/src/main/java/org/apache/stanbol/commons/web/base/jersey/JerseyEndpoint.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.base.jersey;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Set;
-
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
-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.Property;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.ReferencePolicy;
-import org.apache.felix.scr.annotations.ReferencePolicyOption;
-import org.osgi.framework.BundleContext;
-import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.component.ComponentContext;
-import org.osgi.service.http.HttpService;
-import org.osgi.service.http.NamespaceException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-import org.apache.felix.scr.annotations.References;
-import org.glassfish.jersey.server.ResourceConfig;
-import org.glassfish.jersey.servlet.ServletContainer;
-
-/**
- * Jersey-based JAXRS whiteboard implementation.
- * 
- * This exposes JAX-RS resources available as services exposing Object with the property javax.ws.rs=true
- */
-@Component(immediate = true, metatype = true)
-@References({
-    @Reference(name="component", referenceInterface=Object.class, 
-        target="(javax.ws.rs=true)", 
-		cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, 
-        policy=ReferencePolicy.STATIC,
-        policyOption=ReferencePolicyOption.GREEDY)})
-public class JerseyEndpoint {
-
-    private final Logger log = LoggerFactory.getLogger(getClass());
-
-    @Property(value = "/")
-    public static final String ALIAS_PROPERTY = "org.apache.stanbol.commons.web.alias";
-
-    @Property(value = "/static")
-    public static final String STATIC_RESOURCES_URL_ROOT_PROPERTY = "org.apache.stanbol.commons.web.static.url";
-    
-    @Reference
-    HttpService httpService;
-
-    protected ComponentContext componentContext;
-
-    protected ServletContext servletContext;
-
-
-    protected final List<String> registeredAliases = new ArrayList<String>();
-
-    protected Set<String> exposedHeaders;
-    private Set<Object> components = new HashSet<Object>();
-
-    public Dictionary<String,String> getInitParams() {
-        Dictionary<String,String> initParams = new Hashtable<String,String>();
-        // make jersey automatically turn resources into Viewable models and
-        // hence lookup matching freemarker templates
-        initParams.put("com.sun.jersey.config.feature.ImplicitViewables", "true");
-        return initParams;
-    }
-
-    @Activate
-    protected void activate(ComponentContext componentContext) throws IOException,
-                                                 ServletException,
-                                                 NamespaceException,
-                                                 ConfigurationException {
-
-        log.info("Activating Jersey subsystem");
-
-        // register all the JAX-RS resources into a a JAX-RS application and bind it to a configurable URL
-        // prefix
-        DefaultApplication app = new DefaultApplication();
-        String applicationAlias = (String) componentContext.getProperties().get(ALIAS_PROPERTY);
-
-        app.contributeSingletons(components);
-
-        // bind the aggregate JAX-RS application to a dedicated servlet
-        ServletContainer container = new ServletContainer(
-                ResourceConfig.forApplication(app));
-        httpService.registerServlet(applicationAlias, container, getInitParams(), null);
-        registeredAliases.add(applicationAlias);
-
-        // forward the main Stanbol OSGi runtime context so that JAX-RS resources can lookup arbitrary
-        // services
-        servletContext = container.getServletContext();
-        servletContext.setAttribute(BundleContext.class.getName(), componentContext.getBundleContext());
-        log.info("JerseyEndpoint servlet registered at {}", applicationAlias);
-    }
-
-    /** Shutdown Jersey, if there's anything to do */
-    private synchronized void shutdownJersey() {
-        log.debug("Unregistering aliases {}", registeredAliases);
-        for (String alias : registeredAliases) {
-            httpService.unregister(alias);
-        }
-        registeredAliases.clear();
-    }
-
-    @Deactivate
-    protected void deactivate(ComponentContext ctx) {
-        shutdownJersey();
-        servletContext = null;
-    }
-    
-    protected void bindComponent(Object component) throws IOException,
-                                                          ServletException,
-                                                          NamespaceException  {
-        components.add(component);
-    }
-
-    protected void unbindComponent(Object component) throws IOException,
-                                                          ServletException,
-                                                          NamespaceException  {
-        components.remove(component);
-    }    
-}