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 2018/01/30 13:27:25 UTC
[1/3] aries-jax-rs-whiteboard git commit: Client code reorganization
Repository: aries-jax-rs-whiteboard
Updated Branches:
refs/heads/master d9a83a05d -> 7c78ffdad
Client code 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/03f27dc6
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/03f27dc6
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/03f27dc6
Branch: refs/heads/master
Commit: 03f27dc660c8be314d5777315545e955255dd8aa
Parents: d9a83a0
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Jan 30 14:20:33 2018 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Jan 30 14:20:33 2018 +0100
----------------------------------------------------------------------
.../activator/CxfJaxrsBundleActivator.java | 6 ++-
.../internal/ClientBuilderFactory.java | 37 ----------------
.../internal/client/ClientBuilderFactory.java | 44 ++++++++++++++++++++
3 files changed, 49 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/03f27dc6/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 e9b58ba..4f9f3d5 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
@@ -25,7 +25,7 @@ import java.util.List;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.ext.RuntimeDelegate;
-import org.apache.aries.jax.rs.whiteboard.internal.ClientBuilderFactory;
+import org.apache.aries.jax.rs.whiteboard.internal.client.ClientBuilderFactory;
import org.apache.aries.jax.rs.whiteboard.internal.Utils.PropertyHolder;
import org.apache.aries.osgi.functional.OSGi;
import org.apache.aries.osgi.functional.OSGiResult;
@@ -158,4 +158,8 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
);
}
+ private static OSGi<?> registerClient() {
+ return register(ClientBuilder.class, new ClientBuilderFactory(), null);
+ }
+
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/03f27dc6/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ClientBuilderFactory.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ClientBuilderFactory.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ClientBuilderFactory.java
deleted file mode 100644
index 1d5ff81..0000000
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/ClientBuilderFactory.java
+++ /dev/null
@@ -1,37 +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 javax.ws.rs.client.ClientBuilder;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.PrototypeServiceFactory;
-import org.osgi.framework.ServiceRegistration;
-
-public class ClientBuilderFactory implements PrototypeServiceFactory<ClientBuilder> {
-
- @Override
- public ClientBuilder getService(Bundle bundle, ServiceRegistration<ClientBuilder> registration) {
- return new org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl();
- }
-
- @Override
- public void ungetService(Bundle bundle, ServiceRegistration<ClientBuilder> registration, ClientBuilder service) {
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/03f27dc6/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
new file mode 100644
index 0000000..bbbc0ef
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
@@ -0,0 +1,44 @@
+/*
+ * 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.client;
+
+import javax.ws.rs.client.ClientBuilder;
+
+import org.apache.cxf.jaxrs.client.spec.ClientBuilderImpl;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.PrototypeServiceFactory;
+import org.osgi.framework.ServiceRegistration;
+
+public class ClientBuilderFactory
+ implements PrototypeServiceFactory<ClientBuilder> {
+
+ @Override
+ public ClientBuilder getService(
+ Bundle bundle, ServiceRegistration<ClientBuilder> registration) {
+
+ return new ClientBuilderImpl();
+ }
+
+ @Override
+ public void ungetService(
+ Bundle bundle, ServiceRegistration<ClientBuilder> registration,
+ ClientBuilder service) {
+
+ }
+
+}
\ No newline at end of file
[2/3] aries-jax-rs-whiteboard git commit: Not needed anymore
Posted by cs...@apache.org.
Not needed anymore
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/0079ab17
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/0079ab17
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/0079ab17
Branch: refs/heads/master
Commit: 0079ab1753c7fb5e90919c6b3a3dedc448ff9c2f
Parents: 03f27dc
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Jan 30 14:22:44 2018 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Jan 30 14:22:44 2018 +0100
----------------------------------------------------------------------
.../rs/whiteboard/activator/CxfJaxrsBundleActivator.java | 7 ++-----
.../apache/aries/jax/rs/whiteboard/internal/Utils.java | 4 ----
.../aries/jax/rs/whiteboard/internal/Whiteboard.java | 10 +++++-----
3 files changed, 7 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0079ab17/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 4f9f3d5..f7c88f7 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
@@ -39,7 +39,6 @@ import org.slf4j.LoggerFactory;
import static java.lang.String.format;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.canonicalize;
-import static org.apache.aries.jax.rs.whiteboard.internal.Utils.ignoreResult;
import static org.apache.aries.jax.rs.whiteboard.internal.Whiteboard.createWhiteboard;
import static org.apache.aries.osgi.functional.OSGi.all;
import static org.apache.aries.osgi.functional.OSGi.configurations;
@@ -82,10 +81,8 @@ public class CxfJaxrsBundleActivator implements BundleActivator {
_defaultOSGiResult =
all(
- ignoreResult(
- register(
- ClientBuilder.class, new ClientBuilderFactory(), null)),
- ignoreResult(runWhiteboard(bundleContext, defaultConfiguration))
+ ignore(registerClient()),
+ ignore(runWhiteboard(bundleContext, defaultConfiguration))
)
.run(bundleContext);
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0079ab17/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
index c04a6e4..0007673 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Utils.java
@@ -215,10 +215,6 @@ public class Utils {
serviceRegistration.setProperties(properties);
}
- public static OSGi<Void> ignoreResult(OSGi<?> program) {
- return program.map(t -> null);
- }
-
public interface PropertyHolder {
Object get(String propertyName);
}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/0079ab17/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
index 5b473a5..6355a2b 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/Whiteboard.java
@@ -71,12 +71,12 @@ import static org.apache.aries.jax.rs.whiteboard.internal.Utils.canonicalize;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.generateApplicationName;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.getProperties;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.highestPer;
-import static org.apache.aries.jax.rs.whiteboard.internal.Utils.ignoreResult;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.onlyGettables;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.service;
import static org.apache.aries.jax.rs.whiteboard.internal.Utils.updateProperty;
import static org.apache.aries.osgi.functional.OSGi.all;
import static org.apache.aries.osgi.functional.OSGi.effects;
+import static org.apache.aries.osgi.functional.OSGi.ignore;
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;
@@ -149,10 +149,10 @@ public class Whiteboard {
_counter = new ServiceRegistrationChangeCounter(_runtimeRegistration);
_program =
all(
- ignoreResult(registerDefaultApplication()),
- ignoreResult(applications()),
- ignoreResult(applicationResources()),
- ignoreResult(applicationExtensions()
+ ignore(registerDefaultApplication()),
+ ignore(applications()),
+ ignore(applicationResources()),
+ ignore(applicationExtensions()
));
}
[3/3] aries-jax-rs-whiteboard git commit: First implementation of
PromisesRxInvoker
Posted by cs...@apache.org.
First implementation of PromisesRxInvoker
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/7c78ffda
Tree: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/tree/7c78ffda
Diff: http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/diff/7c78ffda
Branch: refs/heads/master
Commit: 7c78ffdad7a342734f6e678543d8e74508251758
Parents: 0079ab1
Author: Carlos Sierra <cs...@apache.org>
Authored: Tue Jan 30 14:26:05 2018 +0100
Committer: Carlos Sierra <cs...@apache.org>
Committed: Tue Jan 30 14:26:05 2018 +0100
----------------------------------------------------------------------
jax-rs.itests/src/main/java/test/JaxrsTest.java | 41 +++++
jax-rs.whiteboard/pom.xml | 5 +
.../internal/client/ClientBuilderFactory.java | 4 +-
.../internal/client/PromiseRxInvokerImpl.java | 172 +++++++++++++++++++
.../client/PromiseRxInvokerProviderImpl.java | 52 ++++++
5 files changed, 273 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c78ffda/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 d2aa9f3..da66980 100644
--- a/jax-rs.itests/src/main/java/test/JaxrsTest.java
+++ b/jax-rs.itests/src/main/java/test/JaxrsTest.java
@@ -21,6 +21,7 @@ import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertTrue;
import static org.osgi.service.jaxrs.whiteboard.JaxrsWhiteboardConstants.*;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -47,6 +48,7 @@ import org.osgi.framework.PrototypeServiceFactory;
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
+import org.osgi.service.jaxrs.client.PromiseRxInvoker;
import org.osgi.service.jaxrs.runtime.JaxrsServiceRuntime;
import org.osgi.service.jaxrs.runtime.dto.ApplicationDTO;
import org.osgi.service.jaxrs.runtime.dto.DTOConstants;
@@ -54,6 +56,7 @@ import org.osgi.service.jaxrs.runtime.dto.FailedApplicationDTO;
import org.osgi.service.jaxrs.runtime.dto.ResourceDTO;
import org.osgi.service.jaxrs.runtime.dto.ResourceMethodInfoDTO;
import org.osgi.service.jaxrs.runtime.dto.RuntimeDTO;
+import org.osgi.util.promise.Promise;
import org.osgi.util.tracker.ServiceTracker;
import test.types.ConfigurationAwareResource;
import test.types.TestAddon;
@@ -864,6 +867,44 @@ public class JaxrsTest extends TestHelper {
}
@Test
+ public void testAsyncResourceClientWithPromises()
+ throws ExecutionException, InterruptedException,
+ InvocationTargetException {
+
+ WebTarget webTarget =
+ createDefaultTarget().path("whiteboard").path("async").
+ path("HelloAsync");
+
+ AtomicBoolean pre = new AtomicBoolean();
+ AtomicBoolean post = new AtomicBoolean();
+
+ CountDownLatch countDownLatch = new CountDownLatch(1);
+
+ registerAddon(
+ new TestAsyncResource(
+ () -> pre.set(true),
+ () -> {
+ post.set(true);
+
+ countDownLatch.countDown();
+ }));
+
+ Promise<String> promise =
+ webTarget.
+ request().
+ rx(PromiseRxInvoker.class).
+ get(String.class);
+
+ String result = promise.getValue();
+
+ countDownLatch.await(1, TimeUnit.MINUTES);
+
+ assertTrue(post.get());
+
+ assertEquals("This should say HelloAsync", "HelloAsync", result);
+ }
+
+ @Test
public void testDefaultServiceReferencePropertiesAreAvailableInFeatures() {
AtomicBoolean executed = new AtomicBoolean();
AtomicReference<Object> propertyvalue = new AtomicReference<>();
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c78ffda/jax-rs.whiteboard/pom.xml
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/pom.xml b/jax-rs.whiteboard/pom.xml
index 3b807a8..d73148e 100644
--- a/jax-rs.whiteboard/pom.xml
+++ b/jax-rs.whiteboard/pom.xml
@@ -130,6 +130,11 @@
<version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.promise</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.2</version>
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c78ffda/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
index bbbc0ef..d98dc24 100644
--- a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/ClientBuilderFactory.java
@@ -31,7 +31,9 @@ public class ClientBuilderFactory
public ClientBuilder getService(
Bundle bundle, ServiceRegistration<ClientBuilder> registration) {
- return new ClientBuilderImpl();
+ ClientBuilderImpl clientBuilder = new ClientBuilderImpl();
+
+ return clientBuilder.register(new PromiseRxInvokerProviderImpl());
}
@Override
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c78ffda/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerImpl.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerImpl.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerImpl.java
new file mode 100644
index 0000000..b1ab900
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerImpl.java
@@ -0,0 +1,172 @@
+/*
+ * 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.client;
+
+import org.osgi.service.jaxrs.client.PromiseRxInvoker;
+import org.osgi.util.promise.Promise;
+import org.osgi.util.promise.PromiseFactory;
+
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.client.SyncInvoker;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.Response;
+
+class PromiseRxInvokerImpl implements PromiseRxInvoker {
+
+ public PromiseRxInvokerImpl(
+ SyncInvoker syncInvoker, PromiseFactory promiseFactory) {
+
+ _syncInvoker = syncInvoker;
+ _promiseFactory = promiseFactory;
+ }
+
+ @Override
+ public Promise<Response> delete() {
+ return method(HttpMethod.DELETE);
+ }
+
+ @Override
+ public <R> Promise<R> delete(Class<R> aClass) {
+ return method(HttpMethod.DELETE, aClass);
+ }
+
+ @Override
+ public <R> Promise<R> delete(GenericType<R> genericType) {
+ return method(HttpMethod.DELETE, genericType);
+ }
+
+ @Override
+ public Promise<Response> get() {
+ return method(HttpMethod.GET);
+ }
+
+ @Override
+ public <R> Promise<R> get(Class<R> aClass) {
+ return method(HttpMethod.GET, aClass);
+ }
+
+ @Override
+ public <R> Promise<R> get(GenericType<R> genericType) {
+ return method(HttpMethod.GET, genericType);
+ }
+
+ @Override
+ public Promise<Response> head() {
+ return method(HttpMethod.HEAD);
+ }
+
+ @Override
+ public <R> Promise<R> method(String s, Class<R> aClass) {
+ return _promiseFactory.submit(() -> _syncInvoker.method(s, aClass));
+ }
+
+ @Override
+ public <R> Promise<R> method(String s, Entity<?> entity, Class<R> aClass) {
+ return _promiseFactory.submit(
+ () -> _syncInvoker.method(s, entity, aClass));
+ }
+
+ @Override
+ public <R> Promise<R> method(
+ String s, Entity<?> entity, GenericType<R> genericType) {
+
+ return _promiseFactory.submit(
+ () -> _syncInvoker.method(s, entity, genericType));
+ }
+
+ @Override
+ public Promise<Response> method(String s, Entity<?> entity) {
+ return _promiseFactory.submit(() -> _syncInvoker.method(s, entity));
+ }
+
+ @Override
+ public <R> Promise<R> method(String s, GenericType<R> genericType) {
+ return _promiseFactory.submit(
+ () -> _syncInvoker.method(s, genericType));
+ }
+
+ @Override
+ public Promise<Response> method(String s) {
+ return _promiseFactory.submit(() -> _syncInvoker.method(s));
+ }
+
+ @Override
+ public Promise<Response> options() {
+ return method(HttpMethod.OPTIONS);
+ }
+
+ @Override
+ public <R> Promise<R> options(Class<R> aClass) {
+ return method(HttpMethod.OPTIONS, aClass);
+ }
+
+ @Override
+ public <R> Promise<R> options(GenericType<R> genericType) {
+ return method(HttpMethod.OPTIONS, genericType);
+ }
+
+ @Override
+ public <R> Promise<R> post(Entity<?> entity, Class<R> aClass) {
+ return method(HttpMethod.POST, entity, aClass);
+ }
+
+ @Override
+ public <R> Promise<R> post(Entity<?> entity, GenericType<R> genericType) {
+ return method(HttpMethod.POST, entity, genericType);
+ }
+
+ @Override
+ public Promise<Response> post(Entity<?> entity) {
+ return method(HttpMethod.POST, entity);
+ }
+
+ @Override
+ public <R> Promise<R> put(Entity<?> entity, Class<R> aClass) {
+ return method(HttpMethod.PUT, entity, aClass);
+ }
+
+ @Override
+ public <R> Promise<R> put(Entity<?> entity, GenericType<R> genericType) {
+ return method(HttpMethod.PUT, entity, genericType);
+ }
+
+ @Override
+ public Promise<Response> put(Entity<?> entity) {
+ return method(HttpMethod.PUT, entity);
+ }
+
+ @Override
+ public Promise<Response> trace() {
+ return method("TRACE", Response.class);
+ }
+
+ @Override
+ public <R> Promise<R> trace(Class<R> aClass) {
+ return method("TRACE", aClass);
+ }
+
+ @Override
+ public <R> Promise<R> trace(GenericType<R> genericType) {
+ return method("TRACE", genericType);
+ }
+
+ private final PromiseFactory _promiseFactory;
+ private final SyncInvoker _syncInvoker;
+
+}
http://git-wip-us.apache.org/repos/asf/aries-jax-rs-whiteboard/blob/7c78ffda/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerProviderImpl.java
----------------------------------------------------------------------
diff --git a/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerProviderImpl.java b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerProviderImpl.java
new file mode 100644
index 0000000..c8b36d1
--- /dev/null
+++ b/jax-rs.whiteboard/src/main/java/org/apache/aries/jax/rs/whiteboard/internal/client/PromiseRxInvokerProviderImpl.java
@@ -0,0 +1,52 @@
+/*
+ * 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.client;
+
+import org.osgi.service.jaxrs.client.PromiseRxInvoker;
+import org.osgi.util.promise.PromiseFactory;
+
+import javax.ws.rs.client.RxInvokerProvider;
+import javax.ws.rs.client.SyncInvoker;
+import java.util.concurrent.ExecutorService;
+
+public class PromiseRxInvokerProviderImpl
+ implements RxInvokerProvider<PromiseRxInvoker> {
+
+ @Override
+ public boolean isProviderFor(Class<?> clazz) {
+ return clazz == PromiseRxInvoker.class;
+ }
+
+ @Override
+ public PromiseRxInvoker getRxInvoker(
+ SyncInvoker syncInvoker, ExecutorService executorService) {
+
+ PromiseFactory promiseFactory;
+
+ if (executorService != null) {
+ promiseFactory = new PromiseFactory(executorService);
+ }
+ else {
+ promiseFactory = new PromiseFactory(
+ PromiseFactory.inlineExecutor());
+ }
+
+ return new PromiseRxInvokerImpl(syncInvoker, promiseFactory);
+ }
+
+}