class GrpcServer{
    private int port;
    private MotanHandlerRegistry registry;
    private Server server;
    private Map<URL, ServerServiceDefinition> serviceDefinetions;
    private boolean init;
    private boolean shareChannel;
    private ExecutorService executor;
    private NettyHttpRequestHandler httpHandler;
    
    public GrpcServer(int port) {
        super();
        this.port = port;
    }

    public GrpcServer(int port, boolean shareChannel) {
        super();
        this.port = port;
        this.shareChannel = shareChannel;
    }
    
    public GrpcServer(int port, boolean shareChannel, ExecutorService executor) {
        super();
        this.port = port;
        this.shareChannel = shareChannel;
        this.executor = executor;
    }

    @SuppressWarnings("rawtypes")
    public void init() throws Exception{
        if(!init){
            synchronized (this) {
                if(!init){
                    registry = new MotanHandlerRegistry();
                    serviceDefinetions = new HashMap<URL, ServerServiceDefinition>();
                    io.grpc.ServerBuilder builder = ServerBuilder.forPort(port);
                    builder.fallbackHandlerRegistry(registry);
                    if(executor != null){
                        builder.executor(executor);
                    }
                    if(builder instanceof NettyServerBuilder){
                        httpHandler = new NettyHttpRequestHandler(executor);
                        ((NettyServerBuilder)builder).protocolNegotiator(new HttpProtocolNegotiator(httpHandler));
                    }
                    server = builder.build();
                    server.start();
                    init = true;
                }
            }
        }
    }
    
    @SuppressWarnings("rawtypes")
    public void addExporter(Exporter<?> exporter) throws Exception{<FILL_FUNCTION_BODY>}
  
    /**
     * remove service specified by url.
     * the server will be closed if all service is remove 
     * @param url
     */
    public void safeRelease(URL url){
        synchronized (serviceDefinetions) {
            registry.removeService(serviceDefinetions.remove(url));
            if(httpHandler != null){
                httpHandler.removeProvider(url);
            }
            if(serviceDefinetions.isEmpty()){
                server.shutdown();
                if(executor != null){
                    executor.shutdownNow();
                }
            }
        }
    }

}

        Provider provider = exporter.getProvider();        
        ServerServiceDefinition serviceDefine = GrpcUtil.getServiceDefByAnnotation(provider.getInterface());
        boolean urlShareChannel = exporter.getUrl().getBooleanParameter(URLParamType.shareChannel.getName(),
          URLParamType.shareChannel.getBooleanValue());
        synchronized (serviceDefinetions) {
            if(!(shareChannel && urlShareChannel) && !serviceDefinetions.isEmpty()){
                URL url = serviceDefinetions.keySet().iterator().next();
                throw new MotanFrameworkException("url:" + exporter.getUrl() + " cannot share channel with url:" + url);
            }
            registry.addService(serviceDefine, provider);
            if(httpHandler != null){
                httpHandler.addProvider(provider);
            }
            serviceDefinetions.put(exporter.getUrl(), serviceDefine);
        }        
    
<no_super_class>