本文整理汇总了Scala中com.google.inject.AbstractModule类的典型用法代码示例。如果您正苦于以下问题:Scala AbstractModule类的具体用法?Scala AbstractModule怎么用?Scala AbstractModule使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractModule类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services.{ApplicationTimer, AtomicCounter, Counter}
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton()
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
}
}
开发者ID:cristianospsp,项目名称:argentum-scala-play,代码行数:20,代码来源:Module.scala
示例2: Module
//设置package包名称以及导入依赖的类
import java.util.function.Function
import akka.actor.ActorRef
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import com.google.inject.util.Providers
import controllers.{DefaultKnolxControllerComponents, KnolxControllerComponents}
import net.codingwell.scalaguice.ScalaModule
import play.libs.Akka
import schedulers.SessionsScheduler
class Module extends AbstractModule with ScalaModule {
override def configure(): Unit = {
bind[ActorRef]
.annotatedWith(Names.named("SessionsScheduler"))
.toProvider(Providers.guicify(Akka.providerOf(classOf[SessionsScheduler], "SessionsScheduler", Function.identity())))
.asEagerSingleton
bind(classOf[KnolxControllerComponents])
.to(classOf[DefaultKnolxControllerComponents])
.asEagerSingleton()
}
}
开发者ID:knoldus,项目名称:knolx-portal,代码行数:26,代码来源:Module.scala
示例3: NoopTracerModule
//设置package包名称以及导入依赖的类
package di
import javax.inject.{Named, Singleton}
import com.google.inject.{AbstractModule, Provides}
import io.opentracing.{NoopTracerFactory, Tracer}
class NoopTracerModule extends AbstractModule {
def configure() = {
}
@Provides
@Singleton
@Named("backend")
def tracer(): Tracer = {
return NoopTracerFactory.create()
}
}
开发者ID:davidB,项目名称:sandbox_context_scala,代码行数:19,代码来源:NoopTracerModule.scala
示例4: Module
//设置package包名称以及导入依赖的类
import javax.inject._
import com.google.inject.AbstractModule
import net.codingwell.scalaguice.ScalaModule
import play.api.{Configuration, Environment}
import jobs._
import models.daos._
import models.services._
class Module(environment: Environment, configuration: Configuration)
extends AbstractModule
with ScalaModule {
override def configure() = {
bind[UserDAO].to[UserDAOImpl]
bind[ClassroomDAO].to[ClassroomDAOImpl]
bind[UserService].to[UserServiceImpl]
bind[ClassroomService].to[ClassroomServiceImpl]
bind[Startup].asEagerSingleton()
}
}
开发者ID:yoo-haemin,项目名称:hufs-classroom,代码行数:26,代码来源:Module.scala
示例5: Module
//设置package包名称以及导入依赖的类
import java.time.Clock
import com.google.inject.AbstractModule
import services.ApplicationTimer
import foo.services.{Counter, AtomicCounter}
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton()
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
}
}
开发者ID:mikegehard,项目名称:intellijSbtComponentTroubles,代码行数:21,代码来源:Module.scala
示例6: CtxBasicModule
//设置package包名称以及导入依赖的类
package context.di
import javax.inject.Singleton
import com.google.inject.{AbstractModule, Provides}
import context.propagation.threadlocal.CurrentCtxLocalThread
import context.{CtxFactory, CtxFactorySpanOnly, CurrentCtx}
class CtxBasicModule extends AbstractModule {
def configure() = {
bind(classOf[CtxFactory]).to(classOf[CtxFactorySpanOnly]).asEagerSingleton()
}
@Provides
@Singleton
def currentCtx(): CurrentCtx = {
CurrentCtx.instance = CurrentCtxLocalThread.instance
CurrentCtx.instance
}
}
开发者ID:davidB,项目名称:sandbox_context_scala,代码行数:22,代码来源:CtxBasicModule.scala
示例7: HawkularModule
//设置package包名称以及导入依赖的类
package di
import javax.inject.{Named, Singleton}
import com.google.inject.{AbstractModule, Provides}
import io.opentracing.Tracer
import org.hawkular.apm.api.utils.PropertyUtil
import org.hawkular.apm.client.api.recorder.BatchTraceRecorder.BatchTraceRecorderBuilder
import org.hawkular.apm.client.api.recorder.TraceRecorder
import org.hawkular.apm.client.api.recorder.BatchTraceRecorder
import org.hawkular.apm.trace.publisher.rest.client.TracePublisherRESTClient
class HawkularModule extends AbstractModule {
def configure() = {
}
//Hawkular seems to failed to load TracePublisher via ServiceLoader, so Made a explicit
@Provides
@Singleton
@Named("backend")
def traceRecorder(): TraceRecorder = {
val publisher = new TracePublisherRESTClient(
PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_USERNAME, "jdoe"),
PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_PASSWORD, "password"),
PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_URI, "http://localhost:8080")
)
val builder = new BatchTraceRecorderBuilder()
builder.withTracePublisher(publisher)
Option(PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHSIZE)).foreach { batchSize =>
builder.withBatchSize(Integer.parseInt(batchSize))
}
Option(PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHTIME)).foreach { batchTime =>
builder.withBatchTime(Integer.parseInt(batchTime))
}
Option(PropertyUtil.getProperty(PropertyUtil.HAWKULAR_APM_COLLECTOR_BATCHTHREADS)).foreach { threadPoolSize =>
builder.withBatchPoolSize(Integer.parseInt(threadPoolSize))
}
builder.withTenantId(PropertyUtil.getProperty("HAWKULAR_APM_TENANTID"))
new BatchTraceRecorder(builder)
}
@Provides
@Singleton
def tracer(traceRecorder: TraceRecorder): Tracer = {
val tracer0 = new org.hawkular.apm.client.opentracing.APMTracer(traceRecorder)
//GlobalTracer.register(tracer0)
//GlobalTracer.get()
tracer0
}
}
开发者ID:davidB,项目名称:sandbox_context_scala,代码行数:53,代码来源:HawkularModule.scala
示例8: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services._
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton()
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
bind(classOf[AdminCredentialsService]).to(classOf[DbAdminCredentialService])
}
}
开发者ID:morpheby,项目名称:ntcu-control-server,代码行数:22,代码来源:Module.scala
示例9: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services.{ApplicationTimer, AtomicCounter, Counter}
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
}
}
开发者ID:mendelmiranda,项目名称:play-scala-crud,代码行数:20,代码来源:Module.scala
示例10: SevenStepsModule
//设置package包名称以及导入依赖的类
package de.htwg.se.SevenSteps
import com.google.inject.AbstractModule
import com.google.inject.assistedinject.FactoryModuleBuilder
import de.htwg.se.SevenSteps.controller.IController
import de.htwg.se.SevenSteps.model.bag.IBag
import de.htwg.se.SevenSteps.model.fileIO.IFileIO
import de.htwg.se.SevenSteps.model.grid.{IGrid, IGridFactory}
import de.htwg.se.SevenSteps.model.player.IPlayers
import de.htwg.se.SevenSteps.model.{bag, fileIO, grid, player}
import net.codingwell.scalaguice.ScalaModule
class SevenStepsModule extends AbstractModule with ScalaModule {
override def configure(): Unit = {
bind[IPlayers].to[player.basicImpl.Players]
bind[IBag].to[bag.basicImpl.Bag]
bind[IController].to[controller.basicImpl.Controller]
bind[IFileIO].to[fileIO.json.Json]
install(new FactoryModuleBuilder()
.implement(classOf[IGrid], classOf[grid.basicImpl.Grid])
.build(classOf[IGridFactory]))
}
}
开发者ID:GrimmT,项目名称:de.htwg.se.SevenSteps,代码行数:24,代码来源:SevenStepsModule.scala
示例11: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services._
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton()
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
bind(classOf[BikeDataReader]).to(classOf[BikeDataReaderImpl])
}
}
开发者ID:fandfisf,项目名称:chicago-cycles,代码行数:21,代码来源:Module.scala
示例12: Actors
//设置package包名称以及导入依赖的类
package modules
import actors.StatisticsProvider
import akka.actor.ActorSystem
import com.google.inject.{AbstractModule, Inject}
import play.api.Configuration
import play.api.libs.ws.WSClient
class Actors @Inject() (system: ActorSystem, ws: WSClient, config: Configuration) extends ApplicationActors {
system.actorOf(
props = StatisticsProvider.props.(ws, config).withDispatcher("control-aware-dispatcher"),
name = "statisticProvider"
)
}
trait ApplicationActors
class ActorsModule extends AbstractModule {
override def configure(): Unit = {
bind(classOf[ApplicationActors]).to(classOf[Actors]).asEagerSingleton
}
}
开发者ID:jborkowski,项目名称:twitter-analytics-service,代码行数:23,代码来源:Actors.scala
示例13: Actors
//设置package包名称以及导入依赖的类
package modules
import javax.inject._
import actors.StatisticsProvider
import akka.actor.ActorSystem
import com.google.inject.AbstractModule
class Actors @Inject()(system: ActorSystem) extends ApplicationActors {
system.actorOf(
props = StatisticsProvider.props.withDispatcher("control-aware-dispatvcher"),
name = "statisticsProvider"
)
}
trait ApplicationActors
class ActorsModule extends AbstractModule {
override def configure(): Unit = {
bind(classOf[ApplicationActors])
.to(classOf[Actors]).asEagerSingleton
}
}
开发者ID:chibariyo,项目名称:twitter-service,代码行数:24,代码来源:Actors.scala
示例14: 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
示例15: 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
示例16: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services.{ApplicationTimer, AtomicCounter, Counter}
@SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements"))
class Module extends AbstractModule {
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
bind(classOf[ApplicationTimer]).asEagerSingleton()
// Set AtomicCounter as the implementation for Counter.
bind(classOf[Counter]).to(classOf[AtomicCounter])
()
}
}
开发者ID:digital-wonderland,项目名称:play-webpack-typescript-react,代码行数:23,代码来源:Module.scala
示例17: AppDependencyModule
//设置package包名称以及导入依赖的类
package modules
import com.google.inject.name.Named
import com.google.inject.{AbstractModule, Singleton, Provides}
import com.redis.RedisClientPool
import infrastructures.SomeModelDAO
import play.api.Configuration
import services.SomeModelStore
class AppDependencyModule extends AbstractModule {
override def configure(): Unit = {
bind(classOf[SomeModelStore]).to(classOf[SomeModelDAO])
}
@Provides
@Singleton
@Named("some_model")
def provideStoreDetailRedisClientPool(
configuration: Configuration
): RedisClientPool = new RedisClientPool(
configuration.getString("redis.host").get,
configuration.getInt("redis.port").get,
database = 1
)
}
开发者ID:UsrNameu1,项目名称:RedisDISample,代码行数:28,代码来源:AppDependencyModule.scala
示例18: 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
示例19: Module
//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import java.time.Clock
import services.dummytracks.InitDummyTracks
class Module extends AbstractModule {
// the Guice-DSL use something like the builder patter and doesn't return Unit
@SuppressWarnings(Array("org.wartremover.warts.NonUnitStatements"))
override def configure() = {
// Use the system clock as the default implementation of Clock
bind(classOf[Clock]).toInstance(Clock.systemDefaultZone)
// Ask Guice to create an instance of ApplicationTimer when the
// application starts.
//Ask Guice to create an instance of InitDummyTracks when application starts
bind(classOf[InitDummyTracks]).asEagerSingleton()
}
}
开发者ID:shiptrail,项目名称:be-be-main,代码行数:21,代码来源:Module.scala
示例20: Module
//设置package包名称以及导入依赖的类
package lumen
import com.google.inject.AbstractModule
import play.{Configuration, Environment}
class Module(environment: Environment, configuration: Configuration) extends AbstractModule {
override def configure() = {
// bind Config
val bindingClassName = configuration.getString("lumen.config")
if(bindingClassName != null) {
val bindingClass: Class[_ <: Config] =
environment.classLoader.loadClass(bindingClassName)
.asSubclass(classOf[Config])
bind(classOf[Config])
.to(bindingClass)
} else {
bind(classOf[Config])
.to(classOf[DefaultConfig])
}
}
}
开发者ID:codeforkjeff,项目名称:lumen,代码行数:26,代码来源:Module.scala
注:本文中的com.google.inject.AbstractModule类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论