aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rotty3...@apache.org
Subject [2/2] aries-jax-rs-whiteboard git commit: small updates
Date Sun, 02 Jul 2017 20:06:34 GMT
small updates

Signed-off-by: Raymond Augé <rotty3000@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/repo
Commit: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/commit/ba62d922
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/ba62d922
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/ba62d922

Branch: refs/heads/master
Commit: ba62d9220baad7bbbc18587aade1ebe39f821928
Parents: 506532b
Author: Raymond Auge <rotty3000@apache.org>
Authored: Sun Jul 2 14:23:56 2017 -0400
Committer: Raymond Auge <rotty3000@apache.org>
Committed: Sun Jul 2 16:05:34 2017 -0400

----------------------------------------------------------------------
 .../aries/jax/rs/example/ExampleAddon.java      |  1 +
 .../aries/jax/rs/example/ExampleFilter.java     | 16 +++++++-
 .../aries/jax/rs/whiteboard/internal/Utils.java | 39 +++++++-------------
 .../src/main/resources/static/index.html        |  8 +++-
 4 files changed, 35 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/ba62d922/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleAddon.java
----------------------------------------------------------------------
diff --git a/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleAddon.java
b/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleAddon.java
index 10f769a..2104504 100644
--- a/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleAddon.java
+++ b/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleAddon.java
@@ -52,4 +52,5 @@ public class ExampleAddon {
 
     private static final Logger _log = LoggerFactory.getLogger(
         ExampleAddon.class);
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/ba62d922/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleFilter.java
----------------------------------------------------------------------
diff --git a/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleFilter.java
b/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleFilter.java
index 151429d..2ab0997 100644
--- a/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleFilter.java
+++ b/jax-rs.example/src/main/java/org/apache/aries/jax/rs/example/ExampleFilter.java
@@ -19,9 +19,13 @@ package org.apache.aries.jax.rs.example;
 
 import org.osgi.service.component.annotations.Component;
 import org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.ws.rs.container.ContainerRequestContext;
 import javax.ws.rs.container.ContainerRequestFilter;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.UriInfo;
 import javax.ws.rs.ext.Provider;
 import java.io.IOException;
 
@@ -38,7 +42,15 @@ public class ExampleFilter implements ContainerRequestFilter {
     public void filter(ContainerRequestContext requestContext)
         throws IOException {
 
-        System.out.println("FILTERED!");
+        if (_log.isDebugEnabled()) {
+            _log.debug("FILTERED: " + _uriInfo.getAbsolutePath());
+        }
     }
 
-}
+    @Context
+    UriInfo _uriInfo;
+
+    private static final Logger _log = LoggerFactory.getLogger(
+        ExampleFilter.class);
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/ba62d922/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
index 0a396f7..7b44394 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
@@ -23,10 +23,8 @@ import org.apache.aries.osgi.functional.OSGi;
 import org.apache.cxf.Bus;
 import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
 import org.apache.cxf.message.Message;
-import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceObjects;
 import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.service.jaxrs.runtime.dto.FailedApplicationDTO;
 
 import javax.ws.rs.core.Application;
@@ -135,22 +133,11 @@ public class Utils {
             CXFJaxRsServiceRegistrator registrator,
             ServiceObjects<T> serviceObjects) {
 
-        Thread thread = Thread.currentThread();
-        ClassLoader contextClassLoader = thread.getContextClassLoader();
-        Bundle bundle = serviceReference.getBundle();
-        BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
-        ClassLoader classLoader = bundleWiring.getClassLoader();
         ResourceProvider resourceProvider = getResourceProvider(serviceObjects);
-        try {
-            thread.setContextClassLoader(classLoader);
-            ResourceInformation<ServiceReference<?>> resourceInformation =
-                new ResourceInformation<>(serviceReference, resourceProvider);
-            registrator.add(resourceInformation);
-            return just(resourceInformation);
-        }
-        finally {
-            thread.setContextClassLoader(contextClassLoader);
-        }
+        ResourceInformation<ServiceReference<?>> resourceInformation =
+            new ResourceInformation<>(serviceReference, resourceProvider);
+        registrator.add(resourceInformation);
+        return just(resourceInformation);
     }
 
     public static String safeToString(Object object) {
@@ -160,11 +147,7 @@ public class Utils {
     public static <T> ResourceProvider getResourceProvider(
         ServiceObjects<T> serviceObjects) {
 
-        ResourceProvider resourceProvider;
-        T service = serviceObjects.getService();
-        Class<?> serviceClass = service.getClass();
-
-        resourceProvider = new ResourceProvider() {
+        return new ResourceProvider() {
 
             @Override
             public Object getInstance(Message m) {
@@ -179,7 +162,14 @@ public class Utils {
 
             @Override
             public Class<?> getResourceClass() {
-                return serviceClass;
+                T service = serviceObjects.getService();
+
+                try {
+                    return service.getClass();
+                }
+                finally {
+                    serviceObjects.ungetService(service);
+                }
             }
 
             @Override
@@ -187,9 +177,6 @@ public class Utils {
                 return false;
             }
         };
-
-        serviceObjects.ungetService(service);
-        return resourceProvider;
     }
 
     public static void unregisterEndpoint(

http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/ba62d922/jax-rs.whiteboard/src/main/resources/static/index.html
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/resources/static/index.html b/jax-rs.whiteboard/src/main/resources/static/index.html
index 6c70dca..8980475 100644
--- a/jax-rs.whiteboard/src/main/resources/static/index.html
+++ b/jax-rs.whiteboard/src/main/resources/static/index.html
@@ -26,9 +26,15 @@
     <main role="main">
         <h2>Welcome to the <code>default</code> Application of the Aries
JAX-RS Whiteboard</h2>
 
+        <p>
+        If you are seeing this page it means that you've successfully deployed the Aries
JAX-RS Whiteboard!
+        </p>
+
         <p>If you want more information about JAX-RS you can find out more about it
<a href="http://docs.oracle.com/javaee/7/tutorial/jaxrs.htm#GIEPU">here</a>.
 
-        <p>As you can see there's nothing fancy going on here yet! What you should
do now is deploy an <code>javax.ws.rs.core.Application</code> or any JAX-RS resource
as an OSGi service. Let's take a look at a couple of examples using the OSGi Declarative Services
specification.</p>
+        <p>
+        What you should do now is deploy an JAX-RS resource as an OSGi service.
+        Let's take a look at a couple of examples which will use OSGi Declarative Services
specification as the means of creating the OSGi services.</p>
 
         <p>The first example will simply add a resource (a.k.a. an endpoint).</p>
 


Mime
View raw message