package org.craft.atom.rpc.api;

import org.craft.atom.rpc.DefaultRpcAcceptor;
import org.craft.atom.rpc.DefaultRpcExecutorFactory;
import org.craft.atom.rpc.DefaultRpcInvoker;
import org.craft.atom.rpc.DefaultRpcProcessor;
import org.craft.atom.rpc.DefaultRpcProtocol;
import org.craft.atom.rpc.DefaultRpcServer;
import org.craft.atom.rpc.spi.RpcAcceptor;
import org.craft.atom.rpc.spi.RpcExecutorFactory;
import org.craft.atom.rpc.spi.RpcInvoker;
import org.craft.atom.rpc.spi.RpcProcessor;
import org.craft.atom.rpc.spi.RpcProtocol;

/**
 * @author mindwind
 * @version 1.0, Aug 7, 2014
 */
public class RpcServerBuilder {
	
	
	private String             host                                                ;
	private int                port                                                ;
	private int                ioTimeoutInMillis  = 300000                         ;
	private RpcAcceptor        acceptor           = new DefaultRpcAcceptor()       ;
	private RpcInvoker         invoker            = new DefaultRpcInvoker()        ;
	private RpcProtocol        protocol           = new DefaultRpcProtocol()       ;
	private RpcProcessor       processor          = new DefaultRpcProcessor()      ;
	private RpcExecutorFactory executorFactory    = new DefaultRpcExecutorFactory();
	
	
	public RpcServerBuilder host              (String       host                 ) { this.host               = host             ; return this; }
	public RpcServerBuilder port              (int          port                 ) { this.port               = port             ; return this; }
	public RpcServerBuilder ioTimeoutInMillis (int          ioTimeoutInMillis    ) { this.ioTimeoutInMillis  = ioTimeoutInMillis; return this; }
	public RpcServerBuilder rpcAcceptor       (RpcAcceptor  acceptor             ) { this.acceptor           = acceptor         ; return this; }
	public RpcServerBuilder rpcInvoker        (RpcInvoker   invoker              ) { this.invoker            = invoker          ; return this; }
	public RpcServerBuilder rpcProtocol       (RpcProtocol  protocol             ) { this.protocol           = protocol         ; return this; }
	public RpcServerBuilder rpcProcessor      (RpcProcessor processor            ) { this.processor          = processor        ; return this; }
	public RpcServerBuilder rpcExecutorFactory(RpcExecutorFactory executorFactory) { this.executorFactory    = executorFactory  ; return this; }
	
	
	public RpcServer build() {
		DefaultRpcServer rs =  new DefaultRpcServer();
		rs.setHost(host);
		rs.setPort(port);
		rs.setIoTimeoutInMillis(ioTimeoutInMillis);
		rs.setAcceptor(acceptor);
		rs.setInvoker(invoker);
		rs.setProtocol(protocol);
		rs.setProcessor(processor);
		rs.setExecutorFactory(executorFactory);
		rs.init();
		return rs;
	}
	
}

@@ -1336,32 +1336,34 @@
 tring       
-host
     
+  host
             
@@ -1480,34 +1480,34 @@
 nt          
-port
       
+port
            )
@@ -1497,32 +1497,34 @@
  port           
+  
 ) %7B this.port   
@@ -1620,32 +1620,38 @@
 s (int          
+      
 ioTimeoutInMilli
@@ -1651,20 +1651,16 @@
 InMillis
-    
 ) %7B this
@@ -1772,16 +1772,22 @@
 ceptor  
+      
 acceptor
@@ -1787,36 +1787,32 @@
 cceptor         
-    
 ) %7B this.accepto
@@ -1916,16 +1916,22 @@
 voker   
+      
 invoker 
@@ -1931,36 +1931,32 @@
 nvoker          
-    
 ) %7B this.invoker
@@ -2060,16 +2060,22 @@
 otocol  
+      
 protocol
@@ -2075,36 +2075,32 @@
 rotocol         
-    
 ) %7B this.protoco
@@ -2204,16 +2204,22 @@
 ocessor 
+      
 processo
@@ -2219,36 +2219,32 @@
 rocessor        
-    
 ) %7B this.process
@@ -2369,16 +2369,18 @@
 rFactory
+  
 ) %7B this

fix - build para setting method alignment