本文整理汇总了Java中org.apache.mina.transport.socket.nio.NioProcessor类的典型用法代码示例。如果您正苦于以下问题:Java NioProcessor类的具体用法?Java NioProcessor怎么用?Java NioProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NioProcessor类属于org.apache.mina.transport.socket.nio包,在下文中一共展示了NioProcessor类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: SlaveHost
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
/**
* Create a new slave host and bind to a single TCP port
*
* @param options
* optional protocol options
* @param port
* the TCP port to bind to
*/
public SlaveHost ( final ProtocolOptions options, final int port ) throws IOException
{
this.options = makeOptions ( options );
this.connector = null;
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
final SocketAcceptor nioAcceptor = new NioSocketAcceptor ( this.processor );
this.acceptor = nioAcceptor;
nioAcceptor.setReuseAddress ( true );
nioAcceptor.setBacklog ( 5 );
this.disposeAcceptor = true;
setupAcceptor ( null );
this.acceptor.bind ( new InetSocketAddress ( port ) );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:28,代码来源:SlaveHost.java
示例2: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
Activator.instance = this;
if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
{
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
}
this.factory = new DriverFactoryImpl ( this.processor );
final Dictionary<String, String> properties = new Hashtable<String, String> ();
properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ca" );
properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA CA NGP Adapter" );
properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:Activator.java
示例3: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
Activator.instance = this;
if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
{
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
}
this.factory = new DriverFactoryImpl ( this.processor );
final Dictionary<String, String> properties = new Hashtable<String, String> ();
properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "hd" );
properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA HD NGP Adapter" );
properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Activator.java
示例4: create
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public static ModbusMaster create ( final BundleContext context, final ScheduledExecutorService executor, final String id, final NioProcessor processor, final Map<String, String> parameters ) throws Exception
{
final ModbusMaster device = new ModbusMaster ( context, id, executor, processor, "ModbusMaster", "modbus" );
try
{
device.configure ( parameters );
}
catch ( final Exception e )
{
// dispose what was already created
device.dispose ();
throw e;
}
return device;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:18,代码来源:ModbusMaster.java
示例5: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
Activator.instance = this;
if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
{
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
}
this.factory = new DriverFactoryImpl ( this.processor );
final Dictionary<String, String> properties = new Hashtable<String, String> ();
properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "da" );
properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA DA NGP Adapter" );
properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Activator.java
示例6: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
@Override
public void start ( final BundleContext context ) throws Exception
{
Activator.instance = this;
if ( !Boolean.getBoolean ( "org.eclipse.scada.core.client.ngp.disableSharedProcessor" ) )
{
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
}
this.factory = new DriverFactoryImpl ( this.processor );
final Dictionary<String, String> properties = new Hashtable<String, String> ();
properties.put ( org.eclipse.scada.core.client.DriverFactory.INTERFACE_NAME, "ae" );
properties.put ( org.eclipse.scada.core.client.DriverFactory.DRIVER_NAME, "ngp" );
properties.put ( Constants.SERVICE_DESCRIPTION, "Eclipse SCADA AE NGP Adapter" );
properties.put ( Constants.SERVICE_VENDOR, "Eclipse SCADA Project" );
this.handle = context.registerService ( org.eclipse.scada.core.client.DriverFactory.class, this.factory, properties );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Activator.java
示例7: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的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
示例8: run
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public void run() throws Exception {
if (start) {
SimpleIoProcessorPool<NioSession> simpleIoProcessorPool = new SimpleIoProcessorPool(
NioProcessor.class, LoginServer.ExecutorService);
acceptor = new NioSocketAcceptor(LoginServer.ExecutorService,
simpleIoProcessorPool);
acceptor.getSessionConfig().setTcpNoDelay(true);
acceptor.getFilterChain().addLast("ThreadPool",
new ExecutorFilter(LoginServer.ExecutorService));
acceptor.getFilterChain().addLast("executor",
new ExecutorFilter(LoginServer.ExecutorService));
acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 15);
acceptor.setHandler(new LoginGatewayHandler(this));
acceptor.bind(new InetSocketAddress(getPort()));
log.info("网关端口监听于 " + getPort());
}
}
开发者ID:316181444,项目名称:Hxms,代码行数:18,代码来源:LoginGateway.java
示例9: SimpleIoProcessorPool
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
/**
* Creates a new instance of SimpleIoProcessorPool with a defined number of IoProcessors in the pool
*
* @param size The number of IoProcessor in the pool
*/
public SimpleIoProcessorPool(int size) {
if (size <= 0) {
throw new IllegalArgumentException("size: " + size + " (expected: positive integer)");
}
executor = Executors.newFixedThreadPool(size,
r -> new Thread(r, NioProcessor.class.getSimpleName() + '-' + idGenerator.incrementAndGet()));
pool = new NioProcessor[size];
boolean success = false;
try {
for (int i = 0; i < pool.length; i++) {
pool[i] = new NioProcessor(executor);
}
success = true;
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (!success) {
dispose();
}
}
}
开发者ID:dwing4g,项目名称:jane,代码行数:30,代码来源:SimpleIoProcessorPool.java
示例10: getProcessor
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
/**
* Find the processor associated to a session.
* If it hasn't be stored into the session's attributes, pick a new processor and stores it.
*/
private NioProcessor getProcessor(NioSession session) {
NioProcessor processor = session.getNioProcessor();
if (processor == null) {
if (disposing) {
throw new IllegalStateException(getClass().getSimpleName() + " is disposed");
}
processor = pool[(int) ((session.getId() & Long.MAX_VALUE) % pool.length)];
if (processor == null) {
throw new IllegalStateException("null processor in pool");
}
session.setNioProcessor(processor);
}
return processor;
}
开发者ID:dwing4g,项目名称:jane,代码行数:23,代码来源:SimpleIoProcessorPool.java
示例11: ExporterFactoryImpl
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public ExporterFactoryImpl ()
{
super ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext () );
this.executor = new ScheduledExportedExecutorService ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getSymbolicName (), 1 );
this.processor = new SimpleIoProcessorPool<> ( NioProcessor.class );
this.hiveSource = new ServiceListenerHiveSource ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext (), this.executor );
this.hiveSource.open ();
this.itemPool = new ObjectPoolImpl<> ();
this.itemPoolHandler = ObjectPoolHelper.registerObjectPool ( FrameworkUtil.getBundle ( ExporterFactoryImpl.class ).getBundleContext (), this.itemPool, DataItem.class );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:15,代码来源:ExporterFactoryImpl.java
示例12: AbstractConnectionDevice
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public AbstractConnectionDevice ( final BundleContext context, final String id, final NioProcessor processor, final ScheduledExecutorService executor, final String itemPrefix )
{
this.id = id;
this.processor = processor;
this.context = context;
this.itemPrefix = itemPrefix;
this.executor = executor;
this.itemFactory = new DataItemFactory ( context, executor, getItemId ( null ) );
this.stateItem = this.itemFactory.createInput ( "state", Collections.<String, Variant> emptyMap () );
this.connectionItem = this.itemFactory.createInput ( "connection", Collections.<String, Variant> emptyMap () );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:13,代码来源:AbstractConnectionDevice.java
示例13: start
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的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
示例14: initializeAndBindPlatypusAcceptor
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
private void initializeAndBindPlatypusAcceptor(InetSocketAddress s) throws IOException, Exception {
//final SslFilter sslFilter = new SslFilter(sslContext); commented out until MINA Sslfilter bugs will be fixed
ThreadPoolExecutor connectionsPollerExecutor = new ThreadPoolExecutor(1, 1,
3L, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(),
new PlatypusThreadFactory("nio-polling-", false));
final IoAcceptor acceptor = new NioSocketAcceptor(connectionsPollerExecutor, new NioProcessor(executor));
//acceptor.getFilterChain().addLast("encryption", sslFilter); commented out until MINA Sslfilter bugs will be fixed
acceptor.getFilterChain().addLast("platypusCodec", new ProtocolCodecFilter(new ResponseEncoder(), new RequestDecoder()));
/*
acceptor.getFilterChain().addLast("executor", new ExecutorFilter(executor, IoEventType.EXCEPTION_CAUGHT,
IoEventType.MESSAGE_RECEIVED, IoEventType.MESSAGE_SENT, IoEventType.SESSION_CLOSED, IoEventType.SESSION_IDLE, IoEventType.CLOSE, IoEventType.WRITE));
*/
PlatypusRequestsHandler handler = new PlatypusRequestsHandler(this);
acceptor.setHandler(handler);
Integer sessionIdleTime = portsSessionIdleTimeouts != null ? portsSessionIdleTimeouts.get(s.getPort()) : null;
if (sessionIdleTime == null || sessionIdleTime == 0) {
sessionIdleTime = PlatypusRequestsHandler.SESSION_TIME_OUT;
}
Integer sessionIdleCheckInterval = portsSessionIdleCheckIntervals != null ? portsSessionIdleCheckIntervals.get(s.getPort()) : null;
if (sessionIdleCheckInterval == null || sessionIdleCheckInterval == 0) {
sessionIdleCheckInterval = PlatypusRequestsHandler.IDLE_TIME_EVENT;
}
handler.setSessionIdleCheckInterval(sessionIdleCheckInterval);
handler.setSessionIdleTime(sessionIdleTime);
acceptor.bind(s);
Logger.getLogger(ServerMain.class.getName()).log(Level.INFO, "Listening platypus protocol on {0}", s.toString());
}
开发者ID:marat-gainullin,项目名称:platypus-js,代码行数:30,代码来源:PlatypusServer.java
示例15: dispose
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
@Override
public final void dispose() {
if (disposing) {
return;
}
synchronized (pool) {
if (disposing) {
return;
}
disposing = true;
for (NioProcessor ioProcessor : pool) {
if (ioProcessor == null) {
// Special case if the pool has not been initialized properly
continue;
}
if (ioProcessor.isDisposing()) {
continue;
}
ioProcessor.dispose();
}
executor.shutdown();
Arrays.fill(pool, null);
disposed = true;
}
}
开发者ID:dwing4g,项目名称:jane,代码行数:32,代码来源:SimpleIoProcessorPool.java
示例16: build
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的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
示例17: ModbusMaster
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public ModbusMaster ( final BundleContext context, final String id, final ScheduledExecutorService executor, final NioProcessor processor, final String threadPrefix, final String itemPrefix )
{
super ( context, id, processor, executor, itemPrefix );
this.jobManager = new JobManager ( executor );
}
开发者ID:eclipse,项目名称:neoscada,代码行数:6,代码来源:ModbusMaster.java
示例18: MasterFactory
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public MasterFactory ( final BundleContext context, final ScheduledExecutorService executor, final NioProcessor processor )
{
super ( context, true );
this.executor = executor;
this.processor = processor;
}
开发者ID:eclipse,项目名称:neoscada,代码行数:7,代码来源:MasterFactory.java
示例19: SharedExecutorMinaServiceServiceFactory
import org.apache.mina.transport.socket.nio.NioProcessor; //导入依赖的package包/类
public SharedExecutorMinaServiceServiceFactory(Executor executor) {
super();
this.executor = executor;
this.ioProcessor = new SimpleIoProcessorPool<NioSession>(NioProcessor.class, executor);
}
开发者ID:cloudnautique,项目名称:cloud-cattle,代码行数:7,代码来源:SharedExecutorMinaServiceServiceFactory.java
注:本文中的org.apache.mina.transport.socket.nio.NioProcessor类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论