package com.ikasoa.core.thrift.server.impl;

import org.apache.thrift.TProcessor;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.ikasoa.core.thrift.server.ThriftServer;
import com.ikasoa.core.thrift.server.ThriftServerConfiguration;

/**
 * Thrift服务器Servlet实现
 * <p>
 * 比较特殊的一种服务器实现,用于http方式来提供Thrift服务.一般用于构造<i>ThriftServlet</i>.
 * <p>
 * 生命周期与WebServer相同,服务端口也与http端口相同,所以<i>ThriftServer</i>的 <code>start()</code>,
 * <code>stop()</code>,<code>isServing()</code>, <code>getServerPort()</code>
 * 方法都没有具体的实现.
 * 
 * @author <a href="mailto:larry7696@gmail.com">Larry</a>
 * @version 0.2
 */
public class ServletThriftServerImpl implements ThriftServer {

	private static final Logger LOG = LoggerFactory.getLogger(ServletThriftServerImpl.class);

	/**
	 * Thrift服务名称
	 */
	private String serverName;

	private ThriftServerConfiguration configuration;

	private TProcessor processor;

	public ServletThriftServerImpl() {
		// Do nothing
	}

	public ServletThriftServerImpl(String serverName, ThriftServerConfiguration configuration, TProcessor processor) {
		setServerName(serverName);
		setThriftServerConfiguration(configuration);
		setProcessor(processor);
	}

	@Override
	public TServerTransport getTransport() throws TTransportException {
		return null;
	}

	@Override
	public void run() {
		// Do nothing
	}

	@Override
	public void stop() {
		// Do nothing
	}

	@Override
	public boolean isServing() {
		return Boolean.TRUE;
	}

	@Override
	public String getServerName() {
		return serverName;
	}

	public void setServerName(String serverName) {
		this.serverName = serverName;
	}

	@Override
	public int getServerPort() {
		LOG.warn("This function not run .");
		return 0;
	}

	@Override
	public ThriftServerConfiguration getThriftServerConfiguration() {
		if (configuration == null) {
			throw new RuntimeException("Thrift server initialize failed ! Configuration is null !");
		}
		return configuration;
	}

	public void setThriftServerConfiguration(ThriftServerConfiguration configuration) {
		this.configuration = configuration;
	}

	@Override
	public TProcessor getProcessor() {
		return processor;
	}

	public void setProcessor(TProcessor processor) {
		this.processor = processor;
	}

}

@@ -423,16 +423,16 @@
 %E5%99%A8%E5%AE%9E%E7%8E%B0,
+%E5%88%A9
 %E7%94%A8
-%E4%BA%8E
 http
-%E6%96%B9%E5%BC%8F
+%E5%8D%8F%E8%AE%AE
 %E6%9D%A5%E6%8F%90%E4%BE%9BT

update code comments