本文整理汇总了Scala中com.google.inject.Injector类的典型用法代码示例。如果您正苦于以下问题:Scala Injector类的具体用法?Scala Injector怎么用?Scala Injector使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Injector类的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: ActorSystemProvider
//设置package包名称以及导入依赖的类
package com.franklevering.banking.infrastructure.dependencyinjection.modules
import akka.actor.ActorSystem
import com.franklevering.banking.infrastructure.dependencyinjection.extension.GuiceAkkaExtension
import com.google.inject.{AbstractModule, Inject, Injector, Provider}
import net.codingwell.scalaguice.ScalaModule
class ActorSystemProvider @Inject() (val injector:Injector) extends Provider[ActorSystem] {
override def get(): ActorSystem = {
val system = ActorSystem("banking-context")
GuiceAkkaExtension(system).initialize(injector)
system
}
}
class AkkaModule extends AbstractModule with ScalaModule {
override def configure(): Unit = {
bind[ActorSystem].toProvider[ActorSystemProvider].asEagerSingleton()
}
}
开发者ID:frankieleef,项目名称:banking,代码行数:20,代码来源:AkkaModule.scala
示例2: ServiceInjector
//设置package包名称以及导入依赖的类
package com.nulabinc.backlog.migration.common.modules
import com.google.inject.{AbstractModule, Guice, Injector}
import com.nulabinc.backlog.migration.common.conf.{BacklogApiConfiguration, BacklogPaths}
import com.nulabinc.backlog.migration.common.service._
import com.nulabinc.backlog4j.conf.BacklogPackageConfigure
import com.nulabinc.backlog4j.{BacklogClient, BacklogClientFactory}
object ServiceInjector {
def createInjector(apiConfig: BacklogApiConfiguration): Injector = {
Guice.createInjector(new AbstractModule() {
override def configure(): Unit = {
val backlogPackageConfigure = new BacklogPackageConfigure(apiConfig.url)
val configure = backlogPackageConfigure.apiKey(apiConfig.key)
val backlog = new BacklogClientFactory(configure).newClient()
bind(classOf[BacklogClient]).toInstance(backlog)
bind(classOf[ProjectService]).to(classOf[ProjectServiceImpl])
bind(classOf[SpaceService]).to(classOf[SpaceServiceImpl])
bind(classOf[UserService]).to(classOf[UserServiceImpl])
bind(classOf[StatusService]).to(classOf[StatusServiceImpl])
bind(classOf[PriorityService]).to(classOf[PriorityServiceImpl])
bind(classOf[BacklogPaths]).toInstance(new BacklogPaths(apiConfig.projectKey))
}
})
}
}
开发者ID:nulab,项目名称:backlog-migration-common,代码行数:31,代码来源:ServiceInjector.scala
示例3: AkkaModule
//设置package包名称以及导入依赖的类
package com.nulabinc.backlog.migration.common.modules
import javax.inject.Inject
import akka.actor.ActorSystem
import com.google.inject.{AbstractModule, Injector, Provider}
import com.nulabinc.backlog.migration.common.modules.akkaguice.GuiceAkkaExtension
import com.nulabinc.backlog.migration.common.modules.AkkaModule.ActorSystemProvider
import com.typesafe.config.Config
import net.codingwell.scalaguice.ScalaModule
object AkkaModule {
class ActorSystemProvider @Inject()(val config: Config, val injector: Injector) extends Provider[ActorSystem] {
override def get() = {
val system = ActorSystem.apply("main-actor-system", config)
// add the GuiceAkkaExtension to the system, and initialize it with the Guice injector
GuiceAkkaExtension(system).initialize(injector)
system
}
}
}
class AkkaModule extends AbstractModule with ScalaModule {
override def configure() {
bind[ActorSystem].toProvider[ActorSystemProvider].asEagerSingleton()
}
}
开发者ID:nulab,项目名称:backlog-migration-common,代码行数:33,代码来源:AkkaModule.scala
示例4: SimpleTest
//设置package包名称以及导入依赖的类
package util
import java.io.File
import com.google.inject.{Guice, Injector}
import modules.{GCloudDataModule, LocalDataModule}
import org.scalatest.FlatSpec
class SimpleTest extends FlatSpec {
// val injector: Injector = Guice.createInjector(new LocalDataModule)
val injector: Injector = Guice.createInjector(new GCloudDataModule)
val dataRepo: DataRepo = injector.getInstance(classOf[DataRepo])
"LocalDataRepo" should "return the correct number of bytes" in {
val data = dataRepo.read("data/classic-rock-raw-data.csv")
val size = data.length
println(s"Size of file is $size")
}
it should "return write the correct number of bytes" in {
val data = dataRepo.read("data/classic-rock-raw-data.csv")
val originalSize = data.length
val outputPath = "data/out"
dataRepo.write(data, outputPath)
val writtenSize = new File(outputPath).length
println(s"Original size vs written size: $originalSize vs $writtenSize")
}
it should "write the correct delimiter" in {
val data = List(List(1, 2, 3), List(4, 5, 6))
dataRepo.writeCsv(data, "data/out.csv", delimiter = '+')
}
it should "read the correct delimiter" in {
println(dataRepo.readCsv("data/out.csv"))
println(dataRepo.readCsv("data/out.csv", delimiter = '+'))
}
it should "read the correct number of lines" in {
assertResult(6513) {
dataRepo.readLines("data/agaricus.txt.train").length
}
}
}
开发者ID:davidheryanto,项目名称:play-with-guice-in-scala-crude-example,代码行数:46,代码来源:SimpleTest.scala
示例5: GuiceAkkaExtensionImpl
//设置package包名称以及导入依赖的类
package io.neons.collector.application.guice.application.akka.actor
import akka.actor._
import com.google.inject.Injector
class GuiceAkkaExtensionImpl extends Extension {
private var injector: Injector = _
def initialize(injector: Injector) = {
this.injector = injector
}
def props(actorName: String) = Props(classOf[GuiceActorProducer], injector, actorName)
}
object GuiceAkkaExtension extends ExtensionId[GuiceAkkaExtensionImpl] with ExtensionIdProvider {
override def createExtension(system: ExtendedActorSystem) = new GuiceAkkaExtensionImpl
override def lookup() = GuiceAkkaExtension
override def get(system: ActorSystem): GuiceAkkaExtensionImpl = super.get(system)
}
trait NamedActor {
def name: String
}
trait GuiceAkkaActorRefProvider {
def propsFor(system: ActorSystem, name: String) = GuiceAkkaExtension(system).props(name)
def provideActorRef(system: ActorSystem, name: String): ActorRef = system.actorOf(propsFor(system, name))
}
开发者ID:NeonsIo,项目名称:collector,代码行数:30,代码来源:GuiceAkkaExtension.scala
示例6: AkkaModule
//设置package包名称以及导入依赖的类
package io.neons.collector.application.guice.application.akka.actor
import javax.inject.Inject
import akka.actor.ActorSystem
import com.google.inject.{AbstractModule, Injector, Provider}
import io.neons.collector.application.guice.application.akka.actor.AkkaModule.ActorSystemProvider
import net.codingwell.scalaguice.ScalaModule
object AkkaModule {
class ActorSystemProvider @Inject()(injector: Injector) extends Provider[ActorSystem] {
override def get = {
val actorSystem = ActorSystem("collector")
GuiceAkkaExtension(actorSystem).initialize(injector)
actorSystem
}
}
}
class AkkaModule extends AbstractModule with ScalaModule {
override def configure(): Unit = {
bind[ActorSystem].toProvider[ActorSystemProvider].asEagerSingleton()
}
}
开发者ID:NeonsIo,项目名称:collector,代码行数:25,代码来源:AkkaModule.scala
示例7: BeamServices
//设置package包名称以及导入依赖的类
package beam.sim
import java.util.concurrent.TimeUnit
import akka.actor.{ActorRef, ActorSystem}
import akka.util.Timeout
import beam.playground.akkaguice.ActorInject
import beam.sim.config.BeamConfig
import beam.agentsim.events.AgentsimEventsBus
import com.google.inject.{Inject, Injector, Singleton}
import glokka.Registry
import org.matsim.api.core.v01.population.Person
import org.matsim.api.core.v01.Id
import org.matsim.core.controler._
import org.matsim.households.Household
import org.matsim.vehicles.Vehicle
import scala.concurrent.duration.FiniteDuration
@Singleton
case class BeamServices @Inject()(protected val injector: Injector) extends ActorInject {
val matsimServices: MatsimServices = injector.getInstance(classOf[MatsimServices])
val bbox: BoundingBox = new BoundingBox()
val controler: ControlerI = injector.getInstance(classOf[ControlerI])
var beamConfig: BeamConfig = injector.getInstance(classOf[BeamConfig])
val agentSimEventsBus = new AgentsimEventsBus
val registry: ActorRef = Registry.start(injector.getInstance(classOf[ActorSystem]), "actor-registry")
//TODO find a better way to inject the router, for now this is initilized inside Agentsim.notifyStartup
var beamRouter : ActorRef = _
var physSim: ActorRef = _
var schedulerRef: ActorRef =_
var taxiManager: ActorRef = _
var persons: Map[Id[Person], Person] = Map()
var vehicles: Map[Id[Vehicle], Vehicle] = Map()
var households : Map[Id[Household], Household] = Map()
}
object BeamServices {
implicit val askTimeout = Timeout(FiniteDuration(5L, TimeUnit.SECONDS))
}
开发者ID:LBNL-UCB-STI,项目名称:beam,代码行数:44,代码来源:BeamServices.scala
示例8: BeamAgentModule
//设置package包名称以及导入依赖的类
package beam.sim.modules
import akka.actor.ActorSystem
import beam.playground.akkaguice.{AkkaGuiceSupport, GuiceAkkaExtension}
import beam.sim.BeamServices
import beam.sim.modules.BeamAgentModule.ActorSystemProvider
import com.google.inject.{AbstractModule, Inject, Injector, Provider}
import com.typesafe.config.Config
import net.codingwell.scalaguice.ScalaModule
import org.slf4j.{Logger, LoggerFactory}
object BeamAgentModule {
private val logger: Logger = LoggerFactory.getLogger(classOf[BeamAgentModule])
class ActorSystemProvider @Inject()(val injector: Injector, config: Config) extends Provider[ActorSystem] {
override def get(): ActorSystem = {
val system = ActorSystem("beam-actor-system", config)
// add the GuiceAkkaExtension to the system, and initialize it with the Guice injector
GuiceAkkaExtension(system).initialize(injector)
system
}
}
}
class BeamAgentModule extends AbstractModule with AkkaGuiceSupport with ScalaModule {
override def configure(): Unit = {
bind[ActorSystem].toProvider[ActorSystemProvider].asEagerSingleton()
bind[BeamServices].asEagerSingleton()
// bind[BeamAgentScheduler].asEagerSingleton()
}
}
开发者ID:LBNL-UCB-STI,项目名称:beam,代码行数:34,代码来源:BeamAgentModule.scala
示例9: ClusterManagerBoot
//设置package包名称以及导入依赖的类
package org.scardiecat.styx.clustermanager.main
import akka.actor.ActorSystem
import com.google.inject.{Guice, Injector}
import com.typesafe.config.{ConfigFactory, Config}
import org.scardiecat.styx.DockerAkkaUtils
import org.scardiecat.styx.akkaguice.AkkaModule
import org.scardiecat.styx.clustermanager.di.ConfigModule
import org.scardiecat.styx.clustermanager.service.ClusterManagerService
import org.scardiecat.styx.utils.commandline.CommandlineParser
import net.codingwell.scalaguice.InjectorExtensions._
import akka.http.scaladsl.Http
import akka.stream.ActorMaterializer
import akka.actor.ActorSystem
import org.scradiecat.styx.clustermanager.membership.{MemberManagement, ClusterManagerInventory}
object ClusterManagerBoot extends App {
val fallbackConfig:Config = ConfigFactory.load()
var commandline = CommandlineParser.parse(args,meta.BuildInfo.name+":"+meta.BuildInfo.version, fallbackConfig, Seq[String]("cluster-manager"))
val hostAddress: String = java.net.InetAddress.getLocalHost.getHostAddress
lazy val actorSystemName:String = commandline.actorSystemName
val config: Config = DockerAkkaUtils.dockerAkkaConfigProvider(fallbackConfig,hostAddress,commandline)
val confModule = new ConfigModule(config, actorSystemName)
val akkaModule = new AkkaModule()
val injector: Injector = Guice.createInjector(confModule,akkaModule)
implicit val system = injector.instance[ActorSystem]
implicit val executionContext = system.dispatcher
implicit val materializer = ActorMaterializer()
// register actor
val monitorActor = system.actorOf(ClusterManagerInventory.props(), "ClusterManagerInventory")
val managerActor = system.actorOf(MemberManagement.props(), "MemberManagement")
//
// override val config = ConfigFactory.load()
// override val logger = Logging(system, getClass)
Http().bindAndHandle(ClusterManagerService.ClusterRoute(monitorActor, managerActor), config.getString("http.interface"), config.getInt("http.port"))
}
开发者ID:Scardiecat,项目名称:styx-cluster-manager,代码行数:46,代码来源:ClusterManagerBoot.scala
示例10: AkkaModule
//设置package包名称以及导入依赖的类
package play.modules.io.joaovasques.playspark.akkaguice
import akka.actor.ActorSystem
import play.modules.io.joaovasques.playspark.akkaguice.AkkaModule.ActorSystemProvider
import com.google.inject.{AbstractModule, Injector, Provider}
import com.typesafe.config.Config
import net.codingwell.scalaguice.ScalaModule
import javax.inject.Inject
object AkkaModule {
class ActorSystemProvider @Inject() (val config: Config, val injector: Injector) extends Provider[ActorSystem] {
override def get() = {
val system = ActorSystem("play-spark-main-actor-system", config)
// add the GuiceAkkaExtension to the system, and initialize it with the Guice injector
GuiceAkkaExtension(system).initialize(injector)
system
}
}
}
class AkkaModule extends AbstractModule with ScalaModule {
override def configure() {
bind[ActorSystem].toProvider[ActorSystemProvider].asEagerSingleton()
}
}
开发者ID:zqhxuyuan,项目名称:first-player,代码行数:28,代码来源:AkkaModule.scala
示例11: YoutubeSyncAcceptanceTest
//设置package包名称以及导入依赖的类
package com.gmadorell.youtube_sync.infrastructure.acceptance
import scala.concurrent.duration._
import com.gmadorell.bus.domain.event.EventBus
import com.gmadorell.youtube_sync.infrastructure.configuration.YoutubeSyncConfiguration
import com.gmadorell.youtube_sync.infrastructure.dependency_injection.YoutubeSyncGuiceModule
import com.gmadorell.youtube_sync.module.youtube.domain.PlayListVideoRepository
import com.google.inject.{Guice, Injector}
import net.codingwell.scalaguice.ScalaModule
import net.codingwell.scalaguice.InjectorExtensions._
import org.scalatest.{Matchers, WordSpec}
import org.scalatest.concurrent.ScalaFutures
abstract class YoutubeSyncAcceptanceTest extends AcceptanceTest {
override def baseModule: ScalaModule = new YoutubeSyncGuiceModule
override implicit def patienceConfig: PatienceConfig = PatienceConfig(10.seconds)
def configuration(implicit injector: Injector): YoutubeSyncConfiguration =
injector.instance[YoutubeSyncConfiguration]
def eventBus(implicit injector: Injector): EventBus = injector.instance[EventBus]
def playListVideoRepository(implicit injector: Injector): PlayListVideoRepository =
injector.instance[PlayListVideoRepository]
}
abstract class AcceptanceTest extends WordSpec with ScalaFutures with Matchers {
type TestResult = Unit
type Test = Injector => TestResult
def baseModule: ScalaModule
def runWithInjector(testToExecute: Test): TestResult =
testToExecute(Guice.createInjector(baseModule))
}
开发者ID:GMadorell,项目名称:youtube_sync,代码行数:36,代码来源:YoutubeSyncAcceptanceTest.scala
示例12: YoutubeSyncIntegrationTest
//设置package包名称以及导入依赖的类
package com.gmadorell.youtube_sync.infrastructure.integration
import com.gmadorell.youtube_sync.infrastructure.dependency_injection.YoutubeSyncGuiceModule
import com.gmadorell.youtube_sync.module.youtube.domain.{PlayListRepository, VideoRepository}
import com.google.inject.{Guice, Injector}
import net.codingwell.scalaguice.ScalaModule
import net.codingwell.scalaguice.InjectorExtensions._
import org.scalatest.{Matchers, WordSpec}
import org.scalatest.concurrent.ScalaFutures
import scala.concurrent.duration._
import com.gmadorell.youtube_sync.infrastructure.configuration.YoutubeSyncConfiguration
abstract class YoutubeSyncIntegrationTest extends IntegrationTest {
override def baseModule: ScalaModule = new YoutubeSyncGuiceModule
override implicit def patienceConfig: PatienceConfig = PatienceConfig(10.seconds)
def configuration(implicit injector: Injector): YoutubeSyncConfiguration =
injector.instance[YoutubeSyncConfiguration]
def playListRepository(implicit injector: Injector): PlayListRepository = injector.instance[PlayListRepository]
def videoRepository(implicit injector: Injector): VideoRepository = injector.instance[VideoRepository]
}
abstract class IntegrationTest extends WordSpec with ScalaFutures with Matchers {
type TestResult = Unit
type Test = Injector => TestResult
def baseModule: ScalaModule
def runWithInjector(testToExecute: Test): TestResult =
testToExecute(Guice.createInjector(baseModule))
}
开发者ID:GMadorell,项目名称:youtube_sync,代码行数:34,代码来源:YoutubeSyncIntegrationTest.scala
示例13: DownloadVideosOnVideoFetchedTest
//设置package包名称以及导入依赖的类
package com.gmadorell.youtube_sync.module.youtube.test.acceptance
import com.gmadorell.youtube_sync.infrastructure.acceptance.YoutubeSyncAcceptanceTest
import com.gmadorell.youtube_sync.module.youtube.application.video.VideoFetched
import com.gmadorell.youtube_sync.module.youtube.test.infrastructure.stub._
import com.google.inject.Injector
final class DownloadVideosOnVideoFetchedTest extends YoutubeSyncAcceptanceTest {
"Videos" should {
"be downloaded on video fetched event" in runWithInjector { implicit injector =>
val videoFetched = obtainRandomVideoFetchedEventFromConfiguration()
val playList = PlayListStub.create(id = PlayListIdStub.create(videoFetched.playListId),
name = PlayListNameStub.create(videoFetched.playListName))
val video = VideoStub.create(id = VideoIdStub.create(videoFetched.videoId),
name = VideoNameStub.create(videoFetched.videoName))
playListVideoRepository.exists(playList, video).futureValue shouldBe false
val handleResult = eventBus.handle(videoFetched)
handleResult.isRight shouldBe true
handleResult.right.get.futureValue
playListVideoRepository.exists(playList, video).futureValue shouldBe true
}
}
private def obtainRandomVideoFetchedEventFromConfiguration()(implicit injector: Injector): VideoFetched = {
configuration.test.playLists.flatMap { playListConfiguration =>
playListConfiguration.videos.map(
videoConfig =>
VideoFetchedStub.create(
channelId = configuration.test.dummyChannelId,
playListId = playListConfiguration.playListId,
playListName = playListConfiguration.name,
videoId = videoConfig.videoId,
videoName = videoConfig.videoName
))
}
}.head
}
开发者ID:GMadorell,项目名称:youtube_sync,代码行数:41,代码来源:DownloadVideosOnVideoFetchedTest.scala
示例14: JdbcPersistentEntityRegistry
//设置package包名称以及导入依赖的类
package com.lightbend.lagom.internal.javadsl.persistence.jdbc
import javax.inject.{ Inject, Singleton }
import akka.actor.ActorSystem
import akka.persistence.jdbc.query.scaladsl.JdbcReadJournal
import akka.persistence.query.scaladsl.EventsByTagQuery
import akka.persistence.query.{ NoOffset, PersistenceQuery, Sequence, Offset => AkkaOffset }
import com.google.inject.Injector
import com.lightbend.lagom.internal.javadsl.persistence.AbstractPersistentEntityRegistry
import com.lightbend.lagom.javadsl.persistence.{ Offset, PersistentEntity }
@Singleton
private[lagom] final class JdbcPersistentEntityRegistry @Inject() (system: ActorSystem, injector: Injector, slickProvider: SlickProvider)
extends AbstractPersistentEntityRegistry(system, injector) {
private lazy val ensureTablesCreated = slickProvider.ensureTablesCreated()
override def register[C, E, S](entityClass: Class[_ <: PersistentEntity[C, E, S]]): Unit = {
ensureTablesCreated
super.register(entityClass)
}
override protected val journalId: String = JdbcReadJournal.Identifier
private val jdbcReadJournal = PersistenceQuery(system).readJournalFor[JdbcReadJournal](journalId)
override protected val eventsByTagQuery: Option[EventsByTagQuery] = Some(jdbcReadJournal)
override protected def mapStartingOffset(storedOffset: Offset): AkkaOffset = storedOffset match {
case Offset.NONE => NoOffset
case seq: Offset.Sequence => Sequence(seq.value() + 1)
case other =>
throw new IllegalArgumentException(s"JDBC does not support ${other.getClass.getSimpleName} offsets")
}
}
开发者ID:lagom,项目名称:lagom,代码行数:37,代码来源:JdbcPersistentEntityRegistry.scala
示例15: TuiSpec
//设置package包名称以及导入依赖的类
package de.htwg.se.wills_quest.b_ui
import de.htwg.se.wills_quest.b_ui.impl.Tui
import com.google.inject.{Guice, Injector}
import de.htwg.se.wills_quest.a_WillsQuest.{AttackFactory, PersonFactory}
import de.htwg.se.wills_quest.d_model.impl.JsonParser
import de.htwg.se.wills_quest.c_controller.impl.Controller
import de.htwg.se.wills_quest.d_model.impl.Person
import de.htwg.se.wills_quest.util.WillsQuestInjector
import org.scalatest.{Matchers, WordSpec}
import scala.collection.mutable.ArrayBuffer
class TuiSpec extends WordSpec with Matchers {
val will_pics = Array("Will_combat.png", "Will_auffordern.png", "Will_frozen.png")
val will = PersonFactory("will", "Will", "Default.png", 120, null)
val putzfrau_pics = Array("putzfrau_intro.png", "Putzfrau_Combat.png", "putzfrau_frozen.png")
val putzfrau_attacks = AttackFactory(Map("Mobwirbel" -> 20, "Wischen" -> 10))
val putzfrau = PersonFactory("enemy", "Putzfrau", "Default.png", 120, putzfrau_attacks)
val buecherwurm_pics = Array("Bucherwurm_Intro.png", "Bucherwurm_combat.png", "Buecherwurm_frozen.png")
val buechderwurm_attacks = AttackFactory(Map("Buecherwurf" -> 30, "Klausurvorbereitung" -> 35, "Prüfungsstress" -> 40))
val buecherwurm = PersonFactory("enemy", "Bücherwurm", "Default.png", 120, buechderwurm_attacks)
val bauingenieur_pics = Array("Bauingenieur_Intro.png", "Bauingenieur_combat.png", "Bauingenieur_frozen.png")
val bauingenieur_attacks = AttackFactory(Map("Bellen" -> 20, "Wetttrinken" -> 38))
val bauingenieur = PersonFactory("enemy", "Bauingenieur", "Default.png", 120, bauingenieur_attacks)
val erstsemester_pics = Array("Erstsemester_Intro.png", "Erstsemester_combat.png", "Erstsemester_frozen.png")
val erstsemester_attacks = AttackFactory(Map("Nasepudern" -> 30))
val erstsemester = PersonFactory("enemy", "Erstsemester", "Default.png", 120, erstsemester_attacks)
val professor_pics = Array("Professor_Intro.png", "Professor_combat.png", "Professor_frozen.png")
val professor_attacks = AttackFactory(Map("Laiserpointer" -> 40, "Redetalent" -> 50))
val professor = PersonFactory("enemy", "Professor", "Default.png", 120, professor_attacks)
val persons = new ArrayBuffer[Person]
persons.append(will, putzfrau, buecherwurm, bauingenieur, erstsemester, professor)
val jsonParser = new JsonParser
val injector:Injector = Guice.createInjector(new WillsQuestInjector)
val controller = new Controller(persons, jsonParser, 1, injector)
val tui = new Tui(controller)
"A tui" should {
"have a level" in {
tui.level should be(1)
}
"should be ready" in {
tui.ready should be(true)
}
"can update the observers" in {
tui.update()
tui.level should be(1)
}
"can process an input line" in {
tui.processInputLine("q") should be(false)
}
}
}
开发者ID:SailReal,项目名称:Wills-Quest,代码行数:61,代码来源:TuiSpec.scala
示例16: AkkaModule
//设置package包名称以及导入依赖的类
package uk.ac.wellcome.finatra.modules
import javax.inject.Singleton
import uk.ac.wellcome.utils.GuiceAkkaExtension
import akka.actor.ActorSystem
import com.google.inject.Provides
import com.google.inject.Injector
import com.twitter.inject.{TwitterModule, InjectorModule}
object AkkaModule extends TwitterModule {
override val modules = Seq(InjectorModule)
@Singleton
@Provides
def providesActorSystem(injector: Injector): ActorSystem = {
val system = ActorSystem("main-actor-system")
GuiceAkkaExtension(system).initialize(injector)
system
}
}
开发者ID:wellcometrust,项目名称:platform-api,代码行数:21,代码来源:AkkaModule.scala
示例17: LioquMigrationResolver
//设置package包名称以及导入依赖的类
package com.mysterria.lioqu.db.migration.migrations
import java.util
import com.google.inject.Injector
import com.mysterria.lioqu.db.migration.LioquInjectedMigration
import com.typesafe.scalalogging.LazyLogging
import org.flywaydb.core.api.MigrationType
import org.flywaydb.core.api.migration.MigrationChecksumProvider
import org.flywaydb.core.api.resolver.{BaseMigrationResolver, ResolvedMigration}
import org.flywaydb.core.internal.resolver.ResolvedMigrationImpl
import scala.collection.JavaConverters._
class LioquMigrationResolver(classes: Seq[Class[_ <: LioquInjectedMigration]], injector: Injector) extends BaseMigrationResolver with LazyLogging {
override def resolveMigrations(): util.Collection[ResolvedMigration] = {
logger.debug(s"Got classes: $classes")
val migrations = classes map {t =>
injector.getInstance(t)
}
logger.debug(s"Got migrations: $migrations")
val resolvedMigrations = migrations map { m =>
val checksum: Integer = m match {
case provider: MigrationChecksumProvider => provider.getChecksum
case _ => null
}
val resolvedMigration = new ResolvedMigrationImpl
resolvedMigration.setVersion(m.getVersion)
resolvedMigration.setDescription(m.getDescription)
resolvedMigration.setScript(m.getClass.getName)
resolvedMigration.setChecksum(checksum)
resolvedMigration.setType(MigrationType.CUSTOM)
resolvedMigration.asInstanceOf[ResolvedMigration]
}
resolvedMigrations.asJava
}
}
开发者ID:TLoD-Snake,项目名称:lioqu,代码行数:39,代码来源:LioquMigrationResolver.scala
注:本文中的com.google.inject.Injector类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论