• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala ChannelPipelineFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中org.jboss.netty.channel.ChannelPipelineFactory的典型用法代码示例。如果您正苦于以下问题:Scala ChannelPipelineFactory类的具体用法?Scala ChannelPipelineFactory怎么用?Scala ChannelPipelineFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ChannelPipelineFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。

示例1: StringCodec

//设置package包名称以及导入依赖的类
package com.twitter.finagle.integration

import com.twitter.finagle._
import java.nio.charset.StandardCharsets.UTF_8
import org.jboss.netty.channel.{ChannelPipelineFactory, Channels}
import org.jboss.netty.handler.codec.frame.{DelimiterBasedFrameDecoder, Delimiters}
import org.jboss.netty.handler.codec.string.{StringDecoder, StringEncoder}

object StringCodec extends StringCodec

class StringCodec extends CodecFactory[String, String] {
  def server = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(100, Delimiters.lineDelimiter: _*))
          pipeline.addLast("stringDecoder", new StringDecoder(UTF_8))
          pipeline.addLast("stringEncoder", new StringEncoder(UTF_8))
          pipeline
        }
      }
    }
  }

  def client = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("stringEncode", new StringEncoder(UTF_8))
          pipeline.addLast("stringDecode", new StringDecoder(UTF_8))
          pipeline
        }
      }

      override def prepareConnFactory(factory: ServiceFactory[String, String], ps: Stack.Params) =
        new AddNewlineFilter andThen factory
    }
  }

  class AddNewlineFilter extends SimpleFilter[String, String] {
    def apply(request: String, service: Service[String, String]) = service(request + "\n")
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:46,代码来源:StringCodec.scala


示例2: ThriftServerFramedCodec

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift

import com.twitter.finagle._
import com.twitter.finagle.stats.{NullStatsReceiver, StatsReceiver}
import com.twitter.finagle.thrift.transport.netty3.ThriftServerFramedPipelineFactory
import com.twitter.finagle.tracing.TraceInitializerFilter
import org.apache.thrift.protocol.TProtocolFactory
import org.jboss.netty.channel.ChannelPipelineFactory

object ThriftServerFramedCodec {
  def apply(statsReceiver: StatsReceiver = NullStatsReceiver): ThriftServerFramedCodecFactory =
    new ThriftServerFramedCodecFactory(statsReceiver)

  def apply(protocolFactory: TProtocolFactory): ThriftServerFramedCodecFactory =
    new ThriftServerFramedCodecFactory(protocolFactory)

  def get(): ThriftServerFramedCodecFactory = apply()
}

class ThriftServerFramedCodecFactory(protocolFactory: TProtocolFactory)
    extends CodecFactory[Array[Byte], Array[Byte]]#Server
{
  def this(statsReceiver: StatsReceiver) =
    this(Protocols.binaryFactory(statsReceiver = statsReceiver))

  def this() = this(NullStatsReceiver)

  def apply(config: ServerCodecConfig): ThriftServerFramedCodec =
    new ThriftServerFramedCodec(config, protocolFactory)
}

class ThriftServerFramedCodec(
    config: ServerCodecConfig,
    protocolFactory: TProtocolFactory = Protocols.binaryFactory()
) extends Codec[Array[Byte], Array[Byte]] {
  def pipelineFactory: ChannelPipelineFactory = ThriftServerFramedPipelineFactory

  private[this] val preparer = ThriftServerPreparer(
    protocolFactory, config.serviceName)

  override def prepareConnFactory(
    factory: ServiceFactory[Array[Byte],
    Array[Byte]], params: Stack.Params
  ): ServiceFactory[Array[Byte], Array[Byte]] = preparer.prepare(factory, params)

  override def newTraceInitializer = TraceInitializerFilter.serverModule[Array[Byte], Array[Byte]]

  override val protocolLibraryName: String = "thrift"
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:50,代码来源:ThriftServerFramedCodec.scala


示例3: ThriftClientFramedPipelineFactory

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift.transport.netty3

import org.jboss.netty.channel.{ChannelPipeline, ChannelPipelineFactory, Channels}


private[finagle]
object ThriftClientFramedPipelineFactory extends ChannelPipelineFactory {
  def getPipeline(): ChannelPipeline = {
    val pipeline = Channels.pipeline()
    pipeline.addLast("thriftFrameCodec", new ThriftFrameCodec)
    pipeline.addLast("byteEncoder",      new ThriftClientChannelBufferEncoder)
    pipeline.addLast("byteDecoder",      new ThriftChannelBufferDecoder)
    pipeline
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:16,代码来源:ThriftClientFramedPipelineFactory.scala


示例4: ThriftServerBufferedPipelineFactory

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift.transport.netty3

import com.twitter.finagle.thrift.{Protocols, ThriftServerFramedCodec}
import com.twitter.finagle.{CodecFactory, ServerCodecConfig}
import org.apache.thrift.protocol.TProtocolFactory
import org.jboss.netty.channel.{ChannelPipeline, ChannelPipelineFactory}

private[netty3]
case class ThriftServerBufferedPipelineFactory(protocolFactory: TProtocolFactory)
    extends ChannelPipelineFactory {

  def getPipeline(): ChannelPipeline = {
    val pipeline = ThriftServerFramedPipelineFactory.getPipeline()
    pipeline.replace(
      "thriftFrameCodec", "thriftBufferDecoder",
      new ThriftBufferedTransportDecoder(protocolFactory))
    pipeline
  }
}


  def apply(config: ServerCodecConfig): ThriftServerBufferedCodec = {
    new ThriftServerBufferedCodec(protocolFactory, config)
  }
}

class ThriftServerBufferedCodec(protocolFactory: TProtocolFactory, config: ServerCodecConfig)
    extends ThriftServerFramedCodec(config) {
  override def pipelineFactory = ThriftServerBufferedPipelineFactory(protocolFactory)
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:31,代码来源:ThriftServerBufferedCodec.scala


示例5: ThriftClientBufferedPipelineFactory

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift.transport.netty3

import org.apache.thrift.protocol.TProtocolFactory
import org.jboss.netty.channel.{ChannelPipeline, ChannelPipelineFactory}

private[netty3] case class ThriftClientBufferedPipelineFactory(
    protocolFactory: TProtocolFactory)
  extends ChannelPipelineFactory {
  def getPipeline(): ChannelPipeline = {
    val pipeline = ThriftClientFramedPipelineFactory.getPipeline()
    pipeline.replace(
      "thriftFrameCodec", "thriftBufferDecoder",
      new ThriftBufferedTransportDecoder(protocolFactory))
    pipeline
  }
} 
开发者ID:wenkeyang,项目名称:finagle,代码行数:17,代码来源:ThriftClientBufferedPipelineFactory.scala


示例6: ServerCodec

//设置package包名称以及导入依赖的类
package org.http4s
package finagle

import com.twitter.finagle.stats.StatsReceiver
import com.twitter.finagle.transport.Transport
import com.twitter.finagle.{ Codec, CodecFactory, Service }
import com.twitter.util.Closable
import org.jboss.netty.channel.{ ChannelPipelineFactory, Channels }
import org.jboss.netty.handler.codec.http.HttpServerCodec

import scalaz.syntax.id._

class ServerCodec(stats: StatsReceiver) extends CodecFactory[Request, Response] {
  def server = Function.const {
    new Codec[Request, Response] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline =
          Channels.pipeline() <| { _.addLast("httpCodec", new HttpServerCodec) }
      }
      override def newServerDispatcher(
        transport: Transport[Any, Any],
        service:   Service[Request, Response]
      ): Closable =
        ServerDispatcher.newServerDispatcher(transport, service, stats)
    }
  }

  def client = throw new RuntimeException()
} 
开发者ID:lukiano,项目名称:finagle-http4s,代码行数:30,代码来源:ServerCodec.scala


示例7: StringCodec

//设置package包名称以及导入依赖的类
package com.twitter.finagle.integration

import com.twitter.finagle.{Service, SimpleFilter, ServiceFactory, Codec, CodecFactory}
import org.jboss.netty.channel.{Channels, ChannelPipelineFactory}
import org.jboss.netty.handler.codec.frame.{Delimiters, DelimiterBasedFrameDecoder}
import org.jboss.netty.util.CharsetUtil
import org.jboss.netty.handler.codec.string.{StringEncoder, StringDecoder}

object StringCodec extends StringCodec

class StringCodec extends CodecFactory[String, String] {
  def server = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("frameDecoder", new DelimiterBasedFrameDecoder(100, Delimiters.lineDelimiter: _*))
          pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8))
          pipeline.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8))
          pipeline
        }
      }
    }
  }

  def client = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("stringEncode", new StringEncoder(CharsetUtil.UTF_8))
          pipeline.addLast("stringDecode", new StringDecoder(CharsetUtil.UTF_8))
          pipeline
        }
      }

      override def prepareConnFactory(factory: ServiceFactory[String, String]) =
        (new AddNewlineFilter) andThen factory
    }
  }

  class AddNewlineFilter extends SimpleFilter[String, String] {
    def apply(request: String, service: Service[String, String]) = service(request + "\n")
  }
} 
开发者ID:deenar,项目名称:fintest,代码行数:46,代码来源:StringCodec.scala


示例8: StringCodec

//设置package包名称以及导入依赖的类
package com.twitter.finagle.example.echo

import com.twitter.finagle.{Codec, CodecFactory}
import org.jboss.netty.handler.codec.string.{StringEncoder, StringDecoder}
import org.jboss.netty.channel.{Channels, ChannelPipelineFactory}
import org.jboss.netty.handler.codec.frame.{Delimiters, DelimiterBasedFrameDecoder}
import org.jboss.netty.util.CharsetUtil


object StringCodec extends StringCodec

class StringCodec extends CodecFactory[String, String] {
  def server = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("line",
            new DelimiterBasedFrameDecoder(100, Delimiters.lineDelimiter: _*))
          pipeline.addLast("stringDecoder", new StringDecoder(CharsetUtil.UTF_8))
          pipeline.addLast("stringEncoder", new StringEncoder(CharsetUtil.UTF_8))
          pipeline
        }
      }
    }
  }

  def client = Function.const {
    new Codec[String, String] {
      def pipelineFactory = new ChannelPipelineFactory {
        def getPipeline = {
          val pipeline = Channels.pipeline()
          pipeline.addLast("stringEncode", new StringEncoder(CharsetUtil.UTF_8))
          pipeline.addLast("stringDecode", new StringDecoder(CharsetUtil.UTF_8))
          pipeline
        }
      }
    }
  }
} 
开发者ID:deenar,项目名称:fintest,代码行数:41,代码来源:StringCodec.scala


示例9: apply

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift

import org.jboss.netty.channel.ChannelPipelineFactory
import com.twitter.finagle.{CodecFactory, ClientCodecConfig}
import org.apache.thrift.protocol.{TBinaryProtocol, TProtocolFactory}


  def apply(config: ClientCodecConfig) = {
    new ThriftClientBufferedCodec(new TBinaryProtocol.Factory(), config)
  }
}

class ThriftClientBufferedCodec(protocolFactory: TProtocolFactory, config: ClientCodecConfig)
  extends ThriftClientFramedCodec(protocolFactory, config)
{
  override def pipelineFactory = {
    val framedPipelineFactory = super.pipelineFactory

    new ChannelPipelineFactory {
      def getPipeline() = {
        val pipeline = framedPipelineFactory.getPipeline
        pipeline.replace(
          "thriftFrameCodec", "thriftBufferDecoder",
          new ThriftBufferDecoder(protocolFactory))
        pipeline
      }
    }
  }
} 
开发者ID:deenar,项目名称:fintest,代码行数:30,代码来源:ThriftClientBufferedCodec.scala


示例10: apply

//设置package包名称以及导入依赖的类
package com.twitter.finagle.thrift

import org.jboss.netty.channel.ChannelPipelineFactory
import com.twitter.finagle.{CodecFactory, ServerCodecConfig}
import org.apache.thrift.protocol.{TBinaryProtocol, TProtocolFactory}


  def apply(config: ServerCodecConfig) = {
    new ThriftServerBufferedCodec(new TBinaryProtocol.Factory(), config)
  }
}

class ThriftServerBufferedCodec(
  protocolFactory: TProtocolFactory,
  config: ServerCodecConfig
)
  extends ThriftServerFramedCodec(config)
{
  override def pipelineFactory = {
    val framedPipelineFactory = super.pipelineFactory

    new ChannelPipelineFactory {
      def getPipeline() = {
        val pipeline = framedPipelineFactory.getPipeline
        pipeline.replace(
          "thriftFrameCodec", "thriftBufferDecoder",
          new ThriftBufferDecoder(protocolFactory))
        pipeline
      }
    }
  }
} 
开发者ID:deenar,项目名称:fintest,代码行数:33,代码来源:ThriftServerBufferedCodec.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala StreamResult类代码示例发布时间:2022-05-23
下一篇:
Scala ExceptionUtils类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap