From 558120a82f719ea68f0be9bb27237be6e0aefe78 Mon Sep 17 00:00:00 2001 From: John McClean Date: Tue, 9 May 2017 16:14:19 +0100 Subject: [PATCH 1/7] Impl for #340 --- .../custom/binder/direct/CustomBinder4.java | 2 + .../binder/direct/AsyncPublisherTest.java | 46 ++++++++++ .../binder/direct/AsyncResource.java | 39 ++++++++ .../micro/server/rest/jersey/AsyncBinder.java | 22 +++++ .../server/rest/jersey/AsyncDispatcher.java | 88 +++++++++++++++++++ .../rest/jersey/AsyncInvocationHandler.java | 26 ++++++ .../rest/jersey/JerseyRestApplication.java | 1 + 7 files changed, 224 insertions(+) create mode 100644 micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java create mode 100644 micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java create mode 100644 micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java create mode 100644 micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java create mode 100644 micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java diff --git a/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java b/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java index 9c2b15310..5e25d0c13 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java +++ b/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java @@ -11,5 +11,7 @@ protected void configure() { // this is where the magic happens! bind(DirectCustomResourceInvocationHandlerProvider.class).to( ResourceMethodInvocationHandlerProvider.class); + + } } \ No newline at end of file diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java new file mode 100644 index 000000000..955853a51 --- /dev/null +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java @@ -0,0 +1,46 @@ +package app.publisher.binder.direct; + +import com.aol.micro.server.MicroserverApp; +import com.aol.micro.server.config.Microserver; +import com.aol.micro.server.module.ConfigurableModule; +import com.aol.micro.server.rest.jersey.AsyncBinder; +import com.aol.micro.server.testing.RestAgent; +import org.glassfish.jersey.server.ResourceConfig; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import java.util.concurrent.ExecutionException; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + +@Microserver +public class AsyncPublisherTest { + RestAgent rest = new RestAgent(); + MicroserverApp server; + @Before + public void startServer(){ + + server = new MicroserverApp(()->"binder"); + server.start(); + + } + + @After + public void stopServer(){ + server.stop(); + } + + @Test + public void runAppAndBasicTest() throws InterruptedException, ExecutionException{ + + + //DirectMyIncovationHandler.captured=false; + assertThat(rest.get("http://localhost:8080/binder/test"),is("hello world!")); + //assertTrue(DirectMyIncovationHandler.captured); + + + } +} diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java new file mode 100644 index 000000000..cb0edafe5 --- /dev/null +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java @@ -0,0 +1,39 @@ +package app.publisher.binder.direct; + +import com.aol.micro.server.auto.discovery.Rest; +import cyclops.async.Future; +import cyclops.stream.ReactiveSeq; +import cyclops.stream.Spouts; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import java.util.concurrent.Executors; +import java.util.stream.Stream; + + +@Rest +@Path("/test") +public class AsyncResource { + + private void sleep(){ + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + @GET + public Future myEndPoint(){ + return Future.ofSupplier(()->{ + sleep(); + return "hello world!"; + }, Executors.newFixedThreadPool(1)); + } + @GET + public ReactiveSeq async2(){ + return Spouts.publishOn(Stream.of("hello"),Executors.newFixedThreadPool(1)); + } + + +} diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java new file mode 100644 index 000000000..16d714b7a --- /dev/null +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java @@ -0,0 +1,22 @@ +package com.aol.micro.server.rest.jersey; + +import org.glassfish.hk2.utilities.binding.AbstractBinder; +import org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher; +import org.glassfish.jersey.server.spi.internal.ResourceMethodInvocationHandlerProvider; + +import javax.inject.Singleton; + + +public class AsyncBinder extends AbstractBinder { + + @Override + protected void configure() { + + bind(AsyncInvocationHandler.class).to( + ResourceMethodInvocationHandlerProvider.class); + + bind(AsyncDispatcher.AsyncDispatcherProvider.class).to( + ResourceMethodDispatcher.Provider.class).in(Singleton.class) + .ranked(1); + } +} \ No newline at end of file diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java new file mode 100644 index 000000000..8bcf11a13 --- /dev/null +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java @@ -0,0 +1,88 @@ +package com.aol.micro.server.rest.jersey; + +import cyclops.stream.ReactiveSeq; +import cyclops.stream.Spouts; +import lombok.AllArgsConstructor; +import lombok.NoArgsConstructor; +import org.glassfish.hk2.api.ServiceHandle; +import org.glassfish.hk2.api.ServiceLocator; +import org.glassfish.jersey.server.ContainerRequest; +import org.glassfish.jersey.server.internal.LocalizationMessages; +import org.glassfish.jersey.server.internal.inject.ConfiguredValidator; +import org.glassfish.jersey.server.internal.process.AsyncContext; +import javax.inject.Provider; + +import org.glassfish.jersey.server.model.Invocable; +import org.glassfish.jersey.server.spi.internal.ResourceMethodDispatcher; +import org.reactivestreams.Publisher; + + +import javax.ws.rs.ProcessingException; +import javax.ws.rs.container.ContainerRequestContext; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import java.lang.reflect.InvocationHandler; +import java.util.Set; +import java.util.stream.Collectors; + +public class AsyncDispatcher implements ResourceMethodDispatcher { + + private final ResourceMethodDispatcher originalDispatcher; + + @Context + private javax.inject.Provider asyncContext; + @Context + private javax.inject.Provider containerRequestContext; + + + public AsyncDispatcher(ResourceMethodDispatcher originalDispatcher) { + this.originalDispatcher = originalDispatcher; + } + + @AllArgsConstructor + @NoArgsConstructor + static class AsyncDispatcherProvider implements Provider{ + @Context + private ServiceLocator serviceLocator; + @Override + public ResourceMethodDispatcher create(Invocable method, InvocationHandler handler, ConfiguredValidator validator) { + final Class returnType = method.getHandlingMethod().getReturnType(); + if(Publisher.class.isAssignableFrom(returnType)){ + Set providers = serviceLocator.getAllServiceHandles(ResourceMethodDispatcher.Provider.class) + .stream() + .filter(h->!h.getActiveDescriptor() + .getImplementationClass() + .equals(AsyncDispatcherProvider.class)) + .map(ServiceHandle::getService) + .collect(Collectors.toSet()); + + for (ResourceMethodDispatcher.Provider provider : providers) { + ResourceMethodDispatcher dispatcher = provider.create(method, handler, validator); + if (dispatcher != null) { + AsyncDispatcher result = new AsyncDispatcher(dispatcher); + serviceLocator.inject(result); + return result; + } + } + + } + return null; + } + } + @Override + public Response dispatch(Object resource, ContainerRequest request) throws ProcessingException { + final AsyncContext context = this.asyncContext.get(); + if(!context.suspend()) + throw new ProcessingException(LocalizationMessages.ERROR_SUSPENDING_ASYNC_REQUEST()); + final ContainerRequestContext requestContext = containerRequestContext.get(); + + Publisher pub = (Publisher)originalDispatcher.dispatch(resource, request) + .getEntity(); + Spouts.from(pub).onEmptySwitch(()->Spouts.of(Response.noContent().build())) + .forEach(1,context::resume, context::resume); + + return null; + } + + +} \ No newline at end of file diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java new file mode 100644 index 000000000..fdeb3013b --- /dev/null +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java @@ -0,0 +1,26 @@ +package com.aol.micro.server.rest.jersey; + +import org.glassfish.jersey.server.model.Invocable; +import org.glassfish.jersey.server.spi.internal.ResourceMethodInvocationHandlerProvider; +import org.reactivestreams.Publisher; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.HashMap; + +public class AsyncInvocationHandler implements ResourceMethodInvocationHandlerProvider { + + + @Override + public InvocationHandler create(Invocable invocable) { + Class returnType = invocable.getRawResponseType(); + return new InvocationHandler() { + @Override + public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { + return method.invoke(proxy, args); + } + }; + } + + +} \ No newline at end of file diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/JerseyRestApplication.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/JerseyRestApplication.java index 2a5dfe330..4abddd118 100644 --- a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/JerseyRestApplication.java +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/JerseyRestApplication.java @@ -51,6 +51,7 @@ public JerseyRestApplication(List allResources,List packages, Li register(next.getClass()); } } + register(new AsyncBinder()); if (serverProperties.isEmpty()) { property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true); From 4674134aaabf0fd8f6696a37d1cd6fcee5c74cb4 Mon Sep 17 00:00:00 2001 From: John McClean Date: Tue, 9 May 2017 20:37:56 +0100 Subject: [PATCH 2/7] better documentation --- micro-jersey/readme.md | 28 ++++++++++++++++++++++++++++ micro-reactive/readme.md | 2 ++ readme.md | 28 ++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+) diff --git a/micro-jersey/readme.md b/micro-jersey/readme.md index 3d5163701..eac5d1701 100644 --- a/micro-jersey/readme.md +++ b/micro-jersey/readme.md @@ -23,4 +23,32 @@ Maven Gradle ```groovy compile 'com.aol.microservices:micro-jersey:x.yz' +``` + +## Baked in async NIO based REST + +Return any reactive-streams Publisher from your REST end point to make them execute asynchronously automatically. + +E.g. Using Future from [cyclops-react](cyclops-react.io) +```java + @GET + public Future myEndPoint(){ + return Future.ofSupplier(()->{ + sleep(); + return "hello world!"; + }, Executors.newFixedThreadPool(1)); + } +``` + +Would be equivalent to the following code + +```java + @GET + public void myEndPoint(@Suspended AsyncResponse asyncResponse){ + Future.ofSupplier(()->{ + sleep(); + asyncResponse.resume("hello world!"); + return 1; + }, Executors.newFixedThreadPool(1)); +} ``` \ No newline at end of file diff --git a/micro-reactive/readme.md b/micro-reactive/readme.md index f1aa7d643..aa8367246 100644 --- a/micro-reactive/readme.md +++ b/micro-reactive/readme.md @@ -4,6 +4,8 @@ The micro-reactive plugin integrates [cyclops-react](https://github.com/aol/cyclops-react) and [Pivotal Reactor](http://projectreactor.io/) to provide a very rich integrated reactive programming environment on top of Spring. +*NB* Microserver's Jersey plugin already makes Publisher a valid return type, converts them to asynchronously executing REST End points + Why? cyclops-react offers a range of functional datatypes and datastructures, many of which act as reactive-streams Publishers /subscribers. Pivotal Reactor offer advanced / specialized processing capabilities for reactive-streams Publishers and subscribers. diff --git a/readme.md b/readme.md index 95cae3364..7e70acf1f 100644 --- a/readme.md +++ b/readme.md @@ -46,6 +46,34 @@ See the response *hello world!* Add plugins by adding them to your build file - rerun the app to get new end points, Spring beans and more! +## Easy to use async NIO based REST + +Return any reactive-streams Publisher from your REST end point to make them execute asynchronously automatically. + +E.g. Using Future from [cyclops-react](cyclops-react.io) +```java + @GET + public Future myEndPoint(){ + return Future.ofSupplier(()->{ + sleep(); + return "hello world!"; + }, Executors.newFixedThreadPool(1)); + } +``` + +Would be equivalent to the following code + +```java + @GET + public void myEndPoint(@Suspended AsyncResponse asyncResponse){ + Future.ofSupplier(()->{ + sleep(); + asyncResponse.resume("hello world!"); + return 1; + }, Executors.newFixedThreadPool(1)); +} +``` + # Why Microserver? Microserver is a plugin engine for building Spring and Spring Boot based microservices. Microserver supports pure microservice and micro-monolith development styles. The micro-monolith style involves packaging multiple services into a single deployment - offering developers the productivity of microservice development without the operational risk. This can help teams adopt a Microservices architecture on projects that are currently monoliths. From 32b8a6a412f922ebccb3226327c6718df3927c22 Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 15 May 2017 12:25:48 +0100 Subject: [PATCH 3/7] fix formatting --- .../binder/direct/AsyncPublisherTest.java | 51 ++++++++++--------- .../binder/direct/AsyncResource.java | 21 ++++---- 2 files changed, 37 insertions(+), 35 deletions(-) diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java index 955853a51..6b52e3063 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java @@ -18,29 +18,30 @@ @Microserver public class AsyncPublisherTest { - RestAgent rest = new RestAgent(); - MicroserverApp server; - @Before - public void startServer(){ - - server = new MicroserverApp(()->"binder"); - server.start(); - - } - - @After - public void stopServer(){ - server.stop(); - } - - @Test - public void runAppAndBasicTest() throws InterruptedException, ExecutionException{ - - - //DirectMyIncovationHandler.captured=false; - assertThat(rest.get("http://localhost:8080/binder/test"),is("hello world!")); - //assertTrue(DirectMyIncovationHandler.captured); - - - } + RestAgent rest = new RestAgent(); + MicroserverApp server; + + @Before + public void startServer() { + + server = new MicroserverApp(() -> "binder"); + server.start(); + + } + + @After + public void stopServer() { + server.stop(); + } + + @Test + public void runAppAndBasicTest() throws InterruptedException, ExecutionException { + + + //DirectMyIncovationHandler.captured=false; + assertThat(rest.get("http://localhost:8080/binder/test"), is("hello world!")); + //assertTrue(DirectMyIncovationHandler.captured); + + + } } diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java index cb0edafe5..e3bc4b62c 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java @@ -15,7 +15,7 @@ @Path("/test") public class AsyncResource { - private void sleep(){ + private void sleep() { try { Thread.sleep(10000); } catch (InterruptedException e) { @@ -23,17 +23,18 @@ private void sleep(){ } } - @GET - public Future myEndPoint(){ - return Future.ofSupplier(()->{ + @GET + public Future myEndPoint() { + return Future.ofSupplier(() -> { sleep(); - return "hello world!"; - }, Executors.newFixedThreadPool(1)); - } + return "hello world!"; + }, Executors.newFixedThreadPool(1)); + } + @GET - public ReactiveSeq async2(){ - return Spouts.publishOn(Stream.of("hello"),Executors.newFixedThreadPool(1)); + public ReactiveSeq async2() { + return Spouts.publishOn(Stream.of("hello"), Executors.newFixedThreadPool(1)); } - + } From ddac5ee0e07a187a5530b5bddfef222c9d5c6412 Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 15 May 2017 13:29:07 +0100 Subject: [PATCH 4/7] remove commented out lines --- .../java/app/publisher/binder/direct/AsyncPublisherTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java index 6b52e3063..b685d3f6c 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java @@ -38,9 +38,9 @@ public void stopServer() { public void runAppAndBasicTest() throws InterruptedException, ExecutionException { - //DirectMyIncovationHandler.captured=false; + assertThat(rest.get("http://localhost:8080/binder/test"), is("hello world!")); - //assertTrue(DirectMyIncovationHandler.captured); + } From 73313a9ce2d6ed4b0a8c952939a01a64bab6990c Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 15 May 2017 15:01:07 +0100 Subject: [PATCH 5/7] code review changes --- .../java/app/custom/binder/direct/CustomBinder4.java | 2 -- .../publisher/binder/direct/AsyncPublisherTest.java | 12 +++++------- .../app/publisher/binder/direct/AsyncResource.java | 2 ++ readme.md | 9 +++++---- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java b/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java index 5e25d0c13..9c2b15310 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java +++ b/micro-grizzly-with-jersey/src/test/java/app/custom/binder/direct/CustomBinder4.java @@ -11,7 +11,5 @@ protected void configure() { // this is where the magic happens! bind(DirectCustomResourceInvocationHandlerProvider.class).to( ResourceMethodInvocationHandlerProvider.class); - - } } \ No newline at end of file diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java index b685d3f6c..a17cb514e 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncPublisherTest.java @@ -36,12 +36,10 @@ public void stopServer() { @Test public void runAppAndBasicTest() throws InterruptedException, ExecutionException { - - - - assertThat(rest.get("http://localhost:8080/binder/test"), is("hello world!")); - - - + assertThat(rest.get("http://localhost:8080/binder/test/myEndPoint"), is("hello world!")); + } + @Test + public void runAppAndBasicTest2() throws InterruptedException, ExecutionException { + assertThat(rest.get("http://localhost:8080/binder/test/async2"), is("hello")); } } diff --git a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java index e3bc4b62c..6f22f806b 100644 --- a/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java +++ b/micro-grizzly-with-jersey/src/test/java/app/publisher/binder/direct/AsyncResource.java @@ -24,6 +24,7 @@ private void sleep() { } @GET + @Path("myEndPoint") public Future myEndPoint() { return Future.ofSupplier(() -> { sleep(); @@ -32,6 +33,7 @@ public Future myEndPoint() { } @GET + @Path("async2") public ReactiveSeq async2() { return Spouts.publishOn(Stream.of("hello"), Executors.newFixedThreadPool(1)); } diff --git a/readme.md b/readme.md index 7e70acf1f..c889e83bf 100644 --- a/readme.md +++ b/readme.md @@ -51,13 +51,14 @@ Add plugins by adding them to your build file - rerun the app to get new end poi Return any reactive-streams Publisher from your REST end point to make them execute asynchronously automatically. E.g. Using Future from [cyclops-react](cyclops-react.io) + ```java @GET public Future myEndPoint(){ - return Future.ofSupplier(()->{ - sleep(); - return "hello world!"; - }, Executors.newFixedThreadPool(1)); + return Future.ofSupplier(()->{ + sleep(); + return "hello world!"; + }, Executors.newFixedThreadPool(1)); } ``` From e3176f2db7c32e9863c3f7c574c3ee54209eb4da Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 15 May 2017 15:03:01 +0100 Subject: [PATCH 6/7] remove unneeded class --- .../micro/server/rest/jersey/AsyncBinder.java | 4 --- .../rest/jersey/AsyncInvocationHandler.java | 26 ------------------- 2 files changed, 30 deletions(-) delete mode 100644 micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java index 16d714b7a..24f81513d 100644 --- a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncBinder.java @@ -11,10 +11,6 @@ public class AsyncBinder extends AbstractBinder { @Override protected void configure() { - - bind(AsyncInvocationHandler.class).to( - ResourceMethodInvocationHandlerProvider.class); - bind(AsyncDispatcher.AsyncDispatcherProvider.class).to( ResourceMethodDispatcher.Provider.class).in(Singleton.class) .ranked(1); diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java deleted file mode 100644 index fdeb3013b..000000000 --- a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncInvocationHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.aol.micro.server.rest.jersey; - -import org.glassfish.jersey.server.model.Invocable; -import org.glassfish.jersey.server.spi.internal.ResourceMethodInvocationHandlerProvider; -import org.reactivestreams.Publisher; - -import java.lang.reflect.InvocationHandler; -import java.lang.reflect.Method; -import java.util.HashMap; - -public class AsyncInvocationHandler implements ResourceMethodInvocationHandlerProvider { - - - @Override - public InvocationHandler create(Invocable invocable) { - Class returnType = invocable.getRawResponseType(); - return new InvocationHandler() { - @Override - public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - return method.invoke(proxy, args); - } - }; - } - - -} \ No newline at end of file From 456a7c48edad689306d1b4cf94ae6937f6945e12 Mon Sep 17 00:00:00 2001 From: John McClean Date: Mon, 15 May 2017 15:04:38 +0100 Subject: [PATCH 7/7] formatting --- .../com/aol/micro/server/rest/jersey/AsyncDispatcher.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java index 8bcf11a13..bc2a4a69e 100644 --- a/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java +++ b/micro-jersey/src/main/java/com/aol/micro/server/rest/jersey/AsyncDispatcher.java @@ -41,7 +41,7 @@ public AsyncDispatcher(ResourceMethodDispatcher originalDispatcher) { @AllArgsConstructor @NoArgsConstructor - static class AsyncDispatcherProvider implements Provider{ + static class AsyncDispatcherProvider implements Provider{ @Context private ServiceLocator serviceLocator; @Override @@ -68,7 +68,7 @@ public ResourceMethodDispatcher create(Invocable method, InvocationHandler handl } return null; } - } + } @Override public Response dispatch(Object resource, ContainerRequest request) throws ProcessingException { final AsyncContext context = this.asyncContext.get();