com.ikasoa.rpc.BaseGetServiceFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ikasoa-rpc Show documentation
Show all versions of ikasoa-rpc Show documentation
ikasoa-rpc is a high performance RPC(Remote Procedure Call) framework.
package com.ikasoa.rpc;
import com.ikasoa.core.thrift.GeneralFactory;
import com.ikasoa.core.thrift.client.ThriftClient;
import com.ikasoa.core.thrift.client.ThriftClientConfiguration;
import com.ikasoa.core.thrift.server.ThriftServerConfiguration;
import com.ikasoa.rpc.client.IkasoaClientService;
import com.ikasoa.rpc.client.InvalidGetService;
import com.ikasoa.rpc.handler.ClientInvocationHandler;
import com.ikasoa.rpc.handler.ProtocolHandler;
import com.ikasoa.rpc.handler.ProtocolHandlerFactory;
import com.ikasoa.rpc.handler.ReturnData;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
/**
* 基础服务工厂
*
* @author Larry
* @version 0.1
*/
@Slf4j
public class BaseGetServiceFactory extends GeneralFactory {
private ProtocolHandlerFactory protocolHandlerFactory = new ProtocolHandlerFactory<>();
@Getter
@Setter
@SuppressWarnings("rawtypes")
private Class protocolHandlerClass;
@Getter
@Setter
private ClientInvocationHandler clientInvocationHandler;
public BaseGetServiceFactory(ThriftServerConfiguration thriftServerConfiguration) {
super(thriftServerConfiguration);
}
public BaseGetServiceFactory(ThriftClientConfiguration thriftClientConfiguration) {
super(thriftClientConfiguration);
}
public BaseGetServiceFactory(ThriftServerConfiguration thriftServerConfiguration,
ThriftClientConfiguration thriftClientConfiguration) {
super(thriftServerConfiguration, thriftClientConfiguration);
}
public BaseGetService getBaseGetService(ThriftClient thriftClient, String serviceKey, ReturnData resultData) {
return getBaseGetService(thriftClient, serviceKey,
protocolHandlerFactory.getProtocolHandler(resultData, getProtocolHandlerClass()));
}
public BaseGetService getBaseGetService(ThriftClient thriftClient, String serviceKey,
ProtocolHandler protocolHandler) {
if (thriftClient == null || serviceKey == null || protocolHandler == null)
return new InvalidGetService();
log.debug("Create new instance 'IkasoaClientService' . (serverHost : {}, serverPort : {}, serviceKey : {})",
thriftClient.getServerHost(), thriftClient.getServerPort(), serviceKey);
return new IkasoaClientService(this, thriftClient, serviceKey, protocolHandler, clientInvocationHandler);
}
}