Skip to content

Commit

Permalink
Removed Promise.class check and got tests to run
Browse files Browse the repository at this point in the history
  • Loading branch information
MammatusPlatypus committed Sep 7, 2016
1 parent 18ea7b0 commit 95df4fe
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

ext {
projectVersion = '1.11.2'
projectVersion = '1.12.0'
boonVersion = '0.6.6'
boonGroup = "io.advantageous.boon"
springFrameworkVersion = '4.2.5.RELEASE'
Expand Down
2 changes: 1 addition & 1 deletion qbit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ project('core') {
compile "$boonGroup:boon-reflekt:$boonVersion"
compile "$boonGroup:boon-json:$boonVersion"
compile 'org.reactivestreams:reactive-streams:1.0.0'
compile 'io.advantageous.reakt:reakt:2.8.17'
compile 'io.advantageous.reakt:reakt:3.1.0'
testCompile project(':qbit:test-support')
testCompile 'org.mockito:mockito-core:1.10.19'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.advantageous.qbit.sender.Sender;
import io.advantageous.qbit.service.BeforeMethodCall;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -352,7 +353,7 @@ private <T> Callback createHandler(final Class<T> serviceInterface, final Method
Class<?> returnType = null;
Class<?> compType = null;

if (method.returnType() == Promise.class) {
if (PromiseHandle.class.isAssignableFrom(method.returnType()) ) {

Type t0 = method.method().getGenericReturnType();
if (t0 instanceof ParameterizedType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.advantageous.qbit.util.Timer;
import io.advantageous.reakt.Callback;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -55,7 +56,7 @@ class BoonInvocationHandlerForEndPoint implements InvocationHandler {


for (Method method : serviceInterface.getMethods()) {
promiseMap.put(method.getName(), method.getReturnType() == Promise.class);
promiseMap.put(method.getName(), PromiseHandle.class.isAssignableFrom(method.getReturnType()) );
methodMetaMap.put(method.getName(), hasReaktCallback(method.getParameterTypes()));
}
timestamp = Timer.timer().now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.advantageous.qbit.util.Timer;
import io.advantageous.reakt.Callback;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -40,7 +41,7 @@ public BoonInvocationHandlerForSendQueue(SendQueue<MethodCall<Object>> sendQueue
};

for (Method method : serviceInterface.getMethods()) {
promiseMap.put(method.getName(), method.getReturnType() == Promise.class);
promiseMap.put(method.getName(), PromiseHandle.class.isAssignableFrom(method.getReturnType()));
methodMetaMap.put(method.getName(), hasReaktCallback(method.getParameterTypes()));
}
timestamp = Timer.timer().now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.advantageous.qbit.service.ServiceMethodHandler;
import io.advantageous.qbit.service.impl.ServiceConstants;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;

import java.lang.reflect.InvocationTargetException;
import java.util.*;
Expand Down Expand Up @@ -137,7 +138,7 @@ protected boolean hasHandlers(MethodCall<Object> methodCall, MethodAccess servic

private boolean hasHandlers(MethodAccess serviceMethod) {

if (serviceMethod.returnType() == Promise.class) {
if (PromiseHandle.class.isAssignableFrom(serviceMethod.returnType())) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.advantageous.qbit.reactive.Callback;
import io.advantageous.qbit.service.impl.ServiceConstants;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;

import java.util.List;

Expand All @@ -23,7 +24,7 @@ public MapAndInvokeDynamic(BoonServiceMethodCallHandler boonServiceMethodCallHan
public Response<Object> mapArgsAsyncHandlersAndInvoke(MethodCall<Object> serviceMethodCall, MethodAccess serviceMethod) {


if (serviceMethod.parameterTypes().length == 0 && !(serviceMethod.returnType() == Promise.class)) {
if (serviceMethod.parameterTypes().length == 0 && !(PromiseHandle.class.isAssignableFrom(serviceMethod.returnType()))) {

Object returnValue = serviceMethod.invokeDynamicObject(boonServiceMethodCallHandler.service, null);
return boonServiceMethodCallHandler.response(serviceMethod, serviceMethodCall, returnValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import io.advantageous.qbit.transforms.Transformer;
import io.advantageous.qbit.util.Timer;
import io.advantageous.reakt.promise.Promise;
import io.advantageous.reakt.promise.PromiseHandle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -699,7 +700,7 @@ private <T> void validateInterface(Class<T> serviceInterface) {
final Method[] declaredMethods = classMeta.cls().getDeclaredMethods();

for (Method m : declaredMethods) {
if (!(m.getReturnType() == void.class || m.getReturnType() == Promise.class)) {
if (!(m.getReturnType() == void.class || PromiseHandle.class.isAssignableFrom(m.getReturnType()))) {
throw new IllegalStateException("Async interface can only return void or a Promise " + serviceInterface.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package io.advantageous.qbit.vertx;

import io.advantageous.qbit.annotation.RequestMapping;
import io.advantageous.qbit.annotation.http.GET;
import io.advantageous.qbit.server.EndpointServerBuilder;

@RequestMapping("/")
public class PerfTestHello {


@GET
public String hello() {
return "hello";
}

public static void main(final String... args) {
final EndpointServerBuilder endpointServerBuilder = EndpointServerBuilder.endpointServerBuilder();
endpointServerBuilder.getRequestQueueBuilder().setBatchSize(1);
endpointServerBuilder.getResponseQueueBuilder().setBatchSize(1);

endpointServerBuilder.setFlushResponseInterval(10)
.setUri("/").setPort(9666)
.addService(new PerfTestHello()).build().startServer();

}
}

0 comments on commit 95df4fe

Please sign in to comment.