本文整理汇总了Scala中com.google.inject.Guice类的典型用法代码示例。如果您正苦于以下问题:Scala Guice类的具体用法?Scala Guice怎么用?Scala Guice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Guice类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Main
//设置package包名称以及导入依赖的类
import akka.actor.ActorSystem
import akka.event.Logging
import akka.event.Logging.InfoLevel
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import com.google.inject.Guice
import service.documents.{DocumentService, DocumentServiceModule}
import service.health._
object Main extends App with HealthRoutes {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val ec = system.dispatcher
val settings = Settings(system)
val logger = Logging(system, getClass)
private val injector = Guice.createInjector(DocumentServiceModule)
private val docService = injector.getInstance(classOf[DocumentService])
val routes = logRequestResult("", InfoLevel)(docService.docRoutes ~ healthRoutes)
Http().bindAndHandle(routes, settings.Http.interface, settings.Http.port) map { binding =>
logger.info(s"Server started on port {}", binding.localAddress.getPort)
} recoverWith { case _ => system.terminate() }
}
开发者ID:devknutst,项目名称:watermarkAkka,代码行数:30,代码来源:Main.scala
示例2: Application
//设置package包名称以及导入依赖的类
package com.franklevering
import com.franklevering.ports.adapters.http.HttpAdapter
import akka.actor.{ActorSystem, Props}
import akka.stream.ActorMaterializer
import com.franklevering.banking.domain.model.account.AccountRepository
import com.franklevering.banking.infrastructure.dependencyinjection.extension.GuiceAkkaExtension
import com.franklevering.banking.infrastructure.dependencyinjection.modules.{AkkaModule, InfrastructureModule, JournalModule}
import com.franklevering.ports.adapters.journal.{CassandraJournal, EngageStreaming}
import com.google.inject.Guice
import net.codingwell.scalaguice.InjectorExtensions._
object Application {
def main(args: Array[String]): Unit = {
val injector = Guice.createInjector(
new AkkaModule(),
new InfrastructureModule(),
new JournalModule()
)
implicit val system = injector.instance[ActorSystem]
implicit val materializer = ActorMaterializer()
implicit val executionContext = system.dispatcher
system.actorOf(Props(classOf[CassandraJournal], injector.instance[AccountRepository])) ! EngageStreaming()
HttpAdapter.startServer
}
}
开发者ID:frankieleef,项目名称:banking,代码行数:28,代码来源:Application.scala
示例3: injectorModules
//设置package包名称以及导入依赖的类
package global
import actors.ChadashSystem
import com.google.inject.{Guice, Module}
import play.api.mvc.{EssentialAction, Filters}
import play.api.{Application, GlobalSettings, Logger, Mode}
import play.filters.gzip.GzipFilter
import play.filters.headers.SecurityHeadersFilter
trait AppGlobalSettings extends GlobalSettings {
private var INJECTOR: Option[com.google.inject.Injector] = None
def injectorModules(): Seq[Module]
override def onStart(app: Application) {
INJECTOR = Some(Guice.createInjector(injectorModules(): _*))
}
override def onStop(app: Application) {
Logger.info("Application shutdown...")
if(app.mode != Mode.Test)
ChadashSystem.system.shutdown()
}
override def doFilter(next: EssentialAction): EssentialAction = {
Filters(super.doFilter(next), new GzipFilter(), SecurityHeadersFilter())
}
override def getControllerInstance[A](controllerClass: Class[A]): A = {
INJECTOR match {
case Some(x) => x.getInstance(controllerClass)
case None => throw new UnsupportedOperationException("The DI framework has not been setup yet!")
}
}
}
开发者ID:lifeway,项目名称:Chadash,代码行数:37,代码来源:AppGlobalSettings.scala
示例4: SevenSteps
//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps
import com.google.inject.Guice
import de.htwg.se.SevenSteps.aview.gui.SwingGui
import de.htwg.se.SevenSteps.aview.tui._
import de.htwg.se.SevenSteps.controller.IController
import scala.io.StdIn.readLine
object SevenSteps {
def main(args: Array[String]): Unit = {
// val con = FactoryBasic.state.newController
val injector = Guice.createInjector(new SevenStepsModule)
var con = injector.getInstance(classOf[IController])
val tui = new Tui(con)
val gui = new SwingGui(con)
while (tui.processInputLine(readLine())) {}
}
}
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:20,代码来源:SevenSteps.scala
示例5: saveAndLoad
//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps.model.fileIO
import com.google.inject.Guice
import de.htwg.se.SevenSteps.SevenStepsModule
import de.htwg.se.SevenSteps.controller.basicImpl.Controller
import org.scalatest.Matchers._
import org.scalatest._
trait FileIOSpec {
this: WordSpec =>
def saveAndLoad(fileIO: IFileIO): Unit = {
"save & restore the default ControllerState" in {
val c = getController
fileIO.save(c.state)
fileIO.load should be(c.state)
}
"save & restore a complex ControllerState" in {
val c = getController
c.addPlayer("Hans").get.addPlayer("Alex").get
.newGrid("aabb", 2).get.startGame().get
fileIO.save(c.state)
fileIO.load should be(c.state)
}
}
def getController: Controller = {
val injector = Guice.createInjector(new SevenStepsModule)
injector.getInstance(classOf[Controller])
}
}
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:30,代码来源:FileIOSpec.scala
示例6: ControllerStateFinishSpec
//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps.controller.basicImpl
import com.google.inject.Guice
import de.htwg.se.SevenSteps.SevenStepsModule
import de.htwg.se.SevenSteps.model.fileIO.IFileIO
import de.htwg.se.SevenSteps.model.grid.IGridFactory
import de.htwg.se.SevenSteps.model.grid.basicImpl.Grid
import de.htwg.se.SevenSteps.model.player.basicImpl.{Player, Players}
import org.junit.runner.RunWith
import org.scalatest.Matchers.{be, _}
import org.scalatest._
import org.scalatest.junit.JUnitRunner
@RunWith(classOf[JUnitRunner])
class ControllerStateFinishSpec extends WordSpec {
def before(colors: String = "aabb", cols: Int = 2, numPlayers: Int = 3): Controller = {
val injector = Guice.createInjector(new SevenStepsModule)
val c = new Controller(injector.getInstance(classOf[ControllerState]),
injector.getInstance(classOf[IGridFactory]),
injector.getInstance(classOf[IFileIO]))
for (i <- 1 to numPlayers)
c.addPlayer("Hans" + i).isSuccess should be(true)
c.newGrid(colors, cols).isSuccess should be(true)
c.startGame().isSuccess should be(true)
c.state.gameState = Finish()
c
}
"A Controller in game phase finish" should {
"can only use newGame Command and can't undo that" in {
val c=before()
c.nextPlayer().isSuccess should be(false)
c.newGrid(" ", 1).isSuccess should be(false)
c.startGame().isSuccess should be(false)
c.setColor(0, 0, 'z').isSuccess should be(false)
c.setStone(0, 0).isSuccess should be(false)
c.newGame().isSuccess should be(true)
c.undo().isSuccess should be(false)
}
"on command newGame go into state Prepare" in{
val c=before()
c.newGame().isSuccess should be(true)
c.state.gameState.isInstanceOf[Prepare] should be(true)
}
"reset on command newGame all Points from Players and Heights of the grid" in{
val c=before()
c.state.players = new Players().push(Player("Hans", 10, None))
c.state.grid = new Grid("a", 1).set(0, 0, 5)
c.newGame().isSuccess should be(true)
c.state.players should be(new Players().push("Hans"))
c.state.grid should be(new Grid("a", 1))
}
}
}
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:54,代码来源:ControllerStateFinishSpec.scala
示例7: GuiceSpec
//设置package包名称以及导入依赖的类
import com.google.inject.{AbstractModule, Guice}
import org.ababup1192._
import org.scalatest._
class GuiceSpec extends FlatSpec with Matchers {
"GuiceMain" should "have Singleton Instance" in {
val injector = Guice.createInjector(new AbstractModule {
override def configure(): Unit = {}
})
val singletonScope = injector.getInstance(classOf[SingletonScope])
val defaultScope = injector.getInstance(classOf[DefaultScope])
singletonScope.count should ===(1000)
defaultScope.count should ===(100)
singletonScope.count = 9999
defaultScope.count = 999
val singletonScope2 = injector.getInstance(classOf[SingletonScope])
val defaultScope2 = injector.getInstance(classOf[DefaultScope])
singletonScope2.count should ===(9999)
defaultScope2.count should ===(100)
}
}
开发者ID:ababup1192,项目名称:GuiceTutorial,代码行数:27,代码来源:GuiceSpec.scala
示例8: ControllerMock
//设置package包名称以及导入依赖的类
package de.htwg.se.menschaergerdichnicht.controller.controllerComponent.controllerMockImpl
import com.google.inject.Guice
import de.htwg.se.menschaergerdichnicht.MenschAergerDichNichtModule
import de.htwg.se.menschaergerdichnicht.aview.gui.SwingGui
import de.htwg.se.menschaergerdichnicht.aview.tui.Tui
import de.htwg.se.menschaergerdichnicht.controller.controllerComponent.ControllerInterface
import de.htwg.se.menschaergerdichnicht.controller.controllerComponent.GameState._
import de.htwg.se.menschaergerdichnicht.model.fieldComponent.PlayingInterface
import de.htwg.se.menschaergerdichnicht.model.fieldComponent.fieldBaseImpl.PlayingField
import de.htwg.se.menschaergerdichnicht.model.playerComponent.playerBaseImpl.Players
import scala.util.{Success, Try}
case class ControllerMock() extends ControllerInterface{
val injector = Guice.createInjector(new MenschAergerDichNichtModule)
var players = Players()
var playingField = injector.getInstance(classOf[PlayingInterface])
var message = ""
var gameState = FINISHED
def addPlayer(name: String): Try[_] = Success()
def startGame(): Try[_] = Success()
def chooseToken(tokenId: Int): Try[_] = Success()
def gameStatus: GameState = FINISHED
}
开发者ID:svantja,项目名称:MenschAergerDichNicht,代码行数:28,代码来源:ControllerMock.scala
示例9: KanColleAnchorModule
//设置package包名称以及导入依赖的类
package inject
import arcade.{UID, UUID}
import com.google.inject.{AbstractModule, Guice}
import time.{ClockProvider, SystemClockProvider}
trait Injector {
protected val injector = Guice.createInjector(new KanColleAnchorModule)
}
trait UIDInjector extends Injector {
protected val uid = injector.getInstance(classOf[UID])
}
private[inject] class KanColleAnchorModule extends AbstractModule {
override def configure(): Unit = {
bind(classOf[UID]).toInstance(UUID)
bind(classOf[ClockProvider]).toInstance(SystemClockProvider)
}
}
开发者ID:harry0000,项目名称:KancolleAnchor,代码行数:23,代码来源:Injector.scala
示例10: Sudoku
//设置package包名称以及导入依赖的类
package de.htwg.se.sudoku
import com.google.inject.Guice
import de.htwg.se.sudoku.aview.Tui
import de.htwg.se.sudoku.aview.gui.SwingGui
import de.htwg.se.sudoku.controller.controllerComponent.ControllerInterface
import scala.io.StdIn.readLine
object Sudoku {
val injector = Guice.createInjector(new SudokuModule)
val controller = injector.getInstance(classOf[ControllerInterface])
val tui = new Tui(controller)
val gui = new SwingGui(controller)
controller.createNewGrid
def main(args: Array[String]): Unit = {
var input: String = ""
do {
input = readLine()
tui.processInputLine(input)
} while (input != "q")
}
}
开发者ID:markoboger,项目名称:de.htwg.se.SudokuInScala,代码行数:26,代码来源:Sudoku.scala
示例11: 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
示例12: AppInjector
//设置package包名称以及导入依赖的类
package pl.writeonly.babel.mediators
import pl.writeonly.babel.beans.FacadeBean
import com.google.inject.Guice
import com.google.inject.AbstractModule
import pl.writeonly.babel.beans.RecordBean
import com.google.inject.Scopes;
import pl.writeonly.babel.daos.DaoCrud
object AppInjector extends AppLogging {
val injector = Guice.createInjector(new CustomModule())
val facade = injector.getInstance(classOf[FacadeBean])
}
class CustomModule extends AbstractModule {
def configure = {
bind(classOf[RecordBean]).to(classOf[RecordBean]).in(Scopes.SINGLETON);
//bind(classOf[Dao]).to(classOf[DaoJdo]).in(Scopes.SINGLETON);
}
}
开发者ID:writeonly,项目名称:babel,代码行数:22,代码来源:AppInjector.scala
示例13: 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
示例14: 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
示例15: Yooloo
//设置package包名称以及导入依赖的类
package de.htwg.se.yooloo
import com.google.inject.Guice
import de.htwg.se.yooloo.aview.gui.Gui
import de.htwg.se.yooloo.aview.tui.Tui
import de.htwg.se.yooloo.controller.GameStartedEvent
import de.htwg.se.yooloo.controller.Impl.Controller
import de.htwg.se.yooloo.model.Impl.{CardsFactory, PlayerFactory}
object Yooloo {
val amountOfCards = 5
val amountOfMaxPlayers = 4
val injector = Guice.createInjector(new YoolooModule)
val playerFactory = injector.getInstance(classOf[PlayerFactory])
val cardsFactory = injector.getInstance(classOf[CardsFactory])
val controller = new Controller(List((playerFactory).create(null)), playerFactory, cardsFactory, amountOfCards, amountOfMaxPlayers)
val tui = new Tui(controller)
val gui = new Gui(controller)
controller.publish(new GameStartedEvent()) //controller.notifyObserver(GameStartedEvent)
def main(args: Array[String]): Unit = {
var input: String = ""
var continue: Boolean = true
do {
input = scala.io.StdIn.readLine()
tui.processInputLine(input)
} while (continue)
}
}
开发者ID:wurstwasser40k,项目名称:YooLoo_SoftwareEngineering,代码行数:36,代码来源:Yooloo.scala
示例16: 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
示例17: 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
示例18: CassandraReadSideSpec
//设置package包名称以及导入依赖的类
package com.lightbend.lagom.javadsl.persistence.cassandra
import java.util.concurrent.CompletionStage
import com.google.inject.Guice
import com.lightbend.lagom.internal.javadsl.persistence.cassandra.{ CassandraPersistentEntityRegistry, CassandraReadSideImpl, JavadslCassandraOffsetStore }
import com.lightbend.lagom.internal.persistence.ReadSideConfig
import com.lightbend.lagom.internal.persistence.cassandra.CassandraReadSideSettings
import com.lightbend.lagom.javadsl.persistence._
import com.typesafe.config.ConfigFactory
import scala.concurrent.duration._
object CassandraReadSideSpec {
val defaultConfig = ConfigFactory.parseString("akka.loglevel = INFO")
val noAutoCreateConfig = ConfigFactory.parseString("lagom.persistence.read-side.cassandra.tables-autocreate = false")
}
class CassandraReadSideSpec extends CassandraPersistenceSpec(CassandraReadSideSpec.defaultConfig) with AbstractReadSideSpec {
import system.dispatcher
private lazy val injector = Guice.createInjector()
override protected lazy val persistentEntityRegistry = new CassandraPersistentEntityRegistry(system, injector)
private lazy val testSession: CassandraSession = new CassandraSession(system)
private lazy val testCasReadSideSettings: CassandraReadSideSettings = new CassandraReadSideSettings(system)
private lazy val offsetStore = new JavadslCassandraOffsetStore(system, testSession, testCasReadSideSettings, ReadSideConfig())
private lazy val cassandraReadSide = new CassandraReadSideImpl(system, testSession, offsetStore, null, injector)
override def processorFactory(): ReadSideProcessor[TestEntity.Evt] =
new TestEntityReadSide.TestEntityReadSideProcessor(cassandraReadSide, testSession)
private lazy val readSide = new TestEntityReadSide(testSession)
override def getAppendCount(id: String): CompletionStage[java.lang.Long] = readSide.getAppendCount(id)
override def afterAll(): Unit = {
persistentEntityRegistry.gracefulShutdown(5.seconds)
super.afterAll()
}
}
class CassandraReadSideAutoCreateSpec extends CassandraPersistenceSpec(CassandraReadSideSpec.noAutoCreateConfig) {
import system.dispatcher
private lazy val testSession: CassandraSession = new CassandraSession(system)
private lazy val testCasReadSideSettings: CassandraReadSideSettings = new CassandraReadSideSettings(system)
private lazy val offsetStore = new JavadslCassandraOffsetStore(system, testSession, testCasReadSideSettings, ReadSideConfig())
"A Cassandra Read-Side" must {
"not send ClusterStartupTask message, so startupTask must return None" +
"when 'lagom.persistence.read-side.cassandra.tables-autocreate' flag is 'false'" in {
offsetStore.startupTask shouldBe None
}
}
}
开发者ID:lagom,项目名称:lagom,代码行数:59,代码来源:CassandraReadSideSpec.scala
示例19: CLI
//设置package包名称以及导入依赖的类
package org.tomahna.scalaresume.cli
import java.io.File
import java.util.ServiceLoader
import scala.io.Source
import org.tomahna.scalaresume.resume.Resume
import org.tomahna.scalaresume.theme.ThemeManager
import com.google.inject.Guice
import com.google.inject.Module
import play.api.libs.json.Json
object CLI {
private val parser = new scopt.OptionParser[Configuration](BuildInfo.name) {
head(BuildInfo.name, BuildInfo.version)
help("help").text("prints this usage text")
arg[File]("inputResume").minOccurs(1).maxOccurs(1)
.action { (x, c) => c.copy(inputResume = x) }
.text("input File")
arg[File]("outputResume").minOccurs(1).maxOccurs(1)
.action { (x, c) => c.copy(outputResume = x) }
.text("output File")
opt[String]('t', "theme")
.action { (x, c) => c.copy(theme = x) }
.text("Theme to use for printing")
}
def main(args: Array[String]): Unit = {
parser.parse(args, Configuration()) match {
case Some(config) => run(config)
case None =>
}
}
def run(configuration: Configuration): Unit = {
val injector = Guice.createInjector(ServiceLoader.load(classOf[Module]))
val themeManager = injector.getInstance(classOf[ThemeManager])
val theme = themeManager.getTheme(configuration.theme)
val input = Source.fromFile(configuration.inputResume, "utf-8").mkString
val resume = Json.parse(input).as[Resume]
theme.outputTex(resume, configuration.outputResume)
}
}
开发者ID:Tomahna,项目名称:scalaresume,代码行数:48,代码来源:CLI.scala
示例20: Main
//设置package包名称以及导入依赖的类
import akka.actor.ActorSystem
import akka.event.Logging
import akka.event.Logging.InfoLevel
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import com.google.inject.Guice
import service.health._
import service.users.{UserService, UserServiceModule}
object Main extends App with HealthRoutes {
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
implicit val ec = system.dispatcher
val settings = Settings(system)
val logger = Logging(system, getClass)
private val injector = Guice.createInjector(UserServiceModule)
private val userService = injector.getInstance(classOf[UserService])
val routes = logRequestResult("", InfoLevel)(userService.userRoutes ~ healthRoutes)
Http().bindAndHandle(routes, settings.Http.interface, settings.Http.port) map { binding =>
logger.info(s"Server started on port {}", binding.localAddress.getPort)
} recoverWith { case _ => system.terminate() }
}
开发者ID:owainlewis,项目名称:activator-akka-http,代码行数:31,代码来源:Main.scala
注:本文中的com.google.inject.Guice类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论