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

Scala BuiltInComponents类代码示例

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

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



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

示例1: ec

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

import akka.actor.ActorSystem
import models.{OrderPlaced, UserRecognized}
import play.api.BuiltInComponents

import scala.concurrent.ExecutionContext

trait DaoModule extends BuiltInComponents {

  import com.softwaremill.macwire.wire
  import com.softwaremill.tagging._

  implicit def ec: ExecutionContext =
    ExecutionContext.global
  implicit def sys: ActorSystem =
    actorSystem

  private def userTopic =
    "users".taggedWith[UserRecognized]
  private def orderTopic = "orders".taggedWith[OrderPlaced]

  lazy val orderDao: EventDao[OrderPlaced] =
    wire[KafkaDao[OrderPlaced]]
  lazy val userDao: EventDao[UserRecognized] =
    wire[KafkaDao[UserRecognized]]
} 
开发者ID:leanovate,项目名称:contoso-conference-manager,代码行数:28,代码来源:DaoModule.scala


示例2: initializeListeners

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

import akka.actor.{ActorRef, Props}
import com.softwaremill.macwire.wire
import config.HomeControllerConfiguration
import model.actuator.impl.ActuatorRepositoryNaive
import mqtt.clown.BridgeListener
import mqtt.watering.{WateringCommander, WateringHelloListener, WateringListener}
import mqtt.{MqttConnector, MqttDispatchingListener, MqttListenerMessage, MqttRepeater}
import play.api.BuiltInComponents


trait MqttConfig extends BuiltInComponents with DaoConfig with ClockConfig {
  lazy val mqttDispatchingListener: MqttDispatchingListener = wire[MqttDispatchingListener]
  lazy val mqttConnector = new MqttConnector(
    HomeControllerConfiguration(
      mqttBrokerUrl = configuration.getString("home_center.mqtt.url").get,
      mqttClientId = configuration.getString("home_center.mqtt.clientId").get
    ),
    mqttDispatchingListener,
    actorSystem
  )
  lazy val wateringCommander = wire[WateringCommander]

  lazy val actuatorRepository: ActuatorRepositoryNaive = wire[ActuatorRepositoryNaive]

  lazy val wateringListener: ActorRef = actorSystem.actorOf(Props(wire[WateringListener]))
  lazy val wateringHelloListener: ActorRef = actorSystem.actorOf(Props(wire[WateringHelloListener]))
  lazy val bcBridgeListenerActor: ActorRef = actorSystem.actorOf(Props(wire[BridgeListener]))
  lazy val mqttRepeaterActor: ActorRef = actorSystem.actorOf(Props(
    new MqttRepeater(
      HomeControllerConfiguration(
        configuration.getString("home_center.mqtt_repeater.url").orNull,
        configuration.getString("home_center.mqtt_repeater.clientId").orNull
      ),
      actorSystem,
      mqttConnector
    )
  ))

  def initializeListeners(): Unit = {
    mqttConnector.reconnect.run()

    bcBridgeListenerActor ! MqttListenerMessage.Ping
    wateringListener ! MqttListenerMessage.Ping
    wateringHelloListener ! MqttListenerMessage.Ping
    mqttRepeaterActor ! MqttListenerMessage.Ping

    mqttDispatchingListener.addListener(bcBridgeListenerActor.path)
    mqttDispatchingListener.addListener(wateringListener.path)
    mqttDispatchingListener.addListener(wateringHelloListener.path)
    mqttDispatchingListener.addListener(mqttRepeaterActor.path)
  }
} 
开发者ID:vavravl1,项目名称:home_center,代码行数:55,代码来源:MqttConfig.scala


示例3: newAppForTest

//设置package包名称以及导入依赖的类
import org.scalatest.{Suite, TestData}
import org.scalatestplus.play.{OneAppPerSuite, OneAppPerTest, OneServerPerSuite, OneServerPerTest}
import play.api.{BuiltInComponents, _}

trait OneAppPerTestWithComponents[T <: BuiltInComponents]
  extends OneAppPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneAppPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneAppPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>
  override implicit lazy val app: Application = newApplication
}

trait OneServerPerTestWithComponents[T <: BuiltInComponents]
  extends OneServerPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneServerPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneServerPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>

  override implicit lazy val app: Application = newApplication
} 
开发者ID:wsargent,项目名称:play-cucumber,代码行数:35,代码来源:ScalaTestWithComponents.scala


示例4: MyApplicationLoader

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

import chat.ChatEngine
import play.api.{ApplicationLoader, BuiltInComponents, BuiltInComponentsFromContext, LoggerConfigurator}
import com.softwaremill.macwire._
import controllers.AssetsComponents
import play.api.inject.DefaultApplicationLifecycle
import play.engineio.EngineIOController
import play.socketio.scaladsl.SocketIOComponents

class MyApplicationLoader extends ApplicationLoader {
  override def load(context: ApplicationLoader.Context) =
    new BuiltInComponentsFromContext(context) with MyApplication {
      LoggerConfigurator.apply(context.environment.classLoader)
        .foreach(_.configure(context.environment))
    }.application
}

trait MyApplication extends BuiltInComponents
  with AssetsComponents
  with SocketIOComponents {

  override def applicationLifecycle: DefaultApplicationLifecycle

  lazy val chatEngine = wire[ChatEngine]
  lazy val engineIOController: EngineIOController = chatEngine.controller

  override lazy val router = {
    val prefix = "/"
    wire[_root_.router.Routes]
  }
  override lazy val httpFilters = Nil
} 
开发者ID:playframework,项目名称:play-socket.io,代码行数:34,代码来源:MyApplicationLoader.scala


示例5: MyApplicationLoader

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

import chat.ChatEngine
import play.api.{ApplicationLoader, BuiltInComponents, BuiltInComponentsFromContext, LoggerConfigurator}
import com.softwaremill.macwire._
import controllers.AssetsComponents
import play.api.inject.DefaultApplicationLifecycle
import play.engineio.{EngineIOComponents, EngineIOController}
import play.socketio.scaladsl.SocketIOComponents

class MyApplicationLoader extends ApplicationLoader {
  override def load(context: ApplicationLoader.Context) =
    new BuiltInComponentsFromContext(context) with MyApplication {
      LoggerConfigurator.apply(context.environment.classLoader)
        .foreach(_.configure(context.environment))
    }.application
}

trait MyApplication extends BuiltInComponents
  with AssetsComponents
  with SocketIOComponents {

  override def applicationLifecycle: DefaultApplicationLifecycle

  lazy val chatEngine = wire[ChatEngine]
  lazy val engineIOController: EngineIOController = chatEngine.controller

  override lazy val router = {
    val prefix = "/"
    wire[_root_.router.Routes]
  }
  override lazy val httpFilters = Nil
} 
开发者ID:playframework,项目名称:play-socket.io,代码行数:34,代码来源:MyApplicationLoader.scala


示例6: components

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

import org.scalatest.TestSuite
import org.scalatestplus.play._
import play.api.{BuiltInComponents, _}
import play.api.ApplicationLoader.Context
import play.api._


trait OneAppPerTestWithComponents[T <: BuiltInComponents]
    extends BaseOneAppPerTest
    with FakeApplicationFactory
    with WithApplicationComponents[T] { this: TestSuite =>
}

trait OneAppPerSuiteWithComponents[T <: BuiltInComponents]
    extends BaseOneAppPerSuite
    with FakeApplicationFactory
    with WithApplicationComponents[T] { this: TestSuite =>
}

trait OneServerPerTestWithComponents[T <: BuiltInComponents]
    extends BaseOneServerPerTest
    with FakeApplicationFactory
    with WithApplicationComponents[T] { this: TestSuite =>

}

trait OneServerPerSuiteWithComponents[T <: BuiltInComponents]
    extends BaseOneServerPerSuite
    with FakeApplicationFactory
    with WithApplicationComponents[T] { this: TestSuite =>

}

trait WithApplicationComponents[T <: BuiltInComponents] {
  private var _components: T = _

  // accessed to get the components in tests
  final def components: T = _components

  // overridden by subclasses
  def createComponents(context: Context): T

  // creates a new application and sets the components
  def fakeApplication(): Application = {
    _components = createComponents(context)
    _components.application
  }

  def context: ApplicationLoader.Context = {
    val classLoader = ApplicationLoader.getClass.getClassLoader
    val env = new Environment(new java.io.File("."), classLoader, Mode.Test)
    ApplicationLoader.createContext(env)
  }
} 
开发者ID:lloydmeta,项目名称:ctdi-play.g8,代码行数:57,代码来源:ScalaTestWithComponents.scala


示例7: components

//设置package包名称以及导入依赖的类
package play.modules.swagger

import play.api.ApplicationLoader.Context
import play.api.inject.ApplicationLifecycle
import play.api.{BuiltInComponents, ApplicationLoader}

import scala.concurrent.Future

trait SwaggerApplicationLoader extends ApplicationLoader {
  def components(context: Context) : BuiltInComponents

  def load(context: Context) = {
    val comp = components(context)
    val application = comp.application
    val life : ApplicationLifecycle = new ApplicationLifecycle() {
      override def addStopHook(hook: () => Future[Unit]): Unit = ()
    }
    new SwaggerPluginImpl(life, comp.router, application)
    application
  }
} 
开发者ID:saifansari1234,项目名称:play-swagger,代码行数:22,代码来源:SwaggerApplicationLoader.scala


示例8: newAppForTest

//设置package包名称以及导入依赖的类
import org.scalatest.{Suite, TestData}
import org.scalatestplus.play._
import play.api.{BuiltInComponents, _}

trait OneAppPerTestWithComponents[T <: BuiltInComponents]
  extends OneAppPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneAppPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneAppPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>
  override implicit lazy val app: Application = newApplication
}

trait OneServerPerTestWithComponents[T <: BuiltInComponents]
  extends OneServerPerTest
    with WithApplicationComponents[T] {
  this: Suite =>

  override def newAppForTest(testData: TestData): Application = newApplication
}

trait OneServerPerSuiteWithComponents[T <: BuiltInComponents]
  extends OneServerPerSuite
    with WithApplicationComponents[T] {
  this: Suite =>

  override implicit lazy val app: Application = newApplication
} 
开发者ID:wsargent,项目名称:slim-play-with-custom-logger,代码行数:35,代码来源:ScalaTestWithComponents.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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