Package com.droidkit.actors.typed.messages

Examples of com.droidkit.actors.typed.messages.TypedRequest


    }

    @Override
    public void onReceive(Object message) {
        if (message instanceof TypedRequest) {
            final TypedRequest req = (TypedRequest) message;
            try {
                if (req.getMethod().getReturnType().equals(Future.class)) {
                    try {
                        Future future = (Future) req.getMethod().invoke(this, req.getArgs());
                        if (future instanceof ResultFuture) {
                            req.getFuture().doComplete(future.get());
                        } else if (future instanceof TypedFuture) {
                            future.addListener(new FutureCallback() {
                                @Override
                                public void onResult(Object result) {
                                    req.getFuture().doComplete(result);
                                }

                                @Override
                                public void onError(Throwable throwable) {
                                    req.getFuture().doError(throwable);
                                }
                            });
                        } else {
                            // Unsupported
                        }
                    } catch (Throwable t) {
                        t.printStackTrace();
                        req.getFuture().doError(t);
                    }

                } else {
                    req.getMethod().invoke(this, req.getArgs());
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
View Full Code Here


                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        ClientFuture future = null;
                        if (method.getReturnType().equals(Future.class)) {
                            future = new ClientFuture();
                        }
                        ref.send(new TypedRequest(future, method, args));
                        return future;
                    }
                });
    }
View Full Code Here

TOP

Related Classes of com.droidkit.actors.typed.messages.TypedRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.