You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by cs...@apache.org on 2017/02/24 16:41:48 UTC
[01/12] aries-jax-rs-whiteboard git commit: [ARIES-JAXRS] use
constants, general cleanup
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master 1463182b8 -> 576f7e395
[ARIES-JAXRS] use constants, general cleanup
Signed-off-by: Raymond Auge <ra...@liferay.com>
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/5b7b1eb8
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/5b7b1eb8
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/5b7b1eb8
Branch: refs/heads/master
Commit: 5b7b1eb899e977519dfec112257685247ff8d68c
Parents: f8a7138
Author: Raymond Auge <ra...@liferay.com>
Authored: Fri Feb 24 10:10:21 2017 -0500
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 48 ++++++++++----------
jax-rs.whiteboard/bnd.bnd | 1 +
.../AriesJaxRSWhiteboardConstants.java | 35 ++++++++++++++
.../activator/CXFJaxRsBundleActivator.java | 29 ++++++------
.../internal/CXFJaxRsServiceRegistrator.java | 12 +++--
.../aries/jax/rs/whiteboard/package-info.java | 21 +++++++++
6 files changed, 106 insertions(+), 40 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 20f8910..646f427 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -17,6 +17,9 @@
package test;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*;
+import static org.apache.aries.jax.rs.whiteboard.AriesJaxRSWhiteboardConstants.*;
+
import java.util.Dictionary;
import java.util.Hashtable;
@@ -126,8 +129,8 @@ public class JaxrsTest {
applicationRegistration = registerApplication();
serviceRegistration = registerAddon(
- "osgi.jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
+ JAX_RS_APPLICATION_SELECT,
+ "(" + JAX_RS_APPLICATION_BASE + "=/test-application)");
assertEquals(
"Hello extended",
@@ -164,8 +167,8 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
+ JAX_RS_APPLICATION_SELECT,
+ "(" + JAX_RS_APPLICATION_BASE + "=/test-application)");
assertEquals(
"Hello extended",
@@ -206,8 +209,8 @@ public class JaxrsTest {
applicationRegistration = registerApplication();
filterRegistration = registerFilter(
- "osgi.jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
+ JAX_RS_APPLICATION_SELECT,
+ "(" + JAX_RS_APPLICATION_BASE + "=/test-application)");
Response response = webTarget.request().get();
@@ -255,8 +258,8 @@ public class JaxrsTest {
try {
filterRegistration = registerFilter(
- "osgi.jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
+ JAX_RS_APPLICATION_SELECT,
+ "(" + JAX_RS_APPLICATION_BASE + "=/test-application)");
response = webTarget.request().get();
@@ -296,7 +299,7 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.resource.base", "/test-addon");
+ JAX_RS_RESOURCE_BASE, "/test-addon");
Response response = webTarget.request().get();
@@ -327,7 +330,7 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.resource.base", "/test-addon");
+ JAX_RS_RESOURCE_BASE, "/test-addon");
assertEquals(
"Hello test",
@@ -357,7 +360,7 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddonLifecycle(
- true, "osgi.jaxrs.resource.base", "/test-addon");
+ true, JAX_RS_RESOURCE_BASE, "/test-addon");
String first = webTarget.request().get().readEntity(String.class);
@@ -384,7 +387,7 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddonLifecycle(
- false, "osgi.jaxrs.resource.base", "/test-addon");
+ false, JAX_RS_RESOURCE_BASE, "/test-addon");
String first = webTarget.request().get().readEntity(String.class);
@@ -414,10 +417,10 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.resource.base", "/test-addon");
+ JAX_RS_RESOURCE_BASE, "/test-addon");
filterRegistration = registerFilter(
- "osgi.jaxrs.extension.name", "test-filter");
+ JAX_RS_EXTENSION_NAME, "test-filter");
Response response = webTarget.request().get();
@@ -450,7 +453,7 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.resource.base", "/test-addon");
+ JAX_RS_RESOURCE_BASE, "/test-addon");
assertEquals("Hello test",
webTarget.request().get().readEntity(String.class));
@@ -464,7 +467,7 @@ public class JaxrsTest {
assertNull(response.getHeaders().getFirst("Filtered"));
filterRegistration = registerFilter(
- "osgi.jaxrs.extension.name", "test-filter");
+ JAX_RS_EXTENSION_NAME, "test-filter");
response = webTarget.request().get();
@@ -508,8 +511,8 @@ public class JaxrsTest {
try {
serviceRegistration = registerAddon(
- "osgi.jaxrs.resource.base", "/test-addon",
- "osgi.jaxrs.extension.select", new String[]{
+ JAX_RS_RESOURCE_BASE, "/test-addon",
+ JAX_RS_EXTENSION_SELECT, new String[]{
"(property one=one)",
"(property two=two)",
});
@@ -601,14 +604,14 @@ public class JaxrsTest {
new PrototypeServiceFactory<Object>() {
@Override
public Object getService(
- Bundle bundle, ServiceRegistration registration) {
+ Bundle bundle, ServiceRegistration<Object> registration) {
return new TestAddonLifecycle();
}
@Override
public void ungetService(
- Bundle bundle, ServiceRegistration registration,
+ Bundle bundle, ServiceRegistration<Object> registration,
Object service) {
}
@@ -626,8 +629,7 @@ public class JaxrsTest {
Dictionary<String, Object> properties = new Hashtable<>();
- properties.put(
- "osgi.jaxrs.application.base", "/test-application");
+ properties.put(JAX_RS_APPLICATION_BASE, "/test-application");
return bundleContext.registerService(
Application.class, testApplication, properties);
@@ -654,7 +656,7 @@ public class JaxrsTest {
Dictionary<String, Object> properties = new Hashtable<>();
- properties.put("osgi.jaxrs.extension.name", name);
+ properties.put(JAX_RS_EXTENSION_NAME, name);
for (int i = 0; i < keyValues.length; i = i + 2) {
properties.put(keyValues[i].toString(), keyValues[i + 1]);
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.whiteboard/bnd.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/bnd.bnd b/jax-rs.whiteboard/bnd.bnd
index f37aab4..2abfe41 100644
--- a/jax-rs.whiteboard/bnd.bnd
+++ b/jax-rs.whiteboard/bnd.bnd
@@ -48,6 +48,7 @@ Import-Package:\
# version:Version=1
-exportcontents:\
+ org.apache.aries.jax.rs.whiteboard,\
org.apache.cxf.jaxrs.ext.*
-includeresource:\
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/AriesJaxRSWhiteboardConstants.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/AriesJaxRSWhiteboardConstants.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/AriesJaxRSWhiteboardConstants.java
new file mode 100644
index 0000000..615f49f
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/AriesJaxRSWhiteboardConstants.java
@@ -0,0 +1,35 @@
+/*
+ * 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.aries.jax.rs.whiteboard;
+
+import java.nio.file.DirectoryStream.Filter;
+
+public class AriesJaxRSWhiteboardConstants {
+
+ /**
+ * A Service property specifying a target filter used to select
+ * an Application onto which to bind the service.
+ * <p>
+ * If this service property is not specified, the service is ignored.
+ * <p>
+ * The value of this service property must be of type {@code String} and be
+ * a valid {@link Filter filter string}.
+ */
+ public static final String JAX_RS_APPLICATION_SELECT = "org.apache.aries.jaxrs.extension.select";
+
+}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 23d0427..d369b47 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -45,12 +45,15 @@ import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
+import static java.lang.String.format;
+import static org.apache.aries.jax.rs.whiteboard.AriesJaxRSWhiteboardConstants.*;
import static org.apache.aries.osgi.functional.OSGi.bundleContext;
import static org.apache.aries.osgi.functional.OSGi.just;
import static org.apache.aries.osgi.functional.OSGi.onClose;
import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
import static org.apache.aries.osgi.functional.OSGi.services;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME;
@@ -109,7 +112,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
flatMap(ref ->
just(
CXFJaxRsServiceRegistrator.getProperties(
- ref, "osgi.jaxrs.application.base")).
+ ref, JAX_RS_APPLICATION_BASE)).
flatMap(properties ->
service(ref).flatMap(application ->
cxfRegistrator(bus, application, properties)
@@ -129,7 +132,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
waitForExtensionDependencies(serviceReference,
just(
CXFJaxRsServiceRegistrator.getProperties(
- serviceReference, "osgi.jaxrs.resource.base")).
+ serviceReference, JAX_RS_RESOURCE_BASE)).
flatMap(properties ->
service(serviceReference).flatMap(service ->
safeRegisterEndpoint(
@@ -149,9 +152,9 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_extensionsResult = extensions.run(bundleContext);
OSGi<?> applicationSingletons =
- serviceReferences("(osgi.jaxrs.application.select=*)").
+ serviceReferences(format("(%s=*)", JAX_RS_APPLICATION_SELECT)).
flatMap(ref ->
- just(ref.getProperty("osgi.jaxrs.application.select").toString()).
+ just(ref.getProperty(JAX_RS_APPLICATION_SELECT).toString()).
flatMap(applicationFilter ->
services(CXFJaxRsServiceRegistrator.class, applicationFilter).
flatMap(registrator ->
@@ -222,14 +225,14 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
private String buildExtensionFilter(String filter) {
- return "(&(osgi.jaxrs.extension.name=*)" + filter + ")";
+ return format("(&%s%s)", getExtensionFilter(), filter);
}
private OSGi<?> waitForExtensionDependencies(
ServiceReference<?> serviceReference, OSGi<?> program) {
String[] extensionDependencies = canonicalize(
- serviceReference.getProperty("osgi.jaxrs.extension.select"));
+ serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
for (String extensionDependency : extensionDependencies) {
program =
@@ -261,7 +264,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
ClassLoader contextClassLoader = thread.getContextClassLoader();
ClassLoader classLoader = ref.getBundle().adapt(BundleWiring.class).
getClassLoader();
- Object resourceBaseObject = ref.getProperty("osgi.jaxrs.resource.base");
+ Object resourceBaseObject = ref.getProperty(JAX_RS_RESOURCE_BASE);
ResourceProvider resourceProvider = getResourceProvider(serviceObjects);
@@ -329,8 +332,8 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
private ServiceRegistration<Servlet> registerCXFServletService(Bus bus) {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT,
- "(" + HTTP_WHITEBOARD_CONTEXT_NAME + "=" +
- HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME + ")");
+ format("(%s=%s)", HTTP_WHITEBOARD_CONTEXT_NAME,
+ HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME));
properties.put(HTTP_WHITEBOARD_SERVLET_PATTERN, "/*");
properties.put(Constants.SERVICE_RANKING, -1);
CXFNonSpringServlet cxfNonSpringServlet = createCXFServlet(bus);
@@ -345,17 +348,17 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
private String getExtensionFilter() {
- return "(osgi.jaxrs.extension.name=*)";
+ return format("(%s=*)", JAX_RS_EXTENSION_NAME);
}
private String getApplicationFilter() {
- return "(osgi.jaxrs.application.base=*)";
+ return format("(%s=*)", JAX_RS_APPLICATION_BASE);
}
private String getSingletonsFilter() {
- return "(osgi.jaxrs.resource.base=*)";
+ return format("(%s=*)", JAX_RS_RESOURCE_BASE);
}
-
+
@Override
public void stop(BundleContext context) throws Exception {
_applicationSingletonsResult.close();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index e6170cb..1ac45ee 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -36,6 +36,8 @@ import org.apache.cxf.jaxrs.model.URITemplate;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
import org.osgi.framework.ServiceReference;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*;
+
public class CXFJaxRsServiceRegistrator {
private volatile boolean _closed = false;
private final Application _application;
@@ -45,6 +47,8 @@ public class CXFJaxRsServiceRegistrator {
private Server _server;
private final Collection<ServiceInformation> _services = new ArrayList<>();
+ private static final String CXF_ENDPOINT_ADDRESS = "CXF_ENDPOINT_ADDRESS";
+
public CXFJaxRsServiceRegistrator(
Bus bus, Application application, Map<String, Object> properties) {
@@ -54,19 +58,19 @@ public class CXFJaxRsServiceRegistrator {
rewire();
}
-
+
public static Map<String, Object> getProperties(ServiceReference<?> sref, String addressKey) {
String[] propertyKeys = sref.getPropertyKeys();
Map<String, Object> properties = new HashMap<String, Object>(propertyKeys.length);
for (String key : propertyKeys) {
- if (key.equals("osgi.jaxrs.resource.base")) {
+ if (key.equals(JAX_RS_RESOURCE_BASE)) {
continue;
}
properties.put(key, sref.getProperty(key));
}
- properties.put("CXF_ENDPOINT_ADDRESS", sref.getProperty(addressKey).toString());
+ properties.put(CXF_ENDPOINT_ADDRESS, sref.getProperty(addressKey).toString());
return properties;
}
@@ -181,7 +185,7 @@ public class CXFJaxRsServiceRegistrator {
}
Object cxfEndpointAddressObject = _properties.get(
- "CXF_ENDPOINT_ADDRESS");
+ CXF_ENDPOINT_ADDRESS);
String address;
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5b7b1eb8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/package-info.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/package-info.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/package-info.java
new file mode 100644
index 0000000..ac5149e
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/package-info.java
@@ -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.
+ */
+
+@Version("1.0.0")
+package org.apache.aries.jax.rs.whiteboard;
+
+import org.osgi.annotation.versioning.Version;
\ No newline at end of file
[06/12] aries-jax-rs-whiteboard git commit: Implemented wait for
extensions
Posted by cs...@apache.org.
Implemented wait for extensions
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/5292346e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/5292346e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/5292346e
Branch: refs/heads/master
Commit: 5292346e0fcd6381c50f2945b624c24bb6fcfab9
Parents: 0e87e50
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 15 15:12:31 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 92 ++++++++++++++++++-
.../activator/CXFJaxRsBundleActivator.java | 94 ++++++++++++++------
2 files changed, 153 insertions(+), 33 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5292346e/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index f7c983d..00282ee 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -260,6 +260,67 @@ public class JaxrsTest {
}
}
+ @Test
+ public void testStandaloneEndpointWithExtensionsDependencies() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-addon").
+ path("test");
+
+ ServiceRegistration<?> serviceRegistration = null;
+ ServiceRegistration<?> extensionRegistration1;
+ ServiceRegistration<?> extensionRegistration2;
+
+ try {
+ serviceRegistration = registerAddon(
+ "osgi.jaxrs.resource.base", "/test-addon",
+ "osgi.jaxrs.extension.select", new String[]{
+ "(property one=one)",
+ "(property two=two)",
+ });
+
+ assertEquals(404, webTarget.request().get().getStatus());
+
+ extensionRegistration1 = registerExtension(
+ "aExtension", "property one", "one");
+
+ assertEquals(404, webTarget.request().get().getStatus());
+
+ extensionRegistration2 = registerExtension(
+ "anotherExtension", "property two", "two");
+
+ Response response = webTarget.request().get();
+
+ assertEquals(
+ "This should say hello", "Hello test",
+ response.readEntity(String.class));
+
+ extensionRegistration1.unregister();
+
+ assertEquals(404, webTarget.request().get().getStatus());
+
+ extensionRegistration1 = registerExtension(
+ "aExtension", "property one", "one");
+
+ assertEquals(
+ "This should say hello", "Hello test",
+ response.readEntity(String.class));
+
+ extensionRegistration2.unregister();
+
+ assertEquals(404, webTarget.request().get().getStatus());
+
+ extensionRegistration1.unregister();
+ }
+ finally {
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
+ }
+
private Client createClient() {
Thread thread = Thread.currentThread();
@@ -276,12 +337,15 @@ public class JaxrsTest {
}
}
- private ServiceRegistration<?> registerAddon(String key, String value) {
+ private ServiceRegistration<?> registerAddon(Object ... keyValues) {
+
TestAddon testAddon = new TestAddon();
Dictionary<String, Object> properties = new Hashtable<>();
- properties.put(key, value);
+ for (int i = 0; i < keyValues.length; i = i + 2) {
+ properties.put(keyValues[i].toString(), keyValues[i + 1]);
+ }
return bundleContext.registerService(
Object.class, testAddon, properties);
@@ -300,12 +364,32 @@ public class JaxrsTest {
Application.class, testApplication, properties);
}
- private ServiceRegistration<?> registerFilter(String key, String value) {
+ private ServiceRegistration<?> registerFilter(Object ... keyValues) {
+
+ TestFilter testFilter = new TestFilter();
+
+ Dictionary<String, Object> properties = new Hashtable<>();
+
+ for (int i = 0; i < keyValues.length; i = i + 2) {
+ properties.put(keyValues[i].toString(), keyValues[i + 1]);
+ }
+
+ return bundleContext.registerService(
+ Object.class, testFilter, properties);
+ }
+
+ private ServiceRegistration<?> registerExtension(
+ String name, Object ... keyValues) {
+
TestFilter testFilter = new TestFilter();
Dictionary<String, Object> properties = new Hashtable<>();
- properties.put(key, value);
+ properties.put("osgi.jaxrs.extension.name", name);
+
+ for (int i = 0; i < keyValues.length; i = i + 2) {
+ properties.put(keyValues[i].toString(), keyValues[i + 1]);
+ }
return bundleContext.registerService(
Object.class, testFilter, properties);
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/5292346e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 45fbf04..1275c0d 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -43,6 +43,7 @@ import java.util.Set;
import static org.apache.aries.osgi.functional.OSGi.bundleContext;
import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
@@ -101,40 +102,44 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
OSGi<?> singletons =
serviceReferences(getSingletonsFilter()).
flatMap(serviceReference ->
- just(
- CXFJaxRsServiceRegistrator.getProperties(
- serviceReference, "osgi.jaxrs.resource.base")).
- flatMap(properties ->
- service(serviceReference).flatMap(service ->
- cxfRegistrator(bus,
- new Application() {
- @Override
- public Set<Object> getSingletons() {
- return Collections.singleton(service);
- }
- },
- properties)
- )));
+ waitForExtensionDependencies(serviceReference,
+ just(
+ CXFJaxRsServiceRegistrator.getProperties(
+ serviceReference, "osgi.jaxrs.resource.base")).
+ flatMap(properties ->
+ service(serviceReference).flatMap(service ->
+ cxfRegistrator(bus,
+ new Application() {
+ @Override
+ public Set<Object> getSingletons() {
+ return Collections.singleton(service);
+ }
+ },
+ properties)
+ )))
+ );
_singletonsResult = singletons.run(bundleContext);
OSGi<?> filters =
serviceReferences(getFiltersFilter()).flatMap(ref ->
- just(
- ref.getProperty("osgi.jaxrs.filter.base").toString()).
- flatMap(filterBase ->
- serviceReferences(
- CXFJaxRsServiceRegistrator.class, "(CXF_ENDPOINT_ADDRESS=*)").
- filter(regref ->
- regref.
- getProperty("CXF_ENDPOINT_ADDRESS").
- toString().
- startsWith(filterBase)).
- flatMap(regref ->
- service(regref).flatMap(registrator ->
- service(ref).flatMap(service ->
- safeRegisterEndpoint(ref, registrator, service)
- )))));
+ waitForExtensionDependencies(ref,
+ just(
+ ref.getProperty("osgi.jaxrs.filter.base").toString()).
+ flatMap(filterBase ->
+ serviceReferences(
+ CXFJaxRsServiceRegistrator.class, "(CXF_ENDPOINT_ADDRESS=*)").
+ filter(regref ->
+ regref.
+ getProperty("CXF_ENDPOINT_ADDRESS").
+ toString().
+ startsWith(filterBase)).
+ flatMap(regref ->
+ service(regref).flatMap(registrator ->
+ service(ref).flatMap(service ->
+ safeRegisterEndpoint(ref, registrator, service)
+ )))))
+ );
_filtersResult = filters.run(bundleContext);
}
@@ -157,6 +162,37 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
}
+ private String[] canonicalize(Object propertyValue) {
+ if (propertyValue == null) {
+ return new String[0];
+ }
+
+ if (propertyValue instanceof String[]) {
+ return (String[]) propertyValue;
+ }
+
+ return new String[]{propertyValue.toString()};
+ }
+
+ private String buildExtensionFilter(String filter) {
+ return "(&(osgi.jaxrs.extension.name=*)" + filter + ")";
+ }
+
+ private OSGi<?> waitForExtensionDependencies(
+ ServiceReference<?> serviceReference, OSGi<?> program) {
+
+ String[] extensionDependencies = canonicalize(
+ serviceReference.getProperty("osgi.jaxrs.extension.select"));
+
+ for (String extensionDependency : extensionDependencies) {
+ program =
+ serviceReferences(buildExtensionFilter(extensionDependency)).
+ then(program);
+ }
+
+ return program;
+ }
+
private OSGi<?> safeRegisterEndpoint(
ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator,
Object service) {
[04/12] aries-jax-rs-whiteboard git commit: We no longer extend
applications with registered services
Posted by cs...@apache.org.
We no longer extend applications with registered services
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/e1300b9e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/e1300b9e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/e1300b9e
Branch: refs/heads/master
Commit: e1300b9ec1d6b2ccebdbbf0130d17620c0e541d5
Parents: 1463182
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Feb 14 15:47:33 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 175 -------------------
.../activator/CXFJaxRsBundleActivator.java | 12 --
.../ServicesServiceTrackerCustomizer.java | 74 --------
3 files changed, 261 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e1300b9e/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index d5f3ec5..f7c983d 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -105,180 +105,6 @@ public class JaxrsTest {
}
@Test
- public void testApplicationEndpointExtension() {
- Client client = createClient();
-
- WebTarget webTarget = client.
- target("http://localhost:8080").
- path("/test-application").
- path("extended");
-
- ServiceRegistration<?> applicationRegistration = null;
-
- ServiceRegistration<?> serviceRegistration = null;
-
- try {
- applicationRegistration = registerApplication();
-
- serviceRegistration = registerAddon(
- "jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
-
- assertEquals(
- "Hello extended",
- webTarget.request().get().readEntity(String.class));
- }
- finally {
- if (applicationRegistration != null) {
- applicationRegistration.unregister();
- }
- if (serviceRegistration != null) {
- serviceRegistration.unregister();
- }
- }
- }
-
- @Test
- public void testApplicationEndpointExtensionReadd() {
- Client client = createClient();
-
- WebTarget webTarget = client.
- target("http://localhost:8080").
- path("/test-application").
- path("extended");
-
- ServiceRegistration<?> applicationRegistration = null;
-
- try {
- applicationRegistration = registerApplication();
-
- Runnable testCase = () -> {
- assertEquals(webTarget.request().get().getStatus(), 404);
-
- ServiceRegistration<?> serviceRegistration = null;
-
- try {
- serviceRegistration = registerAddon(
- "jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
-
- assertEquals(
- "Hello extended",
- webTarget.request().get().readEntity(String.class));
- }
- finally {
- if (serviceRegistration != null) {
- serviceRegistration.unregister();
- }
- }
- };
-
- testCase.run();
-
- testCase.run();
- }
- finally {
- if (applicationRegistration != null) {
- applicationRegistration.unregister();
- }
-
- }
- }
-
- @Test
- public void testApplicationProviderExtension() {
- Client client = createClient();
-
- WebTarget webTarget = client.
- target("http://localhost:8080").
- path("/test-application");
-
- ServiceRegistration<?> applicationRegistration = null;
-
- ServiceRegistration<?> filterRegistration = null;
-
- try {
- applicationRegistration = registerApplication();
-
- filterRegistration = registerFilter(
- "jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
-
- Response response = webTarget.request().get();
-
- assertEquals(
- "Hello application",
- response.readEntity(String.class));
-
- assertEquals(
- response.getHeaders().getFirst("Filtered"),
- "true");
- }
- finally {
- if (applicationRegistration != null) {
- applicationRegistration.unregister();
- }
- if (filterRegistration != null) {
- filterRegistration.unregister();
- }
- }
- }
-
- @Test
- public void testApplicationProviderExtensionReadd() {
- Client client = createClient();
-
- WebTarget webTarget = client.
- target("http://localhost:8080").
- path("/test-application");
-
- ServiceRegistration<?> applicationRegistration = null;
-
- try {
- applicationRegistration = registerApplication();
-
- assertEquals(
- "Hello application",
- webTarget.request().get().readEntity(String.class));
-
- Runnable testCase = () -> {
- Response response = webTarget.request().get();
-
- assertNull(response.getHeaders().getFirst("Filtered"));
-
- ServiceRegistration<?> filterRegistration = null;
-
- try {
- filterRegistration = registerFilter(
- "jaxrs.application.select",
- "(osgi.jaxrs.application.base=/test-application)");
-
- response = webTarget.request().get();
-
- assertEquals(
- response.getHeaders().getFirst("Filtered"),
- "true");
- }
- finally {
- if (filterRegistration != null) {
- filterRegistration.unregister();
- }
- }
- };
-
- testCase.run();
-
- testCase.run();
-
- }
- finally {
- if (applicationRegistration != null) {
- applicationRegistration.unregister();
- }
- }
- }
-
- @Test
public void testStandaloneEndPoint() {
Client client = createClient();
@@ -306,7 +132,6 @@ public class JaxrsTest {
}
}
-
@Test
public void testStandaloneEndPointReadd() {
Client client = createClient();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e1300b9e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 97555bd..a871418 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -37,8 +37,6 @@ import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.util.tracker.ServiceTracker;
-import org.apache.aries.jax.rs.whiteboard.internal.ServicesServiceTrackerCustomizer;
-
import java.util.Dictionary;
import java.util.Hashtable;
@@ -49,7 +47,6 @@ import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHIT
public class CXFJaxRsBundleActivator implements BundleActivator {
- private ServiceTracker<?, ?> _singletonsTracker;
private BundleContext _bundleContext;
private ServiceTracker<Application, ?> _applicationTracker;
private ServiceTracker<Object, ?> _singletonsServiceTracker;
@@ -79,14 +76,6 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
bundleContext, getFiltersFilter(),
new FiltersAndInterceptorsServiceTrackerCustomizer(bundleContext));
_filtersAndInterceptorsServiceTracker.open();
-
- Filter filter = bundleContext.createFilter(
- "(jaxrs.application.select=*)");
-
- _singletonsTracker = new ServiceTracker<>(
- bundleContext, filter,
- new ServicesServiceTrackerCustomizer(bundleContext));
- _singletonsTracker.open();
}
/**
@@ -144,7 +133,6 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_applicationTracker.close();
_filtersAndInterceptorsServiceTracker.close();
_singletonsServiceTracker.close();
- _singletonsTracker.close();
}
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e1300b9e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ServicesServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ServicesServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ServicesServiceTrackerCustomizer.java
deleted file mode 100644
index 758199a..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ServicesServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,74 +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.aries.jax.rs.whiteboard.internal;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ServicesServiceTrackerCustomizer implements ServiceTrackerCustomizer<Object, ServiceTracker<?, ?>> {
-
- private final BundleContext _bundleContext;
-
- public ServicesServiceTrackerCustomizer(BundleContext bundleContext) {
- _bundleContext = bundleContext;
- }
-
- @Override
- public ServiceTracker<?, ?> addingService(ServiceReference<Object> reference) {
- String applicationSelector = reference.getProperty("jaxrs.application.select").toString();
- Bundle bundle = reference.getBundle();
- BundleWiring bundleWiring = bundle.adapt(BundleWiring.class);
- ClassLoader classLoader = bundleWiring.getClassLoader();
- Object service = _bundleContext.getService(reference);
- try {
- Filter filter = _bundleContext.createFilter(
- "(&(objectClass=" + CXFJaxRsServiceRegistrator.class.getName() +
- ")" + applicationSelector + ")");
- ServiceTracker<?, ?> serviceTracker = new ServiceTracker<>(
- _bundleContext,
- filter,
- new AddonsServiceTrackerCustomizer(
- _bundleContext, classLoader, service));
- serviceTracker.open();
- return serviceTracker;
- }
- catch (InvalidSyntaxException ise) {
- _bundleContext.ungetService(reference);
- throw new RuntimeException(ise);
- }
- }
-
- @Override
- public void modifiedService(ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
- removedService(reference, serviceTracker);
- addingService(reference);
- }
-
- @Override
- public void removedService(ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
- serviceTracker.close();
- _bundleContext.ungetService(reference);
- }
-
-}
[05/12] aries-jax-rs-whiteboard git commit: Moved to component dsl
Posted by cs...@apache.org.
Moved to component dsl
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/0e87e50b
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/0e87e50b
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/0e87e50b
Branch: refs/heads/master
Commit: 0e87e50be72f2e05da9be8df34be6065fa76ec1f
Parents: e1300b9
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 15 11:30:45 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.whiteboard/bnd.bnd | 1 +
jax-rs.whiteboard/pom.xml | 5 +
.../activator/CXFJaxRsBundleActivator.java | 167 +++++++++++++++----
.../AddonsServiceTrackerCustomizer.java | 84 ----------
.../ApplicationServiceTrackerCustomizer.java | 66 --------
...AndInterceptorsServiceTrackerCustomizer.java | 121 --------------
.../SingletonServiceTrackerCustomizer.java | 78 ---------
.../internal/TrackedJaxRsRegistrator.java | 45 -----
8 files changed, 138 insertions(+), 429 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/bnd.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/bnd.bnd b/jax-rs.whiteboard/bnd.bnd
index 1f7dc5a..f37aab4 100644
--- a/jax-rs.whiteboard/bnd.bnd
+++ b/jax-rs.whiteboard/bnd.bnd
@@ -51,6 +51,7 @@ Import-Package:\
org.apache.cxf.jaxrs.ext.*
-includeresource:\
+ lib/component-dsl.jar=component-dsl-*.jar;lib:=true,\
lib/cxf-core.jar=cxf-core-*.jar;lib:=true,\
lib/cxf-rt-databinding-jaxb.jar=cxf-rt-databinding-jaxb-*.jar;lib:=true,\
lib/cxf-rt-frontend-jaxrs.jar=cxf-rt-frontend-jaxrs-*.jar;lib:=true,\
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 493f7b2..132eb32 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -102,5 +102,10 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.aries.component-dsl</groupId>
+ <artifactId>component-dsl</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index a871418..45fbf04 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -21,9 +21,9 @@ import javax.servlet.Servlet;
import javax.ws.rs.core.Application;
import javax.ws.rs.ext.RuntimeDelegate;
-import org.apache.aries.jax.rs.whiteboard.internal.ApplicationServiceTrackerCustomizer;
-import org.apache.aries.jax.rs.whiteboard.internal.FiltersAndInterceptorsServiceTrackerCustomizer;
-import org.apache.aries.jax.rs.whiteboard.internal.SingletonServiceTrackerCustomizer;
+import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator;
+import org.apache.aries.osgi.functional.OSGi;
+import org.apache.aries.osgi.functional.OSGiResult;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.CXFBusFactory;
@@ -31,15 +31,21 @@ import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
-import org.osgi.util.tracker.ServiceTracker;
+import java.util.Collections;
import java.util.Dictionary;
import java.util.Hashtable;
-
+import java.util.Map;
+import java.util.Set;
+
+import static org.apache.aries.osgi.functional.OSGi.bundleContext;
+import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.onClose;
+import static org.apache.aries.osgi.functional.OSGi.register;
+import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME;
@@ -48,9 +54,26 @@ import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHIT
public class CXFJaxRsBundleActivator implements BundleActivator {
private BundleContext _bundleContext;
- private ServiceTracker<Application, ?> _applicationTracker;
- private ServiceTracker<Object, ?> _singletonsServiceTracker;
- private ServiceTracker<Object, ?> _filtersAndInterceptorsServiceTracker;
+ private OSGiResult<?> _applicationsResult;
+ private OSGiResult<?> _singletonsResult;
+ private OSGiResult<?> _filtersResult;
+
+ private static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
+ return
+ bundleContext().flatMap(bundleContext ->
+ onClose(() -> bundleContext.ungetService(serviceReference)).then(
+ just(bundleContext.getService(serviceReference))
+ ));
+ }
+
+ private static OSGi<?> cxfRegistrator(
+ Bus bus, Application application, Map<String, Object> props) {
+
+ return
+ just(new CXFJaxRsServiceRegistrator(bus, application, props)).flatMap(registrator ->
+ onClose(registrator::close).then(
+ register(CXFJaxRsServiceRegistrator.class, registrator, props)));
+ }
@Override
public void start(BundleContext bundleContext) throws Exception {
@@ -62,20 +85,58 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
CXFBusFactory.class.getName()).createBus();
registerCXFServletService(bus);
- _applicationTracker = new ServiceTracker<>(
- bundleContext, getApplicationFilter(),
- new ApplicationServiceTrackerCustomizer(bundleContext, bus));
- _applicationTracker.open();
-
- _singletonsServiceTracker = new ServiceTracker<>(
- bundleContext, getSingletonsFilter(),
- new SingletonServiceTrackerCustomizer(bundleContext, bus));
- _singletonsServiceTracker.open();
-
- _filtersAndInterceptorsServiceTracker = new ServiceTracker<>(
- bundleContext, getFiltersFilter(),
- new FiltersAndInterceptorsServiceTrackerCustomizer(bundleContext));
- _filtersAndInterceptorsServiceTracker.open();
+ OSGi<?> applications =
+ serviceReferences(Application.class, getApplicationFilter()).
+ flatMap(ref ->
+ just(
+ CXFJaxRsServiceRegistrator.getProperties(
+ ref, "osgi.jaxrs.application.base")).
+ flatMap(properties ->
+ service(ref).flatMap(application ->
+ cxfRegistrator(bus, application, properties)
+ )));
+
+ _applicationsResult = applications.run(bundleContext);
+
+ OSGi<?> singletons =
+ serviceReferences(getSingletonsFilter()).
+ flatMap(serviceReference ->
+ just(
+ CXFJaxRsServiceRegistrator.getProperties(
+ serviceReference, "osgi.jaxrs.resource.base")).
+ flatMap(properties ->
+ service(serviceReference).flatMap(service ->
+ cxfRegistrator(bus,
+ new Application() {
+ @Override
+ public Set<Object> getSingletons() {
+ return Collections.singleton(service);
+ }
+ },
+ properties)
+ )));
+
+ _singletonsResult = singletons.run(bundleContext);
+
+ OSGi<?> filters =
+ serviceReferences(getFiltersFilter()).flatMap(ref ->
+ just(
+ ref.getProperty("osgi.jaxrs.filter.base").toString()).
+ flatMap(filterBase ->
+ serviceReferences(
+ CXFJaxRsServiceRegistrator.class, "(CXF_ENDPOINT_ADDRESS=*)").
+ filter(regref ->
+ regref.
+ getProperty("CXF_ENDPOINT_ADDRESS").
+ toString().
+ startsWith(filterBase)).
+ flatMap(regref ->
+ service(regref).flatMap(registrator ->
+ service(ref).flatMap(service ->
+ safeRegisterEndpoint(ref, registrator, service)
+ )))));
+
+ _filtersResult = filters.run(bundleContext);
}
/**
@@ -96,6 +157,44 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
}
+ private OSGi<?> safeRegisterEndpoint(
+ ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator,
+ Object service) {
+
+ return
+ onClose(() -> unregisterEndpoint(registrator, service)).then(
+ registerEndpoint(ref, registrator, service));
+ }
+
+ private OSGi<?> registerEndpoint(
+ ServiceReference<?> ref,
+ CXFJaxRsServiceRegistrator registrator, Object service) {
+
+ Thread thread = Thread.currentThread();
+
+ ClassLoader contextClassLoader = thread.getContextClassLoader();
+
+ ClassLoader classLoader = ref.getBundle().adapt(BundleWiring.class).
+ getClassLoader();
+
+ try {
+ thread.setContextClassLoader(classLoader);
+
+ registrator.add(service);
+ }
+ finally {
+ thread.setContextClassLoader(contextClassLoader);
+ }
+
+ return just(service);
+ }
+
+ private void unregisterEndpoint(
+ CXFJaxRsServiceRegistrator registrator, Object service) {
+
+ registrator.remove(service);
+ }
+
private ServiceRegistration<Servlet> registerCXFServletService(Bus bus) {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT,
@@ -114,25 +213,23 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
return cxfNonSpringServlet;
}
- private Filter getFiltersFilter() throws InvalidSyntaxException {
- return _bundleContext.createFilter("(osgi.jaxrs.filter.base=*)");
+ private String getFiltersFilter() {
+ return "(osgi.jaxrs.filter.base=*)";
}
- private Filter getApplicationFilter() throws InvalidSyntaxException {
- return _bundleContext.createFilter(
- "(&(objectClass=" + Application.class.getName() + ")" +
- "(osgi.jaxrs.application.base=*))");
+ private String getApplicationFilter() {
+ return "(osgi.jaxrs.application.base=*)";
}
- private Filter getSingletonsFilter() throws InvalidSyntaxException {
- return _bundleContext.createFilter("(osgi.jaxrs.resource.base=*)");
+ private String getSingletonsFilter() {
+ return "(osgi.jaxrs.resource.base=*)";
}
@Override
public void stop(BundleContext context) throws Exception {
- _applicationTracker.close();
- _filtersAndInterceptorsServiceTracker.close();
- _singletonsServiceTracker.close();
+ _applicationsResult.close();
+ _filtersResult.close();
+ _singletonsResult.close();
}
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
deleted file mode 100644
index 9db1aea..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/AddonsServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,84 +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.aries.jax.rs.whiteboard.internal;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class AddonsServiceTrackerCustomizer
- implements
- ServiceTrackerCustomizer<CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator> {
-
- private final BundleContext _bundleContext;
- private final ClassLoader _classLoader;
- private final Object _service;
-
- public AddonsServiceTrackerCustomizer(
- BundleContext bundleContext, ClassLoader classLoader,
- Object service) {
-
- _bundleContext = bundleContext;
- _classLoader = classLoader;
- _service = service;
- }
-
- @Override
- public CXFJaxRsServiceRegistrator addingService(ServiceReference<CXFJaxRsServiceRegistrator> reference) {
- CXFJaxRsServiceRegistrator registrator = _bundleContext.getService(reference);
- try {
- runInClassLoader(_classLoader, () -> registrator.add(_service));
- return registrator;
- }
- catch (Exception e) {
- _bundleContext.ungetService(reference);
- throw e;
- }
- }
-
- @Override
- public void modifiedService(
- ServiceReference<CXFJaxRsServiceRegistrator> reference,
- CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator) {
-
- removedService(reference, cxfJaxRsServiceRegistrator);
- addingService(reference);
- }
-
- @Override
- public void removedService(
- ServiceReference<CXFJaxRsServiceRegistrator> reference,
- CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator) {
-
- cxfJaxRsServiceRegistrator.remove(_service);
- _bundleContext.ungetService(reference);
- }
-
- private void runInClassLoader(ClassLoader cl, Runnable runable) {
- Thread thread = Thread.currentThread();
- ClassLoader contextClassLoader = thread.getContextClassLoader();
- try {
- thread.setContextClassLoader(_classLoader);
- runable.run();
- }
- finally {
- thread.setContextClassLoader(contextClassLoader);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
deleted file mode 100644
index ccf2165..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ApplicationServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,66 +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.aries.jax.rs.whiteboard.internal;
-
-import java.util.Map;
-
-import javax.ws.rs.core.Application;
-
-import org.apache.cxf.Bus;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class ApplicationServiceTrackerCustomizer
- implements ServiceTrackerCustomizer<Application, TrackedJaxRsRegistrator> {
-
- private BundleContext _bundleContext;
- private Bus _bus;
-
- public ApplicationServiceTrackerCustomizer(BundleContext bundleContext, Bus bus) {
- _bundleContext = bundleContext;
- _bus = bus;
- }
-
- @Override
- public TrackedJaxRsRegistrator addingService(ServiceReference<Application> serviceReference) {
- Application application = _bundleContext.getService(serviceReference);
- try {
- Map<String, Object> props = CXFJaxRsServiceRegistrator
- .getProperties(serviceReference, "osgi.jaxrs.application.base");
- CXFJaxRsServiceRegistrator registrator = new CXFJaxRsServiceRegistrator(_bus, application, props);
- return new TrackedJaxRsRegistrator(registrator, _bundleContext, props);
- }
- catch (Throwable e) {
- _bundleContext.ungetService(serviceReference);
- throw e;
- }
- }
-
- @Override
- public void modifiedService(ServiceReference<Application> serviceReference, TrackedJaxRsRegistrator tracked) {
- removedService(serviceReference, tracked);
- addingService(serviceReference);
- }
-
- @Override
- public void removedService(ServiceReference<Application> reference, TrackedJaxRsRegistrator tracked) {
- _bundleContext.ungetService(reference);
- tracked.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
deleted file mode 100644
index 9e516b8..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/FiltersAndInterceptorsServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,121 +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.aries.jax.rs.whiteboard.internal;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTracker;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class FiltersAndInterceptorsServiceTrackerCustomizer
- implements ServiceTrackerCustomizer<Object, ServiceTracker<?, ?>> {
-
- private BundleContext _bundleContext;
-
- public FiltersAndInterceptorsServiceTrackerCustomizer(
- BundleContext bundleContext) {
-
- _bundleContext = bundleContext;
- }
-
- @Override
- public ServiceTracker<?, ?> addingService(final ServiceReference<Object> reference) {
- final String filterBase =
- reference.getProperty("osgi.jaxrs.filter.base").toString();
-
- final Object service = _bundleContext.getService(reference);
-
- ServiceTracker<CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator> serviceTracker = new ServiceTracker<>(
- _bundleContext, CXFJaxRsServiceRegistrator.class,
- new ServiceTrackerCustomizer
- <CXFJaxRsServiceRegistrator, CXFJaxRsServiceRegistrator>() {
-
- @Override
- public CXFJaxRsServiceRegistrator addingService(
- ServiceReference<CXFJaxRsServiceRegistrator> cxfReference) {
-
- Object resourceBaseObject =
- cxfReference.getProperty("CXF_ENDPOINT_ADDRESS");
-
- if (resourceBaseObject == null) {
- return null;
- }
-
- String resourceBase = resourceBaseObject.toString();
-
- if (resourceBase.startsWith(filterBase)) {
- CXFJaxRsServiceRegistrator serviceRegistrator =
- _bundleContext.getService(cxfReference);
- try {
- serviceRegistrator.add(service);
-
- return serviceRegistrator;
- }
- finally {
- _bundleContext.ungetService(reference);
- }
- }
-
- return null;
- }
-
- @Override
- public void modifiedService(
- ServiceReference<CXFJaxRsServiceRegistrator> reference,
- CXFJaxRsServiceRegistrator serviceRegistrator) {
-
- removedService(reference, serviceRegistrator);
- addingService(reference);
- }
-
- @Override
- public void removedService(
- ServiceReference<CXFJaxRsServiceRegistrator> reference,
- CXFJaxRsServiceRegistrator serviceRegistrator) {
-
- try {
- serviceRegistrator.remove(service);
- }
- finally {
- _bundleContext.ungetService(reference);
- }
- }
- });
-
- serviceTracker.open();
-
- return serviceTracker;
- }
-
- @Override
- public void modifiedService(
- ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
-
- removedService(reference, serviceTracker);
- addingService(reference);
- }
-
- @Override
- public void removedService(
- ServiceReference<Object> reference, ServiceTracker<?, ?> serviceTracker) {
-
- _bundleContext.ungetService(reference);
-
- serviceTracker.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
deleted file mode 100644
index 2d1264d..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/SingletonServiceTrackerCustomizer.java
+++ /dev/null
@@ -1,78 +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.aries.jax.rs.whiteboard.internal;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import javax.ws.rs.core.Application;
-
-import org.apache.cxf.Bus;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceReference;
-import org.osgi.util.tracker.ServiceTrackerCustomizer;
-
-public class SingletonServiceTrackerCustomizer
- implements ServiceTrackerCustomizer<Object, TrackedJaxRsRegistrator> {
-
- private BundleContext _bundleContext;
- private Bus _bus;
-
- public SingletonServiceTrackerCustomizer(BundleContext bundleContext, Bus bus) {
- _bundleContext = bundleContext;
- _bus = bus;
- }
-
- @Override
- public TrackedJaxRsRegistrator addingService(
- ServiceReference<Object> serviceReference) {
-
- final Object service = _bundleContext.getService(serviceReference);
- Application application = new Application() {
- @Override
- public Set<Object> getSingletons() {
- return Collections.singleton(service);
- }
- };
- try {
- Map<String, Object> properties = CXFJaxRsServiceRegistrator
- .getProperties(serviceReference, "osgi.jaxrs.resource.base");
- CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator =
- new CXFJaxRsServiceRegistrator(_bus, application, properties);
- return new TrackedJaxRsRegistrator(cxfJaxRsServiceRegistrator, _bundleContext, properties);
- }
- catch (Exception e) {
- _bundleContext.ungetService(serviceReference);
- throw e;
- }
- }
-
- @Override
- public void modifiedService(ServiceReference<Object> serviceReference, TrackedJaxRsRegistrator tracked) {
- removedService(serviceReference, tracked);
- addingService(serviceReference);
- }
-
- @Override
- public void removedService(ServiceReference<Object> reference, TrackedJaxRsRegistrator tracked) {
- _bundleContext.ungetService(reference);
- tracked.close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0e87e50b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
deleted file mode 100644
index 90ed68e..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/TrackedJaxRsRegistrator.java
+++ /dev/null
@@ -1,45 +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.aries.jax.rs.whiteboard.internal;
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceRegistration;
-
-public class TrackedJaxRsRegistrator {
- private final CXFJaxRsServiceRegistrator _registrator;
- private final ServiceRegistration<?> _sreg;
-
- public TrackedJaxRsRegistrator(CXFJaxRsServiceRegistrator cxfJaxRsServiceRegistrator,
- BundleContext bundleContext,
- Map<String, Object> properties) {
- _registrator = cxfJaxRsServiceRegistrator;
- _sreg = bundleContext.
- registerService(CXFJaxRsServiceRegistrator.class,
- cxfJaxRsServiceRegistrator,
- new Hashtable<>(properties));
- }
-
-
-
- public void close() {
- _registrator.close();
- _sreg.unregister();
- }
-}
\ No newline at end of file
[07/12] aries-jax-rs-whiteboard git commit: Use assert properly
Posted by cs...@apache.org.
Use assert properly
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/d337acdb
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/d337acdb
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/d337acdb
Branch: refs/heads/master
Commit: d337acdb1e8ec19078f29ef525ed5e9e57c00457
Parents: 5292346
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 15 15:12:55 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/d337acdb/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 00282ee..5292cfd 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -78,7 +78,7 @@ public class JaxrsTest {
path("/test-application");
Runnable testCase = () -> {
- assertEquals(webTarget.request().get().getStatus(), 404);
+ assertEquals(404, webTarget.request().get().getStatus());
ServiceRegistration<?> serviceRegistration = null;
@@ -142,7 +142,7 @@ public class JaxrsTest {
path("test");
Runnable testCase = () -> {
- assertEquals(webTarget.request().get().getStatus(), 404);
+ assertEquals(404, webTarget.request().get().getStatus());
ServiceRegistration<?> serviceRegistration = null;
@@ -192,7 +192,7 @@ public class JaxrsTest {
"This should say hello", "Hello test",
response.readEntity(String.class));
- assertEquals(response.getHeaders().getFirst("Filtered"), "true");
+ assertEquals("true", response.getHeaders().getFirst("Filtered"));
}
finally {
if (serviceRegistration != null) {
@@ -239,7 +239,7 @@ public class JaxrsTest {
"Hello test", response.readEntity(String.class));
assertEquals(
- response.getHeaders().getFirst("Filtered"), "true");
+ "true", response.getHeaders().getFirst("Filtered"));
}
finally {
if (filterRegistration != null) {
[11/12] aries-jax-rs-whiteboard git commit: Clean imports
Posted by cs...@apache.org.
Clean imports
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/62b53f9e
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/62b53f9e
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/62b53f9e
Branch: refs/heads/master
Commit: 62b53f9e3d7b8a70f73072f6e67525f792a613d8
Parents: c54be5f
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 22 17:47:03 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
.../jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java | 3 ---
1 file changed, 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/62b53f9e/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 7ca04f5..8618122 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -36,16 +36,13 @@ import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
-import java.util.Collections;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
-import java.util.Set;
import static org.apache.aries.osgi.functional.OSGi.bundleContext;
import static org.apache.aries.osgi.functional.OSGi.just;
-import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
[02/12] aries-jax-rs-whiteboard git commit: [ARIES-JAXRS] simplify
using latest bnd maven plugins
Posted by cs...@apache.org.
[ARIES-JAXRS] simplify using latest bnd maven plugins
Signed-off-by: Raymond Auge <ra...@liferay.com>
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/f8a7138a
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/f8a7138a
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/f8a7138a
Branch: refs/heads/master
Commit: f8a7138a50be8488b1fdb32c92735ee21d2333b6
Parents: 2bac01c
Author: Raymond Auge <ra...@liferay.com>
Authored: Thu Feb 23 16:27:24 2017 -0500
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.example-run/LICENSE | 202 --------------------------------
jax-rs.example-run/augments.bnd | 77 ------------
jax-rs.example-run/example.bndrun | 57 ---------
jax-rs.example-run/pom.xml | 94 ---------------
jax-rs.example/.gitignore | 2 -
jax-rs.example/augments.bnd | 77 ++++++++++++
jax-rs.example/example.bndrun | 49 ++++++++
jax-rs.example/pom.xml | 130 ++++++++++++++++++--
jax-rs.itests-run/LICENSE | 202 --------------------------------
jax-rs.itests-run/itest.bndrun | 56 ---------
jax-rs.itests-run/pom.xml | 92 ---------------
jax-rs.itests/bnd.bnd | 4 +-
jax-rs.itests/itest.bndrun | 45 +++++++
jax-rs.itests/pom.xml | 99 +++++++++++++++-
jax-rs.log4j-configuration/pom.xml | 13 +-
jax-rs.whiteboard/pom.xml | 9 ++
pom.xml | 142 +++++++++++++++-------
17 files changed, 508 insertions(+), 842 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example-run/LICENSE
----------------------------------------------------------------------
diff --git a/jax-rs.example-run/LICENSE b/jax-rs.example-run/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/jax-rs.example-run/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example-run/augments.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.example-run/augments.bnd b/jax-rs.example-run/augments.bnd
deleted file mode 100644
index aa1cca1..0000000
--- a/jax-rs.example-run/augments.bnd
+++ /dev/null
@@ -1,77 +0,0 @@
--augment.javax.servlet-api: \
- javax.servlet-api; \
- requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.http)'"
-
--augment.javax.ws.rs-api: \
- javax.ws.rs-api; \
- requirement:="osgi.implementation;filter:='(osgi.implementation=aries.jax-rs)'"
-
--augment.org.apache.commons.fileupload: \
- org.apache.commons.fileupload; \
- capability:=" generic.dependency;generic.dependency='commons.fileupload'"
-
--augment.org.apache.felix.gogo.command: \
- org.apache.felix.gogo.command; \
- capability:=" generic.dependency;generic.dependency='gogo.shell.command';version:Version='1.0.0'"; \
- version='1.0.0'
-
--augment.org.apache.felix.gogo.shell: \
- org.apache.felix.gogo.shell; \
- capability:=" osgi.implementation;osgi.implementation='gogo.shell';version:Version='1.0.0'"; \
- requirement:="generic.dependency;filter:='(generic.dependency=gogo.shell.command)';effective:=active"; \
- version='1.0.0'
-
--augment.org.apache.felix.gogo.jline: \
- org.apache.felix.gogo.jline; \
- capability:=" osgi.implementation;osgi.implementation='gogo.jline';version:Version='1.0.0'"; \
- requirement:="generic.dependency;filter:='(generic.dependency=gogo.shell.command)';effective:=active"; \
- version='1.0.0'
-
--augment.org.apache.felix.log: \
- org.apache.felix.log; \
- capability:=" osgi.implementation;osgi.implementation=osgi.log"
-
--augment.org.apache.felix.scr: \
- org.apache.felix.scr; \
- requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.metatype)'"
-
--augment.org.eclipse.equinox.coordinator: \
- org.eclipse.equinox.coordinator; \
- capability:=" osgi.service;objectClass=org.osgi.service.coordinator.Coordinator;effective:=active, \
- osgi.implementation;osgi.implementation=osgi.coordinator"
-
--augment.org.eclipse.equinox.event: \
- org.eclipse.equinox.event; \
- capability:=" osgi.service;objectClass=org.osgi.service.event.EventAdmin;effective:=active, \
- osgi.implementation;osgi.implementation=osgi.event"; \
- requirement:="osgi.extender;filter:='(osgi.extender=osgi.component)'"
-
--augment.org.eclipse.equinox.http.jetty: \
- org.eclipse.equinox.http.jetty; \
- capability:=" equinox.module.data;activation.policy=eager, \
- generic.dependency;generic.dependency='osgi.servlet.container';version:Version='1.0.0'"
-
--augment.org.eclipse.equinox.http.servlet: \
- org.eclipse.equinox.http.servlet; \
- capability:=" equinox.module.data;activation.policy=eager"; \
- requirement:="generic.dependency;filter:='(generic.dependency=commons.fileupload)';effective:=active,\
- generic.dependency;filter:='(generic.dependency=osgi.servlet.container)';effective:=active"
-
--augment.org.knopflerfish.bundle.useradmin: \
- org.knopflerfish.bundle.useradmin; \
- capability:=" osgi.service;objectClass:List<String>=org.osgi.service.useradmin.UserAdmin;effective:=active, \
- osgi.implementation;osgi.implementation=osgi.useradmin"
-
--augment.org.osgi.service.event: \
- org.osgi.service.event; \
- requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.event)'"
-
--augment.org.osgi.service.metatype: \
- org.osgi.service.metatype; \
- requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.metatype)'"
-
--augment.org.osgi.service.remoteserviceadmin: \
- org.osgi.service.remoteserviceadmin; \
- requirement:="osgi.remoteserviceadmin.distribution;filter:='(configs=*)', \
- osgi.remoteserviceadmin.topology;filter:='(policy=*)', \
- osgi.remoteserviceadmin.discovery;filter:='(protocols=*)'"
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example-run/example.bndrun
----------------------------------------------------------------------
diff --git a/jax-rs.example-run/example.bndrun b/jax-rs.example-run/example.bndrun
deleted file mode 100644
index 376ea3f..0000000
--- a/jax-rs.example-run/example.bndrun
+++ /dev/null
@@ -1,57 +0,0 @@
--standalone:
--include: ${.}/augments.bnd
--resourceonly: true
-
--plugin.A.pom.repo = \
- aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
- snapshotUrls=https://oss.sonatype.org/content/repositories/osgi/; \
- releaseUrls=https://repo1.maven.org/maven2/; \
- pom=${.}/pom.xml; \
- name=pom.repo; \
- location=${.}/target/cached.xml
-
--runrequires: \
- osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.example)',\
- osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.log4j-configuration)',\
- osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.jline)'
-
- # ,\
-# osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.whiteboard)'
-
--runfw: org.eclipse.osgi;version='[3.10.100.v20150529-1857,3.10.100.v20150529-1857]'
--runbundles: \
- javax.annotation-api; version='[1.2.0,1.2.1)',\
- javax.json-api; version='[1.0.0,1.0.1)',\
- javax.ws.rs-api; version='[2.0.1,2.0.2)',\
- log4j; version='[1.2.17,1.2.18)',\
- org.apache.aries.jax.rs.example; version='[0.0.1,0.0.2)',\
- org.apache.aries.jax.rs.log4j-configuration; version='[0.0.1,0.0.2)',\
- org.apache.aries.jax.rs.whiteboard; version='[0.0.1,0.0.2)',\
- org.apache.felix.bundlerepository; version='[1.6.0,1.6.1)',\
- org.apache.felix.configadmin; version='[1.8.8,1.8.9)',\
- org.apache.felix.gogo.command; version='[1.0.0,1.0.1)',\
- org.apache.felix.gogo.jline; version='[1.0.0,1.0.1)',\
- org.apache.felix.gogo.runtime; version='[1.0.0,1.0.1)',\
- org.apache.felix.http.api; version='[3.0.0,3.0.1)',\
- org.apache.felix.http.jetty; version='[3.4.0,3.4.1)',\
- org.apache.felix.http.servlet-api; version='[1.1.2,1.1.3)',\
- org.apache.felix.scr; version='[2.0.2,2.0.3)',\
- org.apache.ws.xmlschema.core; version='[2.2.1,2.2.2)',\
- org.eclipse.equinox.event; version='[1.3.100,1.3.101)',\
- org.eclipse.equinox.metatype; version='[1.4.100,1.4.101)',\
- org.jline; version='[3.0.0,3.0.1)',\
- org.objectweb.asm; version='[5.0.4,5.0.5)',\
- org.osgi.service.event; version='[1.3.1,1.3.2)',\
- org.osgi.service.metatype; version='[1.3.0,1.3.1)',\
- slf4j.api; version='[1.7.21,1.7.22)',\
- slf4j.log4j12;version='[1.6.1,1.6.2)'
-
--runee: JavaSE-1.8
--resolve.effective: resolve, active
--runproperties: \
- osgi.console.enable.builtin=false, \
- osgi.console=, \
- org.osgi.service.http.port=8080
--runsystemcapabilities.dflt: ${native_capability}
--runblacklist:\
- osgi.identity;filter:='(osgi.identity=org.osgi.compendium)'
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example-run/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.example-run/pom.xml b/jax-rs.example-run/pom.xml
deleted file mode 100644
index 1fe66a1..0000000
--- a/jax-rs.example-run/pom.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </parent>
-
- <artifactId>org.apache.aries.jax.rs.example-run</artifactId>
- <description>Apache Aries JAX-RS Example Run Configuration</description>
- <name>Apache Aries JAX-RS Example Run Configuration</name>
- <packaging>pom</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-export-maven-plugin</artifactId>
- <version>3.4.0-SNAPSHOT</version>
- <configuration>
- <failOnChanges>false</failOnChanges>
- <resolve>false</resolve>
- <bndruns>
- <bndrun>example.bndrun</bndrun>
- </bndruns>
- <targetDir>.</targetDir>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>export</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.example</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.log4j-configuration</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.whiteboard</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.http.jetty</artifactId>
- <version>3.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.command</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.gogo.jline</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.enroute.pom.distro</artifactId>
- <version>2.0.0</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example/.gitignore
----------------------------------------------------------------------
diff --git a/jax-rs.example/.gitignore b/jax-rs.example/.gitignore
deleted file mode 100644
index 83ccc54..0000000
--- a/jax-rs.example/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-/build/
-/bin/
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example/augments.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.example/augments.bnd b/jax-rs.example/augments.bnd
new file mode 100644
index 0000000..aa1cca1
--- /dev/null
+++ b/jax-rs.example/augments.bnd
@@ -0,0 +1,77 @@
+-augment.javax.servlet-api: \
+ javax.servlet-api; \
+ requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.http)'"
+
+-augment.javax.ws.rs-api: \
+ javax.ws.rs-api; \
+ requirement:="osgi.implementation;filter:='(osgi.implementation=aries.jax-rs)'"
+
+-augment.org.apache.commons.fileupload: \
+ org.apache.commons.fileupload; \
+ capability:=" generic.dependency;generic.dependency='commons.fileupload'"
+
+-augment.org.apache.felix.gogo.command: \
+ org.apache.felix.gogo.command; \
+ capability:=" generic.dependency;generic.dependency='gogo.shell.command';version:Version='1.0.0'"; \
+ version='1.0.0'
+
+-augment.org.apache.felix.gogo.shell: \
+ org.apache.felix.gogo.shell; \
+ capability:=" osgi.implementation;osgi.implementation='gogo.shell';version:Version='1.0.0'"; \
+ requirement:="generic.dependency;filter:='(generic.dependency=gogo.shell.command)';effective:=active"; \
+ version='1.0.0'
+
+-augment.org.apache.felix.gogo.jline: \
+ org.apache.felix.gogo.jline; \
+ capability:=" osgi.implementation;osgi.implementation='gogo.jline';version:Version='1.0.0'"; \
+ requirement:="generic.dependency;filter:='(generic.dependency=gogo.shell.command)';effective:=active"; \
+ version='1.0.0'
+
+-augment.org.apache.felix.log: \
+ org.apache.felix.log; \
+ capability:=" osgi.implementation;osgi.implementation=osgi.log"
+
+-augment.org.apache.felix.scr: \
+ org.apache.felix.scr; \
+ requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.metatype)'"
+
+-augment.org.eclipse.equinox.coordinator: \
+ org.eclipse.equinox.coordinator; \
+ capability:=" osgi.service;objectClass=org.osgi.service.coordinator.Coordinator;effective:=active, \
+ osgi.implementation;osgi.implementation=osgi.coordinator"
+
+-augment.org.eclipse.equinox.event: \
+ org.eclipse.equinox.event; \
+ capability:=" osgi.service;objectClass=org.osgi.service.event.EventAdmin;effective:=active, \
+ osgi.implementation;osgi.implementation=osgi.event"; \
+ requirement:="osgi.extender;filter:='(osgi.extender=osgi.component)'"
+
+-augment.org.eclipse.equinox.http.jetty: \
+ org.eclipse.equinox.http.jetty; \
+ capability:=" equinox.module.data;activation.policy=eager, \
+ generic.dependency;generic.dependency='osgi.servlet.container';version:Version='1.0.0'"
+
+-augment.org.eclipse.equinox.http.servlet: \
+ org.eclipse.equinox.http.servlet; \
+ capability:=" equinox.module.data;activation.policy=eager"; \
+ requirement:="generic.dependency;filter:='(generic.dependency=commons.fileupload)';effective:=active,\
+ generic.dependency;filter:='(generic.dependency=osgi.servlet.container)';effective:=active"
+
+-augment.org.knopflerfish.bundle.useradmin: \
+ org.knopflerfish.bundle.useradmin; \
+ capability:=" osgi.service;objectClass:List<String>=org.osgi.service.useradmin.UserAdmin;effective:=active, \
+ osgi.implementation;osgi.implementation=osgi.useradmin"
+
+-augment.org.osgi.service.event: \
+ org.osgi.service.event; \
+ requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.event)'"
+
+-augment.org.osgi.service.metatype: \
+ org.osgi.service.metatype; \
+ requirement:="osgi.implementation;filter:='(osgi.implementation=osgi.metatype)'"
+
+-augment.org.osgi.service.remoteserviceadmin: \
+ org.osgi.service.remoteserviceadmin; \
+ requirement:="osgi.remoteserviceadmin.distribution;filter:='(configs=*)', \
+ osgi.remoteserviceadmin.topology;filter:='(policy=*)', \
+ osgi.remoteserviceadmin.discovery;filter:='(protocols=*)'"
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example/example.bndrun
----------------------------------------------------------------------
diff --git a/jax-rs.example/example.bndrun b/jax-rs.example/example.bndrun
new file mode 100644
index 0000000..de1c487
--- /dev/null
+++ b/jax-rs.example/example.bndrun
@@ -0,0 +1,49 @@
+-standalone: ${.}/target/index.xml
+-include: ${.}/augments.bnd
+-resourceonly: true
+
+-runrequires: \
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.example)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.log4j-configuration)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.whiteboard)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.jline)',\
+ osgi.identity;filter:='(osgi.identity=slf4j.log4j12)'
+
+-runfw: org.eclipse.osgi;version='[3.10.100.v20150529-1857,3.10.100.v20150529-1857]'
+-runbundles: \
+ javax.annotation-api;version='[1.2.0,1.2.1)',\
+ javax.json-api;version='[1.0.0,1.0.1)',\
+ javax.ws.rs-api;version='[2.0.1,2.0.2)',\
+ log4j;version='[1.2.17,1.2.18)',\
+ org.apache.aries.jax.rs.example;version='[0.0.1,0.0.2)',\
+ org.apache.aries.jax.rs.log4j-configuration;version='[0.0.1,0.0.2)',\
+ org.apache.aries.jax.rs.whiteboard;version='[0.0.1,0.0.2)',\
+ org.apache.felix.bundlerepository;version='[1.6.0,1.6.1)',\
+ org.apache.felix.eventadmin;version='[1.4.8,1.4.9)',\
+ org.apache.felix.gogo.command;version='[1.0.0,1.0.1)',\
+ org.apache.felix.gogo.jline;version='[1.0.0,1.0.1)',\
+ org.apache.felix.gogo.runtime;version='[1.0.0,1.0.1)',\
+ org.apache.felix.http.api;version='[3.0.0,3.0.1)',\
+ org.apache.felix.http.jetty;version='[3.4.0,3.4.1)',\
+ org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
+ org.apache.felix.scr;version='[2.0.8,2.0.9)',\
+ org.apache.ws.xmlschema.core;version='[2.2.1,2.2.2)',\
+ org.eclipse.equinox.metatype;version='[1.4.100,1.4.101)',\
+ org.jline;version='[3.0.0,3.0.1)',\
+ org.objectweb.asm;version='[5.0.4,5.0.5)',\
+ org.osgi.service.cm;version='[1.5.0,1.5.1)',\
+ org.osgi.service.metatype;version='[1.3.0,1.3.1)',\
+ slf4j.api;version='[1.7.21,1.7.22)',\
+ slf4j.log4j12;version='[1.6.1,1.6.2)'
+
+-runee: JavaSE-1.8
+-resolve.effective: resolve, active
+-runproperties: \
+ osgi.console.enable.builtin=false, \
+ osgi.console=, \
+ org.osgi.service.http.port=8080
+-runsystemcapabilities: ${native_capability}
+-runblacklist:\
+ osgi.identity;filter:='(osgi.identity=org.osgi.compendium)',\
+ osgi.identity;filter:='(osgi.identity=osgi.cmpn)'
+
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.example/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.example/pom.xml b/jax-rs.example/pom.xml
index 9200bd2..4a71297 100644
--- a/jax-rs.example/pom.xml
+++ b/jax-rs.example/pom.xml
@@ -15,12 +15,10 @@
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/xsd/maven-4.0.0.xsd"
->
+<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.apache.aries.jax.rs</groupId>
<artifactId>org.apache.aries.jax.rs</artifactId>
@@ -28,19 +26,131 @@
</parent>
<artifactId>org.apache.aries.jax.rs.example</artifactId>
- <description>Apache Aries JAX-RS Example</description>
- <name>Apache Aries JAX-RS Example</name>
+ <description>Apache Aries JAX-RS Executable Example</description>
+ <name>Apache Aries JAX-RS Executable Example</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-indexer-maven-plugin</artifactId>
+ <configuration>
+ <includeJar>true</includeJar>
+ <localURLs>REQUIRED</localURLs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-resolver-maven-plugin</artifactId>
+ <configuration>
+ <failOnChanges>false</failOnChanges>
+ <bndruns>
+ <bndrun>example.bndrun</bndrun>
+ </bndruns>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-export-maven-plugin</artifactId>
+ <configuration>
+ <failOnChanges>false</failOnChanges>
+ <resolve>false</resolve>
+ <bndruns>
+ <bndrun>example.bndrun</bndrun>
+ </bndruns>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0.1</version>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.21</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>6.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.jax.rs</groupId>
+ <artifactId>org.apache.aries.jax.rs.log4j-configuration</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.jax.rs</groupId>
+ <artifactId>org.apache.aries.jax.rs.whiteboard</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.eventadmin</artifactId>
+ <version>1.4.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ <version>3.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.servlet-api</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.gogo.command</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.gogo.jline</artifactId>
+ <version>1.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr</artifactId>
+ <version>2.0.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.eclipse.equinox.metatype</artifactId>
+ <version>1.4.100.v20150408-1437</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.10.100.v20150529-1857</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.service.component.annotations</artifactId>
<version>1.3.0</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype</artifactId>
+ <version>1.3.0</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests-run/LICENSE
----------------------------------------------------------------------
diff --git a/jax-rs.itests-run/LICENSE b/jax-rs.itests-run/LICENSE
deleted file mode 100644
index d645695..0000000
--- a/jax-rs.itests-run/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- 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.
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests-run/itest.bndrun
----------------------------------------------------------------------
diff --git a/jax-rs.itests-run/itest.bndrun b/jax-rs.itests-run/itest.bndrun
deleted file mode 100644
index c13d8c2..0000000
--- a/jax-rs.itests-run/itest.bndrun
+++ /dev/null
@@ -1,56 +0,0 @@
--standalone:
-
--plugin.integration.test = \
- aQute.bnd.repository.maven.pom.provider.BndPomRepository; \
- snapshotUrls=https://oss.sonatype.org/content/repositories/osgi/; \
- releaseUrls=https://repo1.maven.org/maven2/; \
- pom=${.}/pom.xml; \
- name=integration.test; \
- location=${.}/target/cached.xml
-
--runrequires: \
- osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.itests)',\
- osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.log4j-configuration)'
-
--runfw: org.eclipse.osgi;version='[3.10.100.v20150529-1857,3.10.100.v20150529-1857]'
-
-#-runtrace: true
-
--runee: JavaSE-1.8
--resolve.effective: resolve, active
-
--runsystempackages.eqnx: javax.script
--runsystemcapabilities.dflt: ${native_capability}
--runproperties: \
- osgi.console.enable.builtin=false, \
- osgi.console=, \
- org.osgi.service.http.port=8080
--runbundles: \
- javax.annotation-api; version='[1.2.0,1.2.1)',\
- javax.json-api; version='[1.0.0,1.0.1)',\
- javax.ws.rs-api; version='[2.0.1,2.0.2)',\
- log4j; version='[1.2.17,1.2.18)',\
- org.apache.aries.jax.rs.itests; version='[0.0.1,0.0.2)',\
- org.apache.aries.jax.rs.log4j-configuration; version='[0.0.1,0.0.2)',\
- org.apache.aries.jax.rs.whiteboard; version='[0.0.1,0.0.2)',\
- org.apache.cxf.cxf-core; version='[3.1.7,3.1.8)',\
- org.apache.cxf.cxf-rt-transports-http; version='[3.1.7,3.1.8)',\
- org.apache.cxf.cxf-rt-frontend-jaxrs; version='[3.1.7,3.1.8)',\
- org.apache.cxf.cxf-rt-rs-client; version='[3.1.7,3.1.8)',\
- org.apache.felix.bundlerepository; version='[1.6.0,1.6.1)',\
- org.apache.felix.configadmin; version='[1.8.8,1.8.9)',\
- org.apache.felix.http.api; version='[3.0.0,3.0.1)',\
- org.apache.felix.http.jetty; version='[3.4.0,3.4.1)',\
- org.apache.felix.http.servlet-api; version='[1.1.2,1.1.3)',\
- org.apache.felix.scr; version='[2.0.2,2.0.3)',\
- org.apache.ws.xmlschema.core; version='[2.2.1,2.2.2)',\
- org.eclipse.equinox.event; version='[1.3.100,1.3.101)',\
- org.eclipse.equinox.metatype; version='[1.4.100,1.4.101)',\
- org.objectweb.asm; version='[5.0.4,5.0.5)',\
- org.osgi.compendium; version='[4.1.0,4.1.1)',\
- org.osgi.service.event; version='[1.3.1,1.3.2)',\
- org.osgi.service.metatype; version='[1.3.0,1.3.1)',\
- osgi.enroute.hamcrest.wrapper; version='[1.3.0,1.3.1)',\
- osgi.enroute.junit.wrapper; version='[4.12.0,4.12.1)',\
- slf4j.api; version='[1.7.21,1.7.22)',\
- slf4j.log4j12; version='[1.6.1,1.6.2)'
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests-run/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.itests-run/pom.xml b/jax-rs.itests-run/pom.xml
deleted file mode 100644
index 19e75e8..0000000
--- a/jax-rs.itests-run/pom.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?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/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <relativePath>..</relativePath>
- </parent>
-
- <artifactId>org.apache.aries.jax.rs.itests-run</artifactId>
- <description>Apache Aries JAX-RS Integration Test Plan</description>
- <name>Apache Aries JAX-RS Integration Test Plan</name>
- <packaging>pom</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-testing-maven-plugin</artifactId>
- <version>3.4.0-SNAPSHOT</version>
- <configuration>
- <failOnChanges>false</failOnChanges>
- <resolve>false</resolve>
- <bndruns>
- <bndrun>itest.bndrun</bndrun>
- </bndruns>
- <targetDir>.</targetDir>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>testing</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- <dependencies>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.itests</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.log4j-configuration</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.aries.jax.rs</groupId>
- <artifactId>org.apache.aries.jax.rs.whiteboard</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-rs-client</artifactId>
- <version>${cxf.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.http.jetty</artifactId>
- <version>3.4.0</version>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.enroute.pom.distro</artifactId>
- <version>2.0.0</version>
- </dependency>
- </dependencies>
-</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests/bnd.bnd
----------------------------------------------------------------------
diff --git a/jax-rs.itests/bnd.bnd b/jax-rs.itests/bnd.bnd
index ff9ca86..f601893 100644
--- a/jax-rs.itests/bnd.bnd
+++ b/jax-rs.itests/bnd.bnd
@@ -1,5 +1,5 @@
Bundle-Description: Integration Test bundle for the JAX-RS extender
Test-Cases: \
- ${classes;CONCRETE;EXTENDS;junit.framework.TestCase},\
- ${classes;CONCRETE;ANNOTATED;org.junit.Test}
+ ${classes;CONCRETE;EXTENDS;junit.framework.TestCase},\
+ ${classes;CONCRETE;ANNOTATED;org.junit.Test}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests/itest.bndrun
----------------------------------------------------------------------
diff --git a/jax-rs.itests/itest.bndrun b/jax-rs.itests/itest.bndrun
new file mode 100644
index 0000000..5d96119
--- /dev/null
+++ b/jax-rs.itests/itest.bndrun
@@ -0,0 +1,45 @@
+-standalone: ${.}/target/index.xml
+
+-runrequires: \
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.itests)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.log4j-configuration)',\
+ osgi.identity;filter:='(osgi.identity=org.apache.aries.jax.rs.whiteboard)',\
+ osgi.identity;filter:='(osgi.identity=slf4j.log4j12)'
+
+-runfw: org.eclipse.osgi;version='[3.10.100.v20150529-1857,3.10.100.v20150529-1857]'
+
+#-runtrace: true
+
+-runee: JavaSE-1.8
+-resolve.effective: resolve, active
+
+-runsystemcapabilities: ${native_capability}
+-runproperties: \
+ osgi.console.enable.builtin=false, \
+ osgi.console=, \
+ org.osgi.service.http.port=8080
+-runblacklist:\
+ osgi.identity;filter:='(osgi.identity=org.osgi.compendium)',\
+ osgi.identity;filter:='(osgi.identity=osgi.cmpn)'
+-runbundles: \
+ javax.annotation-api;version='[1.2.0,1.2.1)',\
+ javax.ws.rs-api;version='[2.0.1,2.0.2)',\
+ log4j;version='[1.2.17,1.2.18)',\
+ org.apache.aries.jax.rs.itests;version='[0.0.1,0.0.2)',\
+ org.apache.aries.jax.rs.log4j-configuration;version='[0.0.1,0.0.2)',\
+ org.apache.cxf.cxf-core;version='[3.1.7,3.1.8)',\
+ org.apache.cxf.cxf-rt-transports-http;version='[3.1.7,3.1.8)',\
+ org.apache.cxf.cxf-rt-frontend-jaxrs;version='[3.1.7,3.1.8)',\
+ org.apache.cxf.cxf-rt-rs-client;version='[3.1.7,3.1.8)',\
+ org.apache.ws.xmlschema.core;version='[2.2.1,2.2.2)',\
+ osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
+ osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
+ javax.json-api;version='[1.0.0,1.0.1)',\
+ org.apache.aries.jax.rs.whiteboard;version='[0.0.1,0.0.2)',\
+ org.apache.felix.http.jetty;version='[3.4.0,3.4.1)',\
+ org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
+ org.objectweb.asm;version='[5.0.4,5.0.5)',\
+ slf4j.api;version='[1.7.21,1.7.22)',\
+ slf4j.log4j12;version='[1.6.1,1.6.2)',\
+ org.apache.felix.eventadmin;version='[1.4.8,1.4.9)',\
+ org.osgi.service.cm;version='[1.5.0,1.5.1)'
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.itests/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.itests/pom.xml b/jax-rs.itests/pom.xml
index d5147a1..06729b7 100644
--- a/jax-rs.itests/pom.xml
+++ b/jax-rs.itests/pom.xml
@@ -19,24 +19,91 @@
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/xsd/maven-4.0.0.xsd">
-
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.aries.jax.rs</groupId>
<artifactId>org.apache.aries.jax.rs</artifactId>
<version>0.0.1-SNAPSHOT</version>
+ <relativePath>..</relativePath>
</parent>
<artifactId>org.apache.aries.jax.rs.itests</artifactId>
<description>Apache Aries JAX-RS Integration Tests</description>
<name>Apache Aries JAX-RS Integration Tests</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-indexer-maven-plugin</artifactId>
+ <configuration>
+ <includeJar>true</includeJar>
+ <localURLs>REQUIRED</localURLs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-resolver-maven-plugin</artifactId>
+ <configuration>
+ <failOnChanges>false</failOnChanges>
+ <bndruns>
+ <bndrun>itest.bndrun</bndrun>
+ </bndruns>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-testing-maven-plugin</artifactId>
+ <configuration>
+ <failOnChanges>false</failOnChanges>
+ <resolve>false</resolve>
+ <bndruns>
+ <bndrun>itest.bndrun</bndrun>
+ </bndruns>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>javax.ws.rs-api</artifactId>
- <version>2.0.1</version>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.7.21</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.6.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>6.0.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.json</groupId>
+ <artifactId>javax.json-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.jax.rs</groupId>
+ <artifactId>org.apache.aries.jax.rs.log4j-configuration</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.aries.jax.rs</groupId>
+ <artifactId>org.apache.aries.jax.rs.whiteboard</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
@@ -44,14 +111,34 @@
<version>${cxf.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.eventadmin</artifactId>
+ <version>1.4.8</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.jetty</artifactId>
+ <version>3.4.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.http.servlet-api</artifactId>
+ <version>1.1.2</version>
+ </dependency>
+ <dependency>
<groupId>org.osgi</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>6.0.0</version>
+ <artifactId>org.eclipse.osgi</artifactId>
+ <version>3.10.100.v20150529-1857</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.enroute.junit.wrapper</artifactId>
<version>4.12.0</version>
</dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.enroute.hamcrest.wrapper</artifactId>
+ <version>1.3.0</version>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.log4j-configuration/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.log4j-configuration/pom.xml b/jax-rs.log4j-configuration/pom.xml
index a72beee..cf5f881 100644
--- a/jax-rs.log4j-configuration/pom.xml
+++ b/jax-rs.log4j-configuration/pom.xml
@@ -15,8 +15,8 @@
specific language governing permissions and limitations
under the License.
-->
-<project
- xmlns="http://maven.apache.org/POM/4.0.0"
+<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/xsd/maven-4.0.0.xsd"
>
@@ -30,4 +30,13 @@
<artifactId>org.apache.aries.jax.rs.log4j-configuration</artifactId>
<description>Apache Aries JAX-RS Log4J Configuration Fragment</description>
<name>Apache Aries JAX-RS Log4J Configuration Fragment</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index b3db5cd..1ebcc29 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -108,4 +108,13 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
</project>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f8a7138a/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 72c613e..009ce6e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,8 +16,8 @@
under the License.
-->
<project
- xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ 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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -28,9 +28,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<cxf.version>3.1.7</cxf.version>
+ <bnd.version>3.4.0-SNAPSHOT</bnd.version>
</properties>
-
- <distributionManagement>
+
+ <distributionManagement>
<repository>
<id>apache.releases.https</id>
<name>Apache Release Distribution Repository</name>
@@ -44,49 +45,105 @@
</snapshotRepository>
</distributionManagement>
-
<build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.1</version>
- <configuration>
- <source>1.8</source>
- <target>1.8</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <version>3.0.1</version>
- <configuration>
- <archive>
- <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
- </archive>
- </configuration>
- </plugin>
- <plugin>
- <groupId>biz.aQute.bnd</groupId>
- <artifactId>bnd-maven-plugin</artifactId>
- <version>3.4.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>bnd-process</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.1</version>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <version>3.0.1</version>
+ <configuration>
+ <archive>
+ <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+ </archive>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-baseline-maven-plugin</artifactId>
+ <version>${bnd.version}</version>
+ <configuration>
+ <includeDistributionManagement>false</includeDistributionManagement>
+ <fullReport>true</fullReport>
+ </configuration>
+ <executions>
+ <execution>
+ <id>baseline</id>
+ <goals>
+ <goal>baseline</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-export-maven-plugin</artifactId>
+ <version>${bnd.version}</version>
+ <executions>
+ <execution>
+ <id>export</id>
+ <goals>
+ <goal>export</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-indexer-maven-plugin</artifactId>
+ <version>${bnd.version}</version>
+ <executions>
+ <execution>
+ <id>index</id>
+ <goals>
+ <goal>index</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ <version>${bnd.version}</version>
+ <executions>
+ <execution>
+ <id>bnd-process</id>
+ <goals>
+ <goal>bnd-process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-testing-maven-plugin</artifactId>
+ <version>${bnd.version}</version>
+ <executions>
+ <execution>
+ <id>testing</id>
+ <goals>
+ <goal>testing</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
</build>
<modules>
<module>jax-rs.whiteboard</module>
<module>jax-rs.log4j-configuration</module>
<module>jax-rs.itests</module>
- <module>jax-rs.itests-run</module>
<module>jax-rs.example</module>
- <module>jax-rs.example-run</module>
</modules>
<dependencies>
<dependency>
@@ -97,6 +154,11 @@
</dependencies>
<repositories>
<repository>
+ <id>apache snapshots</id>
+ <url>http://repository.apache.org/snapshots/</url>
+ <layout>default</layout>
+ </repository>
+ <repository>
<id>osgi-releases-and-snapshots</id>
<url>https://oss.sonatype.org/content/groups/osgi/</url>
<layout>default</layout>
[09/12] aries-jax-rs-whiteboard git commit: Add support for services
lifecycle
Posted by cs...@apache.org.
Add support for services lifecycle
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/2bac01c8
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/2bac01c8
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/2bac01c8
Branch: refs/heads/master
Commit: 2bac01c8f35d79686c0d28c0b86eff137998d2fc
Parents: 62b53f9
Author: Carlos Sierra <cs...@apache.org>
Authored: Thu Feb 23 15:44:41 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/pom.xml | 2 +-
jax-rs.itests/src/main/java/test/JaxrsTest.java | 97 +++++++++++++++-
.../java/test/types/TestAddonLifecycle.java | 31 +++++
jax-rs.whiteboard/pom.xml | 2 +-
.../activator/CXFJaxRsBundleActivator.java | 114 ++++++++++++++++---
.../internal/CXFJaxRsServiceRegistrator.java | 68 +++++------
6 files changed, 260 insertions(+), 54 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.itests/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.itests/pom.xml b/jax-rs.itests/pom.xml
index 59e4b50..d5147a1 100644
--- a/jax-rs.itests/pom.xml
+++ b/jax-rs.itests/pom.xml
@@ -46,7 +46,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>5.0.0</version>
+ <version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index f5b434b..20f8910 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -21,11 +21,15 @@ import java.util.Dictionary;
import java.util.Hashtable;
import org.junit.Test;
+import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.PrototypeServiceFactory;
+import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
import test.types.TestAddon;
+import test.types.TestAddonLifecycle;
import test.types.TestApplication;
import test.types.TestFilter;
@@ -36,6 +40,7 @@ import javax.ws.rs.core.Application;
import javax.ws.rs.core.Response;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
@@ -341,6 +346,60 @@ public class JaxrsTest {
}
@Test
+ public void testStandaloneEndPointSingletonLifecycle() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-addon");
+
+ ServiceRegistration<?> serviceRegistration = null;
+
+ try {
+ serviceRegistration = registerAddonLifecycle(
+ true, "osgi.jaxrs.resource.base", "/test-addon");
+
+ String first = webTarget.request().get().readEntity(String.class);
+
+ String second = webTarget.request().get().readEntity(String.class);
+
+ assertEquals("This should be equal", first, second);
+ }
+ finally {
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
+ }
+
+ @Test
+ public void testStandaloneEndPointPrototypeLifecycle() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-addon");
+
+ ServiceRegistration<?> serviceRegistration = null;
+
+ try {
+ serviceRegistration = registerAddonLifecycle(
+ false, "osgi.jaxrs.resource.base", "/test-addon");
+
+ String first = webTarget.request().get().readEntity(String.class);
+
+ String second = webTarget.request().get().readEntity(String.class);
+
+ assertNotEquals("This should be different", first, second);
+ }
+ finally {
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
+ }
+
+ @Test
public void testStandaloneFilter() {
Client client = createClient();
@@ -512,7 +571,6 @@ public class JaxrsTest {
}
private ServiceRegistration<?> registerAddon(Object ... keyValues) {
-
TestAddon testAddon = new TestAddon();
Dictionary<String, Object> properties = new Hashtable<>();
@@ -525,6 +583,43 @@ public class JaxrsTest {
Object.class, testAddon, properties);
}
+ private ServiceRegistration<?> registerAddonLifecycle(
+ boolean singleton, Object ... keyValues) {
+
+ Dictionary<String, Object> properties = new Hashtable<>();
+
+ for (int i = 0; i < keyValues.length; i = i + 2) {
+ properties.put(keyValues[i].toString(), keyValues[i + 1]);
+ }
+
+ if (singleton) {
+ return bundleContext.registerService(
+ Object.class, new TestAddonLifecycle(), properties);
+ }
+ else {
+ PrototypeServiceFactory<Object> prototypeServiceFactory =
+ new PrototypeServiceFactory<Object>() {
+ @Override
+ public Object getService(
+ Bundle bundle, ServiceRegistration registration) {
+
+ return new TestAddonLifecycle();
+ }
+
+ @Override
+ public void ungetService(
+ Bundle bundle, ServiceRegistration registration,
+ Object service) {
+
+ }
+ };
+
+ return bundleContext.registerService(
+ Object.class, (ServiceFactory<?>)prototypeServiceFactory,
+ properties);
+ }
+ }
+
private ServiceRegistration<?> registerApplication() {
TestApplication testApplication = new TestApplication();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.itests/src/main/java/test/types/TestAddonLifecycle.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/types/TestAddonLifecycle.java b/jax-rs.itests/src/main/java/test/types/TestAddonLifecycle.java
new file mode 100644
index 0000000..f271dc7
--- /dev/null
+++ b/jax-rs.itests/src/main/java/test/types/TestAddonLifecycle.java
@@ -0,0 +1,31 @@
+/*
+ * 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 test.types;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+public class TestAddonLifecycle {
+
+ @GET
+ @Path("/")
+ public String sayHello() {
+ return this.toString();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 132eb32..b3db5cd 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -80,7 +80,7 @@
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
- <version>5.0.0</version>
+ <version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 8618122..23d0427 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -19,6 +19,7 @@ package org.apache.aries.jax.rs.whiteboard.activator;
import javax.servlet.Servlet;
import javax.ws.rs.core.Application;
+import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator;
@@ -28,10 +29,13 @@ import org.apache.aries.osgi.functional.OSGiResult;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.CXFBusFactory;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
+import org.apache.cxf.message.Message;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.ServiceObjects;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
@@ -68,6 +72,15 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
));
}
+ private static <T> OSGi<ServiceObjects<T>> serviceObjects(
+ ServiceReference<T> serviceReference) {
+
+ return
+ bundleContext().flatMap(bundleContext ->
+ just(bundleContext.getServiceObjects(serviceReference))
+ );
+ }
+
private static OSGi<CXFJaxRsServiceRegistrator> cxfRegistrator(
Bus bus, Application application, Map<String, Object> props) {
@@ -129,7 +142,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
OSGi<?> extensions =
serviceReferences(getExtensionFilter()).flatMap(ref ->
waitForExtensionDependencies(ref,
- safeRegisterEndpoint(ref, defaultServiceRegistrator)
+ safeRegisterExtension(ref, defaultServiceRegistrator)
)
);
@@ -142,12 +155,44 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
flatMap(applicationFilter ->
services(CXFJaxRsServiceRegistrator.class, applicationFilter).
flatMap(registrator ->
- safeRegisterEndpoint(ref, registrator)
+ testProvider(ref).flatMap(isProvider -> {
+ if (isProvider) {
+ return safeRegisterExtension(ref, registrator);
+ }
+ else {
+ return safeRegisterEndpoint(ref, registrator);
+ }
+ })
)));
_applicationSingletonsResult = applicationSingletons.run(bundleContext);
}
+ private OSGi<Boolean> testProvider(ServiceReference<?> serviceReference) {
+ return bundleContext().flatMap(bundleContext -> {
+ Object service = bundleContext.getService(serviceReference);
+ Class<?> serviceClass = service.getClass();
+ if (serviceClass.isAnnotationPresent(Provider.class)) {
+ return just(Boolean.TRUE);
+ }
+ else {
+ return just(Boolean.FALSE);
+ }
+ });
+ }
+
+ private OSGi<?> safeRegisterExtension(
+ ServiceReference<Object> ref,
+ CXFJaxRsServiceRegistrator registrator) {
+
+ return
+ service(ref).flatMap(extension ->
+ onClose(() -> registrator.removeProvider(extension)).
+ foreach(ign ->
+ registrator.addProvider(extension)
+ ));
+ }
+
/**
* Initialize instance so it is never looked up again
* @param bundleContext
@@ -195,20 +240,22 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
return program;
}
- private OSGi<?> safeRegisterEndpoint(
- ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator) {
+ private <T> OSGi<?> safeRegisterEndpoint(
+ ServiceReference<T> ref, CXFJaxRsServiceRegistrator registrator) {
return
bundleContext().flatMap(bundleContext ->
- service(ref).flatMap(service ->
- onClose(() -> unregisterEndpoint(registrator, service)).then(
- registerEndpoint(ref, registrator, service)
- )));
+ serviceObjects(ref).flatMap(service ->
+ registerEndpoint(ref, registrator, service).
+ flatMap(serviceInformation ->
+ onClose(
+ () -> unregisterEndpoint(registrator, serviceInformation)))));
}
- private OSGi<?> registerEndpoint(
+ private <T> OSGi<ServiceInformation> registerEndpoint(
ServiceReference<?> ref,
- CXFJaxRsServiceRegistrator registrator, Object service) {
+ CXFJaxRsServiceRegistrator registrator,
+ ServiceObjects<T> serviceObjects) {
Thread thread = Thread.currentThread();
ClassLoader contextClassLoader = thread.getContextClassLoader();
@@ -216,6 +263,8 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
getClassLoader();
Object resourceBaseObject = ref.getProperty("osgi.jaxrs.resource.base");
+ ResourceProvider resourceProvider = getResourceProvider(serviceObjects);
+
String resourceBase;
if (resourceBaseObject == null) {
@@ -226,18 +275,55 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
try {
thread.setContextClassLoader(classLoader);
- registrator.add(new ServiceInformation(resourceBase, "", service));
+ ServiceInformation serviceInformation = new ServiceInformation(
+ resourceBase, resourceProvider);
+ registrator.add(serviceInformation);
+ return just(serviceInformation);
}
finally {
thread.setContextClassLoader(contextClassLoader);
}
- return just(service);
+ }
+
+ private <T> ResourceProvider getResourceProvider(
+ ServiceObjects<T> serviceObjects) {
+
+ ResourceProvider resourceProvider;
+ T service = serviceObjects.getService();
+ Class<?> serviceClass = service.getClass();
+
+ resourceProvider = new ResourceProvider() {
+
+ @Override
+ public Object getInstance(Message m) {
+ return serviceObjects.getService();
+ }
+
+ @Override
+ public void releaseInstance(Message m, Object o) {
+ serviceObjects.ungetService((T)o);
+ }
+
+ @Override
+ public Class<?> getResourceClass() {
+ return serviceClass;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+ };
+
+ serviceObjects.ungetService(service);
+ return resourceProvider;
}
private void unregisterEndpoint(
- CXFJaxRsServiceRegistrator registrator, Object service) {
+ CXFJaxRsServiceRegistrator registrator,
+ ServiceInformation serviceInformation) {
- registrator.remove(service);
+ registrator.remove(serviceInformation);
}
private ServiceRegistration<Servlet> registerCXFServletService(Bus bus) {
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/2bac01c8/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index 683cb0f..e6170cb 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -20,19 +20,17 @@ package org.apache.aries.jax.rs.whiteboard.internal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Application;
-import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
-import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
import org.apache.cxf.jaxrs.model.ClassResourceInfo;
import org.apache.cxf.jaxrs.model.URITemplate;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
@@ -89,38 +87,40 @@ public class CXFJaxRsServiceRegistrator {
return;
}
- Object object = serviceInformation.getService();
+ _services.add(serviceInformation);
- if (object.getClass().isAnnotationPresent(Provider.class)) {
- _providers.add(object);
- } else {
- _services.add(serviceInformation);
- }
rewire();
}
- public void remove(Object object) {
+ public void remove(ServiceInformation serviceInformation) {
if (_closed) {
return;
}
- if (object.getClass().isAnnotationPresent(Provider.class)) {
- _providers.remove(object);
- }
- else {
- Iterator<ServiceInformation> iterator = _services.iterator();
- while (iterator.hasNext()) {
- ServiceInformation next = iterator.next();
+ _services.remove(serviceInformation);
- if (next.getService() == object) {
- iterator.remove();
- }
- }
+ rewire();
+ }
+
+ public void addProvider(Object provider) {
+ if (_closed) {
+ return;
}
+ _providers.add(provider);
+
rewire();
}
+ public void removeProvider(Object provider) {
+ if (_closed) {
+ return;
+ }
+
+ _providers.remove(provider);
+
+ rewire();
+ }
protected synchronized void rewire() {
if (_server != null) {
_server.destroy();
@@ -159,18 +159,18 @@ public class CXFJaxRsServiceRegistrator {
jaxRsServerFactoryBean.getServiceFactory();
for (ServiceInformation serviceInformation : _services) {
- Object service = serviceInformation.getService();
- SingletonResourceProvider rp = new SingletonResourceProvider(
- service, true);
+ ResourceProvider resourceProvider =
+ serviceInformation.getResourceProvider();
- jaxRsServerFactoryBean.setResourceProvider(rp);
+ jaxRsServerFactoryBean.setResourceProvider(resourceProvider);
List<ClassResourceInfo> classResourceInfo =
serviceFactory.getClassResourceInfo();
for (ClassResourceInfo resourceInfo : classResourceInfo) {
- if (resourceInfo.getServiceClass() == service.getClass()) {
+ if (resourceInfo.getServiceClass() ==
+ resourceProvider.getResourceClass()) {
URITemplate uriTemplate = resourceInfo.getURITemplate();
resourceInfo.setURITemplate(
new URITemplate(
@@ -203,27 +203,21 @@ public class CXFJaxRsServiceRegistrator {
public static class ServiceInformation {
private final String prefixPath;
- private final String scope;
- private final Object service;
+ private final ResourceProvider _resourceProvider;
public ServiceInformation(
- String prefixPath, String scope, Object service) {
+ String prefixPath, ResourceProvider resourceProvider) {
this.prefixPath = prefixPath;
- this.scope = scope;
- this.service = service;
+ this._resourceProvider = resourceProvider;
}
public String getPrefixPath() {
return prefixPath;
}
- public String getScope() {
- return scope;
- }
-
- public Object getService() {
- return service;
+ public ResourceProvider getResourceProvider() {
+ return _resourceProvider;
}
}
[12/12] aries-jax-rs-whiteboard git commit: Source formatting and
reorganization
Posted by cs...@apache.org.
Source formatting and reorganization
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/576f7e39
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/576f7e39
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/576f7e39
Branch: refs/heads/master
Commit: 576f7e39547e3ff0e45187beeee4a150938e3c67
Parents: 5b7b1eb
Author: Carlos Sierra <cs...@apache.org>
Authored: Fri Feb 24 17:40:21 2017 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Fri Feb 24 17:40:21 2017 +0100
----------------------------------------------------------------------
.../activator/CXFJaxRsBundleActivator.java | 297 +++++--------------
.../internal/CXFJaxRsServiceRegistrator.java | 61 ++--
.../aries/jax/rs/whiteboard/internal/Utils.java | 187 ++++++++++++
3 files changed, 287 insertions(+), 258 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/576f7e39/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index d369b47..ab06853 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -19,23 +19,18 @@ package org.apache.aries.jax.rs.whiteboard.activator;
import javax.servlet.Servlet;
import javax.ws.rs.core.Application;
-import javax.ws.rs.ext.Provider;
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator;
-import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator.ServiceInformation;
import org.apache.aries.osgi.functional.OSGi;
import org.apache.aries.osgi.functional.OSGiResult;
import org.apache.cxf.Bus;
import org.apache.cxf.BusFactory;
import org.apache.cxf.bus.CXFBusFactory;
-import org.apache.cxf.jaxrs.lifecycle.ResourceProvider;
-import org.apache.cxf.message.Message;
import org.apache.cxf.transport.servlet.CXFNonSpringServlet;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
-import org.osgi.framework.ServiceObjects;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
import org.osgi.framework.wiring.BundleWiring;
@@ -43,14 +38,11 @@ import org.osgi.framework.wiring.BundleWiring;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.Map;
import static java.lang.String.format;
import static org.apache.aries.jax.rs.whiteboard.AriesJaxRSWhiteboardConstants.*;
-import static org.apache.aries.osgi.functional.OSGi.bundleContext;
+import static org.apache.aries.jax.rs.whiteboard.internal.Utils.*;
import static org.apache.aries.osgi.functional.OSGi.just;
-import static org.apache.aries.osgi.functional.OSGi.onClose;
-import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
import static org.apache.aries.osgi.functional.OSGi.services;
import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*;
@@ -61,41 +53,12 @@ import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHIT
public class CXFJaxRsBundleActivator implements BundleActivator {
- private BundleContext _bundleContext;
private OSGiResult<?> _applicationsResult;
- private OSGiResult<?> _singletonsResult;
- private OSGiResult<?> _extensionsResult;
private OSGiResult<?> _applicationSingletonsResult;
-
- private static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
- return
- bundleContext().flatMap(bundleContext ->
- onClose(() -> bundleContext.ungetService(serviceReference)).then(
- just(bundleContext.getService(serviceReference))
- ));
- }
-
- private static <T> OSGi<ServiceObjects<T>> serviceObjects(
- ServiceReference<T> serviceReference) {
-
- return
- bundleContext().flatMap(bundleContext ->
- just(bundleContext.getServiceObjects(serviceReference))
- );
- }
-
- private static OSGi<CXFJaxRsServiceRegistrator> cxfRegistrator(
- Bus bus, Application application, Map<String, Object> props) {
-
- CXFJaxRsServiceRegistrator registrator =
- new CXFJaxRsServiceRegistrator(bus, application, props);
-
- return
- onClose(registrator::close).then(
- register(CXFJaxRsServiceRegistrator.class, registrator, props).then(
- just(registrator)
- ));
- }
+ private BundleContext _bundleContext;
+ private Bus _bus;
+ private OSGiResult<?> _extensionsResult;
+ private OSGiResult<?> _singletonsResult;
@Override
public void start(BundleContext bundleContext) throws Exception {
@@ -103,9 +66,9 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
initRuntimeDelegate(bundleContext);
// TODO make the context path of the JAX-RS Whiteboard configurable.
- Bus bus = BusFactory.newInstance(
+ _bus = BusFactory.newInstance(
CXFBusFactory.class.getName()).createBus();
- registerCXFServletService(bus);
+ registerCXFServletService(_bus);
OSGi<?> applications =
serviceReferences(Application.class, getApplicationFilter()).
@@ -115,16 +78,37 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
ref, JAX_RS_APPLICATION_BASE)).
flatMap(properties ->
service(ref).flatMap(application ->
- cxfRegistrator(bus, application, properties)
+ cxfRegistrator(_bus, application, properties)
)));
_applicationsResult = applications.run(bundleContext);
+ OSGi<?> applicationSingletons =
+ serviceReferences(format("(%s=*)", JAX_RS_APPLICATION_SELECT)).
+ flatMap(ref ->
+ just(ref.getProperty(JAX_RS_APPLICATION_SELECT).toString()).
+ flatMap(applicationFilter ->
+ services(CXFJaxRsServiceRegistrator.class, applicationFilter).
+ flatMap(registrator ->
+ safeRegisterGeneric(ref, registrator)
+ )));
+
+ _applicationSingletonsResult = applicationSingletons.run(bundleContext);
+
Application defaultApplication = new Application() {};
CXFJaxRsServiceRegistrator defaultServiceRegistrator =
new CXFJaxRsServiceRegistrator(
- bus, defaultApplication, new HashMap<>());
+ _bus, defaultApplication, new HashMap<>());
+
+ OSGi<?> extensions =
+ serviceReferences(getExtensionFilter()).flatMap(ref ->
+ waitForExtensionDependencies(ref,
+ safeRegisterExtension(ref, defaultServiceRegistrator)
+ )
+ );
+
+ _extensionsResult = extensions.run(bundleContext);
OSGi<?> singletons =
serviceReferences(getSingletonsFilter()).
@@ -141,80 +125,21 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
);
_singletonsResult = singletons.run(bundleContext);
-
- OSGi<?> extensions =
- serviceReferences(getExtensionFilter()).flatMap(ref ->
- waitForExtensionDependencies(ref,
- safeRegisterExtension(ref, defaultServiceRegistrator)
- )
- );
-
- _extensionsResult = extensions.run(bundleContext);
-
- OSGi<?> applicationSingletons =
- serviceReferences(format("(%s=*)", JAX_RS_APPLICATION_SELECT)).
- flatMap(ref ->
- just(ref.getProperty(JAX_RS_APPLICATION_SELECT).toString()).
- flatMap(applicationFilter ->
- services(CXFJaxRsServiceRegistrator.class, applicationFilter).
- flatMap(registrator ->
- testProvider(ref).flatMap(isProvider -> {
- if (isProvider) {
- return safeRegisterExtension(ref, registrator);
- }
- else {
- return safeRegisterEndpoint(ref, registrator);
- }
- })
- )));
-
- _applicationSingletonsResult = applicationSingletons.run(bundleContext);
}
- private OSGi<Boolean> testProvider(ServiceReference<?> serviceReference) {
- return bundleContext().flatMap(bundleContext -> {
- Object service = bundleContext.getService(serviceReference);
- Class<?> serviceClass = service.getClass();
- if (serviceClass.isAnnotationPresent(Provider.class)) {
- return just(Boolean.TRUE);
- }
- else {
- return just(Boolean.FALSE);
- }
- });
- }
-
- private OSGi<?> safeRegisterExtension(
- ServiceReference<Object> ref,
- CXFJaxRsServiceRegistrator registrator) {
-
- return
- service(ref).flatMap(extension ->
- onClose(() -> registrator.removeProvider(extension)).
- foreach(ign ->
- registrator.addProvider(extension)
- ));
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ _applicationsResult.close();
+ _applicationSingletonsResult.close();
+ _extensionsResult.close();
+ _singletonsResult.close();
}
- /**
- * Initialize instance so it is never looked up again
- * @param bundleContext
- */
- private void initRuntimeDelegate(BundleContext bundleContext) {
- Thread thread = Thread.currentThread();
- ClassLoader oldClassLoader = thread.getContextClassLoader();
- BundleWiring bundleWiring = bundleContext.getBundle().adapt(
- BundleWiring.class);
- thread.setContextClassLoader(bundleWiring.getClassLoader());
- try {
- RuntimeDelegate.getInstance();
- }
- finally {
- thread.setContextClassLoader(oldClassLoader);
- }
+ private static String buildExtensionFilter(String filter) {
+ return String.format("(&%s%s)", getExtensionFilter(), filter);
}
- private String[] canonicalize(Object propertyValue) {
+ private static String[] canonicalize(Object propertyValue) {
if (propertyValue == null) {
return new String[0];
}
@@ -224,111 +149,42 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
return new String[]{propertyValue.toString()};
}
- private String buildExtensionFilter(String filter) {
- return format("(&%s%s)", getExtensionFilter(), filter);
+ private static CXFNonSpringServlet createCXFServlet(Bus bus) {
+ CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet();
+ cxfNonSpringServlet.setBus(bus);
+ return cxfNonSpringServlet;
}
- private OSGi<?> waitForExtensionDependencies(
- ServiceReference<?> serviceReference, OSGi<?> program) {
-
- String[] extensionDependencies = canonicalize(
- serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
-
- for (String extensionDependency : extensionDependencies) {
- program =
- serviceReferences(buildExtensionFilter(extensionDependency)).
- then(program);
- }
-
- return program;
+ private static String getApplicationFilter() {
+ return format("(%s=*)", JAX_RS_APPLICATION_BASE);
}
- private <T> OSGi<?> safeRegisterEndpoint(
- ServiceReference<T> ref, CXFJaxRsServiceRegistrator registrator) {
-
- return
- bundleContext().flatMap(bundleContext ->
- serviceObjects(ref).flatMap(service ->
- registerEndpoint(ref, registrator, service).
- flatMap(serviceInformation ->
- onClose(
- () -> unregisterEndpoint(registrator, serviceInformation)))));
+ private static String getExtensionFilter() {
+ return format("(%s=*)", JAX_RS_EXTENSION_NAME);
}
- private <T> OSGi<ServiceInformation> registerEndpoint(
- ServiceReference<?> ref,
- CXFJaxRsServiceRegistrator registrator,
- ServiceObjects<T> serviceObjects) {
+ private static String getSingletonsFilter() {
+ return format("(%s=*)", JAX_RS_RESOURCE_BASE);
+ }
+ /**
+ * Initialize instance so it is never looked up again
+ * @param bundleContext
+ */
+ private void initRuntimeDelegate(BundleContext bundleContext) {
Thread thread = Thread.currentThread();
- ClassLoader contextClassLoader = thread.getContextClassLoader();
- ClassLoader classLoader = ref.getBundle().adapt(BundleWiring.class).
- getClassLoader();
- Object resourceBaseObject = ref.getProperty(JAX_RS_RESOURCE_BASE);
-
- ResourceProvider resourceProvider = getResourceProvider(serviceObjects);
-
- String resourceBase;
-
- if (resourceBaseObject == null) {
- resourceBase = "";
- }
- else {
- resourceBase = resourceBaseObject.toString();
- }
+ ClassLoader oldClassLoader = thread.getContextClassLoader();
+ BundleWiring bundleWiring = bundleContext.getBundle().adapt(
+ BundleWiring.class);
+ thread.setContextClassLoader(bundleWiring.getClassLoader());
try {
- thread.setContextClassLoader(classLoader);
- ServiceInformation serviceInformation = new ServiceInformation(
- resourceBase, resourceProvider);
- registrator.add(serviceInformation);
- return just(serviceInformation);
+ RuntimeDelegate.getInstance();
}
finally {
- thread.setContextClassLoader(contextClassLoader);
+ thread.setContextClassLoader(oldClassLoader);
}
}
- private <T> ResourceProvider getResourceProvider(
- ServiceObjects<T> serviceObjects) {
-
- ResourceProvider resourceProvider;
- T service = serviceObjects.getService();
- Class<?> serviceClass = service.getClass();
-
- resourceProvider = new ResourceProvider() {
-
- @Override
- public Object getInstance(Message m) {
- return serviceObjects.getService();
- }
-
- @Override
- public void releaseInstance(Message m, Object o) {
- serviceObjects.ungetService((T)o);
- }
-
- @Override
- public Class<?> getResourceClass() {
- return serviceClass;
- }
-
- @Override
- public boolean isSingleton() {
- return false;
- }
- };
-
- serviceObjects.ungetService(service);
- return resourceProvider;
- }
-
- private void unregisterEndpoint(
- CXFJaxRsServiceRegistrator registrator,
- ServiceInformation serviceInformation) {
-
- registrator.remove(serviceInformation);
- }
-
private ServiceRegistration<Servlet> registerCXFServletService(Bus bus) {
Dictionary<String, Object> properties = new Hashtable<>();
properties.put(HTTP_WHITEBOARD_CONTEXT_SELECT,
@@ -341,30 +197,19 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
Servlet.class, cxfNonSpringServlet, properties);
}
- private CXFNonSpringServlet createCXFServlet(Bus bus) {
- CXFNonSpringServlet cxfNonSpringServlet = new CXFNonSpringServlet();
- cxfNonSpringServlet.setBus(bus);
- return cxfNonSpringServlet;
- }
-
- private String getExtensionFilter() {
- return format("(%s=*)", JAX_RS_EXTENSION_NAME);
- }
+ private static OSGi<?> waitForExtensionDependencies(
+ ServiceReference<?> serviceReference, OSGi<?> program) {
- private String getApplicationFilter() {
- return format("(%s=*)", JAX_RS_APPLICATION_BASE);
- }
+ String[] extensionDependencies = canonicalize(
+ serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
- private String getSingletonsFilter() {
- return format("(%s=*)", JAX_RS_RESOURCE_BASE);
- }
+ for (String extensionDependency : extensionDependencies) {
+ program =
+ serviceReferences(buildExtensionFilter(extensionDependency)).
+ then(program);
+ }
- @Override
- public void stop(BundleContext context) throws Exception {
- _applicationSingletonsResult.close();
- _applicationsResult.close();
- _extensionsResult.close();
- _singletonsResult.close();
+ return program;
}
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/576f7e39/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index 1ac45ee..dd91521 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -36,16 +36,18 @@ import org.apache.cxf.jaxrs.model.URITemplate;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
import org.osgi.framework.ServiceReference;
+import static org.apache.aries.jax.rs.whiteboard.internal.Utils.safeToString;
import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.*;
public class CXFJaxRsServiceRegistrator {
+
private volatile boolean _closed = false;
private final Application _application;
private final Bus _bus;
private final Map<String, Object> _properties;
private final Collection<Object> _providers = new ArrayList<>();
private Server _server;
- private final Collection<ServiceInformation> _services = new ArrayList<>();
+ private final Collection<ResourceInformation> _services = new ArrayList<>();
private static final String CXF_ENDPOINT_ADDRESS = "CXF_ENDPOINT_ADDRESS";
@@ -59,9 +61,11 @@ public class CXFJaxRsServiceRegistrator {
rewire();
}
- public static Map<String, Object> getProperties(ServiceReference<?> sref, String addressKey) {
+ public static Map<String, Object> getProperties(
+ ServiceReference<?> sref, String addressKey) {
+
String[] propertyKeys = sref.getPropertyKeys();
- Map<String, Object> properties = new HashMap<String, Object>(propertyKeys.length);
+ Map<String, Object> properties = new HashMap<>(propertyKeys.length);
for (String key : propertyKeys) {
if (key.equals(JAX_RS_RESOURCE_BASE)) {
@@ -70,48 +74,49 @@ public class CXFJaxRsServiceRegistrator {
properties.put(key, sref.getProperty(key));
}
- properties.put(CXF_ENDPOINT_ADDRESS, sref.getProperty(addressKey).toString());
+ properties.put(
+ CXF_ENDPOINT_ADDRESS, sref.getProperty(addressKey).toString());
return properties;
}
- public void close() {
+ public void add(ResourceInformation resourceInformation) {
if (_closed) {
return;
}
- if (_server != null) {
- _server.destroy();
- }
+ _services.add(resourceInformation);
- _closed = true;
+ rewire();
}
- public void add(ServiceInformation serviceInformation) {
+ public void addProvider(Object provider) {
if (_closed) {
return;
}
- _services.add(serviceInformation);
+ _providers.add(provider);
rewire();
}
- public void remove(ServiceInformation serviceInformation) {
+ public void close() {
if (_closed) {
return;
}
- _services.remove(serviceInformation);
+ if (_server != null) {
+ _server.destroy();
+ }
- rewire();
+ _closed = true;
}
- public void addProvider(Object provider) {
+ public void remove(ResourceInformation resourceInformation) {
if (_closed) {
return;
}
- _providers.add(provider);
+ _services.remove(resourceInformation);
rewire();
}
@@ -125,6 +130,7 @@ public class CXFJaxRsServiceRegistrator {
rewire();
}
+
protected synchronized void rewire() {
if (_server != null) {
_server.destroy();
@@ -162,13 +168,14 @@ public class CXFJaxRsServiceRegistrator {
JAXRSServiceFactoryBean serviceFactory =
jaxRsServerFactoryBean.getServiceFactory();
- for (ServiceInformation serviceInformation : _services) {
+ for (ResourceInformation resourceInformation : _services) {
ResourceProvider resourceProvider =
- serviceInformation.getResourceProvider();
+ resourceInformation.getResourceProvider();
jaxRsServerFactoryBean.setResourceProvider(resourceProvider);
+ //FIXME: this is hack to programmatically prefix only resource path
List<ClassResourceInfo> classResourceInfo =
serviceFactory.getClassResourceInfo();
@@ -178,23 +185,13 @@ public class CXFJaxRsServiceRegistrator {
URITemplate uriTemplate = resourceInfo.getURITemplate();
resourceInfo.setURITemplate(
new URITemplate(
- serviceInformation.getPrefixPath() +
+ resourceInformation.getPrefixPath() +
uriTemplate.getValue()));
}
}
}
- Object cxfEndpointAddressObject = _properties.get(
- CXF_ENDPOINT_ADDRESS);
-
- String address;
-
- if (cxfEndpointAddressObject == null) {
- address = "";
- }
- else {
- address = cxfEndpointAddressObject.toString();
- }
+ String address = safeToString(_properties.get(CXF_ENDPOINT_ADDRESS));
if (address != null) {
jaxRsServerFactoryBean.setAddress(address);
@@ -205,11 +202,11 @@ public class CXFJaxRsServiceRegistrator {
_server.start();
}
- public static class ServiceInformation {
+ public static class ResourceInformation {
private final String prefixPath;
private final ResourceProvider _resourceProvider;
- public ServiceInformation(
+ public ResourceInformation(
String prefixPath, ResourceProvider resourceProvider) {
this.prefixPath = prefixPath;
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/576f7e39/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
new file mode 100644
index 0000000..0951f6e
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
@@ -0,0 +1,187 @@
+/*
+ * 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.aries.jax.rs.whiteboard.internal;
+
+import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator.ResourceInformation;
+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 javax.ws.rs.core.Application;
+import javax.ws.rs.ext.Provider;
+import java.util.Map;
+
+import static org.apache.aries.osgi.functional.OSGi.bundleContext;
+import static org.apache.aries.osgi.functional.OSGi.just;
+import static org.apache.aries.osgi.functional.OSGi.onClose;
+import static org.apache.aries.osgi.functional.OSGi.register;
+import static org.osgi.service.jaxrs.whiteboard.JaxRSWhiteboardConstants.JAX_RS_RESOURCE_BASE;
+
+/**
+ * @author Carlos Sierra Andr�s
+ */
+public class Utils {
+
+ public static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
+ return
+ bundleContext().flatMap(bundleContext ->
+ onClose(() -> bundleContext.ungetService(serviceReference)).then(
+ just(bundleContext.getService(serviceReference))
+ ));
+ }
+
+ public static <T> OSGi<ServiceObjects<T>> serviceObjects(
+ ServiceReference<T> serviceReference) {
+
+ return
+ bundleContext().flatMap(bundleContext ->
+ just(bundleContext.getServiceObjects(serviceReference))
+ );
+ }
+
+ public static OSGi<CXFJaxRsServiceRegistrator> cxfRegistrator(
+ Bus bus, Application application, Map<String, Object> props) {
+
+ CXFJaxRsServiceRegistrator registrator =
+ new CXFJaxRsServiceRegistrator(bus, application, props);
+
+ return
+ onClose(registrator::close).then(
+ register(CXFJaxRsServiceRegistrator.class, registrator, props).then(
+ just(registrator)
+ ));
+ }
+
+ public static OSGi<?> safeRegisterGeneric(
+ ServiceReference<?> serviceReference,
+ CXFJaxRsServiceRegistrator registrator) {
+
+ return bundleContext().flatMap(bundleContext -> {
+ Object service = bundleContext.getService(serviceReference);
+ Class<?> serviceClass = service.getClass();
+ bundleContext.ungetService(serviceReference);
+ if (serviceClass.isAnnotationPresent(Provider.class)) {
+ return safeRegisterExtension(serviceReference, registrator);
+ }
+ else {
+ return safeRegisterEndpoint(serviceReference, registrator);
+ }
+ });
+ }
+
+ public static OSGi<?> safeRegisterExtension(
+ ServiceReference<?> serviceReference,
+ CXFJaxRsServiceRegistrator registrator) {
+
+ return
+ service(serviceReference).flatMap(extension ->
+ onClose(() -> registrator.removeProvider(extension)).
+ foreach(ign ->
+ registrator.addProvider(extension)
+ ));
+ }
+
+ public static <T> OSGi<?> safeRegisterEndpoint(
+ ServiceReference<T> ref, CXFJaxRsServiceRegistrator registrator) {
+
+ return
+ bundleContext().flatMap(bundleContext ->
+ serviceObjects(ref).flatMap(service ->
+ registerEndpoint(ref, registrator, service).
+ flatMap(serviceInformation ->
+ onClose(() ->
+ unregisterEndpoint(registrator, serviceInformation)))));
+ }
+
+ public static <T> OSGi<ResourceInformation> registerEndpoint(
+ ServiceReference<?> serviceReference,
+ 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);
+ String resourceBase = safeToString(
+ serviceReference.getProperty(JAX_RS_RESOURCE_BASE));
+
+ try {
+ thread.setContextClassLoader(classLoader);
+ ResourceInformation resourceInformation = new ResourceInformation(
+ resourceBase, resourceProvider);
+ registrator.add(resourceInformation);
+ return just(resourceInformation);
+ }
+ finally {
+ thread.setContextClassLoader(contextClassLoader);
+ }
+ }
+
+ public static String safeToString(Object resourceBaseObject) {
+ return resourceBaseObject == null ? "" : resourceBaseObject.toString();
+ }
+
+ public static <T> ResourceProvider getResourceProvider(
+ ServiceObjects<T> serviceObjects) {
+
+ ResourceProvider resourceProvider;
+ T service = serviceObjects.getService();
+ Class<?> serviceClass = service.getClass();
+
+ resourceProvider = new ResourceProvider() {
+
+ @Override
+ public Object getInstance(Message m) {
+ return serviceObjects.getService();
+ }
+
+ @Override
+ public void releaseInstance(Message m, Object o) {
+ serviceObjects.ungetService((T)o);
+ }
+
+ @Override
+ public Class<?> getResourceClass() {
+ return serviceClass;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false;
+ }
+ };
+
+ serviceObjects.ungetService(service);
+ return resourceProvider;
+ }
+
+ public static void unregisterEndpoint(
+ CXFJaxRsServiceRegistrator registrator,
+ ResourceInformation resourceInformation) {
+
+ registrator.remove(resourceInformation);
+ }
+
+}
[03/12] aries-jax-rs-whiteboard git commit: Deploy extensions in
default application
Posted by cs...@apache.org.
Deploy extensions in default application
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/f51b5770
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/f51b5770
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/f51b5770
Branch: refs/heads/master
Commit: f51b57703fe7e55e02ec63ad093491950cb722a8
Parents: e7caec3
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 22 17:44:39 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 4 +--
.../activator/CXFJaxRsBundleActivator.java | 31 ++++++--------------
2 files changed, 11 insertions(+), 24 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f51b5770/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 5292cfd..3fc9c52 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -184,7 +184,7 @@ public class JaxrsTest {
"osgi.jaxrs.resource.base", "/test-addon");
filterRegistration = registerFilter(
- "osgi.jaxrs.filter.base", "/test-addon");
+ "osgi.jaxrs.extension.name", "test-filter");
Response response = webTarget.request().get();
@@ -231,7 +231,7 @@ public class JaxrsTest {
assertNull(response.getHeaders().getFirst("Filtered"));
filterRegistration = registerFilter(
- "osgi.jaxrs.filter.base", "/test-addon");
+ "osgi.jaxrs.extension.name", "test-filter");
response = webTarget.request().get();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/f51b5770/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index e40b991..4260db0 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -59,7 +59,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
private BundleContext _bundleContext;
private OSGiResult<?> _applicationsResult;
private OSGiResult<?> _singletonsResult;
- private OSGiResult<?> _filtersResult;
+ private OSGiResult<?> _extensionsResult;
private static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
return
@@ -127,27 +127,14 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_singletonsResult = singletons.run(bundleContext);
- OSGi<?> filters =
- serviceReferences(getFiltersFilter()).flatMap(ref ->
+ OSGi<?> extensions =
+ serviceReferences(getExtensionFilter()).flatMap(ref ->
waitForExtensionDependencies(ref,
- just(
- ref.getProperty("osgi.jaxrs.filter.base").toString()).
- flatMap(filterBase ->
- serviceReferences(
- CXFJaxRsServiceRegistrator.class, "(CXF_ENDPOINT_ADDRESS=*)").
- filter(regref ->
- regref.
- getProperty("CXF_ENDPOINT_ADDRESS").
- toString().
- startsWith(filterBase)).
- flatMap(regref ->
- service(regref).flatMap(registrator ->
- service(ref).flatMap(service ->
- safeRegisterEndpoint(ref, registrator, service)
- )))))
+ safeRegisterEndpoint(ref, defaultServiceRegistrator)
+ )
);
- _filtersResult = filters.run(bundleContext);
+ _extensionsResult = extensions.run(bundleContext);
}
/**
@@ -260,8 +247,8 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
return cxfNonSpringServlet;
}
- private String getFiltersFilter() {
- return "(osgi.jaxrs.filter.base=*)";
+ private String getExtensionFilter() {
+ return "(osgi.jaxrs.extension.name=*)";
}
private String getApplicationFilter() {
@@ -275,7 +262,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
@Override
public void stop(BundleContext context) throws Exception {
_applicationsResult.close();
- _filtersResult.close();
+ _extensionsResult.close();
_singletonsResult.close();
}
[08/12] aries-jax-rs-whiteboard git commit: Readd support for
application extension
Posted by cs...@apache.org.
Readd support for application extension
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/c54be5f2
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/c54be5f2
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/c54be5f2
Branch: refs/heads/master
Commit: c54be5f2e68c8c41f1d4691faa135c8c940953be
Parents: f51b577
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 22 17:45:47 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 174 +++++++++++++++++++
.../activator/CXFJaxRsBundleActivator.java | 15 ++
2 files changed, 189 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/c54be5f2/jax-rs.itests/src/main/java/test/JaxrsTest.java
----------------------------------------------------------------------
diff --git a/jax-rs.itests/src/main/java/test/JaxrsTest.java b/jax-rs.itests/src/main/java/test/JaxrsTest.java
index 3fc9c52..f5b434b 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -105,6 +105,180 @@ public class JaxrsTest {
}
@Test
+ public void testApplicationEndpointExtension() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-application").
+ path("extended");
+
+ ServiceRegistration<?> applicationRegistration = null;
+
+ ServiceRegistration<?> serviceRegistration = null;
+
+ try {
+ applicationRegistration = registerApplication();
+
+ serviceRegistration = registerAddon(
+ "osgi.jaxrs.application.select",
+ "(osgi.jaxrs.application.base=/test-application)");
+
+ assertEquals(
+ "Hello extended",
+ webTarget.request().get().readEntity(String.class));
+ }
+ finally {
+ if (applicationRegistration != null) {
+ applicationRegistration.unregister();
+ }
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
+ }
+
+ @Test
+ public void testApplicationEndpointExtensionReadd() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-application").
+ path("extended");
+
+ ServiceRegistration<?> applicationRegistration = null;
+
+ try {
+ applicationRegistration = registerApplication();
+
+ Runnable testCase = () -> {
+ assertEquals(webTarget.request().get().getStatus(), 404);
+
+ ServiceRegistration<?> serviceRegistration = null;
+
+ try {
+ serviceRegistration = registerAddon(
+ "osgi.jaxrs.application.select",
+ "(osgi.jaxrs.application.base=/test-application)");
+
+ assertEquals(
+ "Hello extended",
+ webTarget.request().get().readEntity(String.class));
+ }
+ finally {
+ if (serviceRegistration != null) {
+ serviceRegistration.unregister();
+ }
+ }
+ };
+
+ testCase.run();
+
+ testCase.run();
+ }
+ finally {
+ if (applicationRegistration != null) {
+ applicationRegistration.unregister();
+ }
+
+ }
+ }
+
+ @Test
+ public void testApplicationProviderExtension() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-application");
+
+ ServiceRegistration<?> applicationRegistration = null;
+
+ ServiceRegistration<?> filterRegistration = null;
+
+ try {
+ applicationRegistration = registerApplication();
+
+ filterRegistration = registerFilter(
+ "osgi.jaxrs.application.select",
+ "(osgi.jaxrs.application.base=/test-application)");
+
+ Response response = webTarget.request().get();
+
+ assertEquals(
+ "Hello application",
+ response.readEntity(String.class));
+
+ assertEquals(
+ response.getHeaders().getFirst("Filtered"),
+ "true");
+ }
+ finally {
+ if (applicationRegistration != null) {
+ applicationRegistration.unregister();
+ }
+ if (filterRegistration != null) {
+ filterRegistration.unregister();
+ }
+ }
+ }
+
+ @Test
+ public void testApplicationProviderExtensionReadd() {
+ Client client = createClient();
+
+ WebTarget webTarget = client.
+ target("http://localhost:8080").
+ path("/test-application");
+
+ ServiceRegistration<?> applicationRegistration = null;
+
+ try {
+ applicationRegistration = registerApplication();
+
+ assertEquals(
+ "Hello application",
+ webTarget.request().get().readEntity(String.class));
+
+ Runnable testCase = () -> {
+ Response response = webTarget.request().get();
+
+ assertNull(response.getHeaders().getFirst("Filtered"));
+
+ ServiceRegistration<?> filterRegistration = null;
+
+ try {
+ filterRegistration = registerFilter(
+ "osgi.jaxrs.application.select",
+ "(osgi.jaxrs.application.base=/test-application)");
+
+ response = webTarget.request().get();
+
+ assertEquals(
+ response.getHeaders().getFirst("Filtered"),
+ "true");
+ }
+ finally {
+ if (filterRegistration != null) {
+ filterRegistration.unregister();
+ }
+ }
+ };
+
+ testCase.run();
+
+ testCase.run();
+
+ }
+ finally {
+ if (applicationRegistration != null) {
+ applicationRegistration.unregister();
+ }
+ }
+ }
+
+ @Test
public void testStandaloneEndPoint() {
Client client = createClient();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/c54be5f2/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 4260db0..7ca04f5 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -49,6 +49,7 @@ import static org.apache.aries.osgi.functional.OSGi.nothing;
import static org.apache.aries.osgi.functional.OSGi.onClose;
import static org.apache.aries.osgi.functional.OSGi.register;
import static org.apache.aries.osgi.functional.OSGi.serviceReferences;
+import static org.apache.aries.osgi.functional.OSGi.services;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_NAME;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_CONTEXT_SELECT;
import static org.osgi.service.http.whiteboard.HttpWhiteboardConstants.HTTP_WHITEBOARD_DEFAULT_CONTEXT_NAME;
@@ -60,6 +61,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
private OSGiResult<?> _applicationsResult;
private OSGiResult<?> _singletonsResult;
private OSGiResult<?> _extensionsResult;
+ private OSGiResult<?> _applicationSingletonsResult;
private static <T> OSGi<T> service(ServiceReference<T> serviceReference) {
return
@@ -135,6 +137,18 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
);
_extensionsResult = extensions.run(bundleContext);
+
+ OSGi<?> applicationSingletons =
+ serviceReferences("(osgi.jaxrs.application.select=*)").
+ flatMap(ref ->
+ just(ref.getProperty("osgi.jaxrs.application.select").toString()).
+ flatMap(applicationFilter ->
+ services(CXFJaxRsServiceRegistrator.class, applicationFilter).
+ flatMap(registrator ->
+ safeRegisterEndpoint(ref, registrator)
+ )));
+
+ _applicationSingletonsResult = applicationSingletons.run(bundleContext);
}
/**
@@ -261,6 +275,7 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
@Override
public void stop(BundleContext context) throws Exception {
+ _applicationSingletonsResult.close();
_applicationsResult.close();
_extensionsResult.close();
_singletonsResult.close();
[10/12] aries-jax-rs-whiteboard git commit: Deploy raw services in
the same application
Posted by cs...@apache.org.
Deploy raw services in the same application
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/e7caec34
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/e7caec34
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/e7caec34
Branch: refs/heads/master
Commit: e7caec349a925e31d0734a7ff065c4da6bb724c9
Parents: d337acd
Author: Carlos Sierra <cs...@apache.org>
Authored: Wed Feb 22 17:41:57 2017 +0100
Committer: Raymond Auge <ra...@liferay.com>
Committed: Fri Feb 24 10:11:03 2017 -0500
----------------------------------------------------------------------
.../activator/CXFJaxRsBundleActivator.java | 57 ++++++-----
.../internal/CXFJaxRsServiceRegistrator.java | 100 +++++++++++++++++--
2 files changed, 125 insertions(+), 32 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e7caec34/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
index 1275c0d..e40b991 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/activator/CXFJaxRsBundleActivator.java
@@ -22,6 +22,7 @@ import javax.ws.rs.core.Application;
import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator;
+import org.apache.aries.jax.rs.whiteboard.internal.CXFJaxRsServiceRegistrator.ServiceInformation;
import org.apache.aries.osgi.functional.OSGi;
import org.apache.aries.osgi.functional.OSGiResult;
import org.apache.cxf.Bus;
@@ -37,6 +38,7 @@ import org.osgi.framework.wiring.BundleWiring;
import java.util.Collections;
import java.util.Dictionary;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
@@ -67,13 +69,17 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
));
}
- private static OSGi<?> cxfRegistrator(
+ private static OSGi<CXFJaxRsServiceRegistrator> cxfRegistrator(
Bus bus, Application application, Map<String, Object> props) {
+ CXFJaxRsServiceRegistrator registrator =
+ new CXFJaxRsServiceRegistrator(bus, application, props);
+
return
- just(new CXFJaxRsServiceRegistrator(bus, application, props)).flatMap(registrator ->
onClose(registrator::close).then(
- register(CXFJaxRsServiceRegistrator.class, registrator, props)));
+ register(CXFJaxRsServiceRegistrator.class, registrator, props).then(
+ just(registrator)
+ ));
}
@Override
@@ -99,6 +105,12 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
_applicationsResult = applications.run(bundleContext);
+ Application defaultApplication = new Application() {};
+
+ CXFJaxRsServiceRegistrator defaultServiceRegistrator =
+ new CXFJaxRsServiceRegistrator(
+ bus, defaultApplication, new HashMap<>());
+
OSGi<?> singletons =
serviceReferences(getSingletonsFilter()).
flatMap(serviceReference ->
@@ -108,16 +120,10 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
serviceReference, "osgi.jaxrs.resource.base")).
flatMap(properties ->
service(serviceReference).flatMap(service ->
- cxfRegistrator(bus,
- new Application() {
- @Override
- public Set<Object> getSingletons() {
- return Collections.singleton(service);
- }
- },
- properties)
- )))
- );
+ safeRegisterEndpoint(
+ serviceReference, defaultServiceRegistrator)
+ )))
+ );
_singletonsResult = singletons.run(bundleContext);
@@ -166,11 +172,9 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
if (propertyValue == null) {
return new String[0];
}
-
if (propertyValue instanceof String[]) {
return (String[]) propertyValue;
}
-
return new String[]{propertyValue.toString()};
}
@@ -194,12 +198,14 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
}
private OSGi<?> safeRegisterEndpoint(
- ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator,
- Object service) {
+ ServiceReference<?> ref, CXFJaxRsServiceRegistrator registrator) {
return
+ bundleContext().flatMap(bundleContext ->
+ service(ref).flatMap(service ->
onClose(() -> unregisterEndpoint(registrator, service)).then(
- registerEndpoint(ref, registrator, service));
+ registerEndpoint(ref, registrator, service)
+ )));
}
private OSGi<?> registerEndpoint(
@@ -207,21 +213,26 @@ public class CXFJaxRsBundleActivator implements BundleActivator {
CXFJaxRsServiceRegistrator registrator, Object service) {
Thread thread = Thread.currentThread();
-
ClassLoader contextClassLoader = thread.getContextClassLoader();
-
ClassLoader classLoader = ref.getBundle().adapt(BundleWiring.class).
getClassLoader();
+ Object resourceBaseObject = ref.getProperty("osgi.jaxrs.resource.base");
+
+ String resourceBase;
+ if (resourceBaseObject == null) {
+ resourceBase = "";
+ }
+ else {
+ resourceBase = resourceBaseObject.toString();
+ }
try {
thread.setContextClassLoader(classLoader);
-
- registrator.add(service);
+ registrator.add(new ServiceInformation(resourceBase, "", service));
}
finally {
thread.setContextClassLoader(contextClassLoader);
}
-
return just(service);
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/e7caec34/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
index 43f6ddb..683cb0f 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/CXFJaxRsServiceRegistrator.java
@@ -20,6 +20,8 @@ package org.apache.aries.jax.rs.whiteboard.internal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import javax.ws.rs.core.Application;
@@ -29,7 +31,10 @@ import javax.ws.rs.ext.RuntimeDelegate;
import org.apache.cxf.Bus;
import org.apache.cxf.endpoint.Server;
import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
+import org.apache.cxf.jaxrs.JAXRSServiceFactoryBean;
import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
+import org.apache.cxf.jaxrs.model.ClassResourceInfo;
+import org.apache.cxf.jaxrs.model.URITemplate;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
import org.osgi.framework.ServiceReference;
@@ -40,7 +45,7 @@ public class CXFJaxRsServiceRegistrator {
private final Map<String, Object> _properties;
private final Collection<Object> _providers = new ArrayList<>();
private Server _server;
- private final Collection<Object> _services = new ArrayList<>();
+ private final Collection<ServiceInformation> _services = new ArrayList<>();
public CXFJaxRsServiceRegistrator(
Bus bus, Application application, Map<String, Object> properties) {
@@ -79,14 +84,17 @@ public class CXFJaxRsServiceRegistrator {
_closed = true;
}
- public void add(Object object) {
+ public void add(ServiceInformation serviceInformation) {
if (_closed) {
return;
}
+
+ Object object = serviceInformation.getService();
+
if (object.getClass().isAnnotationPresent(Provider.class)) {
_providers.add(object);
} else {
- _services.add(object);
+ _services.add(serviceInformation);
}
rewire();
}
@@ -95,11 +103,21 @@ public class CXFJaxRsServiceRegistrator {
if (_closed) {
return;
}
+
if (object.getClass().isAnnotationPresent(Provider.class)) {
_providers.remove(object);
- } else {
- _services.remove(object);
}
+ else {
+ Iterator<ServiceInformation> iterator = _services.iterator();
+ while (iterator.hasNext()) {
+ ServiceInformation next = iterator.next();
+
+ if (next.getService() == object) {
+ iterator.remove();
+ }
+ }
+ }
+
rewire();
}
@@ -108,6 +126,13 @@ public class CXFJaxRsServiceRegistrator {
_server.destroy();
}
+ if (_services.isEmpty() &&
+ _application.getSingletons().isEmpty() &&
+ _application.getClasses().isEmpty()) {
+
+ return;
+ }
+
RuntimeDelegate runtimeDelegate = RuntimeDelegate.getInstance();
JAXRSServerFactoryBean jaxRsServerFactoryBean =
@@ -130,12 +155,42 @@ public class CXFJaxRsServiceRegistrator {
jaxRsServerFactoryBean.setProvider(provider);
}
- for (Object service : _services) {
- jaxRsServerFactoryBean.setResourceProvider(
- new SingletonResourceProvider(service, true));
+ JAXRSServiceFactoryBean serviceFactory =
+ jaxRsServerFactoryBean.getServiceFactory();
+
+ for (ServiceInformation serviceInformation : _services) {
+ Object service = serviceInformation.getService();
+
+ SingletonResourceProvider rp = new SingletonResourceProvider(
+ service, true);
+
+ jaxRsServerFactoryBean.setResourceProvider(rp);
+
+ List<ClassResourceInfo> classResourceInfo =
+ serviceFactory.getClassResourceInfo();
+
+ for (ClassResourceInfo resourceInfo : classResourceInfo) {
+ if (resourceInfo.getServiceClass() == service.getClass()) {
+ URITemplate uriTemplate = resourceInfo.getURITemplate();
+ resourceInfo.setURITemplate(
+ new URITemplate(
+ serviceInformation.getPrefixPath() +
+ uriTemplate.getValue()));
+ }
+ }
}
- String address = _properties.get("CXF_ENDPOINT_ADDRESS").toString();
+ Object cxfEndpointAddressObject = _properties.get(
+ "CXF_ENDPOINT_ADDRESS");
+
+ String address;
+
+ if (cxfEndpointAddressObject == null) {
+ address = "";
+ }
+ else {
+ address = cxfEndpointAddressObject.toString();
+ }
if (address != null) {
jaxRsServerFactoryBean.setAddress(address);
@@ -146,4 +201,31 @@ public class CXFJaxRsServiceRegistrator {
_server.start();
}
+ public static class ServiceInformation {
+ private final String prefixPath;
+ private final String scope;
+ private final Object service;
+
+ public ServiceInformation(
+ String prefixPath, String scope, Object service) {
+
+ this.prefixPath = prefixPath;
+ this.scope = scope;
+ this.service = service;
+ }
+
+ public String getPrefixPath() {
+ return prefixPath;
+ }
+
+ public String getScope() {
+ return scope;
+ }
+
+ public Object getService() {
+ return service;
+ }
+
+ }
+
}