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

Scala JsonSerializer类代码示例

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

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



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

示例1: SaveNewMessage

//设置package包名称以及导入依赖的类
package sample.helloworldconsumer.impl

import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import play.api.libs.json.Json
import akka.Done
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}

import scala.collection.immutable.Seq


sealed trait MessageCommand [T] extends ReplyType[T]

case class SaveNewMessage(message: String) extends MessageCommand[Done]

object SaveNewMessage {
  implicit val formatter = Json.format[SaveNewMessage]
}

object HelloConsumerSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq(
    JsonSerializer[SaveNewMessage],
    JsonSerializer[MessageSaved],
    JsonSerializer[MessageState]
  )
} 
开发者ID:knoldus,项目名称:lagom-scala-wordcount.g8,代码行数:26,代码来源:MessageCommand.scala


示例2: AccountSerializerRegistry

//设置package包名称以及导入依赖的类
package org.ioreskovic.greatmaterialcontinuum.impl.ent.acc

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import org.ioreskovic.greatmaterialcontinuum.impl.cmd.acc._
import org.ioreskovic.greatmaterialcontinuum.impl.evt.acc._
import org.ioreskovic.greatmaterialcontinuum.impl.stt.acc.AccountState

import scala.collection.immutable

object AccountSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: immutable.Seq[JsonSerializer[_]] = immutable.Seq(
    JsonSerializer[AccountState],

    JsonSerializer[CreateAccount],
    JsonSerializer[DeleteAccount],
    JsonSerializer[ActivateAccount],
    JsonSerializer[DeactivateAccount],
    JsonSerializer[RetrieveAccount],

    JsonSerializer[AccountCreated],
    JsonSerializer[AccountDeleted],
    JsonSerializer[AccountActivated],
    JsonSerializer[AccountDeactivated],
    JsonSerializer[AccountRetrieved]
  )
} 
开发者ID:ioreskovic,项目名称:great-material-continuum,代码行数:27,代码来源:AccountSerializerRegistry.scala


示例3: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire._
import demo.api.basket.{Basket, BasketService}
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }

  persistentEntityRegistry.register(wire[BasketEntity])
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  import BasketEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = Seq (
    JsonSerializer[AddItem],
    JsonSerializer[GetBasket.type],
    JsonSerializer[GetTotal.type],
    JsonSerializer[ClearAll.type],
    JsonSerializer[BasketCleared.type],
    JsonSerializer[ItemAdded],
    JsonSerializer[BasketEntityState],
    JsonSerializer[Basket],
    JsonSerializer[OrderPlaced],
    JsonSerializer[PlaceOrder.type],
    JsonSerializer[Basket]
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:55,代码来源:BasketApplication.scala


示例4: OrderApplication

//设置package包名称以及导入依赖的类
package demo.impl.order

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire.wire
import demo.api.basket.BasketService
import demo.api.order.OrderService
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq

abstract class OrderApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with CassandraPersistenceComponents
  with LagomKafkaComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[OrderService].to(wire[OrderServiceImpl])
  }

  lazy val basketService: BasketService = serviceClient.implement[BasketService]

  persistentEntityRegistry.register(wire[Order])

  wire[BasketServiceSubscriber]
}

class OrderApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication = {
    new OrderApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = OrderSerializerRegistry
    }
  }

  override def load(context: LagomApplicationContext): LagomApplication = {
    new OrderApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
      override def jsonSerializerRegistry: JsonSerializerRegistry = OrderSerializerRegistry
    }
  }
}

object OrderSerializerRegistry extends JsonSerializerRegistry {
  import OrderEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = {
    Seq(JsonSerializer[OrderInitialized],
      JsonSerializer[OrderState],
      JsonSerializer[CreateOrder],
      JsonSerializer[GetOrder.type],
      JsonSerializer[OrderItems])
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:57,代码来源:OrderApplication.scala


示例5: OrderEntityFormats

//设置package包名称以及导入依赖的类
package demo.impl.order

import akka.Done
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
import play.api.libs.json.{Format, Json}

object OrderEntityFormats {
  implicit val orderItemsFormat: Format[OrderItems] = Json.format
  implicit val createOrderFormat: Format[CreateOrder] = Json.format
  implicit val getOrderFormat = JsonSerializer.emptySingletonFormat(GetOrder)
  implicit val orderInitialisedFormat: Format[OrderInitialized] = Json.format
  implicit val orderStateFormat: Format[OrderState] = Json.format
}

case class OrderItems (items: Seq[String])

trait OrderCommand
case class CreateOrder(items: Seq[String]) extends OrderCommand with ReplyType[Done]
case object GetOrder extends OrderCommand with ReplyType[OrderItems]

trait OrderEvent
case class OrderInitialized(items: Seq[String]) extends OrderEvent
case class OrderState(items: Seq[String])

object OrderState {
  def empty = OrderState(Seq())
}

class Order extends PersistentEntity {
  override type Command = OrderCommand
  override type Event = OrderEvent
  override type State = OrderState

  override def initialState = OrderState.empty

  override def behavior: Behavior = Actions()
    .onCommand[CreateOrder, Done] {
      case (CreateOrder(items), ctx, state) => {
        ctx.thenPersist(OrderInitialized(items)){
          evt => ctx.reply(Done)
        }
      }
    }
    .onReadOnlyCommand[GetOrder.type, OrderItems] {
      case (GetOrder, ctx, state) => ctx.reply(OrderItems(state.items))
    }
    .onEvent{
      case (OrderInitialized(items), state) => OrderState(items)
    }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:53,代码来源:Order.scala


示例6: OrderSpec

//设置package包名称以及导入依赖的类
import akka.Done
import akka.actor.ActorSystem
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.testkit.PersistentEntityTestDriver
import com.typesafe.config.ConfigFactory
import demo.impl.order._
import org.scalactic.TypeCheckedTripleEquals
import org.scalatest.{BeforeAndAfterAll, Matchers, WordSpecLike}

import scala.concurrent.duration._
import scala.concurrent.Await

class OrderSpec extends WordSpecLike with Matchers with BeforeAndAfterAll with TypeCheckedTripleEquals {
  val system = ActorSystem("PostSpec", JsonSerializerRegistry.actorSystemSetupFor(OrderSerializerRegistry))

  override protected def afterAll() {
    Await.ready(system.terminate(), 20.seconds)
  }

  "Order" must {
    "be created" in {
      val driver = new PersistentEntityTestDriver(system, new Order, "order1")
      val items = IndexedSeq("Apple", "Banana")
      val outcome = driver.run(CreateOrder(items))
      outcome.issues should ===(List())
      outcome.state should ===(OrderState(items))
      outcome.events should ===(List(OrderInitialized(items)))
      outcome.replies should ===(List(Done))

      val getOutcome = driver.run(GetOrder)

      getOutcome.issues should ===(List())
      getOutcome.state should ===(OrderState(items))
      getOutcome.replies should ===(List(OrderItems(items)))
    }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:38,代码来源:OrderSpec.scala


示例7: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire._
import demo.api.basket.{Basket, BasketService}
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }


  persistentEntityRegistry.register(wire[BasketEntity])
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  import BasketEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = Seq (
    JsonSerializer[AddItem],
    JsonSerializer[GetBasket.type],
    JsonSerializer[GetTotal.type],
    JsonSerializer[ClearAll.type],
    JsonSerializer[BasketCleared.type],
    JsonSerializer[ItemAdded],
    JsonSerializer[BasketEntityState],
    JsonSerializer[Basket],
    JsonSerializer[OrderPlaced],
    JsonSerializer[PlaceOrder.type],
    JsonSerializer[Basket]
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:56,代码来源:BasketApplication.scala


示例8: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import demo.api.basket.{Basket, BasketService, Item}
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }

  persistentEntityRegistry.register(wire[BasketEntity])
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  import BasketEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = Seq (
    JsonSerializer[AddItem],
    JsonSerializer[GetBasket.type],
    JsonSerializer[GetTotal.type],
    JsonSerializer[ItemAdded],
    JsonSerializer[BasketEntityState],
    JsonSerializer[Basket]
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:50,代码来源:BasketApplication.scala


示例9: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import demo.api.basket.{BasketService, Item}
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq (
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:41,代码来源:BasketApplication.scala


示例10: BasketEntityFormats

//设置package包名称以及导入依赖的类
package demo.impl.basket

import akka.{Done, NotUsed}
import com.lightbend.lagom.scaladsl.persistence.PersistentEntity.ReplyType
import com.lightbend.lagom.scaladsl.persistence.{AggregateEvent, AggregateEventTag, PersistentEntity}
import com.lightbend.lagom.scaladsl.playjson.JsonSerializer
import demo.api.basket.{Basket, Item}
import play.api.libs.json.{Format, Json}

object BasketEntityFormats {
  implicit val addItemFormat: Format[AddItem] = Json.format
  implicit val getBasketFormat: Format[GetBasket.type] = JsonSerializer.emptySingletonFormat(GetBasket)
  implicit val itemAddedFormat: Format[ItemAdded] = Json.format
  implicit val basketEntityStateFormat: Format[BasketEntityState] = Json.format
}

trait BasketEntityCommand
case class AddItem(item: Item) extends BasketEntityCommand with ReplyType[Done]
case object GetBasket extends BasketEntityCommand with ReplyType[Basket]

case class BasketEntityState(currentBasket: Basket)
object BasketEntityState{
  val initial = BasketEntityState(Basket(Seq(), 0))
}

sealed trait BasketEntityEvent extends AggregateEvent[BasketEntityEvent] {
  override def aggregateTag = BasketEntityEvent.Tag
}

object BasketEntityEvent {
  val Tag = AggregateEventTag.sharded[BasketEntityEvent](4)
}

case class ItemAdded(item: Item) extends BasketEntityEvent

final class BasketEntity extends PersistentEntity {
  override type Command = BasketEntityCommand
  override type Event = BasketEntityEvent
  override type State = BasketEntityState

  override def initialState = BasketEntityState.initial

  override def behavior: Behavior = {
    Actions()
      .onCommand[AddItem, Done] {
        case (AddItem(item), ctx, state) =>
          ctx.thenPersist(ItemAdded(item))(_ => ctx.reply(Done))
      }
      .onReadOnlyCommand[GetBasket.type, Basket] {
        case (GetBasket, ctx, state) => ctx.reply(state.currentBasket)
      }
      .onEvent {
        case (ItemAdded(item), state) => {
          val newItems = state.currentBasket.items :+ item
          state.copy(Basket(newItems, newItems.map(_.price).sum))
        }
      }
  }
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:60,代码来源:BasketEntity.scala


示例11: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import demo.api.basket.{Basket, BasketService, Item}
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }

  persistentEntityRegistry.register(wire[BasketEntity])
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  import BasketEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = Seq (
    JsonSerializer[AddItem],
    JsonSerializer[GetBasket.type],
    JsonSerializer[ItemAdded],
    JsonSerializer[BasketEntityState],
    JsonSerializer[Basket]
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:49,代码来源:BasketApplication.scala


示例12: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import demo.api.basket.{BasketService}
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    ???
    //bindService[BasketService].to(wire[BasketServiceImpl])
  }
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq (
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:42,代码来源:BasketApplication.scala


示例13: BasketApplication

//设置package包名称以及导入依赖的类
package demo.impl.basket

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire._
import demo.api.basket.{Basket, BasketService}
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq

abstract class BasketApplication(ctx: LagomApplicationContext) extends LagomApplication(ctx)
  with AhcWSComponents
  with LagomKafkaComponents
  with CassandraPersistenceComponents {
  override def lagomServer: LagomServer = LagomServer.forServices {
    bindService[BasketService].to(wire[BasketServiceImpl])
  }

  persistentEntityRegistry.register(wire[BasketEntity])
}

class BasketApplicationLoader extends LagomApplicationLoader {
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new BasketApplication(context) with LagomDevModeComponents {
      override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
    }

  override def load(context: LagomApplicationContext): LagomApplication = new BasketApplication(context) {
    override def serviceLocator: ServiceLocator = NoServiceLocator
    override def jsonSerializerRegistry: JsonSerializerRegistry = BasketSerializerRegistry
  }
}

object BasketSerializerRegistry extends JsonSerializerRegistry {
  import BasketEntityFormats._
  override def serializers: Seq[JsonSerializer[_]] = Seq (
    JsonSerializer[AddItem],
    JsonSerializer[GetBasket.type],
    JsonSerializer[GetTotal.type],
    JsonSerializer[ClearAll.type],
    JsonSerializer[BasketCleared.type],
    JsonSerializer[ItemAdded],
    JsonSerializer[BasketEntityState],
    JsonSerializer[Basket]
  )
} 
开发者ID:tommpy,项目名称:demo-lagom-checkout,代码行数:52,代码来源:BasketApplication.scala


示例14: MappingLoader

//设置package包名称以及导入依赖的类
package com.ss.mapping.impl

import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.api.{Descriptor, ServiceLocator}
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.lightbend.lagom.scaladsl.server._
import com.softwaremill.macwire._
import com.ss.mapping.api.MappingService
import org.slf4j.LoggerFactory
import play.api.libs.ws.ahc.AhcWSComponents

import scala.collection.immutable.Seq


class MappingLoader extends LagomApplicationLoader {
  val logger = LoggerFactory.getLogger(getClass)
  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new MappingApplication(context) with LagomDevModeComponents

  override def load(context: LagomApplicationContext): LagomApplication =
    new MappingApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }

  override def describeServices: Seq[Descriptor] = Seq(
    readDescriptor[MappingService]
  )
}

abstract class MappingApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with CassandraPersistenceComponents
    with AhcWSComponents {
  override def jsonSerializerRegistry: JsonSerializerRegistry = {
    MappingSerializerRegistry
  }
  override def lagomServer: LagomServer = {
    LagomServer.forServices(
      bindService[MappingService].to(wire[MappingServiceImpl])
    )
  }
  readSide.register(wire[NodeReadEventsProcessor])
}

object MappingSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq(
    JsonSerializer[RegisterMapping],
    JsonSerializer[MappingRegistered],
    JsonSerializer[LoadMapping.type],
    JsonSerializer[UnregisterMapping.type],
    JsonSerializer[MappingUnregistered.type]
  )
} 
开发者ID:ytaras,项目名称:iot_lagom_poc,代码行数:56,代码来源:MappingLoader.scala


示例15: UserApplication

//设置package包名称以及导入依赖的类
package com.grossbit.user.impl

import com.lightbend.lagom.scaladsl.api.ServiceLocator
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.persistence.cassandra.CassandraPersistenceComponents
import com.lightbend.lagom.scaladsl.server._
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import play.api.libs.ws.ahc.AhcWSComponents
import com.grossbit.user.api.{ResponseDone, User, UserService}
import com.grossbit.user.impl.UserEntity
import com.grossbit.user.impl.persistance.Command.{CreateUser, UpdateUser}
import com.grossbit.user.impl.persistance.state.UserState
import com.lightbend.lagom.scaladsl.playjson
import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import com.softwaremill.macwire._

import scala.collection.immutable.Seq


abstract class UserApplication(context: LagomApplicationContext)
  extends LagomApplication(context)
    with CassandraPersistenceComponents
    with AhcWSComponents {

  // Bind the service that this server provides
  override lazy val lagomServer = serverFor[UserService](wire[UserServiceImpl])

  // Register the JSON serializer registry
  override lazy val jsonSerializerRegistry = UserSerializerRegistry

  // Register the User persistent entity
  persistentEntityRegistry.register(wire[UserEntity])
}

class UserLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext): LagomApplication =
    new UserApplication(context) {
      override def serviceLocator: ServiceLocator = NoServiceLocator
    }

  override def loadDevMode(context: LagomApplicationContext): LagomApplication =
    new UserApplication(context) with LagomDevModeComponents

  override def describeServices = List(
    readDescriptor[UserService]
  )
}



object UserSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq(
    JsonSerializer[UserState],
    JsonSerializer[User],
    JsonSerializer[CreateUser],
    JsonSerializer[UpdateUser],
    JsonSerializer[List[User]],
    JsonSerializer[ResponseDone]
  )
} 
开发者ID:sarathraj-coder,项目名称:lagommicroapp,代码行数:62,代码来源:UserLoader.scala


示例16: BiddingSerializerRegistry

//设置package包名称以及导入依赖的类
package com.example.auction.bidding.impl

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializerRegistry, JsonSerializer}

import scala.collection.immutable.Seq

object BiddingSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq(
    // State
    JsonSerializer[AuctionState],
    // Commands and replies
    JsonSerializer[GetAuction.type],
    JsonSerializer[StartAuction],
    JsonSerializer[PlaceBid],
    JsonSerializer[PlaceBidResult],
    JsonSerializer[FinishBidding.type],
    JsonSerializer[CancelAuction.type],
    // Events
    JsonSerializer[AuctionStarted],
    JsonSerializer[BidPlaced],
    JsonSerializer[BiddingFinished.type],
    JsonSerializer[AuctionCancelled.type]
  )
} 
开发者ID:lagom,项目名称:online-auction-scala,代码行数:25,代码来源:BiddingSerializerRegistry.scala


示例17: ItemSerializerRegistry

//设置package包名称以及导入依赖的类
package com.example.auction.item.impl

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializerRegistry, JsonSerializer}

object ItemSerializerRegistry extends JsonSerializerRegistry {
  override def serializers = List(
    JsonSerializer[Item],

    JsonSerializer[CreateItem],
    JsonSerializer[StartAuction],
    JsonSerializer[UpdatePrice],
    JsonSerializer[FinishAuction],
    JsonSerializer[GetItem.type],

    JsonSerializer[ItemCreated],
    JsonSerializer[AuctionStarted],
    JsonSerializer[PriceUpdated],
    JsonSerializer[AuctionFinished]
  )
} 
开发者ID:lagom,项目名称:online-auction-scala,代码行数:21,代码来源:ItemSerializerRegistry.scala


示例18: ShoppingListSerializerRegistry

//设置package包名称以及导入依赖的类
package uk.co.turingatemyhamster.shoppinglist.shoppinglist.impl

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}

import scala.collection.immutable


object ShoppingListSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: immutable.Seq[JsonSerializer[_]] = immutable.Seq(
    JsonSerializer[CreateList],
    JsonSerializer[GetList],
    JsonSerializer[ShareList],
    JsonSerializer[AddItem],
    JsonSerializer[ListCreated],
    JsonSerializer[ListShared],
    JsonSerializer[ItemAdded],
    JsonSerializer[ShoppingListState],
    JsonSerializer[ShoppingListAndShares]
  )
} 
开发者ID:drdozer,项目名称:shoppinglist,代码行数:21,代码来源:ShoppingListSerializerRegistry.scala


示例19: UserSerializerRegistry

//设置package包名称以及导入依赖的类
package uk.co.turingatemyhamster.shoppinglist.user.impl

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import uk.co.turingatemyhamster.shoppinglist.user.api.{EmailAddress, FriendId, User, UserFriends}

import scala.collection.immutable


object UserSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: immutable.Seq[JsonSerializer[_]] = immutable.Seq(
    JsonSerializer[UserState],
    JsonSerializer[UserWithFriends],
    JsonSerializer[EmailAddress],
    JsonSerializer[User],
    JsonSerializer[UserFriends],
    JsonSerializer[FriendId],
    JsonSerializer[UserCreated],
    JsonSerializer[FriendAdded],
    JsonSerializer[CreateUser],
    JsonSerializer[GetUser],
    JsonSerializer[AddFriend],
    JsonSerializer[ListFriends]
  )
} 
开发者ID:drdozer,项目名称:shoppinglist,代码行数:25,代码来源:UserSerializerRegistry.scala


示例20: ClientSerializerRegistry

//设置package包名称以及导入依赖的类
package com.packt.chapter11.trip.impl

import com.lightbend.lagom.scaladsl.playjson.{JsonSerializer, JsonSerializerRegistry}
import scala.collection.immutable.Seq

object ClientSerializerRegistry extends JsonSerializerRegistry {
  override def serializers: Seq[JsonSerializer[_]] = Seq(
    JsonSerializer[Location],
    JsonSerializer[ClientState],
    JsonSerializer[TripStarted],
    JsonSerializer[TripEnded],
    JsonSerializer[LocationAdded],
    JsonSerializer[AddLocation]
  )
} 
开发者ID:PacktPublishing,项目名称:Akka-Cookbook,代码行数:16,代码来源:ClientSerializerRegistry.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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