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

Scala Names类代码示例

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

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



在下文中一共展示了Names类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: AppModule

//设置package包名称以及导入依赖的类
package com.jxjxgo.gamegateway.guice

import java.util

import com.google.inject.{AbstractModule, TypeLiteral}
import com.google.inject.name.Names
import com.jxjxgo.common.helper.ConfigHelper
import com.jxjxgo.gamecenter.rpc.domain.GameEndpoint
import com.jxjxgo.gamegateway.service.GameGatewayEndpointImpl
import com.jxjxgo.scrooge.thrift.template.{ScroogeThriftServerTemplate, ScroogeThriftServerTemplateImpl}
import com.jxjxgo.sso.rpc.domain.SSOServiceEndpoint
import com.twitter.finagle.Thrift
import com.twitter.scrooge.ThriftService
import com.twitter.util.Future
import com.typesafe.config.{Config, ConfigFactory}


class AppModule extends AbstractModule{
  override def configure(): Unit = {
    val map: util.HashMap[String, String] = ConfigHelper.configMap
    Names.bindProperties(binder(), map)
    val config: Config = ConfigFactory.load()
    bind(new TypeLiteral[SSOServiceEndpoint[Future]]() {}).toInstance(Thrift.client.newIface[SSOServiceEndpoint[Future]](config.getString("sso.thrift.host.port")))
    bind(new TypeLiteral[GameEndpoint[Future]]() {}).toInstance(Thrift.client.newIface[GameEndpoint[Future]](config.getString("gamecenter.thrift.host.port")))
    bind(classOf[InstanceHolder]).to(classOf[InstanceHolderImpl]).asEagerSingleton()

    bind(classOf[ThriftService]).to(classOf[GameGatewayEndpointImpl]).asEagerSingleton()
    bind(classOf[ScroogeThriftServerTemplate]).to(classOf[ScroogeThriftServerTemplateImpl]).asEagerSingleton()
  }
} 
开发者ID:fangzhongwei,项目名称:gamegateway,代码行数:31,代码来源:AppModule.scala


示例3: BaseRestModule

//设置package包名称以及导入依赖的类
package mesosphere.marathon.api

import com.codahale.metrics.servlets.MetricsServlet
import com.google.inject.Scopes
import com.google.inject.name.Names
import com.google.inject.servlet.ServletModule
import com.sun.jersey.guice.spi.container.servlet.GuiceContainer
import mesosphere.chaos.ServiceStatus
import mesosphere.chaos.http.{ HelpServlet, LogConfigServlet, PingServlet, ServiceStatusServlet }


class BaseRestModule extends ServletModule {

  // Override these in a subclass to mount resources at a different path
  val pingUrl = "/ping"
  val metricsUrl = "/metrics"
  val loggingUrl = "/logging"
  val helpUrl = "/help"
  val guiceContainerUrl = "/*"
  val statusUrl = "/status"
  val statusCatchAllUrl = "/status/*"

  protected override def configureServlets(): Unit = {
    bind(classOf[PingServlet]).in(Scopes.SINGLETON)
    bind(classOf[MetricsServlet]).in(Scopes.SINGLETON)
    bind(classOf[LogConfigServlet]).in(Scopes.SINGLETON)
    bind(classOf[HelpServlet]).in(Scopes.SINGLETON)
    bind(classOf[ServiceStatus]).asEagerSingleton()
    bind(classOf[ServiceStatusServlet]).in(Scopes.SINGLETON)

    bind(classOf[String]).annotatedWith(Names.named("helpPathPrefix")).toInstance(helpUrl)

    serve(statusUrl).`with`(classOf[ServiceStatusServlet])
    serve(statusCatchAllUrl).`with`(classOf[ServiceStatusServlet])
    serve(pingUrl).`with`(classOf[PingServlet])
    serve(metricsUrl).`with`(classOf[MetricsServlet])
    serve(loggingUrl).`with`(classOf[LogConfigServlet])
    serve(guiceContainerUrl).`with`(classOf[GuiceContainer])
  }
} 
开发者ID:xiaozai512,项目名称:marathon,代码行数:41,代码来源:BaseRestModule.scala


示例4: DefaultModule

//设置package包名称以及导入依赖的类
package com.nulabinc.backlog.migration.common.modules

import com.google.inject.AbstractModule
import com.google.inject.name.Names
import com.nulabinc.backlog.migration.common.conf.{BacklogApiConfiguration, BacklogPaths}
import com.nulabinc.backlog.migration.common.domain.PropertyValue
import com.nulabinc.backlog.migration.common.service._
import com.nulabinc.backlog4j.conf.BacklogPackageConfigure
import com.nulabinc.backlog4j.{BacklogClient, BacklogClientFactory, IssueType}

import scala.collection.JavaConverters._


class DefaultModule(apiConfig: BacklogApiConfiguration) extends AbstractModule {

  val backlog = createBacklogClient()

  override def configure() = {
    //base
    bind(classOf[BacklogClient]).toInstance(backlog)
    bind(classOf[String]).annotatedWith(Names.named("projectKey")).toInstance(apiConfig.projectKey)
    bind(classOf[BacklogPaths]).toInstance(new BacklogPaths(apiConfig.projectKey))
    bind(classOf[PropertyValue]).toInstance(createPropertyValue())

    bind(classOf[CommentService]).to(classOf[CommentServiceImpl])
    bind(classOf[CustomFieldSettingService]).to(classOf[CustomFieldSettingServiceImpl])
    bind(classOf[GroupService]).to(classOf[GroupServiceImpl])
    bind(classOf[IssueCategoryService]).to(classOf[IssueCategoryServiceImpl])
    bind(classOf[IssueService]).to(classOf[IssueServiceImpl])
    bind(classOf[IssueTypeService]).to(classOf[IssueTypeServiceImpl])
    bind(classOf[ProjectService]).to(classOf[ProjectServiceImpl])
    bind(classOf[ProjectUserService]).to(classOf[ProjectUserServiceImpl])
    bind(classOf[SharedFileService]).to(classOf[SharedFileServiceImpl])
    bind(classOf[VersionService]).to(classOf[VersionServiceImpl])
    bind(classOf[WikiService]).to(classOf[WikiServiceImpl])
    bind(classOf[ResolutionService]).to(classOf[ResolutionServiceImpl])
    bind(classOf[StatusService]).to(classOf[StatusServiceImpl])
    bind(classOf[UserService]).to(classOf[UserServiceImpl])
    bind(classOf[PriorityService]).to(classOf[PriorityServiceImpl])
    bind(classOf[SpaceService]).to(classOf[SpaceServiceImpl])
    bind(classOf[AttachmentService]).to(classOf[AttachmentServiceImpl])
  }

  private[this] def createBacklogClient(): BacklogClient = {
    val backlogPackageConfigure = new BacklogPackageConfigure(apiConfig.url)
    val configure               = backlogPackageConfigure.apiKey(apiConfig.key)
    new BacklogClientFactory(configure).newClient()
  }

  private[this] def createPropertyValue(): PropertyValue = {
    val issueTypes = try {
      backlog.getIssueTypes(apiConfig.projectKey).asScala
    } catch {
      case _: Throwable => Seq.empty[IssueType]
    }
    PropertyValue(issueTypes)
  }

} 
开发者ID:nulab,项目名称:backlog-migration-common,代码行数:60,代码来源:DefaultModule.scala


示例5: CachecoolModule

//设置package包名称以及导入依赖的类
package de.zalando.cachecool.playmodule

import com.google.inject.name.Names
import com.typesafe.config.{ConfigObject, ConfigValue}
import de.zalando.cachecool.{CacheDefinition, GenericCache, CachecoolFactory}
import play.api.{Configuration, Environment, Logger}
import play.api.inject.{Binding, Module}
import scala.collection.JavaConverters._



class CachecoolModule extends Module {

  private val logger = Logger(this.getClass.getName)


  override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = {
    val factories = loadCacheFactories(environment, configuration)

    val cachecoolCachesConfig: ConfigObject = configuration.getObject("cachecool.caches").getOrElse(throw new RuntimeException("Please provide cache configs"))
    val caches = cachecoolCachesConfig.asScala
    caches.flatMap { case (name, config) => buildCache(name, config, factories)
    }.toSeq
  }

  def buildCache(name: String, config: ConfigValue, factories: Map[String, CachecoolFactory]): Seq[Binding[_]] = {
    val cacheDef = CacheDefinition(config)
    val factory = factories.get(cacheDef.factoryName).getOrElse(throw new RuntimeException(s"No factory is defined for ${cacheDef.factoryName}"))

    val cache = factory.build(name, cacheDef.factoryConfig, factories)
    val default = cacheDef.isDefault match {
      case true => Some(bind(classOf[GenericCache]).toInstance(cache))
      case _ => None
    }
    Seq(Some(bind(classOf[GenericCache]).qualifiedWith(Names.named(name)).toInstance(cache)), default).flatten
  }


  private def loadCacheFactories(environment: Environment, configuration: Configuration): Map[String, CachecoolFactory] = {
    val factoriesDefinition = configuration.getObject("cachecool.factories").getOrElse(throw new RuntimeException("Please provide cache factories in config file")).asScala
    (factoriesDefinition map {
      case (name, className) => {
        val clazz: Class[_] = environment.classLoader.loadClass(className.unwrapped().toString)
        logger.info(s"Loading cache factory with name:$name and class:${clazz}")
        val constructor = clazz.getConstructor(classOf[ClassLoader])
        val factoryInstance: CachecoolFactory = constructor.newInstance(environment.classLoader).asInstanceOf[CachecoolFactory]
        (name -> factoryInstance)
      }
    }).toMap

  }
} 
开发者ID:psycho-ir,项目名称:cachecool,代码行数:53,代码来源:CachecoolModule.scala


示例6: ActorFactoryModule

//设置package包名称以及导入依赖的类
package com.yper.utils

import javax.inject.Inject

import akka.actor.{ActorRef, ActorSystem}
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import com.yper.users.actors.UserActor
import play.api.libs.concurrent.AkkaGuiceSupport
import play.api.{Configuration, Environment}



class ActorFactoryModule @Inject() (
                                    environment: Environment,
                                    configuration: Configuration
                                   ) extends AbstractModule with AkkaGuiceSupport{

  override def configure(): Unit = {
    println(s"Configuring ActorFactoryModule!")
    val actorSystem = ActorSystem.create("YperActorSystem")

    lazy val userActor = actorSystem.actorOf(UserActor.props)
    bind(classOf[ActorRef])
      .annotatedWith(Names.named("userActor"))
      .toInstance(userActor);


    lazy val anotherUserActor = actorSystem.actorOf(UserActor.props)
    bind(classOf[ActorRef])
      .annotatedWith(Names.named("anotherUserActor"))
      .toInstance(anotherUserActor);

  }
} 
开发者ID:vi-kas,项目名称:yper,代码行数:36,代码来源:ActorFactoryModule.scala


示例7: ShiroAuthModule

//设置package包名称以及导入依赖的类
package allawala.chassis.auth.shiro.module

import javax.inject.Singleton

import allawala.chassis.auth.shiro.ShiroLifecycleListener
import allawala.chassis.auth.shiro.realm.{JWTRealm, UsernamePasswordRealm}
import com.google.inject.Provides
import com.google.inject.multibindings.Multibinder
import com.google.inject.name.Names
import org.apache.shiro.guice.ShiroModule
import org.apache.shiro.realm.Realm

class ShiroAuthModule extends ShiroModule {
  override def configureShiro(): Unit = {
    
    bindConstant.annotatedWith(Names.named("shiro.sessionStorageEnabled")).to(false)
    bind(classOf[ShiroLifecycleListener]).asEagerSingleton()

    bindRealms()
  }

  protected def bindRealms(): Unit = {

    val multibinder = Multibinder.newSetBinder(binder, classOf[Realm])
    multibinder.addBinding().to(classOf[JWTRealm])
    multibinder.addBinding().to(classOf[UsernamePasswordRealm])
  }
}

object ShiroAuthModule {

  @Provides
  @Singleton
  def getJWTRealm(): JWTRealm = {
    new JWTRealm
  }
} 
开发者ID:allawala,项目名称:service-chassis,代码行数:38,代码来源:ShiroAuthModule.scala


示例8: JobcoinConfigProvider

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

import java.util.concurrent.TimeUnit

import com.google.inject.AbstractModule
import com.google.inject.name.Names
import play.api.{Configuration, Environment}
import constants.Constants._
import exceptions.MissingConfigurationException
import helpers.JobcoinConfig

import scala.concurrent.duration.FiniteDuration

class JobcoinConfigProvider(
  environment: Environment,
  configuration: Configuration
) extends AbstractModule {

  override def configure(): Unit = {
    val url = configuration.getString(urlPath).getOrElse(throw MissingConfigurationException(urlPath))
    val transActionEndpoint = configuration.getString(transactionsEndpointPath).getOrElse(throw MissingConfigurationException(transactionsEndpointPath))
    val addressEndpoint = configuration.getString(addressesEndpointPath).getOrElse(throw MissingConfigurationException(addressesEndpointPath))
    val retries = configuration.getInt(jobcoinRetries).getOrElse(throw MissingConfigurationException(jobcoinRetries))
    val timeout = FiniteDuration(configuration.getMilliseconds(jobcoinTimeout).get, TimeUnit.MILLISECONDS)

    bind(classOf[JobcoinConfig])
      .annotatedWith(Names.named(jobcoinConfig))
      .toInstance(new JobcoinConfig(url, transActionEndpoint, addressEndpoint, retries, timeout))

  }

} 
开发者ID:agaro1121,项目名称:jobcoin-mixer,代码行数:33,代码来源:JobcoinConfigProvider.scala


示例9: AppModule

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

import java.time.{Clock, ZoneId}

import akka.actor.{Actor, ActorRef, Props}
import com.google.api.client.googleapis.auth.oauth2.GoogleIdTokenVerifier
import com.google.api.client.http.javanet.NetHttpTransport
import com.google.api.client.json.jackson2.JacksonFactory
import com.google.api.client.util.store.AbstractDataStoreFactory
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import com.google.inject.util.Providers
import controllers.AppController
import play.api.libs.concurrent.{Akka, AkkaGuiceSupport}
import services._
import services.support.SystemClock

import scala.reflect.ClassTag

class AppModule extends AbstractModule {
  def configure = {
    bind(classOf[AppController]).asEagerSingleton // in prod mode all dependencies of AppController get built at startup time
    bind(classOf[AbstractDataStoreFactory]).to(classOf[RepositoryDataStoreFactory])
    bind(classOf[GoogleIdTokenVerifier]).toInstance(new GoogleIdTokenVerifier.Builder(new NetHttpTransport, new JacksonFactory).build)
    bind(classOf[Clock]).toInstance(new SystemClock(ZoneId.systemDefault()))
  }
}

class AkkaModule extends AbstractModule with AkkaGuiceSupport {
  def configure = {
    bindActorNoEager[SuperSupervisorActor](SuperSupervisorActor.actorName)
    bindActorFactory[UserSupervisorActor, UserSupervisorActor.Factory]
  }

  private def bindActorNoEager[T <: Actor : ClassTag](name: String, props: Props => Props = identity): Unit = {
    binder.bind(classOf[ActorRef])
      .annotatedWith(Names.named(name))
      .toProvider(Providers.guicify(Akka.providerOf[T](name, props)))
  }
} 
开发者ID:phdezann,项目名称:connectus,代码行数:41,代码来源:Module.scala


示例10: Module

//设置package包名称以及导入依赖的类
import java.time.Clock
import javax.inject.Singleton

import com.amazonaws.services.dynamodbv2.AmazonDynamoDBAsyncClient
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import config.Guice
import controllers.PersonController
import database.PersonsRepository
import database.dynamodb
import database.dynamodb.DynamoDBClientProvider
import net.codingwell.scalaguice.ScalaModule
import play.api.{Configuration, Environment}

import scala.concurrent.ExecutionContext



class Module(environment: Environment, configuration: Configuration) extends AbstractModule with ScalaModule {

  override def configure(): Unit = {
    // Use the system clock as the default implementation of Clock
    bind[Clock].toInstance(Clock.systemDefaultZone)

    bind[PersonController]

    bind[ExecutionContext]
      .annotatedWith(Names.named(Guice.DynamoRepository))
      .toProvider[dynamodb.RepositoryExecutionContextProvider]
      .in[Singleton]

    bind[AmazonDynamoDBAsyncClient].toProvider[DynamoDBClientProvider].in[Singleton]

    bind[PersonsRepository].to[dynamodb.PersonsRepositoryImpl].in[Singleton]
  }
} 
开发者ID:calvinlfer,项目名称:Play-Framework-DynamoDB-example,代码行数:37,代码来源:Module.scala


示例11: Deps

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

import com.google.inject.AbstractModule
import com.google.inject.name.Names
import providers.{ImdbProvider, KatcrProvider, SearchProvider}


class Deps extends AbstractModule {
  def configure() = {

    bind(classOf[SearchProvider])
      .annotatedWith(Names.named("katcr"))
      .to(classOf[KatcrProvider])
//
//    bind(classOf[SearchProvider])
//      .annotatedWith(Names.named("imdb"))
//      .to(classOf[ImdbProvider])
  }
} 
开发者ID:aashiks,项目名称:jIgor,代码行数:20,代码来源:Deps.scala


示例12: EventBussProvider

//设置package包名称以及导入依赖的类
import javax.inject.Inject

import akka.actor.{ ActorRef, ActorSystem }
import akka.stream.Materializer
import com.github.j5ik2o.spetstore.adaptor.aggregate.{ CustomerMessageBroker, ItemTypeMessageBroker }
import com.github.j5ik2o.spetstore.adaptor.eventbus.EventBus
import com.google.inject.name.Names
import com.google.inject.{ AbstractModule, Provider }
import play.api.libs.concurrent.AkkaGuiceSupport

class EventBussProvider @Inject() (actorSystem: ActorSystem, materializer: Materializer) extends Provider[EventBus] {
  override def get(): EventBus = {
    EventBus.ofRemote(actorSystem)
  }
}

class CustomerAggregateProvider @Inject() (actorSystem: ActorSystem, eventBus: EventBus) extends Provider[ActorRef] {
  override def get(): ActorRef = {
    CustomerMessageBroker(eventBus)(actorSystem)
  }
}

class ItemTypeAggregateProvider @Inject() (actorSystem: ActorSystem, eventBus: EventBus) extends Provider[ActorRef] {
  override def get(): ActorRef = {
    ItemTypeMessageBroker(eventBus)(actorSystem)
  }
}

class Module extends AbstractModule with AkkaGuiceSupport {

  override def configure() = {
    bind(classOf[SharedJournalStarter]).asEagerSingleton()
    bind(classOf[EventBus])
      .toProvider(classOf[EventBussProvider])
      .asEagerSingleton()
    bind(classOf[ActorRef])
      .annotatedWith(Names.named("customer-aggregate"))
      .toProvider(classOf[CustomerAggregateProvider])
      .asEagerSingleton()
    bind(classOf[ActorRef])
      .annotatedWith(Names.named("item-type-aggregate"))
      .toProvider(classOf[ItemTypeAggregateProvider])
      .asEagerSingleton()
  }

} 
开发者ID:j5ik2o,项目名称:spetstore-cqrs-es-akka,代码行数:47,代码来源:Module.scala


示例13: InputModule

//设置package包名称以及导入依赖的类
package recipestore.input

import java.io.{IOException, InputStream}
import java.nio.file.{Files, Paths, StandardOpenOption}

import com.google.inject.Provides
import com.google.inject.name.Names
import recipestore.db.triplestore.{FileBasedTripleStoreDAO, TripleStoreDAO}
import recipestore.{AppResource, CommonModule, ResourceLoader}

object InputModule {
  private val DATASET_FILE_LOC: String = ResourceLoader.apply(AppResource.TriplestoreResource, "input-file").get

  @Provides def providesDatasetStream: InputStream = {
    try {
      return Files.newInputStream(Paths.get(DATASET_FILE_LOC), StandardOpenOption.READ)
    }
    catch {
      case e: IOException => {
        throw new RuntimeException("Failed initializing module. Input quad file is mandatory")
      }
    }
  }
}

class InputModule extends CommonModule {
  override protected def configure() {
    super.configure()
    bind(classOf[TripleStoreDAO]).to(classOf[FileBasedTripleStoreDAO])
    bind(classOf[String]).annotatedWith(Names.named("datasetName")).toInstance("recipe")
  }
} 
开发者ID:prad-a-RuntimeException,项目名称:semantic-store,代码行数:33,代码来源:InputModule.scala


示例14: Module

//设置package包名称以及导入依赖的类
import com.google.inject.AbstractModule
import com.google.inject.name.Names
import model.{CandlestickDAO, DealDAO}
import play.api.libs.concurrent.AkkaGuiceSupport
import services.strategies.{MACDTradingStrategy, TradingStrategy}
import services.{Calculator, ApplicationInit}
import services.clients.ExchangeClientFactory
import services.actors.{TradingActor, MonitoringActor}


class Module extends AbstractModule with AkkaGuiceSupport {

  override def configure() = {
    bindActor[MonitoringActor]("monitoring-actor")
    bindActor[TradingActor]("trading-actor")
    bind(classOf[DealDAO]).asEagerSingleton()
    bind(classOf[CandlestickDAO]).asEagerSingleton()
    bind(classOf[ApplicationInit]).asEagerSingleton()
    bind(classOf[ExchangeClientFactory]).asEagerSingleton()
    bind(classOf[Calculator])
    bind(classOf[TradingStrategy]).annotatedWith(Names.named("macd"))
      .to(classOf[MACDTradingStrategy])
  }

} 
开发者ID:dendec,项目名称:speculator,代码行数:26,代码来源:Module.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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