⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smapprocessor.java

📁 用java实现的一个socket服务器。采用非阻塞模式
💻 JAVA
字号:
package com.huawei.comm.smap;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2007</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

import java.net.InetAddress;
import java.util.Properties;
import java.util.Collection;

/**
 * Transport using NIO
 * @author Scott Marlow
 * @author Alex Fu
 * @author Bela Ban
 * @version $Id: TCP_NIO.java,v 1.7 2006/06/24 13:17:32 smarlownovell Exp $
 */
public class SMAPProcessor
    extends Protocol
{

  public void start()
      throws Exception
  {

    super.start();
  }

  public void retainAll(Collection members)
  {
    //  ct.retainAll(members);
  }

  public void stop()
  {

    super.stop();
  }

  public String getName()
  {
    return "SMAP_APP";
  }

  public Event handleUpEvent(Event evt)
  {
       System.out.println(getName()+"收到上行消息******************************");
    return evt;
  }

  public Event handleDownEvent(Event evt)
  {

    return evt;
  }

  /** Setup the Protocol instance acording to the configuration string */
  public boolean setProperties(Properties props)
  {
    String str;

    str = props.getProperty("reader_threads");
    if (str != null)
    {
      m_reader_threads = Integer.parseInt(str);
      props.remove("reader_threads");
    }

    str = props.getProperty("writer_threads");
    if (str != null)
    {
      m_writer_threads = Integer.parseInt(str);
      props.remove("writer_threads");
    }

    str = props.getProperty("processor_threads");
    if (str != null)
    {
      m_processor_threads = Integer.parseInt(str);
      props.remove("processor_threads");
    }

    str = props.getProperty("processor_minThreads");
    if (str != null)
    {
      m_processor_minThreads = Integer.parseInt(str);
      props.remove("processor_minThreads");
    }

    str = props.getProperty("processor_maxThreads");
    if (str != null)
    {
      m_processor_maxThreads = Integer.parseInt(str);
      props.remove("processor_maxThreads");
    }

    str = props.getProperty("processor_queueSize");
    if (str != null)
    {
      m_processor_queueSize = Integer.parseInt(str);
      props.remove("processor_queueSize");
    }

    str = props.getProperty("processor_keepAliveTime");
    if (str != null)
    {
      m_processor_keepAliveTime = Integer.parseInt(str);
      props.remove("processor_keepAliveTime");
    }

    return super.setProperties(props);
  }

  private int m_reader_threads = 8;

  private int m_writer_threads = 8;

  private int m_processor_threads = 10; // PooledExecutor.createThreads()
  private int m_processor_minThreads = 10; // PooledExecutor.setMinimumPoolSize()
  private int m_processor_maxThreads = 10; // PooledExecutor.setMaxThreads()
  private int m_processor_queueSize = 100; // Number of queued requests that can be pending waiting

  // for a background thread to run the request.
  private int m_processor_keepAliveTime = -1; // PooledExecutor.setKeepAliveTime( milliseconds);

  // A negative value means to wait forever

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -