diff --git a/qbit/admin/src/main/java/io/advantageous/qbit/metrics/StatReplicator.java b/qbit/admin/src/main/java/io/advantageous/qbit/metrics/StatReplicator.java index 2470dad6..90fe6865 100644 --- a/qbit/admin/src/main/java/io/advantageous/qbit/metrics/StatReplicator.java +++ b/qbit/admin/src/main/java/io/advantageous/qbit/metrics/StatReplicator.java @@ -32,5 +32,7 @@ public interface StatReplicator extends RemoteTCPClientProxy, ServiceFlushable, void replicateLevel(String name, long level, long time); - void replicateTiming(String name, long timing, long time); + default void replicateTiming(String name, long level, long time) { + + } } diff --git a/qbit/admin/src/main/java/io/advantageous/qbit/metrics/support/NoOpReplicator.java b/qbit/admin/src/main/java/io/advantageous/qbit/metrics/support/NoOpReplicator.java index 689deff9..dfef1d95 100644 --- a/qbit/admin/src/main/java/io/advantageous/qbit/metrics/support/NoOpReplicator.java +++ b/qbit/admin/src/main/java/io/advantageous/qbit/metrics/support/NoOpReplicator.java @@ -32,9 +32,4 @@ public final void replicateCount(String name, long count, long now) { @Override public final void replicateLevel(String name, long level, long now) { } - - @Override - public void replicateTiming(String name, long level, long time) { - - } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/boon/client/BoonClientFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/boon/client/BoonClientFactory.java index eb12f9cb..9abb7e29 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/boon/client/BoonClientFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/boon/client/BoonClientFactory.java @@ -19,9 +19,6 @@ package io.advantageous.qbit.boon.client; import io.advantageous.boon.core.Sys; -import io.advantageous.qbit.client.BeforeMethodSent; -import io.advantageous.qbit.client.Client; -import io.advantageous.qbit.http.client.HttpClient; import io.advantageous.qbit.spi.ClientFactory; public class BoonClientFactory implements ClientFactory { @@ -30,13 +27,4 @@ public class BoonClientFactory implements ClientFactory { * Holds on to Boon cache so we don't have to recreate reflected gak. */ Object context = Sys.contextToHold(); - - - @Override - public Client create(final String uri, - final HttpClient httpClient, - final int requestBatchSize, - final BeforeMethodSent beforeMethodSent) { - return new BoonClient(uri, httpClient, requestBatchSize, beforeMethodSent); - } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventBusProxyCreator.java b/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventBusProxyCreator.java index 65f7b0d6..ff5d5e12 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventBusProxyCreator.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventBusProxyCreator.java @@ -49,12 +49,6 @@ public class BoonEventBusProxyCreator implements EventBusProxyCreator { */ Object context = Sys.contextToHold(); - @Override - public T createProxy(final EventManager eventManager, final Class eventBusProxyInterface) { - - return createProxyWithChannelPrefix(eventManager, eventBusProxyInterface, null); - } - @Override public T createProxyWithChannelPrefix(final EventManager eventManager, final Class eventBusProxyInterface, final String channelPrefix) { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventManager.java b/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventManager.java index a400d0d1..f7b3cd42 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventManager.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/boon/events/impl/BoonEventManager.java @@ -21,7 +21,6 @@ import io.advantageous.boon.core.Str; import io.advantageous.boon.core.Sys; import io.advantageous.boon.core.reflection.AnnotationData; -import io.advantageous.boon.core.reflection.BeanUtils; import io.advantageous.boon.core.reflection.ClassMeta; import io.advantageous.boon.core.reflection.MethodAccess; import io.advantageous.qbit.GlobalConstants; @@ -47,7 +46,6 @@ import static io.advantageous.boon.core.reflection.ClassMeta.classMeta; import static io.advantageous.qbit.annotation.AnnotationUtils.*; -import static io.advantageous.qbit.service.ServiceContext.serviceContext; /** * @author rhightower @@ -206,13 +204,6 @@ public void joinService(final ServiceQueue serviceQueue) { } - @Override - public void leave() { - final ServiceQueue serviceQueue = serviceContext().currentService(); - leaveEventBus(serviceQueue); - } - - @Override public void leaveEventBus(final ServiceQueue serviceQueue) { if (serviceQueue == null) { @@ -495,13 +486,6 @@ private List events(String channel) { return events; } - @Override - public void sendCopy(String channel, T event) { - - T copy = BeanUtils.copy(event); - this.send(channel, copy); - } - @Override public void forwardEvent(final EventTransferObject event) { messageCountSinceLastFlush++; diff --git a/qbit/core/src/main/java/io/advantageous/qbit/boon/service/impl/BoonServiceProxyFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/boon/service/impl/BoonServiceProxyFactory.java index d0659e44..39cb1791 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/boon/service/impl/BoonServiceProxyFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/boon/service/impl/BoonServiceProxyFactory.java @@ -110,10 +110,4 @@ private InvocationHandler createInvocationHandler(Class serviceInterface, } - @Override - public T createProxy(Class serviceInterface, String serviceName, EndPoint endPoint, BeforeMethodSent beforeMethodSent) { - return createProxyWithReturnAddress(serviceInterface, serviceName, "local", 0, new AtomicBoolean(true), "", endPoint, beforeMethodSent); - } - - } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/boon/spi/BoonProtocolParser.java b/qbit/core/src/main/java/io/advantageous/qbit/boon/spi/BoonProtocolParser.java index f35d0889..55340216 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/boon/spi/BoonProtocolParser.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/boon/spi/BoonProtocolParser.java @@ -92,19 +92,6 @@ public List> parse(String address, String args) { } - @Override - public List> parseMethodCalls(String address, String body) { - //noinspection unchecked - return (List>) (Object) parse(address, body); - } - - @Override - public List> parseResponses(String address, String body) { - //noinspection unchecked - return (List>) (Object) parse(address, body); - } - - private Response parseResponseFromChars(char[] args, final String returnAddress) { final char[][] chars = CharScanner.splitFromStartWithLimit(args, (char) PROTOCOL_SEPARATOR, 0, RESPONSE_RETURN); diff --git a/qbit/core/src/main/java/io/advantageous/qbit/client/ServiceProxyFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/client/ServiceProxyFactory.java index fa1e9e7c..086f9476 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/client/ServiceProxyFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/client/ServiceProxyFactory.java @@ -38,8 +38,10 @@ T createProxyWithReturnAddress(Class serviceInterface, EndPoint serviceBundle, BeforeMethodSent beforeMethodSent); - T createProxy(Class serviceInterface, + default T createProxy(Class serviceInterface, String serviceName, - EndPoint serviceBundle, - BeforeMethodSent beforeMethodSent); + EndPoint endPoint, + BeforeMethodSent beforeMethodSent) { + return createProxyWithReturnAddress(serviceInterface, serviceName, "local", 0, new AtomicBoolean(true), "", endPoint, beforeMethodSent); + } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/events/EventBusProxyCreator.java b/qbit/core/src/main/java/io/advantageous/qbit/events/EventBusProxyCreator.java index 2bb747cd..5beb9ef2 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/events/EventBusProxyCreator.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/events/EventBusProxyCreator.java @@ -31,7 +31,10 @@ default T createProxy(final Class eventBusProxyInterface) { return createProxy(QBit.factory().systemEventManager(), eventBusProxyInterface); } - T createProxy(final EventManager eventManager, final Class eventBusProxyInterface); + default T createProxy(final EventManager eventManager, final Class eventBusProxyInterface) { + + return createProxyWithChannelPrefix(eventManager, eventBusProxyInterface, null); + } T createProxyWithChannelPrefix(final EventManager eventManager, diff --git a/qbit/core/src/main/java/io/advantageous/qbit/events/EventManager.java b/qbit/core/src/main/java/io/advantageous/qbit/events/EventManager.java index e3b6b020..c1da37a2 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/events/EventManager.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/events/EventManager.java @@ -18,6 +18,9 @@ package io.advantageous.qbit.events; +import static io.advantageous.qbit.service.ServiceContext.serviceContext; + +import io.advantageous.boon.core.reflection.BeanUtils; import io.advantageous.qbit.events.spi.EventTransferObject; import io.advantageous.qbit.service.ServiceQueue; @@ -57,7 +60,10 @@ default void joinServices(ServiceQueue... serviceQueues) { /** * Opposite of join. ONLY FOR SERVICES. */ - void leave(); + default void leave() { + final ServiceQueue serviceQueue = serviceContext().currentService(); + leaveEventBus(serviceQueue); + } /** * This method can be called outside of a service. @@ -131,7 +137,11 @@ default void joinServices(ServiceQueue... serviceQueues) { * @param event event * @param T */ - void sendCopy(String channel, T event); + default void sendCopy(String channel, T event) { + + T copy = BeanUtils.copy(event); + this.send(channel, copy); + } void forwardEvent(EventTransferObject event); diff --git a/qbit/core/src/main/java/io/advantageous/qbit/events/spi/EventTransferObject.java b/qbit/core/src/main/java/io/advantageous/qbit/events/spi/EventTransferObject.java index c6fb31db..11e1bd13 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/events/spi/EventTransferObject.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/events/spi/EventTransferObject.java @@ -54,11 +54,6 @@ public T body() { return body; } - @Override - public boolean isSingleton() { - return true; - } - @Override public String toString() { return "EventImpl{" + diff --git a/qbit/core/src/main/java/io/advantageous/qbit/http/HttpTransport.java b/qbit/core/src/main/java/io/advantageous/qbit/http/HttpTransport.java index f70fa240..4d50ddac 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/http/HttpTransport.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/http/HttpTransport.java @@ -72,7 +72,9 @@ default void setShouldContinueWebSocket(Predicate predicate) { void setHttpRequestsIdleConsumer(Consumer idleConsumer); - void setWebSocketIdleConsume(Consumer idleConsumer); + default void setWebSocketIdleConsume(Consumer idleConsumer) { + + } default HttpTransport startTransport() { start(); diff --git a/qbit/core/src/main/java/io/advantageous/qbit/http/request/HttpRequest.java b/qbit/core/src/main/java/io/advantageous/qbit/http/request/HttpRequest.java index 86154ec3..2a1bf1db 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/http/request/HttpRequest.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/http/request/HttpRequest.java @@ -113,16 +113,6 @@ public MultiMap getFormParams() { return formParams(); } - @Override - public boolean hasParams() { - return false; - } - - @Override - public boolean hasHeaders() { - return false; - } - @Override public long timestamp() { return timestamp; diff --git a/qbit/core/src/main/java/io/advantageous/qbit/http/server/websocket/WebSocketMessage.java b/qbit/core/src/main/java/io/advantageous/qbit/http/server/websocket/WebSocketMessage.java index 63a15e18..a306a605 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/http/server/websocket/WebSocketMessage.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/http/server/websocket/WebSocketMessage.java @@ -90,16 +90,6 @@ public MultiMap headers() { return MultiMap.empty(); } - @Override - public boolean hasParams() { - return false; - } - - @Override - public boolean hasHeaders() { - return false; - } - @Override public long timestamp() { return timestamp; @@ -125,11 +115,6 @@ public Object body() { return message; } - @Override - public boolean isSingleton() { - return true; - } - public String getUri() { return uri; } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/Message.java b/qbit/core/src/main/java/io/advantageous/qbit/message/Message.java index d0139e2f..cd56ae6a 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/Message.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/Message.java @@ -33,7 +33,9 @@ public interface Message { T body(); //Body could be a Map for parameters for forms or JSON or bytes[] or String - boolean isSingleton(); + default boolean isSingleton() { + return true; + } default MultiMap params() { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/MethodCall.java b/qbit/core/src/main/java/io/advantageous/qbit/message/MethodCall.java index 0d72aabd..0f5db984 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/MethodCall.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/MethodCall.java @@ -33,7 +33,9 @@ public interface MethodCall extends Request { long timestamp(); - String objectName(); + default String objectName() { + return ""; + } boolean hasCallback(); diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/Request.java b/qbit/core/src/main/java/io/advantageous/qbit/message/Request.java index 9921dfc0..e4001a24 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/Request.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/Request.java @@ -37,15 +37,23 @@ default Request originatingRequest() { } - boolean hasParams(); + default boolean hasParams() { + return false; + } - boolean hasHeaders(); + default boolean hasHeaders() { + return false; + } long timestamp(); - boolean isHandled(); + default boolean isHandled() { + return false; + } - void handled(); + default void handled() { + + } default boolean hasCallback() { return false; diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallImpl.java b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallImpl.java index 1c370cd2..c4cf1f2a 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallImpl.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallImpl.java @@ -93,16 +93,6 @@ public long timestamp() { return timestamp; } - @Override - public boolean isHandled() { - return false; - } - - @Override - public void handled() { - - } - @Override public String objectName() { return objectName; @@ -154,11 +144,6 @@ public void originatingRequest(Request originatingRequest) { this.originatingRequest = originatingRequest; } - @Override - public boolean isSingleton() { - return true; - } - public boolean hasParams() { return params != null && params.size() > 0; } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallLocal.java b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallLocal.java index 43294cb5..43643620 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallLocal.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/MethodCallLocal.java @@ -85,35 +85,11 @@ public MultiMap headers() { return null; } - @Override - public boolean hasParams() { - return false; - } - - @Override - public boolean hasHeaders() { - return false; - } - @Override public long timestamp() { return timestamp; } - @Override - public boolean isHandled() { - return false; - } - - @Override - public void handled() { - } - - @Override - public String objectName() { - return ""; - } - @Override public Request originatingRequest() { return originatingRequest; @@ -128,9 +104,4 @@ public long id() { public Object body() { return arguments; } - - @Override - public boolean isSingleton() { - return true; - } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/ResponseImpl.java b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/ResponseImpl.java index 75a122d0..15446525 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/message/impl/ResponseImpl.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/message/impl/ResponseImpl.java @@ -131,11 +131,6 @@ public T body() { } } - @Override - public boolean isSingleton() { - return true; - } - @Override public boolean wasErrors() { return errors; diff --git a/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/RequestTransformer.java b/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/RequestTransformer.java index 443e40b1..952d572c 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/RequestTransformer.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/RequestTransformer.java @@ -18,6 +18,7 @@ package io.advantageous.qbit.meta.transformer; import io.advantageous.qbit.http.request.HttpRequest; +import io.advantageous.qbit.http.request.HttpRequestBuilder; import io.advantageous.qbit.message.MethodCall; import java.util.List; @@ -27,12 +28,19 @@ */ public interface RequestTransformer { - MethodCall transform(HttpRequest request, List errorsList); + default MethodCall transform(HttpRequest request, List errorsList) { + + return transformByPosition(request, errorsList, false); + } MethodCall transformByPosition(final HttpRequest request, final List errorsList, boolean byPosition); - MethodCall transFormBridgeBody(Object body, List errors, String address, String method); + default MethodCall transFormBridgeBody(Object body, List errors, String address, String method) { + final String uri = ("/" + address + "/" + method).replace("//", "/"); + final HttpRequest request = HttpRequestBuilder.httpRequestBuilder().setUri(uri).setBody(body == null ? null : body.toString()).setMethod("BRIDGE").build(); + return this.transformByPosition(request, errors, true); + } } \ No newline at end of file diff --git a/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/StandardRequestTransformer.java b/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/StandardRequestTransformer.java index d99d4569..472d74c0 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/StandardRequestTransformer.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/meta/transformer/StandardRequestTransformer.java @@ -26,7 +26,6 @@ import io.advantageous.qbit.QBit; import io.advantageous.qbit.annotation.RequestMethod; import io.advantageous.qbit.http.request.HttpRequest; -import io.advantageous.qbit.http.request.HttpRequestBuilder; import io.advantageous.qbit.json.JsonMapper; import io.advantageous.qbit.message.MethodCall; import io.advantageous.qbit.message.MethodCallBuilder; @@ -89,14 +88,6 @@ private final String decodeURLEncoding(String value) { } - @Override - public MethodCall transform(final HttpRequest request, - final List errorsList) { - - return transformByPosition(request, errorsList, false); - } - - @Override public MethodCall transformByPosition(final HttpRequest request, final List errorsList, boolean byPosition) { @@ -329,13 +320,6 @@ public MethodCall transformByPosition(final HttpRequest request, } - @Override - public MethodCall transFormBridgeBody(Object body, List errors, String address, String method) { - final String uri = ("/" + address + "/" + method).replace("//", "/"); - final HttpRequest request = HttpRequestBuilder.httpRequestBuilder().setUri(uri).setBody(body == null ? null : body.toString()).setMethod("BRIDGE").build(); - return this.transformByPosition(request, errors, true); - } - private void handleMehtodTransformError(List errorsList, MethodCallBuilder methodCallBuilder, Exception exception) { if (errorHandler.isPresent()) { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/network/NetSocket.java b/qbit/core/src/main/java/io/advantageous/qbit/network/NetSocket.java index 603e79dd..46713291 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/network/NetSocket.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/network/NetSocket.java @@ -82,7 +82,11 @@ default void open() { void openAndWait(); - void openAndNotify(final Consumer openConsumer, Consumer exceptionConsumer); + default void openAndNotify(final Consumer openConsumer, Consumer exceptionConsumer) { + + this.setOpenConsumer(aVoid -> openConsumer.accept(this)); + open(exceptionConsumer); + } default void openAndNotify(final Consumer openConsumer) { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/network/impl/NetSocketBase.java b/qbit/core/src/main/java/io/advantageous/qbit/network/impl/NetSocketBase.java index fcb68d20..1ad44768 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/network/impl/NetSocketBase.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/network/impl/NetSocketBase.java @@ -184,13 +184,6 @@ public void open(Consumer exceptionConsumer) { } - @Override - public void openAndNotify(Consumer openConsumer, Consumer exceptionConsumer) { - - this.setOpenConsumer(aVoid -> openConsumer.accept(this)); - open(exceptionConsumer); - } - @Override public void openAndWait() { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManager.java b/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManager.java index 958d78af..a2953789 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManager.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManager.java @@ -7,7 +7,11 @@ public interface CallbackManager { void registerCallbacks(MethodCall methodCall); - void startReturnHandlerProcessor(Queue> responseQueue); + default void startReturnHandlerProcessor(Queue> responseQueue) { + + //noinspection Convert2MethodRef + responseQueue.startListener(response -> handleResponse(response)); + } void handleResponse(Response response); diff --git a/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManagerWithTimeout.java b/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManagerWithTimeout.java index 91a95c04..4867cebb 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManagerWithTimeout.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/service/impl/CallbackManagerWithTimeout.java @@ -20,7 +20,6 @@ import io.advantageous.qbit.message.MethodCall; import io.advantageous.qbit.message.Response; -import io.advantageous.qbit.queue.Queue; import io.advantageous.qbit.reactive.Callback; import io.advantageous.qbit.util.Timer; import org.slf4j.Logger; @@ -93,18 +92,6 @@ public void registerCallbacks(final MethodCall methodCall) { } - /** - * Handles responses coming back from services. - * - * @param responseQueue response queue - */ - @Override - public void startReturnHandlerProcessor(final Queue> responseQueue) { - - //noinspection Convert2MethodRef - responseQueue.startListener(response -> handleResponse(response)); - } - @Override public void handleResponse(final Response response) { diff --git a/qbit/core/src/main/java/io/advantageous/qbit/spi/ClientFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/spi/ClientFactory.java index 82b9d310..4c8f745c 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/spi/ClientFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/spi/ClientFactory.java @@ -18,6 +18,7 @@ package io.advantageous.qbit.spi; +import io.advantageous.qbit.boon.client.BoonClient; import io.advantageous.qbit.client.BeforeMethodSent; import io.advantageous.qbit.client.Client; import io.advantageous.qbit.http.client.HttpClient; @@ -31,8 +32,10 @@ */ public interface ClientFactory { - Client create(String uri, + default Client create(String uri, HttpClient httpClient, int requestBatchSize, - final BeforeMethodSent beforeMethodSent); + final BeforeMethodSent beforeMethodSent) { + return new BoonClient(uri, httpClient, requestBatchSize, beforeMethodSent); + } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpClientFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpClientFactory.java index 3d74da93..d9a2fb3f 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpClientFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpClientFactory.java @@ -19,6 +19,7 @@ package io.advantageous.qbit.spi; import io.advantageous.qbit.http.client.HttpClient; +import io.advantageous.qbit.vertx.http.client.HttpVertxClient; import java.util.function.Consumer; @@ -26,7 +27,7 @@ * created by rhightower on 11/13/14. */ public interface HttpClientFactory { - HttpClient create(String host, int port, + default HttpClient create(String host, int port, int timeOutInMilliseconds, int poolSize, boolean autoFlush, int flushRate, boolean keepAlive, boolean pipeLine, boolean ssl, @@ -38,5 +39,9 @@ HttpClient create(String host, int port, String trustStorePassword, boolean tcpNoDelay, int soLinger, - Consumer errorHandler); + Consumer errorHandler) { + return new HttpVertxClient(host, port, timeOutInMilliseconds, poolSize, autoFlush, + flushRate, keepAlive, pipeLine, ssl, verifyHost, trustAll, maxWebSocketFrameSize, + tryUseCompression, trustStorePath, trustStorePassword, tcpNoDelay, soLinger, errorHandler); + } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpServerFactory.java b/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpServerFactory.java index 67ccf43d..a5ca512c 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpServerFactory.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/spi/HttpServerFactory.java @@ -26,6 +26,8 @@ import io.advantageous.qbit.service.discovery.ServiceDiscovery; import io.advantageous.qbit.service.health.HealthServiceAsync; import io.advantageous.qbit.system.QBitSystemManager; +import io.advantageous.qbit.vertx.http.server.HttpServerVertx; +import io.vertx.core.Vertx; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.TimeUnit; @@ -36,7 +38,7 @@ */ public interface HttpServerFactory { - HttpServer create( + default HttpServer create( HttpServerOptions options, String endPointName, QBitSystemManager systemManager, @@ -45,5 +47,12 @@ HttpServer create( final int serviceDiscoveryTtl, final TimeUnit serviceDiscoveryTtlTimeUnit, final CopyOnWriteArrayList decorators, - final HttpResponseCreator httpResponseCreator, RequestContinuePredicate requestBodyContinuePredicate); + final HttpResponseCreator httpResponseCreator, RequestContinuePredicate requestBodyContinuePredicate) { + + + return new HttpServerVertx(true, Vertx.vertx(), endPointName, options, + systemManager, serviceDiscovery, healthServiceAsync, + serviceDiscoveryTtl, serviceDiscoveryTtlTimeUnit, decorators, httpResponseCreator, requestBodyContinuePredicate); + + } } diff --git a/qbit/core/src/main/java/io/advantageous/qbit/spi/ProtocolParser.java b/qbit/core/src/main/java/io/advantageous/qbit/spi/ProtocolParser.java index 15e64e92..179777fc 100644 --- a/qbit/core/src/main/java/io/advantageous/qbit/spi/ProtocolParser.java +++ b/qbit/core/src/main/java/io/advantageous/qbit/spi/ProtocolParser.java @@ -36,9 +36,15 @@ public interface ProtocolParser { List> parse(String address, String body); - List> parseMethodCalls(String addressPrefix, String body); - - List> parseResponses(String addressPrefix, String body); + default List> parseMethodCalls(String address, String body) { + //noinspection unchecked + return (List>) (Object) parse(address, body); + } + + default List> parseResponses(String address, String body) { + //noinspection unchecked + return (List>) (Object) parse(address, body); + } } diff --git a/qbit/core/src/test/java/io/advantageous/qbit/service/rest/endpoint/tests/sim/HttpServerSimulator.java b/qbit/core/src/test/java/io/advantageous/qbit/service/rest/endpoint/tests/sim/HttpServerSimulator.java index 46463c18..75516711 100644 --- a/qbit/core/src/test/java/io/advantageous/qbit/service/rest/endpoint/tests/sim/HttpServerSimulator.java +++ b/qbit/core/src/test/java/io/advantageous/qbit/service/rest/endpoint/tests/sim/HttpServerSimulator.java @@ -196,11 +196,6 @@ public void setHttpRequestsIdleConsumer(Consumer idleConsumer) { this.idleConsumer = idleConsumer; } - @Override - public void setWebSocketIdleConsume(Consumer idleConsumer) { - - } - @Override public void start() { diff --git a/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/client/HttpVertxClientFactory.java b/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/client/HttpVertxClientFactory.java index ded44576..9c5853b1 100644 --- a/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/client/HttpVertxClientFactory.java +++ b/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/client/HttpVertxClientFactory.java @@ -1,32 +1,6 @@ package io.advantageous.qbit.vertx.http.client; -import io.advantageous.qbit.http.client.HttpClient; import io.advantageous.qbit.spi.HttpClientFactory; -import java.util.function.Consumer; - public class HttpVertxClientFactory implements HttpClientFactory { - @Override - public HttpClient create(String host, - int port, - int timeOutInMilliseconds, - int poolSize, - boolean autoFlush, - int flushRate, - boolean keepAlive, - boolean pipeLine, - boolean ssl, - boolean verifyHost, - boolean trustAll, - int maxWebSocketFrameSize, - boolean tryUseCompression, - String trustStorePath, - String trustStorePassword, - boolean tcpNoDelay, - int soLinger, - Consumer errorHandler) { - return new HttpVertxClient(host, port, timeOutInMilliseconds, poolSize, autoFlush, - flushRate, keepAlive, pipeLine, ssl, verifyHost, trustAll, maxWebSocketFrameSize, - tryUseCompression, trustStorePath, trustStorePassword, tcpNoDelay, soLinger, errorHandler); - } } diff --git a/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/server/HttpServerVertxFactory.java b/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/server/HttpServerVertxFactory.java index 3ca66ae4..9e22c4bf 100644 --- a/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/server/HttpServerVertxFactory.java +++ b/qbit/vertx/src/main/java/io/advantageous/qbit/vertx/http/server/HttpServerVertxFactory.java @@ -18,42 +18,10 @@ package io.advantageous.qbit.vertx.http.server; -import io.advantageous.qbit.http.config.HttpServerOptions; -import io.advantageous.qbit.http.request.HttpResponseCreator; -import io.advantageous.qbit.http.request.decorator.HttpResponseDecorator; -import io.advantageous.qbit.http.server.HttpServer; -import io.advantageous.qbit.http.server.RequestContinuePredicate; -import io.advantageous.qbit.service.discovery.ServiceDiscovery; -import io.advantageous.qbit.service.health.HealthServiceAsync; import io.advantageous.qbit.spi.HttpServerFactory; -import io.advantageous.qbit.system.QBitSystemManager; -import io.vertx.core.Vertx; - -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; /** * @author rhightower on 1/26/15. */ public class HttpServerVertxFactory implements HttpServerFactory { - - - @Override - public HttpServer create(final HttpServerOptions options, - final String endPointName, - final QBitSystemManager systemManager, - final ServiceDiscovery serviceDiscovery, - final HealthServiceAsync healthServiceAsync, - final int serviceDiscoveryTtl, - final TimeUnit serviceDiscoveryTtlTimeUnit, - final CopyOnWriteArrayList decorators, - final HttpResponseCreator httpResponseCreator, - final RequestContinuePredicate requestBodyContinuePredicate) { - - - return new HttpServerVertx(true, Vertx.vertx(), endPointName, options, - systemManager, serviceDiscovery, healthServiceAsync, - serviceDiscoveryTtl, serviceDiscoveryTtlTimeUnit, decorators, httpResponseCreator, requestBodyContinuePredicate); - - } }