当前位置: 首页>>代码示例>>Scala>>正文


Scala ScalaModule类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: HelloModule

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

import javax.inject._

import com.google.inject.AbstractModule
import domain._
import infra.jdbc._
import net.codingwell.scalaguice.ScalaModule
import scalikejdbc.AutoSession
import support.IOContextProvider


class HelloModule extends AbstractModule with ScalaModule {
  override def configure(): Unit = {
    bindRepository()
    bindIOContext()
  }

  private def bindRepository():Unit = {
    bind[AttendanceApplicationRepository].to[AttendanceApplicationRepositoryOnDB].in[Singleton]
    bind[AttendanceRepository].to[AttendanceRepositoryOnDB].in[Singleton]
    bind[ExtraworkApplicationRepository].to[ExtraworkApplicationRepositoryOnDB].in[Singleton]
    bind[GivenHolidayRepository].to[GivenHolidayRepositoryOnDB].in[Singleton]
    bind[HolidayApplicationRepository].to[HolidayApplicationRepositoryOnDB].in[Singleton]
    bind[OfficeRepository].to[OfficeRepositoryOnDB].in[Singleton]
    bind[OfficialHolidayRepository].to[OfficialHolidayRepositoryOnDB].in[Singleton]
    bind[RestRepository].to[RestRepositoryOnDB].in[Singleton]
    bind[SpaceRepository].to[SpaceRepositoryOnDB].in[Singleton]
    bind[TypetalkRepository].to[TypetalkRepositoryOnDB].in[Singleton]
    bind[UserRepository].to[UserRepositoryOnDB].in[Singleton]
  }

  private def bindIOContext():Unit = {
    bind[IOContextProvider].toInstance(new IOContextProviderOnJDBC(AutoSession))
  }
} 
开发者ID:tockri,项目名称:hello-next,代码行数:37,代码来源:HelloModule.scala

示例7: Module

//设置package包名称以及导入依赖的类
import com.eigenroute.authentication._
import com.eigenroute.id.{UUIDProvider, UUIDProviderImpl}
import com.eigenroute.plumbing.PublisherSubscriber
import com.eigenroute.scalikejdbchelpers.{DBConfig, ScalikeJDBCDevProdDBConfig, ScalikeJDBCSessionProvider, ScalikeJDBCSessionProviderImpl}
import com.eigenroute.time.{TimeProvider, TimeProviderImpl}
import com.google.inject.AbstractModule
import net.codingwell.scalaguice.ScalaModule
import plumbing.messagebroker.MessageBrokerMessageSubscriber


class Module extends AbstractModule with ScalaModule {

  override def configure() = {
    // bind[API].to[Facade]
    bind[TimeProvider].to[TimeProviderImpl]
    bind[UUIDProvider].to[UUIDProviderImpl]
    bind[JWTAlgorithmProvider].to[JWTAlgorithmProviderImpl]
    bind[JWTPublicKeyProvider].to[JWTPublicKeyProviderImpl]
    bind[JWTPrivateKeyProvider].to[JWTPrivateKeyProviderImpl]
    // bind[DAO].to[DAOImpl]
    bind[ScalikeJDBCSessionProvider].to[ScalikeJDBCSessionProviderImpl]
    bind[DBConfig].to[ScalikeJDBCDevProdDBConfig]
    bind[PublisherSubscriber].to[MessageBrokerMessageSubscriber]
  }

} 
开发者ID:shafiquejamal,项目名称:microservice-template-play,代码行数:27,代码来源:Module.scala

示例8: ConsulBot

//设置package包名称以及导入依赖的类
package mm4s.examples.consulbot

import akka.actor.{Actor, ActorLogging, ActorRef}
import akka.stream.ActorMaterializer
import consulq.ConsulQuery
import mm4s.api.{Post, Posted}
import mm4s.bots.api.{Bot, BotID, Ready}
import net.codingwell.scalaguice.ScalaModule



class ConsulBot extends Actor with Bot with ActorLogging {
  import context.dispatcher
  implicit val mat: ActorMaterializer = ActorMaterializer()


  def receive: Receive = {
    case Ready(api, id) => context.become(ready(api, id))
  }

  def ready(api: ActorRef, id: BotID): Receive = {
    import context.system
    log.debug("ConsulBot [{}] ready", id.username)
    api ! Post("ConsulBot ready")

    {
      case Posted(t) if t.startsWith("@consul") =>
        log.debug("{} received {}", self.path.name, t)

        ConsulQuery().services().map { s =>
          s.foldLeft(
            """
              || name | address | port |
              ||------|--------|--------|""".stripMargin) {
            (acc, s) => acc ++ s"\n|${s.name}|${s.address}|${s.port}|"
          }
        }.foreach(api ! Post(_))
    }
  }

  override def preStart(): Unit = {
    log.debug("ConsulBot starting")
  }
}


class ConsulBotModule extends ScalaModule {
  def configure(): Unit = {
    bind[Bot].to[ConsulBot]
  }
}

object ConsulBotBoot4dev extends App {
  mm4s.bots.Boot.main(Array.empty)
} 
开发者ID:jw3,项目名称:mm4s-examples,代码行数:56,代码来源:ConsulBot.scala

示例9: LogSinkModule

//设置package包名称以及导入依赖的类
package io.neons.collector.application.guice.infrastructure.log.sink

import java.util.{Properties, UUID}

import com.google.inject.{AbstractModule, Inject, Provider}
import io.neons.collector.application.config.CollectorConfig
import io.neons.collector.application.guice.infrastructure.log.sink.LogSinkModule.KafkaLogSinkModuleProvider
import io.neons.collector.infrastructure.log.sink.KafkaLogSink
import io.neons.collector.model.log.{Log, LogSink}
import net.codingwell.scalaguice.ScalaModule
import org.apache.kafka.clients.producer.KafkaProducer

object LogSinkModule {
  class KafkaLogSinkModuleProvider @Inject()(collectorConfig: CollectorConfig) extends Provider[KafkaProducer[UUID, Log]] {
    override def get(): KafkaProducer[UUID, Log] = {
      val kafkaConfig = collectorConfig.sink.kafkaSinkConfig
      val properties = new Properties()
      properties.put("bootstrap.servers", kafkaConfig.host.concat(":").concat(kafkaConfig.port.toString))
      properties.put("client.id", kafkaConfig.clientId)
      properties.put("max.block.ms", "5000")
      properties.put("request.timeout.ms", "10000")
      properties.put("acks", "all")
      properties.put("key.serializer", "io.neons.collector.application.guice.infrastructure.log.sink.serialization.UuidSerializer")
      properties.put("value.serializer", "io.neons.collector.application.guice.infrastructure.log.sink.serialization.RawEventSerializer")

      new KafkaProducer[UUID, Log](properties)
    }
  }
}

class LogSinkModule extends AbstractModule with ScalaModule {
  override def configure(): Unit = {
    bind[LogSink].to[KafkaLogSink].asEagerSingleton()
    bind[KafkaProducer[UUID, Log]].toProvider[KafkaLogSinkModuleProvider].asEagerSingleton()
  }
} 
开发者ID:NeonsIo,项目名称:collector,代码行数:37,代码来源:LogSinkModule.scala

示例10: ActorMaterializerModule

//设置package包名称以及导入依赖的类
package io.neons.collector.application.guice.application.akka.actor

import javax.inject.Inject

import akka.actor.ActorSystem
import akka.stream.ActorMaterializer
import com.google.inject.{AbstractModule, Provider}
import io.neons.collector.application.guice.application.akka.actor.ActorMaterializerModule.ActorMaterializerProvider
import net.codingwell.scalaguice.ScalaModule

object ActorMaterializerModule {
  class ActorMaterializerProvider @Inject()(actorSystem: ActorSystem) extends Provider[ActorMaterializer] {
    override def get(): ActorMaterializer = ActorMaterializer.apply()(context = actorSystem)
  }
}

class ActorMaterializerModule extends AbstractModule with ScalaModule {
  override def configure(): Unit = {
    bind[ActorMaterializer].toProvider[ActorMaterializerProvider].asEagerSingleton()
  }
} 
开发者ID:NeonsIo,项目名称:collector,代码行数:22,代码来源:ActorMaterializerModule.scala

示例11: 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

示例12: CollectorConfigModule

//设置package包名称以及导入依赖的类
package io.neons.collector.application.guice.application.config

import com.google.inject.{AbstractModule, Provider}
import com.typesafe.config.ConfigFactory
import io.neons.collector.application.config.CollectorConfig
import io.neons.collector.application.guice.application.config.CollectorConfigModule.CollectorConfigProvider
import net.codingwell.scalaguice.ScalaModule

object CollectorConfigModule {
  class CollectorConfigProvider extends Provider[CollectorConfig] {
    override def get(): CollectorConfig = {
      CollectorConfig.load(ConfigFactory.load())
    }
  }
}

class CollectorConfigModule extends AbstractModule with ScalaModule {
  override def configure(): Unit = {
    bind[CollectorConfig].toProvider[CollectorConfigProvider].asEagerSingleton()
  }
} 
开发者ID:NeonsIo,项目名称:collector,代码行数:22,代码来源:CollectorConfigModule.scala

示例13: RuleModule

//设置package包名称以及导入依赖的类
package br.unb.cic.poo.gol.model

import com.google.inject.AbstractModule
import net.codingwell.scalaguice.ScalaModule
import net.codingwell.scalaguice.ScalaMultibinder
import br.unb.cic.poo.gol.HighLife

class RuleModule extends AbstractModule with ScalaModule{
  
  override def configure() : Unit = {
    val setBinder = ScalaMultibinder.newSetBinder[Rule](binder)
    setBinder.addBinding.to(classOf[ConwayRule])
    setBinder.addBinding.to(classOf[HighLife])
    
    //Implementação ideal porem https://github.com/codingwell/scala-guice/issues/50
    /*val mapBinder = ScalaMapBinder.newMapBinder[Int, Rule](binder)
    mapBinder.addBinding(1).to(classOf[ConwayRule])
    mapBinder.addBinding(2).to(classOf[HighLife])*/
  }
  
} 
开发者ID:rdinizcal,项目名称:GameOfLife-TP1,代码行数:22,代码来源:RuleModule.scala

示例14: 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

示例15: ConfigModule

//设置package包名称以及导入依赖的类
package org.scardiecat.styx.clustermanager.di

import com.google.inject.AbstractModule
import com.typesafe.config.{ConfigFactory, Config}
import net.codingwell.scalaguice.ScalaModule

class ConfigModule(config:Config, actorSystemName:String)  extends AbstractModule with ScalaModule{
  // Create an Akka system
  val finalConfig =
    ConfigFactory.parseString(
      s"""
         |styx.actor-system-name=$actorSystemName
         """.stripMargin).
      withFallback(config)

  override  def configure(): Unit = {
    bind[Config].toInstance(this.finalConfig)
  }
} 
开发者ID:Scardiecat,项目名称:styx-cluster-manager,代码行数:20,代码来源:ConfigModule.scala


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