随想 20180811

Distributor Software Desgin:

Netty RPC (Reactor Model) -->  Proxy or Reflection --> Busisness Logic 

1. Configuration

2. BuildFactory --> Context or Env

3. BuildFactory --> Serialize & Deserialize Instance with Poxy or Reflection ( Class.forName().newInstance())

4. ThreadPool Generation

5. Dispatcher Generation

5.1 Register itself to master or zookeeper / Master-Slave / NameServer

5.2 Register Handler 

5.3 Create receiver to save msg

5.4 Create ThreadPool to handle msg from receiver

5.5 Memory Allocation/Persistent, Syn/Ack

6. Netty Server Start

7. Future --> ListenerFuture<?>, ChannelFuture<?>, FutureTask<?>

public class JavassistProxyFactory extends AbstractProxyFactory {    
    @SuppressWarnings("unchecked")
    public <T> T getProxy(Invoker<T> invoker, Class<?>[] interfaces) {
        return (T) Proxy.getProxy(interfaces).newInstance(
                   new InvokerInvocationHandler(invoker)
                );
    }

    public <T> Invoker<T> getInvoker(T proxy, Class<T> type, URL url) {
        final Wrapper wrapper = Wrapper.getWrapper(
                      proxy.getClass().getName().indexOf('$') < 0 ? 
                      proxy.getClass() : type);
        return new AbstractProxyInvoker<T>(proxy, type, url) {
            @Override
            protected Object doInvoke(T proxy, String methodName, 
                                      Class<?>[] parameterTypes, 
                                      Object[] arguments) throws Throwable {
                return wrapper.invokeMethod(proxy, methodName, parameterTypes, arguments);
            }
        };
    }
}
原文地址:https://www.cnblogs.com/iiiDragon/p/9458517.html