当前位置: 首页>>代码示例>>Java>>正文


Java LineDelimiter类代码示例

本文整理汇总了Java中org.apache.mina.filter.codec.textline.LineDelimiter的典型用法代码示例。如果您正苦于以下问题:Java LineDelimiter类的具体用法?Java LineDelimiter怎么用?Java LineDelimiter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LineDelimiter类属于org.apache.mina.filter.codec.textline包,在下文中一共展示了LineDelimiter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLineDelimiterParameter

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
private static LineDelimiter getLineDelimiterParameter(TextLineDelimiter delimiter) {
    if (delimiter == null) {
        return LineDelimiter.DEFAULT;
    }

    switch (delimiter) {
    case DEFAULT:
        return LineDelimiter.DEFAULT;
    case AUTO:
        return LineDelimiter.AUTO;
    case UNIX:
        return LineDelimiter.UNIX;
    case WINDOWS:
        return LineDelimiter.WINDOWS;
    case MAC:
        return LineDelimiter.MAC;
    default:
        throw new IllegalArgumentException("Unknown textline delimiter: " + delimiter);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:MinaComponent.java

示例2: getLineDelimiterParameter

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
private static LineDelimiter getLineDelimiterParameter(Mina2TextLineDelimiter delimiter) {
    if (delimiter == null) {
        return LineDelimiter.DEFAULT;
    }

    switch (delimiter) {
    case DEFAULT:
        return LineDelimiter.DEFAULT;
    case AUTO:
        return LineDelimiter.AUTO;
    case UNIX:
        return LineDelimiter.UNIX;
    case WINDOWS:
        return LineDelimiter.WINDOWS;
    case MAC:
        return LineDelimiter.MAC;
    default:
        throw new IllegalArgumentException("Unknown textline delimiter: " + delimiter);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:Mina2Producer.java

示例3: importFromEmailFile

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public static void importFromEmailFile(String fileName)
{
	try
	{
		FileInputStream in = new FileInputStream(fileName);

		SmtpMessageFactory factory = new SmtpMessageFactory(MailsterConstants.DEFAULT_CHARSET, new LineDelimiter("\n"));

		MailsterSmtpService smtp = MailsterSWT.getInstance().getSMTPService();
		smtp.addReceivedEmail(factory.asSmtpMessage(in, null));
		smtp.refreshEmailQueue(false);
		in.close();
	} catch (Exception e)
	{
		ErrorDialog dlg = new ErrorDialog(MailsterSWT.getInstance().getShell(), "Exception occured",
				"Failed importing email file : " + fileName,
				new Status(IStatus.ERROR, "Mailster", "Unable to import file", e), IStatus.ERROR);
		dlg.open();
	}
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:21,代码来源:ImportExportUtilities.java

示例4: SmtpMessageFactory

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
/**
   * Creates a new instance with the specified <tt>charset</tt> and
   * the specified <tt>delimiter</tt>.
   */
  public SmtpMessageFactory(Charset charset, LineDelimiter delimiter)
  {
      if(charset == null)
      {
          throw new NullPointerException("charset");
      }
      this.charset = charset;
      
      if (delimiter == null)
      {
          throw new NullPointerException("delimiter");
      }
      
      // Convert delimiter to IoBuffer.
      delimBuf = IoBuffer.allocate(delimiter.getValue().length()).setAutoExpand(true);
      try 
      {
	delimBuf.putString(delimiter.getValue(), charset.newEncoder());
} 
      catch (CharacterCodingException e) 
      {
	throw new RuntimeException(e);
}
      delimBuf.flip();
  }
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:30,代码来源:SmtpMessageFactory.java

示例5: initService

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
private void initService() throws Exception
  {
      IoBuffer.setUseDirectBuffer(false);

      acceptor = new NioSocketAcceptor(
      		Runtime.getRuntime().availableProcessors() + 1);
      config = acceptor.getSessionConfig();
      config.setReuseAddress(true);
      DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();

      chain.addLast("codec", new ProtocolCodecFilter(
      		new TextLineCodecFactory(
              		MailsterConstants.DEFAULT_CHARSET, 
              		LineDelimiter.CRLF, 
              		LineDelimiter.CRLF)));

executor = Executors.newCachedThreadPool(
		ThreadFactoryUtilities.createFactory("POP3 Thread"));
chain.addLast("threadPool", new ExecutorFilter(executor));

      handler = new Pop3ProtocolHandler(userManager);
  }
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:23,代码来源:MailsterPop3Service.java

示例6: MinaCubeClient

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public MinaCubeClient(String hostname, int port) {
    this.hostname = hostname;
    this.port = port;
    connector = new NioSocketConnector(1);
    connector.setConnectTimeoutMillis(2000);

    connector.getFilterChain().addLast("logger", new LoggingFilter());
    TextLineCodecFactory codecFactory = new TextLineCodecFactory(UTF_8, LineDelimiter.CRLF, LineDelimiter.AUTO);
    codecFactory.setDecoderMaxLineLength(4096);
    codecFactory.setEncoderMaxLineLength(4096);
    connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));

    handler = new ConnectHandler();
    connector.setHandler(handler);
}
 
开发者ID:spinscale,项目名称:maxcube-java,代码行数:16,代码来源:MinaCubeClient.java

示例7: start

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public void start() throws IOException {
    // enable for debug
    acceptor.getFilterChain().addLast("logger", new LoggingFilter());
    TextLineCodecFactory codecFactory = new TextLineCodecFactory(UTF_8, LineDelimiter.CRLF, LineDelimiter.CRLF);
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
    acceptor.setHandler(handler);
    acceptor.bind(new InetSocketAddress(0) );
    acceptor.setCloseOnDeactivation(true);
    logger.info("Cube server bound to [{}]", acceptor.getLocalAddress());
}
 
开发者ID:spinscale,项目名称:maxcube-java,代码行数:11,代码来源:CubeClientTest.java

示例8: startup

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public void startup() throws Exception {
    acceptor = new NioSocketAcceptor();
    Mina2TextLineCodecFactory codecFactory = new Mina2TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.UNIX);
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
    acceptor.setHandler(new ServerHandler());
    acceptor.bind(new InetSocketAddress("127.0.0.1", port));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:Mina2ClientModeTcpTextlineDelimiterTest.java

示例9: startMinaServer

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
private void startMinaServer() {
        initNotify();
//        serverThread = new Thread(new Runnable() {
//            @Override
//            public void run() {
//
//            }
//        });
//        serverThread.start();
        try{
            //创建一个非阻塞的server端的Socket
            acceptor = new NioSocketAcceptor();
            //设置过滤器(使用mina提供的文本换行符编解码器)
            acceptor.getFilterChain().addLast(
                    "codec", new ProtocolCodecFilter(
                            new TextLineCodecFactory(
                                    Charset.forName("UTF-8"),
                                    LineDelimiter.WINDOWS.getValue(),
                                    LineDelimiter.WINDOWS.getValue()
                            )
                    )
            );
            //自定义的编解码器
            //acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(new CharsetCodecFactory()));
            //设置读取数据的换从区大小
            acceptor.getSessionConfig().setReadBufferSize(2048);
            //读写通道10秒内无操作进入空闲状态
            acceptor.getSessionConfig().setIdleTime(IdleStatus.BOTH_IDLE, 10);
            //为接收器设置管理服务
            acceptor.setHandler(new ServerHandler());
            //绑定端口
            acceptor.bind(new InetSocketAddress(PORT));
            LogUtils.i("服务器启动成功...    端口号:"+PORT);
        }catch (Exception e){
            LogUtils.e("服务器异常.."+e);
        }
    }
 
开发者ID:384401056,项目名称:itheima,代码行数:38,代码来源:MinaService.java

示例10: TextLineConsumer

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
/**
   * Creates a new instance with the specified <tt>charset</tt>
   * the specified <tt>delimiter</tt> and the specified
   * {@link IoFilterCodec}. Delimiter
   * {@link LineDelimiter#AUTO} is not allowed.
   */
  public TextLineConsumer( Charset charset, LineDelimiter delimiter, IoFilterCodec codec )
  {
      if( charset == null )
      {
          throw new NullPointerException( "charset" );
      }
      if( delimiter == null )
      {
          throw new NullPointerException( "delimiter" );
      }
      if( delimiter == LineDelimiter.AUTO )
      {
      	throw new IllegalArgumentException("LineDelimiter.AUTO is not allowed");
      }

      this.codec = codec;
      
      // Convert delimiter to ByteBuffer.
      delimBuf = IoBuffer.allocate( 2 ).setAutoExpand( true );
      try 
      {
	delimBuf.putString( delimiter.getValue(), charset.newEncoder() );
} 
      catch (CharacterCodingException e) 
      {
	throw new RuntimeException(e);
}
      delimBuf.flip();
  }
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:36,代码来源:TextLineConsumer.java

示例11: TextLineDecoder

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
/**
 * Creates a new instance with the specified <tt>charset</tt> and the
 * specified <tt>delimiter</tt>.
 */
public TextLineDecoder(Charset charset, LineDelimiter delimiter) {
  if (charset == null) {
    throw new IllegalArgumentException("charset parameter shuld not be null");
  }

  if (delimiter == null) {
    throw new IllegalArgumentException(
        "delimiter parameter should not be null");
  }

  this.charset = charset;
  this.delimiter = delimiter;

  // Convert delimiter to ByteBuffer if not done yet.
  if (delimBuf == null) {
    IoBuffer tmp = IoBuffer.allocate(2).setAutoExpand(true);

    try {
      tmp.putString(delimiter.getValue(), charset.newEncoder());
    } catch (CharacterCodingException cce) {

    }

    tmp.flip();
    delimBuf = tmp;
  }
}
 
开发者ID:blackberry,项目名称:hadoop-logdriver,代码行数:32,代码来源:TextLineDecoder.java

示例12: decode

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
public void decode(IoSession session, IoBuffer in, ProtocolDecoderOutput out)
    throws Exception {
  Context ctx = getContext(session);

  if (LineDelimiter.AUTO.equals(delimiter)) {
    decodeAuto(ctx, session, in, out);
  } else {
    decodeNormal(ctx, session, in, out);
  }
}
 
开发者ID:blackberry,项目名称:hadoop-logdriver,代码行数:14,代码来源:TextLineDecoder.java

示例13: startListening

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
protected void startListening(boolean activateSSL)
{
	try
	{
		this.acceptor = new NioSocketAcceptor();
        ((NioSocketAcceptor)this.acceptor).setReuseAddress(true);
       
        if(activateSSL)
        {
        	//Makes the tcp connection protected with SSL
        	SslFilter sslFilter = new SslFilter(this.getSSLContext());	        
        	this.acceptor.getFilterChain().addLast("ssl", sslFilter);
        }
        
        //
        //TextLineCodecFactory textLine = new TextLineCodecFactory(Charset.forName("UTF-8"));	
        TextLineCodecFactory textLine = new TextLineCodecFactory(Charset.forName("UTF-8"),
    	        LineDelimiter.UNIX.getValue(),
    	        "EOF");
        textLine.setDecoderMaxLineLength(Integer.MAX_VALUE);
        textLine.setEncoderMaxLineLength(Integer.MAX_VALUE);
        ProtocolCodecFilter codecFilter = new ProtocolCodecFilter(textLine);
        this.acceptor.getFilterChain().addLast( "codec", codecFilter);
        
        //
        this.acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter());
        
      //Add Custom filters here
        if(this.payloadFilter != null)
        {
        	this.acceptor.getFilterChain().addLast("payloadFilter", this.payloadFilter);
        }
        
        if(this.requestFilter != null)
        {
        	this.acceptor.getFilterChain().addLast("requestFilter", this.requestFilter);
        }
        
        if(this.transactionFilter != null)
        {
        	this.acceptor.getFilterChain().addLast("transactionFilter", this.transactionFilter);	   
        }
        
        if(this.authenticationFilter != null)
        {
        	this.acceptor.getFilterChain().addLast("authenticationFilter", this.authenticationFilter);
        }
        
        //session specific configuration
        this.acceptor.getSessionConfig().setBothIdleTime(10);
        
        this.acceptor.setHandler(this.handler);
        this.acceptor.bind(new InetSocketAddress(this.port));
        
        log.info("--------------------------------------------");
        log.info("Mobile Data Server successfully loaded on port ("+this.port+").....");
        log.info("--------------------------------------------");
	}
	catch(Exception e)
	{
		log.error(this, e);
		this.stop();
		throw new RuntimeException(e);
	}
}
 
开发者ID:ZalemSoftware,项目名称:OpenMobster,代码行数:66,代码来源:Server.java

示例14: main

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public static void main(String[] args) {    
    // 创建一个非组设的客户端客户端     
    IoConnector connector = new NioSocketConnector();    
    // 设置链接超时时间     
    connector.setConnectTimeoutMillis(30000);    
    // 添加过滤器     
    connector.getFilterChain().addLast( // 添加消息过滤器     
            "codec",    
            // Mina自带的根据文本换行符编解码的TextLineCodec过滤器 看到\r\n就认为一个完整的消息结束了  
            new ProtocolCodecFilter(new TextLineCodecFactory(Charset    
                    .forName("UTF-8"), LineDelimiter.MAC.getValue(),    
                    LineDelimiter.MAC.getValue())));    
    // 添加业务逻辑处理器类     
    connector.setHandler(new ClientMessageHandler());    
    IoSession session = null;    
    try {    
        ConnectFuture future = connector.connect(new InetSocketAddress(    
                HOST, PORT));    
        future.awaitUninterruptibly(); // 等待连接创建完成     
        session = future.getSession();
        long t1 = System.currentTimeMillis();
        StringBuffer sb = new StringBuffer();
        for(int i=0;i<200000;i++){
        	System.out.println(i);
        	sb.append("ysqysq nginx_ccc [0050d2bf234311e6ba8cac853da49b78 type=nginx_access_log tag=\"mylog\"] /Users/sishuyss/ysq_access/$2016-04-05T11:12:24.230148+08:00/$100.97.184.152 - - [25/May/2016:01:10:07 +0800] \"GET /index.php?disp=dynamic HTTP/1.0\" 301 278 \"http://log.dtstack.com/\" \"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;Alibaba.Security.Heimdall.1142964)\" 121.42.0.85 - - - 0").append(LineDelimiter.UNIX.getValue());
        	if(i%200==0){
                session.write(sb.toString()); 
                sb =  new StringBuffer();
        	}
        }
        session.write(sb.toString()); 
        System.out.println("time:"+(System.currentTimeMillis()-t1));
    } catch (Exception e) {   
    	System.out.println(e.getCause());
        logger.info("客户端链接异常...");    
    }    

    session.getCloseFuture().awaitUninterruptibly();    
    logger.info("Mina要关闭了");    
    connector.dispose();    
}
 
开发者ID:DTStack,项目名称:jlogstash-input-plugin,代码行数:42,代码来源:MyClient.java

示例15: startup

import org.apache.mina.filter.codec.textline.LineDelimiter; //导入依赖的package包/类
public void startup() throws Exception {
    acceptor = new SocketAcceptor();
    TextLineCodecFactory codecFactory = new TextLineCodecFactory(Charset.forName("UTF-8"), LineDelimiter.UNIX);
    acceptor.getFilterChain().addLast("codec", new ProtocolCodecFilter(codecFactory));
    acceptor.bind(new InetSocketAddress("127.0.0.1", port), new ServerHandler());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:MinaClientModeTcpTextlineDelimiterTest.java


注:本文中的org.apache.mina.filter.codec.textline.LineDelimiter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。