wsky / top-link

embedded duplex multi-channel endpoint and connection management for c#/java/...
6 stars 1 forks source link

make remoting can run on http #28

Open wsky opened 11 years ago

wsky commented 11 years ago

direct use channel to send, and using same binary protocol currently:

DynamicProxy.java:

public MethodReturn invoke(MethodCall methodCall,
            int executionTimeoutMillisecond) throws RemotingException, FormatterException {
        SynchronizedRemotingCallback syncCallback = new SynchronizedRemotingCallback();

        HashMap<String, Object> transportHeaders = new HashMap<String, Object>();
        transportHeaders.put(TcpTransportHeader.RequestUri, this.uriString);

        ClientChannel channel = this.getChannel();
        try {
            return this.send(channel,
                    this.channelHandler.pending(syncCallback,
                            TcpOperations.Request, transportHeaders, methodCall),
                    syncCallback,
                    executionTimeoutMillisecond);
        } finally {
            this.selector.returnChannel(channel);
        }
    }

but, via http, restful is better, and text protocol needed.

private ClientChannel getChannel() throws RemotingException {
        try {
            ClientChannel channel = this.selector.getChannel(this.remoteUri);
            channel.setChannelHandler(channelHandler);
            return channel;
        } catch (ChannelException e) {
            throw new RemotingException(Text.RPC_CAN_NOT_GET_CHANNEL, e);
        }
    }

change to:

getRemotingChannelSink(uri).send(methodCall);

remoting codec can be extend.

wsky commented 11 years ago

json support also needed https://github.com/douglascrockford/JSON-java