本文整理汇总了Java中org.jboss.netty.handler.codec.serialization.ClassResolvers类的典型用法代码示例。如果您正苦于以下问题:Java ClassResolvers类的具体用法?Java ClassResolvers怎么用?Java ClassResolvers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ClassResolvers类属于org.jboss.netty.handler.codec.serialization包,在下文中一共展示了ClassResolvers类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createDecoder
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
public static ChannelHandler createDecoder() {
int maxObjectSize = AppProperties.getAsInt("rpc_common_maxObjectSize",
1024 * 1024);
String f = AppProperties.get("rpc_common_codec", "java");
if (f.equalsIgnoreCase("java")) {
return new ObjectDecoder(maxObjectSize,
ClassResolvers.softCachingConcurrentResolver(null));
} else if (f.equalsIgnoreCase("jbossSerialization")) {
return new JBossSerializationDecoder(maxObjectSize);
} else if (f.equalsIgnoreCase("json")) {
throw new AppRuntimeException("not support " + f + " yet!");
} else if (f.equalsIgnoreCase("hessian")) {
return new HessianDecoder(maxObjectSize);
} else {
throw new AppRuntimeException("not support " + f + " yet!");
}
}
开发者ID:jbeetle,项目名称:BJAF3.x,代码行数:18,代码来源:CodecFactory.java
示例2: startRPCServer
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
/**
* Start rpc server which is used to update progress.
*/
private void startRPCServer() {
this.rpcServer = new ServerBootstrap(new NioServerSocketChannelFactory(
Executors.newFixedThreadPool(GuaguaYarnConstants.DEFAULT_STATUS_RPC_SERVER_THREAD_COUNT),
Executors.newCachedThreadPool(new MasterThreadFactory())));
// Set up the pipeline factory.
this.rpcServer.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new ObjectEncoder(),
new ObjectDecoder(ClassResolvers.cacheDisabled(getClass().getClassLoader())),
new ServerHandler());
}
});
// Bind and start to accept incoming connections.
this.rpcServer.bind(new InetSocketAddress(rpcPort));
}
开发者ID:ShifuML,项目名称:guagua,代码行数:21,代码来源:GuaguaAppMaster.java
示例3: initRPCClient
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
/**
* Connect to app master for status RPC report.
*/
private void initRPCClient() {
this.rpcClient = new ClientBootstrap(new NioClientSocketChannelFactory(Executors.newSingleThreadExecutor(),
Executors.newSingleThreadExecutor()));
// Set up the pipeline factory.
this.rpcClient.setPipelineFactory(new ChannelPipelineFactory() {
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(new ObjectEncoder(),
new ObjectDecoder(ClassResolvers.cacheDisabled(getClass().getClassLoader())),
new ClientHandler());
}
});
// Start the connection attempt.
ChannelFuture future = this.rpcClient.connect(new InetSocketAddress(this.rpcHostName, this.rpcPort));
LOG.info("Connect to {}:{}", this.rpcHostName, this.rpcPort);
this.rpcClientChannel = future.awaitUninterruptibly().getChannel();
}
开发者ID:ShifuML,项目名称:guagua,代码行数:22,代码来源:GuaguaYarnTask.java
示例4: DefaultClient
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
/**
* Creates a new instance that talks to a {@link DefaultServer} on the specified host and port.
*
* @param clientId
* A unique id. No two clients with the same id can access the same
* {@link DefaultServer}
* @param host
* The host the {@link DefaultServer} runs on
* @param port
* The port the {@link DefaultServer} runs on
*/
public DefaultClient(final String clientId, final String host, final int port) {
this.clientId = clientId;
this.host = host;
this.port = port;
// Configure the client.
bootstrap = new ClientBootstrap(
new OioClientSocketChannelFactory(Executors.newCachedThreadPool(new DaemonThreadFactory())));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
new ObjectEncoder(ENCODER_ESTIMATED_LENGTH),
new ObjectDecoder(DECODER_ESTIMATED_LENGTH, ClassResolvers.weakCachingResolver(null)),
new ClientHandshakeHandler(new Handshake(clientId), HANDSHAKE_TIMEOUT_MILLIS),
clientHandler);
}
});
bootstrap.setOption("tcpNoDelay", true);
bootstrap.setOption("keepAlive", true);
bootstrap.setOption("soTimeout", 10000L);
}
开发者ID:mgm-tp,项目名称:perfload-core,代码行数:37,代码来源:DefaultClient.java
示例5: newObjectDecoder
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
public static ChannelHandlerFactory newObjectDecoder() {
return new ChannelHandlerFactory() {
@Override
public ChannelHandler newChannelHandler() {
return new ObjectDecoder(ClassResolvers.weakCachingResolver(null));
}
};
}
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:ChannelHandlerFactories.java
示例6: getPipeline
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception
{
ChannelPipeline pipeline = Channels.pipeline();
// ���������
pipeline.addLast("objectencoder", new ObjectEncoder());
// ���������
pipeline.addLast("objectdecoder", new ObjectDecoder(ClassResolvers.cacheDisabled(this.getClass().getClassLoader())));
// ��������ҵ����
pipeline.addLast("clientHandler", myClientHandler);
return pipeline;
}
开发者ID:JAYAndroid,项目名称:whiteboard,代码行数:13,代码来源:MyChannelPipelineFactory.java
示例7: getPipeline
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
@Override
public ChannelPipeline getPipeline() throws Exception {
ChannelPipeline pipeline = Channels.pipeline();
pipeline.addLast("objectencoder", new ObjectEncoder());
pipeline.addLast("objectdecoder", new ObjectDecoder(ClassResolvers
.cacheDisabled(this.getClass().getClassLoader())));
pipeline.addLast("serverhandler", new MyServerHandler());
return pipeline;
}
开发者ID:JAYAndroid,项目名称:whiteboard,代码行数:12,代码来源:MyChannelPipelineFactory.java
示例8: DefaultServer
import org.jboss.netty.handler.codec.serialization.ClassResolvers; //导入依赖的package包/类
/**
* Creates a new server instance on the specified port.
*
* @param port
* The port
*/
public DefaultServer(final int port) {
this.port = port;
// Configure the server.
bootstrap = new ServerBootstrap(
new OioServerSocketChannelFactory(
Executors.newCachedThreadPool(new DaemonThreadFactory()),
Executors.newCachedThreadPool(new DaemonThreadFactory())));
// Set up the pipeline factory.
bootstrap.setPipelineFactory(new ChannelPipelineFactory() {
@Override
public ChannelPipeline getPipeline() throws Exception {
return Channels.pipeline(
new ObjectEncoder(ENCODER_ESTIMATED_LENGTH), // 1 MB default size
new ObjectDecoder(DECODER_ESTIMATED_LENGTH, ClassResolvers.weakCachingResolver(null)), // 20 MB max. size - should be largely sufficient
new ServerHandshakeHandler(channelContainer, HANDSHAKE_TIMEOUT_MILLIS),
serverHandler);
}
});
bootstrap.setOption("tcpNoDelay", true);
bootstrap.setOption("keepAlive", true);
bootstrap.setOption("child.tcpNoDelay", true);
bootstrap.setOption("child.keepAlive", true);
}
开发者ID:mgm-tp,项目名称:perfload-core,代码行数:33,代码来源:DefaultServer.java
注:本文中的org.jboss.netty.handler.codec.serialization.ClassResolvers类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论