本文整理汇总了Java中org.apache.mina.core.service.IoProcessor类的典型用法代码示例。如果您正苦于以下问题:Java IoProcessor类的具体用法?Java IoProcessor怎么用?Java IoProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IoProcessor类属于org.apache.mina.core.service包,在下文中一共展示了IoProcessor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: accept
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected NioSession accept(IoProcessor<NioSession> processor, ServerSocketChannel handle) throws Exception {
SelectionKey key = handle.keyFor(selector);
if ((key == null) || (!key.isValid()) || (!key.isAcceptable())) {
return null;
}
// accept the connection from the client
SocketChannel ch = handle.accept();
if (ch == null) {
return null;
}
return new NioSocketSession(this, processor, ch);
}
开发者ID:eclipse,项目名称:neoscada,代码行数:22,代码来源:NioSocketAcceptor.java
示例2: ModbusExport
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Create a new modbus exporter
*
* @param executor
* the executor used for
* @param processor
* the IO processor
* @param hiveSource
* the source of the hive to export
* @param itemFactory
* an optional item factory for publishing statistics
* @param logName
* an optional name for logging
*/
public ModbusExport ( final ScheduledExecutorService executor, final IoProcessor<NioSession> processor, final HiveSource hiveSource, final ObjectPoolDataItemFactory itemFactory, final String logName )
{
this.executor = executor;
this.hiveSource = hiveSource;
this.processor = processor;
this.logName = logName != null ? logName : toString ();
if ( itemFactory != null )
{
this.exporter = new ObjectExporter ( itemFactory, true, true );
this.exporter.attachTarget ( this.info );
}
else
{
this.exporter = null;
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:32,代码来源:ModbusExport.java
示例3: start
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
protected void start() throws Exception{
buildExecutors();
IoProcessor<NioSession> processor = new SimpleIoProcessorPool<NioSession>(NioProcessor.class, ioExecutor, coreSize);
acceptor = new NioSocketAcceptor(acceptorExecutor, processor);
// acceptor.setBacklog(cfg.getBacklog());
buildFilterChain();
acceptor.setHandler(handler);
try {
List<SocketAddress> address = new ArrayList<SocketAddress>();
//可添加多个
address.add(new InetSocketAddress((String)rule.get("ip"), (Integer)rule.get("port")));
acceptor.bind(address);
} catch (IOException e) {
stop();
throw e;
}
}
开发者ID:dreajay,项目名称:jcode,代码行数:20,代码来源:TcpAcceptor.java
示例4: NioDatagramSession
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Creates a new acceptor-side session instance.
*/
NioDatagramSession(IoService service, DatagramChannel channel, IoProcessor<NioSession> processor,
SocketAddress remoteAddress) {
super(processor, service, channel);
config = new NioDatagramSessionConfig(channel);
config.setAll(service.getSessionConfig());
this.remoteAddress = (InetSocketAddress) remoteAddress;
this.localAddress = (InetSocketAddress) channel.socket().getLocalSocketAddress();
}
开发者ID:eclipse,项目名称:neoscada,代码行数:12,代码来源:NioDatagramSession.java
示例5: StaticModbusExport
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
private StaticModbusExport ( final ScheduledExecutorService executor, final IoProcessor<NioSession> processor, final HiveSource hiveSource, final ObjectPoolDataItemFactory itemFactory, final boolean disposeProcessor )
{
super ( executor, processor, hiveSource, itemFactory );
this.executor = executor;
this.processor = processor;
this.disposeProcessor = disposeProcessor;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:StaticModbusExport.java
示例6: ConnectionBaseImpl
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
public ConnectionBaseImpl ( final ProtocolConfigurationFactory protocolConfigurationFactory, final ConnectionInformation connectionInformation, final IoProcessor<NioSession> processor ) throws Exception
{
super ( new ProtocolIoHandlerFactory ( protocolConfigurationFactory ), new FilterChainBuilder ( true ), connectionInformation, processor );
this.responseManager = new ResponseManager ( this.statistics, this.messageSender, this.executor );
this.callbackHandlerManager = new CallbackHandlerManager ( this.statistics );
this.callbackManager = new OpenCallbacksManager ( this, this.statistics, this.executor );
this.callbackFactory = new DefaultCallbackFactory ();
}
开发者ID:eclipse,项目名称:neoscada,代码行数:9,代码来源:ConnectionBaseImpl.java
示例7: ClientBaseConnection
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
protected ClientBaseConnection ( final IoHandlerFactory handlerFactory, final IoLoggerFilterChainBuilder chainBuilder, final ConnectionInformation connectionInformation, final IoProcessor<NioSession> processor ) throws Exception
{
super ( connectionInformation );
this.stateNotifier = new StateNotifier ( this.executor, this );
this.handler = handlerFactory.create ( this );
if ( processor != null )
{
this.connector = new NioSocketConnector ( processor );
}
else
{
this.connector = new NioSocketConnector ();
}
this.chainBuilder = chainBuilder;
this.chainBuilder.setLoggerName ( ClientBaseConnection.class.getName () + ".protocol" );
this.connector.setFilterChainBuilder ( this.chainBuilder );
this.connector.setHandler ( this.handler );
this.statistics.setLabel ( STATS_CACHE_ADDRESS, "Flag if the IP address gets cached" );
this.statistics.setCurrentValue ( STATS_CACHE_ADDRESS, this.cacheAddress ? 1.0 : 0.0 );
this.statistics.setLabel ( STATS_CURRENT_STATE, "Numeric connection state" );
this.statistics.setLabel ( STATS_CONNECT_CALLS, "Calls to connect" );
this.statistics.setLabel ( STATS_DISCONNECT_CALLS, "Calls to disconnect" );
this.statistics.setLabel ( STATS_MESSAGES_SENT, "Messages sent" );
this.statistics.setLabel ( STATS_MESSAGES_RECEIVED, "Messages received" );
this.statistics.setLabel ( STATS_CREATION_TIMESTAMP, "Timestamp of creation (in seconds)" );
this.statistics.setCurrentValue ( STATS_CREATION_TIMESTAMP, Math.floor ( System.currentTimeMillis () / 1000 ) );
this.statistics.setLabel ( STATS_LAST_CONNECT_TIMESTAMP, "Timestamp of last CONNECT (in seconds)" );
this.statistics.setLabel ( STATS_LAST_BOUND_TIMESTAMP, "Timestamp of last BOUND (in seconds)" );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:40,代码来源:ClientBaseConnection.java
示例8: start
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
public void start() throws Exception {
buildExecutors();
IoProcessor<NioSession> processor = new SimpleIoProcessorPool<NioSession>(
NioProcessor.class, ioExecutor, coreSize);
connector = new NioSocketConnector(connectorExecutor, processor);
connector.setConnectTimeoutMillis((Integer) rule.get("timeout")); // 设置连接超时。见AbstractPollingIoConnector.processTimedOutSessions()与ConnectionRequest类
// connector.getSessionConfig().setUseReadOperation(true); //
// 亦可使用该方式实现同步发送并接收数据,这样无须设置Handler,通过session.read()获取
handler = new ShortConnectorHandler();
connector.setHandler(handler);
DefaultIoFilterChainBuilder filterChain = connector.getFilterChain();
filterChain.addLast("codec", new ProtocolCodecFilter(
ProtocolCodecFactoryFactory.getInstance(rule)));
}
开发者ID:dreajay,项目名称:jcode,代码行数:15,代码来源:TcpConnector.java
示例9: Delegator
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
public Delegator(IoProcessor<NioSession> ioProcessor, CertificateManager certificateManager) {
this.ioProcessor = ioProcessor;
this.certificateManager = certificateManager;
acceptor = new NioSocketAcceptor(ioProcessor);
acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new DelegatorRemoteCodecFactory()));
acceptor.setReuseAddress(true);
acceptor.setHandler(this);
}
开发者ID:Akdeniz,项目名称:mitmsocks4j,代码行数:9,代码来源:Delegator.java
示例10: NioSession
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Creates a new instance of NioSession, with its associated IoProcessor.
*
* @param service The associated {@link IoService}
* @param processor The associated {@link IoProcessor}
* @param channel The associated {@link Channel}
*/
NioSession(IoService service, IoProcessor<NioSession> processor, SocketChannel channel) {
super(service);
this.processor = processor;
this.channel = channel;
filterChain = new DefaultIoFilterChain(this);
config = new SessionConfigImpl(service);
}
开发者ID:dwing4g,项目名称:jane,代码行数:15,代码来源:NioSession.java
示例11: accept
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
@SuppressWarnings("resource")
@Override
protected NioSession accept(IoProcessor<NioSession> processor, ServerSocketChannel channel) throws IOException {
SelectionKey key = null;
if (channel != null) {
key = channel.keyFor(selector);
}
if (key == null || !key.isValid() || !key.isAcceptable()) {
return null;
}
// accept the connection from the client
try {
SocketChannel ch = (channel != null ? channel.accept() : null);
return ch != null ? new NioSession(this, processor, ch) : null;
} catch (Throwable t) {
ExceptionMonitor.getInstance().error("Error Calling Accept on Socket - Sleeping Acceptor Thread. Check the ulimit parameter", t);
try {
// Sleep 50 ms, so that the select does not spin like crazy doing nothing but eating CPU
// This is typically what will happen if we don't have any more File handle on the server
// Check the ulimit parameter
// NOTE : this is a workaround, there is no way we can handle this exception in any smarter way...
Thread.sleep(50L);
} catch (InterruptedException ie) {
// Nothing to do
}
// No session when we have met an exception
return null;
}
}
开发者ID:dwing4g,项目名称:jane,代码行数:35,代码来源:NioSocketAcceptor.java
示例12: checkDeadLock
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Check for a deadlock, ie look into the stack trace that we don't have already an instance of the caller.
*/
private void checkDeadLock() {
// Only read / write / connect / write future can cause dead lock.
if (!(this instanceof CloseFuture || this instanceof WriteFuture || this instanceof ConnectFuture)) {
return;
}
// Get the current thread stackTrace.
// Using Thread.currentThread().getStackTrace() is the best solution,
// even if slightly less efficient than doing a new Exception().getStackTrace(),
// as internally, it does exactly the same thing. The advantage of using
// this solution is that we may benefit some improvement with some future versions of Java.
StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
// Simple and quick check.
for (StackTraceElement stackElement : stackTrace) {
if (AbstractPollingIoProcessor.class.getName().equals(stackElement.getClassName())) {
// new IllegalStateException("t").getStackTrace();
throw new IllegalStateException("DEAD LOCK: " + IoFuture.class.getSimpleName()
+ ".await() was invoked from an I/O processor thread. Please use "
+ IoFutureListener.class.getSimpleName() + " or configure a proper thread model alternatively.");
}
}
// And then more precisely.
for (StackTraceElement s : stackTrace) {
try {
Class<?> cls = DefaultIoFuture.class.getClassLoader().loadClass(s.getClassName());
if (IoProcessor.class.isAssignableFrom(cls)) {
throw new IllegalStateException("DEAD LOCK: " + IoFuture.class.getSimpleName()
+ ".await() was invoked from an I/O processor thread. Please use "
+ IoFutureListener.class.getSimpleName()
+ " or configure a proper thread model alternatively.");
}
} catch (ClassNotFoundException cnfe) {
// Ignore
}
}
}
开发者ID:dwing4g,项目名称:jane,代码行数:43,代码来源:DefaultIoFuture.java
示例13: newSession
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected NioSession newSession(IoProcessor<NioSession> processor, SocketChannel handle) {
return new NioSocketSession(this, processor, handle);
}
开发者ID:eclipse,项目名称:neoscada,代码行数:8,代码来源:NioSocketConnector.java
示例14: NioDatagramConnector
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Creates a new instance.
*/
public NioDatagramConnector(IoProcessor<NioSession> processor) {
super(new DefaultDatagramSessionConfig(), processor);
}
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:NioDatagramConnector.java
示例15: newSession
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
@Override
protected NioSession newSession(IoProcessor<NioSession> processor, DatagramChannel handle) {
NioSession session = new NioDatagramSession(this, handle, processor);
session.getConfig().setAll(getSessionConfig());
return session;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:NioDatagramConnector.java
示例16: getProcessor
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public IoProcessor<NioSession> getProcessor() {
return processor;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:NioSession.java
示例17: getProcessor
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
IoProcessor<VmPipeSession> getProcessor() {
return processor;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:4,代码来源:VmPipeFilterChain.java
示例18: getProcessor
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
@Override
public IoProcessor<VmPipeSession> getProcessor() {
return filterChain.getProcessor();
}
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:VmPipeSession.java
示例19: getProcessor
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
@Override
public final IoProcessor<AbstractIoSession> getProcessor() {
return processor;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:5,代码来源:DummySession.java
示例20: build
import org.apache.mina.core.service.IoProcessor; //导入依赖的package包/类
/**
* Build a new modbus export instance based on the current builder state
* <br/>
* <em>Note:</em> The call is responsible for disposing the created
* instance using {@link ModbusExport#dispose()}.
*
* @return a newly created modbus instance
*/
public ModbusExport build ()
{
final ScheduledExecutorService executor;
if ( this.threadFactory == null )
{
executor = ScheduledExportedExecutorService.newSingleThreadExportedScheduledExecutor ( "StaticModubusExporter/" + COUNTER.incrementAndGet () );
}
else
{
executor = new ScheduledExportedExecutorService ( "StaticModubusExporter/" + COUNTER.incrementAndGet (), 1, this.threadFactory );
}
boolean disposeProcessor;
final IoProcessor<NioSession> processor;
if ( this.processor == null )
{
processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
disposeProcessor = true;
}
else
{
processor = this.processor;
disposeProcessor = false;
}
final StaticModbusExport result = new StaticModbusExport ( executor, processor, this.hiveSource, null, disposeProcessor );
try
{
result.setProperties ( this.hiveProperies );
result.setReadTimeout ( this.readTimeout );
result.setSlaveId ( this.slaveId );
result.setPort ( this.port );
// we must call this after "setProperties", since this method creates the block
result.setBlockConfiguration ( this.definitions );
return result;
}
catch ( final Throwable e )
{
result.dispose ();
throw new RuntimeException ( "Failed to start exporter", e );
}
}
开发者ID:eclipse,项目名称:neoscada,代码行数:55,代码来源:StaticModbusExport.java
注:本文中的org.apache.mina.core.service.IoProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论