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

Scala SerializerWithStringManifest类代码示例

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

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



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

示例1: HmdaFilingViewProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.query.serialization

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.model.serialization.HmdaFilingViewState.FilingViewStateMessage
import hmda.query.view.filing.HmdaFilingView.FilingViewState
import hmda.query.serialization.HmdaFilingViewProtobufConverter._

class HmdaFilingViewProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1012

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val FilingViewStateManifest = classOf[FilingViewState].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case state: FilingViewState => filingViewStateToProtobuf(state).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case FilingViewStateManifest =>
      filingViewStateFromProtobuf(FilingViewStateMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }

} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:27,代码来源:HmdaFilingViewProtobufSerializer.scala


示例2: InstitutionViewProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.query.serialization

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.model.serialization.InstitutionViewEvents.InstitutionViewStateMessage
import hmda.query.view.institutions.InstitutionView.InstitutionViewState
import hmda.query.serialization.InstitutionViewProtobufConverter._

class InstitutionViewProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1011

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val InstitutionViewStateManifest = classOf[InstitutionViewState].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case state: InstitutionViewState => institutionViewStateToProtobuf(state).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case InstitutionViewStateManifest =>
      institutionViewStateFromProtobuf(InstitutionViewStateMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:26,代码来源:InstitutionViewProtobufSerializer.scala


示例3: InstitutionProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.institutions

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.institutions.InstitutionEvents.{ InstitutionCreated, InstitutionModified }
import hmda.persistence.model.serialization.InstitutionEvents.{ InstitutionCreatedMessage, InstitutionModifiedMessage }
import hmda.persistence.serialization.institutions.InstitutionProtobufConverter._

class InstitutionProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1000

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val InstitutionCreatedManifest = classOf[InstitutionCreated].getName
  final val InstitutionModifiedManifest = classOf[InstitutionModified].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: InstitutionCreated => institutionCreatedToProtobuf(evt).toByteArray
    case evt: InstitutionModified => institutionModifiedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case InstitutionCreatedManifest =>
      institutionCreatedFromProtobuf(InstitutionCreatedMessage.parseFrom(bytes))
    case InstitutionModifiedManifest =>
      institutionModifiedFromProtobuf(InstitutionModifiedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:30,代码来源:InstitutionProtobufSerializer.scala


示例4: FilingProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.filing

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.institutions.FilingEvents.{ FilingCreated, FilingStatusUpdated }
import hmda.persistence.model.serialization.FilingEvents.{ FilingCreatedMessage, FilingStatusUpdatedMessage }
import hmda.persistence.serialization.filing.FilingProtobufConverter._

class FilingProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1002

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val FilingCreatedManifest = classOf[FilingCreated].getName
  final val FilingStatusUpdatedManifest = classOf[FilingStatusUpdated].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: FilingCreated => filingCreatedToProtobuf(evt).toByteArray
    case evt: FilingStatusUpdated => filingStatusUpdatedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case FilingCreatedManifest =>
      filingCreatedFromProtobuf(FilingCreatedMessage.parseFrom(bytes))
    case FilingStatusUpdatedManifest =>
      filingStatusUpdatedFromProtobuf(FilingStatusUpdatedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:30,代码来源:FilingProtobufSerializer.scala


示例5: HmdaFileParserProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.parser

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.processing.HmdaFileParserEvents._
import hmda.persistence.model.serialization.HmdaFileParserEvents._
import hmda.persistence.serialization.parser.HmdaFileParserProtobufConverter._

class HmdaFileParserProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1003

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val TsParsedManifest = classOf[TsParsed].getName
  final val TsParsedErrorsManifest = classOf[TsParsedErrors].getName
  final val LarParsedManifest = classOf[LarParsed].getName
  final val LarParsedErrorsManifest = classOf[LarParsedErrors].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case event: TsParsed => tsParsedToProtobuf(event).toByteArray
    case event: TsParsedErrors => tsParsedErrorsToProtobuf(event).toByteArray
    case event: LarParsed => larParsedToProtobuf(event).toByteArray
    case event: LarParsedErrors => larParsedErrorsToProtobuf(event).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize message: $msg")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case TsParsedManifest => tsParsedFromProtobuf(TsParsedMessage.parseFrom(bytes))
    case TsParsedErrorsManifest => tsParsedErrorsFromProtobuf(TsParsedErrorsMessage.parseFrom(bytes))
    case LarParsedManifest => larParsedFromProtobuf(LarParsedMessage.parseFrom(bytes))
    case LarParsedErrorsManifest => larParsedErrorsFromProtobuf(LarParsedErrorsMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize message: $msg")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:34,代码来源:HmdaFileParserProtobufSerializer.scala


示例6: UploadProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.upload

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.processing.FileUploadEvents.{ FileNameAdded, LineAdded }
import hmda.persistence.model.serialization.FileUpload.{ FileNameAddedMessage, LineAddedMessage }
import hmda.persistence.serialization.upload.UploadProtobufConverter._

class UploadProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1005

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val LineAddedManifest = classOf[LineAdded].getName
  final val FileNameAddedManifest = classOf[FileNameAdded].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: LineAdded => lineAddedToProtobuf(evt).toByteArray
    case evt: FileNameAdded => fileNameAddedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case LineAddedManifest =>
      lineAddedFromProtobuf(LineAddedMessage.parseFrom(bytes))
    case FileNameAddedManifest =>
      fileNameAddedFromProtobuf(FileNameAddedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:30,代码来源:UploadProtobufSerializer.scala


示例7: HmdaValidatorProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.validation

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.processing.CommonHmdaValidatorEvents.{ LarValidated, TsValidated }
import hmda.persistence.model.serialization.CommonHmdaValidator.{ LarValidatedMessage, TsValidatedMessage }
import hmda.persistence.serialization.validation.HmdaValidatorProtobufConverter._

class HmdaValidatorProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1004

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val LarValidatedManifest = classOf[LarValidated].getName
  final val TsValidatedManifest = classOf[TsValidated].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: LarValidated => larValidatedToProtobuf(evt).toByteArray
    case evt: TsValidated => tsValidatedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case LarValidatedManifest =>
      larValidatedFromProtobuf(LarValidatedMessage.parseFrom(bytes))
    case TsValidatedManifest =>
      tsValidatedFromProtobuf(TsValidatedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:30,代码来源:HmdaValidatorProtobufSerializer.scala


示例8: HmdaFileValidatorProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.validation

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.processing.HmdaFileValidatorEvents._
import hmda.persistence.model.serialization.HmdaFileValidatorEvents._
import hmda.persistence.serialization.validation.HmdaFileValidatorProtobufConverter._

class HmdaFileValidatorProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1006

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val EditsVerifiedManifest = classOf[EditsVerified].getName
  final val TsSyntacticalErrorManifest = classOf[TsSyntacticalError].getName
  final val TsValidityErrorManifest = classOf[TsValidityError].getName
  final val TsQualityErrorManifest = classOf[TsQualityError].getName
  final val LarSyntacticalErrorManifest = classOf[LarSyntacticalError].getName
  final val LarValidityErrorManifest = classOf[LarValidityError].getName
  final val LarQualityErrorManifest = classOf[LarQualityError].getName
  final val LarMacroErrorManifest = classOf[LarMacroError].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: EditsVerified => editsVerifiedToProtobuf(evt).toByteArray
    case evt: TsSyntacticalError => tsSyntacticalErrorToProtobuf(evt).toByteArray
    case evt: TsValidityError => tsValidityErrorToProtobuf(evt).toByteArray
    case evt: TsQualityError => tsQualityErrorToProtobuf(evt).toByteArray
    case evt: LarSyntacticalError => larSyntacticalErrorToProtobuf(evt).toByteArray
    case evt: LarValidityError => larValidityErrorToProtobuf(evt).toByteArray
    case evt: LarQualityError => larQualityErrorToProtobuf(evt).toByteArray
    case evt: LarMacroError => larMacroErrorToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize message $msg")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case EditsVerifiedManifest => editsVerifiedFromProtobuf(EditsVerifiedMessage.parseFrom(bytes))
    case TsSyntacticalErrorManifest => tsSyntacticalErrorFromProtobuf(TsSyntacticalErrorMessage.parseFrom(bytes))
    case TsValidityErrorManifest => tsValidityErrorFromProtobuf(TsValidityErrorMessage.parseFrom(bytes))
    case TsQualityErrorManifest => tsQualityErrorFromProtobuf(TsQualityErrorMessage.parseFrom(bytes))
    case LarSyntacticalErrorManifest => larSyntacticalErrorFromProtobuf(LarSyntacticalErrorMessage.parseFrom(bytes))
    case LarValidityErrorManifest => larValidityErrorFromProtobuf(LarValidityErrorMessage.parseFrom(bytes))
    case LarQualityErrorManifest => larQualityErrorFromProtobuf(LarQualityErrorMessage.parseFrom(bytes))
    case LarMacroErrorManifest => larMacroErrorFromProtobuf(LarMacroErrorMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize message $msg")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:46,代码来源:HmdaFileValidatorProtobufSerializer.scala


示例9: ValidationStatsProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.validation

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.validation.ValidationStatsEvents._
import hmda.persistence.model.serialization.ValidationStatsEvents._
import hmda.persistence.serialization.validation.ValidationStatsProtobufConverter._

class ValidationStatsProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1008

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val SubmissionSubmittedTotalsAddedManifest = classOf[SubmissionSubmittedTotalsAdded].getName
  final val SubmissionTaxIdAddedManifest = classOf[SubmissionTaxIdAdded].getName
  final val SubmissionMacroStatsAddedManifest = classOf[SubmissionMacroStatsAdded].getName
  final val IrsStatsAddedManifest = classOf[IrsStatsAdded].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: SubmissionSubmittedTotalsAdded => submissionSubmittedTotalsAddedToProtobuf(evt).toByteArray
    case evt: SubmissionTaxIdAdded => submissionTaxIdAddedToProtobuf(evt).toByteArray
    case evt: SubmissionMacroStatsAdded => submissionMacroStatsAddedToProtobuf(evt).toByteArray
    case evt: IrsStatsAdded => irsStatsAddedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize message $msg")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case SubmissionSubmittedTotalsAddedManifest =>
      submissionSubmittedTotalsAddedFromProtobuf(SubmissionSubmittedTotalsAddedMessage.parseFrom(bytes))
    case SubmissionTaxIdAddedManifest =>
      submissionTaxIdAddedFromProtobuf(SubmissionTaxIdAddedMessage.parseFrom(bytes))
    case SubmissionMacroStatsAddedManifest =>
      submissionMacroStatsAddedFromProtobuf(SubmissionMacroStatsAddedMessage.parseFrom(bytes))
    case IrsStatsAddedManifest =>
      irsStatsAddedFromProtobuf(IrsStatsAddedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize message $msg")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:38,代码来源:ValidationStatsProtobufSerializer.scala


示例10: SubmissionLarStatsProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.validation

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.validation.SubmissionLarStatsEvents.{ IrsStatsUpdated, MacroStatsUpdated, SubmittedLarsUpdated }
import hmda.persistence.model.serialization.SubmissionLarStatsEvents.{ IrsStatsUpdatedMessage, MacroStatsUpdatedMessage, SubmittedLarsUpdatedMessage }
import hmda.persistence.serialization.validation.SubmissionLarStatsProtobufConverter._

class SubmissionLarStatsProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1007

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val SubmittedLarsUpdatedManifest = classOf[SubmittedLarsUpdated].getName
  final val MacroStatsUpdatedManifest = classOf[MacroStatsUpdated].getName
  final val IrsStatsUpdatedManifest = classOf[IrsStatsUpdated].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: SubmittedLarsUpdated => submittedLarsUpdatedToProtobuf(evt).toByteArray
    case evt: MacroStatsUpdated => macroStatsUpdatedToProtobuf(evt).toByteArray
    case evt: IrsStatsUpdated => irsStatsUpdatedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case SubmittedLarsUpdatedManifest =>
      submittedLarsUpdatedFromProtobuf(SubmittedLarsUpdatedMessage.parseFrom(bytes))
    case MacroStatsUpdatedManifest =>
      macroStatsUpdatedFromProtobuf(MacroStatsUpdatedMessage.parseFrom(bytes))
    case IrsStatsUpdatedManifest =>
      irsStatsUpdatedFromProtobuf(IrsStatsUpdatedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:34,代码来源:SubmissionLarStatsProtobufSerializer.scala


示例11: SubmissionProtobufSerializer

//设置package包名称以及导入依赖的类
package hmda.persistence.serialization.submission

import akka.serialization.SerializerWithStringManifest
import hmda.persistence.messages.events.institutions.SubmissionEvents.{ SubmissionCreated, SubmissionStatusUpdated }
import hmda.persistence.model.serialization.SubmissionEvents.{ SubmissionCreatedMessage, SubmissionStatusUpdatedMessage }
import hmda.persistence.serialization.submission.SubmissionProtobufConverter._

class SubmissionProtobufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 1001

  override def manifest(o: AnyRef): String = o.getClass.getName

  final val SubmissionCreatedManifest = classOf[SubmissionCreated].getName
  final val SubmissionStatusUpdatedManifest = classOf[SubmissionStatusUpdated].getName

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case evt: SubmissionCreated => submissionCreatedToProtobuf(evt).toByteArray
    case evt: SubmissionStatusUpdated => submissionStatusUpdatedToProtobuf(evt).toByteArray
    case msg: Any => throw new RuntimeException(s"Cannot serialize this message: ${msg.toString}")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = manifest match {
    case SubmissionCreatedManifest =>
      submissionCreatedFromProtobuf(SubmissionCreatedMessage.parseFrom(bytes))
    case SubmissionStatusUpdatedManifest =>
      submissionStatusUpdatedFromProtobuf(SubmissionStatusUpdatedMessage.parseFrom(bytes))
    case msg: Any => throw new RuntimeException(s"Cannot deserialize this message: ${msg.toString}")
  }
} 
开发者ID:cfpb,项目名称:hmda-platform,代码行数:30,代码来源:SubmissionProtobufSerializer.scala


示例12: FlightLastKnownPaxProtoBufSerializer

//设置package包名称以及导入依赖的类
package actors.serializers

import akka.serialization.SerializerWithStringManifest
import server.protobuf.messages.FlightsMessage.FlightLastKnownPaxMessage

class FlightLastKnownPaxProtoBufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 9005

  override def manifest(targetObject: AnyRef): String = {
    targetObject.getClass.getName
  }

  final val manifestName = classOf[FlightLastKnownPaxMessage].getName

  override def toBinary(objectToSerialize: AnyRef): Array[Byte] = {
    objectToSerialize match {
      case sms: FlightLastKnownPaxMessage => sms.toByteArray
    }
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case `manifestName` => FlightLastKnownPaxMessage.parseFrom(bytes)
    }
  }
} 
开发者ID:UKHomeOffice,项目名称:drt-scalajs-spa-exploration,代码行数:27,代码来源:FlightLastKnownPaxProtoBufSerializer.scala


示例13: FlightsProtoBufSerializer

//设置package包名称以及导入依赖的类
package actors.serializers

import akka.serialization.SerializerWithStringManifest
import server.protobuf.messages.FlightsMessage.FlightsMessage
import server.protobuf.messages.StaffMovementMessages.StaffMovementsMessage

class FlightsProtoBufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 9002

  override def manifest(targetObject: AnyRef): String = {
    targetObject.getClass.getName
  }

  final val manifestName = classOf[FlightsMessage].getName

  override def toBinary(objectToSerialize: AnyRef): Array[Byte] = {
    objectToSerialize match {
      case sms: FlightsMessage => sms.toByteArray
    }
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case `manifestName` => FlightsMessage.parseFrom(bytes)
    }
  }
} 
开发者ID:UKHomeOffice,项目名称:drt-scalajs-spa-exploration,代码行数:28,代码来源:FlightsProtoBufSerializer.scala


示例14: ShiftsProtoBufSerializer

//设置package包名称以及导入依赖的类
package actors.serializers

import akka.serialization.SerializerWithStringManifest
import server.protobuf.messages.ShiftMessage.ShiftsMessage

class ShiftsProtoBufSerializer extends SerializerWithStringManifest {

  override def identifier: Int = 9003

  override def manifest(targetObject: AnyRef): String = {
    targetObject.getClass.getName
  }

  final val ShiftsManifest = classOf[ShiftsMessage].getName

  override def toBinary(objectToSerialize: AnyRef): Array[Byte] = {
    objectToSerialize match {
      case sm: ShiftsMessage => sm.toByteArray
    }
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case ShiftsManifest => ShiftsMessage.parseFrom(bytes)
    }
  }
} 
开发者ID:UKHomeOffice,项目名称:drt-scalajs-spa-exploration,代码行数:28,代码来源:ShiftsProtoBufSerializer.scala


示例15: FlightStateSnapshotProtoBufSerializer

//设置package包名称以及导入依赖的类
package actors.serializers

import akka.serialization.SerializerWithStringManifest
import server.protobuf.messages.FlightsMessage.FlightStateSnapshotMessage

class FlightStateSnapshotProtoBufSerializer extends SerializerWithStringManifest {
  override def identifier: Int = 9004

  override def manifest(targetObject: AnyRef): String = {
    targetObject.getClass.getName
  }

  final val manifestName = classOf[FlightStateSnapshotMessage].getName

  override def toBinary(objectToSerialize: AnyRef): Array[Byte] = {
    objectToSerialize match {
      case sms: FlightStateSnapshotMessage => sms.toByteArray
    }
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case `manifestName` => FlightStateSnapshotMessage.parseFrom(bytes)
    }
  }
} 
开发者ID:UKHomeOffice,项目名称:drt-scalajs-spa-exploration,代码行数:27,代码来源:FlightStateSnapshotProtoBufSerializer.scala


示例16: StaffMovementProtoBufSerializer

//设置package包名称以及导入依赖的类
package actors.serializers

import akka.serialization.SerializerWithStringManifest
import server.protobuf.messages.StaffMovementMessages.StaffMovementsMessage

class StaffMovementProtoBufSerializer extends SerializerWithStringManifest {

  override def identifier: Int = 9001

  override def manifest(targetObject: AnyRef): String = {
    targetObject.getClass.getName
  }

  final val StaffMovementsManifest = classOf[StaffMovementsMessage].getName

  override def toBinary(objectToSerialize: AnyRef): Array[Byte] = {
    objectToSerialize match {
      case sms: StaffMovementsMessage => sms.toByteArray
    }
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case StaffMovementsManifest => StaffMovementsMessage.parseFrom(bytes)
    }
  }
} 
开发者ID:UKHomeOffice,项目名称:drt-scalajs-spa-exploration,代码行数:28,代码来源:StaffMovementProtoBufSerializer.scala


示例17: TodoSerializer

//设置package包名称以及导入依赖的类
package com.todos.protobuf

import akka.serialization.SerializerWithStringManifest
import com.todos.event.event.{TodoCreatedEvt, TodoRemovedEvt}
import com.todos.event.{TodoCreated, TodoRemoved}
import com.todos.model.TodoRegistry
import com.todos.model.model.TodoRegistryMdl

class TodoSerializer extends SerializerWithStringManifest
  with TodoToProtobufTransformers with TodoFromProtobufTransformers {

  // should be unique, check other serializers before assigning
  def identifier: Int = 256

  def manifest(o: AnyRef): String = {
    o match {
      case _: TodoRegistry => TodoRegistry.serializeId
      case _: TodoCreated => TodoCreated.serializeId
      case _: TodoRemoved => TodoRemoved.serializeId
    }
  }

  def toBinary(o: AnyRef): Array[Byte] = {
    o match {
      case o: TodoRegistry => toProtobuf(o).toByteArray
      case o: TodoCreated => toProtobuf(o).toByteArray
      case o: TodoRemoved => toProtobuf(o).toByteArray
    }
  }

  def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = {
    manifest match {
      case TodoRegistry.serializeId => fromProtobuf(TodoRegistryMdl.parseFrom(bytes))
      case TodoCreated.serializeId => fromProtobuf(TodoCreatedEvt.parseFrom(bytes))
      case TodoRemoved.serializeId => fromProtobuf(TodoRemovedEvt.parseFrom(bytes))
    }
  }
} 
开发者ID:benniekrijger,项目名称:todo-service,代码行数:39,代码来源:TodoSerializer.scala


示例18: MessageSerializer

//设置package包名称以及导入依赖的类
package aecor.distributedprocessing.serialization

import aecor.distributedprocessing.DistributedProcessingWorker.KeepRunning
import akka.actor.ExtendedActorSystem
import akka.serialization.{ BaseSerializer, SerializerWithStringManifest }

class MessageSerializer(val system: ExtendedActorSystem)
    extends SerializerWithStringManifest
    with BaseSerializer {
  val KeepRunningManifest = "A"
  override def manifest(o: AnyRef): String = o match {
    case KeepRunning(_) => KeepRunningManifest
    case x => throw new IllegalArgumentException(s"Serialization of [$x] is not supported")
  }

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case KeepRunning(workerId) => msg.KeepRunning(workerId).toByteArray
    case x => throw new IllegalArgumentException(s"Serialization of [$x] is not supported")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef =
    manifest match {
      case KeepRunningManifest =>
        KeepRunning(msg.KeepRunning.parseFrom(bytes).workerId)
      case other => throw new IllegalArgumentException(s"Unknown manifest [$other]")
    }
} 
开发者ID:notxcain,项目名称:aecor,代码行数:28,代码来源:MessageSerializer.scala


示例19: PersistentRepr

//设置package包名称以及导入依赖的类
package aecor.runtime.akkapersistence.serialization

import akka.actor.ExtendedActorSystem
import akka.serialization.{ BaseSerializer, SerializerWithStringManifest }

final case class PersistentRepr(manifest: String, payload: Array[Byte])

class PersistentReprSerializer(val system: ExtendedActorSystem)
    extends SerializerWithStringManifest
    with BaseSerializer {

  override def toBinary(o: AnyRef): Array[Byte] = o match {
    case pr: PersistentRepr => pr.payload
    case x => throw new IllegalArgumentException(s"Serialization of [$x] is not supported")
  }

  override def manifest(o: AnyRef): String = o match {
    case pr: PersistentRepr => pr.manifest
    case x => throw new IllegalArgumentException(s"Serialization of [$x] is not supported")
  }

  override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef =
    PersistentRepr(manifest, bytes)
} 
开发者ID:notxcain,项目名称:aecor,代码行数:25,代码来源:PersistentRepr.scala


示例20: ChatEventSerializer

//设置package包名称以及导入依赖的类
package chat

import akka.actor.ExtendedActorSystem
import akka.serialization.{BaseSerializer, SerializerWithStringManifest}
import play.api.libs.json.Json


class ChatEventSerializer(val system: ExtendedActorSystem) extends SerializerWithStringManifest with BaseSerializer {
  override def manifest(o: AnyRef) = o match {
    case _: ChatMessage => "M"
    case _: JoinRoom => "J"
    case _: LeaveRoom => "L"
    case other => sys.error("Don't know how to serialize " + other)
  }

  override def toBinary(o: AnyRef) = {
    val json = o match {
      case cm: ChatMessage => Json.toJson(cm)
      case jr: JoinRoom => Json.toJson(jr)
      case lr: LeaveRoom => Json.toJson(lr)
      case other => sys.error("Don't know how to serialize " + other)
    }
    Json.toBytes(json)
  }

  override def fromBinary(bytes: Array[Byte], manifest: String) = {
    val json = Json.parse(bytes)
    manifest match {
      case "M" => json.as[ChatMessage]
      case "J" => json.as[JoinRoom]
      case "L" => json.as[LeaveRoom]
      case other => sys.error("Unknown manifest " + other)
    }
  }
} 
开发者ID:playframework,项目名称:play-socket.io,代码行数:36,代码来源:ChatEventSerializer.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Scala Point类代码示例发布时间:2022-05-23
下一篇:
Scala Session类代码示例发布时间: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