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

Scala Config类代码示例

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

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



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

示例1: Request

//设置package包名称以及导入依赖的类
package org.freetrm.eventstore.http

import akka.actor.{ActorRef, ActorSystem}
import akka.http.scaladsl.Http
import akka.http.scaladsl.Http.ServerBinding
import akka.http.scaladsl.model._
import akka.stream.ActorMaterializer
import akka.util.Timeout
import com.typesafe.config.Config
import org.freetrm.eventstore.utils.Log
import org.freetrm.eventstore.{EventSourceReader, EventSourceWriter}
import scaldi.Module

import scala.concurrent.Future
import scala.concurrent.duration._


case class Request(client: ActorRef, req: HttpRequest)

class WebService extends Module with Log {
  implicit lazy val system = inject[ActorSystem]
  implicit lazy val mat = ActorMaterializer()

  def start(): Future[ServerBinding] = {

    val conf = inject[Config]

    implicit val timeout = Timeout(5.seconds)
    val interface = conf.getString("www-service.interface")
    val port = conf.getInt("www-service.port")

    log.info(s"Starting http server on $interface:$port")
    
    Http().bindAndHandle(service.flow, interface, port)
  }

  def stop() {}

  def service: EventStoreHttpServer = {
    implicit val system = inject[ActorSystem]
    val conf = inject[Config]

    val cookie = conf.getString("www-service.cookie")
    new EventStoreHttpServer(
      inject[EventSourceWriter],
      inject[EventSourceReader], 
      cookie)
  }
} 
开发者ID:topaztechnology,项目名称:eventstore,代码行数:50,代码来源:WebService.scala


示例2: CallingThreadDispatcherModelSpec

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

import java.util.concurrent.atomic.AtomicInteger
import akka.actor.dispatch.ActorModelSpec
import com.typesafe.config.Config
import akka.dispatch.DispatcherPrerequisites
import akka.dispatch.MessageDispatcher
import akka.dispatch.MessageDispatcherConfigurator
import akka.dispatch.UnboundedMailbox

object CallingThreadDispatcherModelSpec {
  import ActorModelSpec._

  val config = {
    """
      boss {
        executor = thread-pool-executor
        type = PinnedDispatcher
      }
    """ +
      // use unique dispatcher id for each test, since MessageDispatcherInterceptor holds state
      (for (n ? 1 to 30) yield """
        test-calling-thread-%s {
          type = "akka.testkit.CallingThreadDispatcherModelSpec$CallingThreadDispatcherInterceptorConfigurator"
        }""".format(n)).mkString
  }

  class CallingThreadDispatcherInterceptorConfigurator(config: Config, prerequisites: DispatcherPrerequisites)
    extends MessageDispatcherConfigurator(config, prerequisites) {

    private val instance: MessageDispatcher =
      new CallingThreadDispatcher(this) with MessageDispatcherInterceptor {
        override def id: String = config.getString("id")
      }

    override def dispatcher(): MessageDispatcher = instance

  }

}

@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class CallingThreadDispatcherModelSpec extends ActorModelSpec(CallingThreadDispatcherModelSpec.config) {
  import ActorModelSpec._

  val dispatcherCount = new AtomicInteger()

  override def interceptedDispatcher(): MessageDispatcherInterceptor = {
    // use new id for each test, since the MessageDispatcherInterceptor holds state
    system.dispatchers.lookup("test-calling-thread-" + dispatcherCount.incrementAndGet()).asInstanceOf[MessageDispatcherInterceptor]
  }
  override def dispatcherType = "Calling Thread Dispatcher"

} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:55,代码来源:CallingThreadDispatcherModelSpec.scala


示例3: TestKitExtension

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

import com.typesafe.config.Config
import akka.util.Timeout
import akka.actor.{ ExtensionId, ActorSystem, Extension, ExtendedActorSystem }
import scala.concurrent.duration.FiniteDuration

object TestKitExtension extends ExtensionId[TestKitSettings] {
  override def get(system: ActorSystem): TestKitSettings = super.get(system)
  def createExtension(system: ExtendedActorSystem): TestKitSettings = new TestKitSettings(system.settings.config)
}

class TestKitSettings(val config: Config) extends Extension {

  import akka.util.Helpers._

  val TestTimeFactor = config.getDouble("akka.test.timefactor").
    requiring(tf ? !tf.isInfinite && tf > 0, "akka.test.timefactor must be positive finite double")
  val SingleExpectDefaultTimeout: FiniteDuration = config.getMillisDuration("akka.test.single-expect-default")
  val TestEventFilterLeeway: FiniteDuration = config.getMillisDuration("akka.test.filter-leeway")
  val DefaultTimeout: Timeout = Timeout(config.getMillisDuration("akka.test.default-timeout"))
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:23,代码来源:TestKitExtension.scala


示例4: DurableExecutableMailboxConfig

//设置package包名称以及导入依赖的类
package akka.actor.mailbox

import akka.dispatch.{ Envelope, MessageQueue }
import akka.remote.MessageSerializer
import akka.remote.WireFormats.{ ActorRefData, RemoteEnvelope }
import com.typesafe.config.Config
import akka.actor._

private[akka] object DurableExecutableMailboxConfig {
  val Name = "[\\.\\/\\$\\s]".r
}

@deprecated("durable mailboxes are superseded by akka-persistence", "2.3")
abstract class DurableMessageQueue(val owner: ActorRef, val system: ExtendedActorSystem) extends MessageQueue {
  import DurableExecutableMailboxConfig._

  def ownerPath: ActorPath = owner.path
  val ownerPathString: String = ownerPath.elements.mkString("/")
  val name: String = "mailbox_" + Name.replaceAllIn(ownerPathString, "_")

}


  def initialize: Config =
    if (userConfig.hasPath(name))
      userConfig.getConfig(name).withFallback(systemSettings.config.getConfig("akka.actor.mailbox." + name))
    else systemSettings.config.getConfig("akka.actor.mailbox." + name)
} 
开发者ID:love1314sea,项目名称:akka-2.3.16,代码行数:29,代码来源:DurableMailbox.scala


示例5: UsersProtonModule

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

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.{ExceptionHandler, Route, RouteResult}
import akka.stream.ActorMaterializer
import com.typesafe.config.Config
import com.typesafe.scalalogging.LazyLogging
import scaldi.{Injectable, Module, TypesafeConfigInjector}
import spray.json.{CompactPrinter, JsonPrinter}

import scala.concurrent.ExecutionContext

class UsersProtonModule(config: Config) extends Module {
  bind[ExecutionContext] to scala.concurrent.ExecutionContext.Implicits.global
  bind[ActorSystem] to ActorSystem("ProtonUsers", config) destroyWith (_.terminate())
  bind[JsonPrinter] to CompactPrinter
}

object UsersProtonApp extends App with Injectable with LazyLogging with SprayJsonSupport with UsersProtocol {
  ProtonConfig.parse("users-dev.conf", args).foreach(c => {
    val config = c.config
    implicit val injector = TypesafeConfigInjector(config) :: new UsersProtonModule(config)
    implicit val executionContext = inject[ExecutionContext]
    implicit val system = inject[ActorSystem]
    implicit val materializer = ActorMaterializer()
    implicit val printer = inject[JsonPrinter]

    implicit val exceptionHandler = ExceptionHandler {
      case e: Exception =>
        logger.error("HTTP unhandled exception.", e)
        var message = "HTTP unhandled exception."
        if (e != null) {
          message = e.getMessage
        }
        complete(InternalServerError -> Message(message, UsersEvents.Unhandled))
    }

    def route: Route =
      pathSingleSlash {
        get {
          complete("test")
        }
      }

    Http().bindAndHandle(route, config.getString("proton.ip"), config.getInt("proton.users.http.port"))
  })
} 
开发者ID:Morgan-Stanley,项目名称:proton,代码行数:52,代码来源:UsersProtonApp.scala


示例6: AWSRegionNames

//设置package包名称以及导入依赖的类
package akka.persistence.s3

import com.amazonaws.regions.{ Regions, Region }
import com.typesafe.config.Config

private object AWSRegionNames {
  val GovCloud = Regions.GovCloud.getName
  val US_EAST_1 = Regions.US_EAST_1.getName
  val US_WEST_1 = Regions.US_WEST_1.getName
  val US_WEST_2 = Regions.US_WEST_2.getName
  val EU_WEST_1 = Regions.EU_WEST_1.getName
  val EU_CENTRAL_1 = Regions.EU_CENTRAL_1.getName
  val AP_SOUTHEAST_1 = Regions.AP_SOUTHEAST_1.getName
  val AP_SOUTHEAST_2 = Regions.AP_SOUTHEAST_2.getName
  val AP_NORTHEAST_1 = Regions.AP_NORTHEAST_1.getName
  val AP_NORTHEAST_2 = Regions.AP_NORTHEAST_2.getName
  val SA_EAST_1 = Regions.SA_EAST_1.getName
  val CN_NORTH_1 = Regions.CN_NORTH_1.getName
}

class S3ClientConfig(config: Config) {
  import AWSRegionNames._
  val awsKey = config getString "aws-access-key-id"
  val awsSecret = config getString "aws-secret-access-key"
  val awsUseDefaultCredentialsProviderChain = config getBoolean "aws-use-default-credentials-provider-chain"
  val region: Region = config getString "region" match {
    case GovCloud       => Region.getRegion(Regions.GovCloud)
    case US_EAST_1      => Region.getRegion(Regions.US_EAST_1)
    case US_WEST_1      => Region.getRegion(Regions.US_WEST_1)
    case US_WEST_2      => Region.getRegion(Regions.US_WEST_2)
    case EU_WEST_1      => Region.getRegion(Regions.EU_WEST_1)
    case EU_CENTRAL_1   => Region.getRegion(Regions.EU_CENTRAL_1)
    case AP_SOUTHEAST_1 => Region.getRegion(Regions.AP_SOUTHEAST_1)
    case AP_SOUTHEAST_2 => Region.getRegion(Regions.AP_SOUTHEAST_2)
    case AP_NORTHEAST_1 => Region.getRegion(Regions.AP_NORTHEAST_1)
    case AP_NORTHEAST_2 => Region.getRegion(Regions.AP_NORTHEAST_2)
    case SA_EAST_1      => Region.getRegion(Regions.SA_EAST_1)
    case CN_NORTH_1     => Region.getRegion(Regions.CN_NORTH_1)
  }
  val endpoint: Option[String] = {
    val e = config getString "endpoint"
    if (e == "default") None else Some(e)
  }
  object options {
    val pathStyleAccess = config getBoolean "options.path-style-access"
    val chunkedEncodingDisabled = config getBoolean "options.chunked-encoding-disabled"
  }
} 
开发者ID:TanUkkii007,项目名称:akka-persistence-s3,代码行数:49,代码来源:S3Config.scala


示例7: MonitoringServer

//设置package包名称以及导入依赖的类
package com.scalaio.http.monitoring

import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.ContentTypes._
import akka.http.scaladsl.model.{HttpEntity, HttpResponse, StatusCodes, Uri}
import akka.http.scaladsl.model.StatusCodes._
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server._
import akka.stream.Materializer
import com.typesafe.config.Config
import com.yammer.metrics.HealthChecks
import com.yammer.metrics.core.HealthCheckRegistry
import org.slf4j.LoggerFactory
import play.api.libs.json.{JsArray, Json}

import scala.util.{Failure, Success}
import scala.collection.convert.wrapAsScala._

object MonitoringServer {

  lazy val logger = LoggerFactory.getLogger(getClass)

  def handleHealthchecks(registry: HealthCheckRegistry): Route = {
    path("health") {
      get {
        complete {
          val checks = registry.runHealthChecks
          val payload = JsArray(checks.map {
            case (name, result) =>
              Json.obj(
                "name" -> name,
                "healthy" -> result.isHealthy,
                "message" -> result.getMessage
              )
          }.toSeq)
          val status = if (checks.values().forall(_.isHealthy)) OK else InternalServerError
          HttpResponse(entity = HttpEntity(`application/json`, Json.stringify(payload)), status = status)
        }
      }
    }
  }

  def start(serverConfig: Config, registry: HealthCheckRegistry = HealthChecks.defaultRegistry())
           (implicit system: ActorSystem, materializer: Materializer): Unit = {
    val host = serverConfig.getString("host")
    val port = serverConfig.getInt("port")
    logger.info(s"Starting monitoring server at: $host:$port")

    val routes = handleHealthchecks(registry) ~ redirect(Uri("/health"), StatusCodes.SeeOther)
    import system.dispatcher
    Http()
      .bindAndHandle(routes, host, port).onComplete {
      case Success(Http.ServerBinding(address)) =>
        logger.info(s"Monitoring server started at :$address")
      case Failure(t) =>
        logger.error("Error while trying to start monitoring server", t)
    }
  }
} 
开发者ID:fagossa,项目名称:scalaio_akka,代码行数:61,代码来源:MonitoringServer.scala


示例8: DbDriversBuilder

//设置package包名称以及导入依赖的类
package com.criteo.qwebmon.drivers

import java.util.Properties
import javax.sql.DataSource

import com.criteo.qwebmon.DbDriver
import com.mchange.v2.c3p0.ComboPooledDataSource
import com.typesafe.config.{Config, ConfigObject, ConfigValueType}

import scala.collection.JavaConverters._

class DbDriversBuilder(config: Config) {

  val dbDrivers: Map[String, DbDriver] = config.getObject("targets")
    .entrySet().asScala
    .foldLeft(Map.empty[String, DbDriver]) { case (acc, entry) =>

    val targetName = entry.getKey
    val targetConfig = entry.getValue match {
      case c if c.valueType() == ConfigValueType.OBJECT => c.asInstanceOf[ConfigObject].toConfig
      case x => sys.error(s"illegal config syntax at $x")
    }

    targetConfig.getString("driver") match {
      case "fake-db" => acc + (targetName -> new FakeDbDriver(targetName))
      case "mysql" => acc + (targetName -> new MysqlDbDriver(targetName, buildDataSource(targetConfig)))
      case "vertica" => acc + (targetName -> new VerticaDbDriver(targetName, buildDataSource(targetConfig)))
      case x => sys.error(s"unknown driver supplied: $x, for target named: $targetName, with config: $targetConfig")
    }
  }

  private def buildDataSource(config: Config): DataSource = {
    val dataSource = new ComboPooledDataSource()

    if (config.hasPath("properties")) {
      val connectionProps = new Properties()
      config.getConfig("properties").entrySet().asScala.foreach { entry =>
        val key = entry.getKey
        val value = entry.getValue.unwrapped().toString

        connectionProps.setProperty(key, value)
      }
      dataSource.setProperties(connectionProps)
    }

    dataSource.setJdbcUrl(config.getString("url"))
    dataSource.setUser(config.getString("user"))
    dataSource.setPassword(config.getString("password"))

    dataSource
  }
} 
开发者ID:jqcoffey,项目名称:qwebmon,代码行数:53,代码来源:DbDriversBuilder.scala


示例9: RandomVal

//设置package包名称以及导入依赖的类
package com.jetprobe.fastgen.generators.entity

import java.security.SecureRandom

import com.jetprobe.fastgen.generators.{
  EntityGenerator,
  FieldOption,
  StringType
}
import com.typesafe.config.Config

import scala.util.matching.Regex


class RandomVal(datasetConfig: Config, regexMatcher: Regex.MatchIterator)
    extends EntityGenerator(datasetConfig, regexMatcher)

object RandomVal {
  val abc = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
  val numberStr = "0123456789"
  lazy val rnd = new SecureRandom()

  def apply(datasetConfig: Config,
            regexMatcher: Regex.MatchIterator): RandomVal = {
    val random = new RandomVal(datasetConfig, regexMatcher)

    random.addField("Random.String", StringType, (fieldOpt: FieldOption) => {
      val sb = new StringBuilder(10)
      for (i <- 0 until 20) {
        sb.append(abc(rnd.nextInt(abc.length)))
      }
      sb.toString
    })

    random.addField(
      "Random.number",
      StringType,
      (fieldOpt: FieldOption) => {
        val sb = new StringBuilder(10)
        for (i <- 0 until 10) {
          sb.append(abc(rnd.nextInt(numberStr.length)))
        }
        sb.toString
      }
    )

    random
  }
} 
开发者ID:amezng,项目名称:fastgen,代码行数:50,代码来源:RandomVal.scala


示例10: UsersMailbox

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

import java.util.Comparator

import akka.actor.ActorSystem
import akka.dispatch.{Envelope, UnboundedStablePriorityMailbox}
import com.typesafe.config.Config


class UsersMailbox(settings: ActorSystem.Settings, config: Config)
  extends UnboundedStablePriorityMailbox(UsersPriorityGenerator)

object UsersPriorityGenerator extends Comparator[Envelope] {

  override def compare(o1: Envelope, o2: Envelope) = {
    if (o1.message.isInstanceOf[Add] && o2.message.isInstanceOf[Add]) {
      val m1 = o1.message.asInstanceOf[Add]
      val m2 = o2.message.asInstanceOf[Add]

      if (m1.connectionInfo.connectedTime > m2.connectionInfo.connectedTime) {
        1
      } else {
        -1
      }
    } else {
      0
    }
  }
} 
开发者ID:fjaros,项目名称:init6,代码行数:30,代码来源:UsersMailbox.scala


示例11: create

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.ironmq

import akka.actor.ActorSystem
import akka.http.scaladsl.model.Uri
import akka.stream.alpakka.ironmq.ConfigIronMqSettings.ConfigConsumerSettings
import akka.stream.alpakka.ironmq.IronMqSettings.ConsumerSettings
import com.typesafe.config.Config

import scala.concurrent.duration.FiniteDuration


  def create(as: ActorSystem): IronMqSettings = apply()(as)
}

object ConfigIronMqSettings {

  class ConfigConsumerSettings(config: Config) extends ConsumerSettings {
    override val bufferMinSize: Int = config.getInt("buffer-min-size")
    override val bufferMaxSize: Int = config.getInt("buffer-max-size")
    override val fetchInterval: FiniteDuration = config.getDuration("fetch-interval").asScala
    override val pollTimeout: FiniteDuration = config.getDuration("poll-timeout").asScala
    override val reservationTimeout: FiniteDuration = config.getDuration("reservation-timeout").asScala
  }

}

class ConfigIronMqSettings(config: Config) extends IronMqSettings {
  override val endpoint: Uri = config.getString("endpoint")
  override val projectId: String = config.getString("credentials.project-id")
  override val token: String = config.getString("credentials.token")

  override def consumerSettings: ConsumerSettings = new ConfigConsumerSettings(config.getConfig("consumer"))
} 
开发者ID:akka,项目名称:alpakka,代码行数:34,代码来源:IronMqSettings.scala


示例12: ironMqClient

//设置package包名称以及导入依赖的类
package akka.stream.alpakka.ironmq

import java.util.UUID

import com.typesafe.config.{Config, ConfigFactory}
import org.scalatest.concurrent.ScalaFutures
import org.scalatest.{BeforeAndAfterEach, Notifying, Suite}

import scala.concurrent.ExecutionContext
import scala.util.hashing.MurmurHash3

trait IronMqFixture extends AkkaStreamFixture with BeforeAndAfterEach with ScalaFutures { _: Suite with Notifying =>

  private implicit val ec = ExecutionContext.global
  private var mutableIronMqClient = Option.empty[IronMqClient]

  def ironMqClient: IronMqClient =
    mutableIronMqClient.getOrElse(throw new IllegalStateException("The IronMqClient is not initialized"))

  override protected def initConfig(): Config =
    ConfigFactory.parseString(s"""akka.stream.alpakka.ironmq {
        |  credentials {
        |    project-id = "${MurmurHash3.stringHash(System.currentTimeMillis().toString)}"
        |  }
        |}
      """.stripMargin).withFallback(super.initConfig())

  override protected def beforeEach(): Unit = {
    super.beforeEach()
    mutableIronMqClient = Option(IronMqClient(IronMqSettings(config.getConfig("akka.stream.alpakka.ironmq"))))
  }

  override protected def afterEach(): Unit = {
    mutableIronMqClient = Option.empty
    super.afterEach()
  }

  def givenQueue(name: Queue.Name): Queue = {
    val created = ironMqClient.createQueue(name).futureValue
    note(s"Queue created: ${created.name.value}", Some(created))
    created
  }

  def givenQueue(): Queue =
    givenQueue(Queue.Name(s"test-${UUID.randomUUID()}"))
} 
开发者ID:akka,项目名称:alpakka,代码行数:47,代码来源:IronMqFixture.scala


示例13: RegionSource

//设置package包名称以及导入依赖的类
package au.csiro.data61.magda.spatial

import java.net.URL

import au.csiro.data61.magda.AppConfig
import com.typesafe.config.{ Config, ConfigObject }

import scala.collection.JavaConversions._

case class RegionSource(
  name: String,
  url: URL,
  idProperty: String,
  nameProperty: String,
  includeIdInName: Boolean,
  disabled: Boolean,
  order: Int)

object RegionSource {
  def generateRegionId(regionType: String, id: String) = s"${regionType}/$id".toLowerCase
}

class RegionSources(config: Config) {
  val sources = loadFromConfig(config)

  private lazy val lookup = sources.groupBy(_.name.toLowerCase).mapValues(_.head)

  def forName(name: String): Option[RegionSource] = lookup.get(name.toLowerCase)

  private def loadFromConfig(config: Config): Seq[RegionSource] = {
    config.root().map {
      case (name: String, config: ConfigObject) =>
        val regionSourceConfig = config.toConfig()
        RegionSource(
          name = name,
          url = new URL(regionSourceConfig.getString("url")),
          idProperty = regionSourceConfig.getString("idField"),
          nameProperty = regionSourceConfig.getString("nameField"),
          includeIdInName = if (regionSourceConfig.hasPath("includeIdInName")) regionSourceConfig.getBoolean("includeIdInName") else false,
          disabled = regionSourceConfig.hasPath("disabled") && regionSourceConfig.getBoolean("disabled"),
          order = regionSourceConfig.getInt("order"))
    }.toSeq.filterNot(_.disabled)
  }
} 
开发者ID:TerriaJS,项目名称:magda,代码行数:45,代码来源:RegionSource.scala


示例14: indexVersions

//设置package包名称以及导入依赖的类
package au.csiro.data61.magda.search.elasticsearch

import scala.collection.JavaConversions._
import com.sksamuel.elastic4s.ElasticDsl._
import com.sksamuel.elastic4s.IndexesAndTypes
import com.typesafe.config.Config
import com.typesafe.config.ConfigObject
import au.csiro.data61.magda.model.misc._

trait Indices {
  def indexVersions(config: Config) = config.getConfig("elasticSearch.indices").root().map {
    case (name: String, config: ConfigObject) => name -> config.toConfig.getInt("version")
  }

  def getIndex(config: Config, index: Indices.Index): String = {
    (index.name + indexVersions(config)(index.name))
  }

  def getType(`type`: Indices.IndexType) = `type`.name

  def typeForFacet(facetType: FacetType) = facetType match {
    case Format    => Indices.FormatsIndexType
    case Publisher => Indices.PublisherIndexType
    case Year      => throw new RuntimeException("No type for year")
  }

}

object DefaultIndices extends Indices {}


object Indices {
  sealed trait Index {
    def name: String
  }
  case object DataSetsIndex extends Index {
    override def name = "datasets"
  }
  case object RegionsIndex extends Index {
    override def name = "regions"
  }

  sealed trait IndexType {
    def name: String
  }

  case object DataSetsIndexType extends IndexType {
    override def name() = "datasets"
  }
  case object RegionsIndexType extends IndexType {
    override def name() = "regions"
  }
  case object FormatsIndexType extends IndexType {
    override def name() = Format.id
  }
  case object PublisherIndexType extends IndexType {
    override def name() = Publisher.id
  }
} 
开发者ID:TerriaJS,项目名称:magda,代码行数:60,代码来源:Indices.scala


示例15: VKitMServerStartable

//设置package包名称以及导入依赖的类
package com.github.mmolimar.vkitm.server

import com.typesafe.config.Config
import kafka.utils.Logging

object VKitMServerStartable {
  def fromProps(serverConfig: Config, producerConfig: Config, consumerConfig: Config) = {
    new VKitMServerStartable(VKitMConfig.fromProps(serverConfig, producerConfig, consumerConfig))
  }
}

class VKitMServerStartable(val config: VKitMConfig) extends Logging {
  private[vkitm] val server = new VKitMServer(config)

  def startup() {
    try {
      server.startup()
    }
    catch {
      case e: Throwable =>
        fatal("Fatal error during VKitMServerStable startup. Prepare to shutdown", e)
        System.exit(1)
    }
  }

  def shutdown() {
    try {
      server.shutdown()
    }
    catch {
      case e: Throwable =>
        fatal("Fatal error during VKitMServerStable shutdown. Prepare to halt", e)
        Runtime.getRuntime.halt(1)
    }
  }

  def awaitShutdown() =
    server.awaitShutdown

} 
开发者ID:mmolimar,项目名称:vkitm,代码行数:41,代码来源:VKitMServerStartable.scala


示例16: FrontendGlobal

//设置package包名称以及导入依赖的类
package uk.gov.hmrc.trustregistration

import java.io.File

import com.typesafe.config.Config
import net.ceedubs.ficus.Ficus._
import play.api.Mode._
import play.api.mvc.Request
import play.api.{Application, Configuration, Play}
import play.twirl.api.Html
import uk.gov.hmrc.crypto.ApplicationCrypto
import uk.gov.hmrc.play.audit.filters.FrontendAuditFilter
import uk.gov.hmrc.play.config.{AppName, ControllerConfig, RunMode}
import uk.gov.hmrc.play.frontend.bootstrap.DefaultFrontendGlobal
import uk.gov.hmrc.play.http.logging.filters.FrontendLoggingFilter


object FrontendGlobal
  extends DefaultFrontendGlobal {

  override val auditConnector = FrontendAuditConnector
  override val loggingFilter = LoggingFilter
  override val frontendAuditFilter = AuditFilter

  override def onStart(app: Application) {
    super.onStart(app)
    ApplicationCrypto.verifyConfiguration()
  }

  override def onLoadConfig(config: Configuration, path: File, classloader: ClassLoader, mode: Mode): Configuration = {
    super.onLoadConfig(config, path, classloader, mode)
  }

  override def standardErrorTemplate(pageTitle: String, heading: String, message: String)(implicit rh: Request[_]): Html =
    uk.gov.hmrc.trustregistration.views.html.error_template(pageTitle, heading, message)

  override def microserviceMetricsConfig(implicit app: Application): Option[Configuration] = app.configuration.getConfig(s"microservice.metrics")
}

object ControllerConfiguration extends ControllerConfig {
  lazy val controllerConfigs = Play.current.configuration.underlying.as[Config]("controllers")
}

object LoggingFilter extends FrontendLoggingFilter {
  override def controllerNeedsLogging(controllerName: String) = ControllerConfiguration.paramsForController(controllerName).needsLogging
}

object AuditFilter extends FrontendAuditFilter with RunMode with AppName {

  override lazy val maskedFormFields = Seq("password")

  override lazy val applicationPort = None

  override lazy val auditConnector = FrontendAuditConnector

  override def controllerNeedsAuditing(controllerName: String) = ControllerConfiguration.paramsForController(controllerName).needsAuditing
} 
开发者ID:hmrc,项目名称:trust-registration-frontend,代码行数:58,代码来源:frontendGlobal.scala


示例17: PostgresConnection

//设置package包名称以及导入依赖的类
package cz.alenkacz.db.postgresscala

import com.github.mauricio.async.db.pool.ConnectionPool
import com.github.mauricio.async.db.postgresql.PostgreSQLConnection
import com.github.mauricio.async.db.postgresql.pool.PostgreSQLConnectionFactory
import com.typesafe.config.{Config, ConfigFactory}
import cz.alenkacz.db.postgresscala.ConfigParser.PostgresConfiguration

import scala.concurrent.{ExecutionContext, Future}

object PostgresConnection {
  private val defaultConfig = ConfigFactory.defaultReference().getConfig("postgres-connection-defaults")
  def fromConfig(config: Config)(implicit executionContext: ExecutionContext): Future[Connection] = {
    val finalConfig = config.withFallback(defaultConfig)

    val parsedConfig = ConfigParser.parse(finalConfig)
    parsedConfig match {
      case PostgresConfiguration(conf, disconnectTimeout, None) =>
        new PostgreSQLConnection(conf).connect.map(new PostgresAsyncConnection(_, disconnectTimeout))
      case PostgresConfiguration(conf, disconnectTimeout, Some(poolConfig)) =>
        new ConnectionPool[PostgreSQLConnection](new PostgreSQLConnectionFactory(conf), poolConfig).connect.map(new PostgresAsyncConnection(_, disconnectTimeout))
    }
  }
} 
开发者ID:alenkacz,项目名称:postgres-scala,代码行数:25,代码来源:PostgresConnection.scala


示例18: Configuration

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

import com.typesafe.config.{Config, ConfigFactory}

class Configuration(config: Config) {

  object app {
    val name: String = config.getString("dummy-authenticator.name")
  }

  object server {
    val interface: String = config.getString("http.interface")
    val dummy_port: Int   = config.getInt("dummy-authenticator.port")
    val riakHost: String  = config.getString("services.riak-api.host")
    val riakPort: Int     = config.getInt("services.riak-api.port")
  }
}

object Configuration {
  val get = new Configuration(ConfigFactory.load())
} 
开发者ID:DalenWBrauner,项目名称:Alkes-Prototype,代码行数:22,代码来源:Configuration.scala


示例19: LogConfig

//设置package包名称以及导入依赖的类
package knot.core.config

import com.typesafe.config.Config
import knot.core.logging.LoggerFactory
import knot.core.util.Utils

object LogConfig {
  def apply(config: Config): LogConfig = new LogConfig(config)
}

class LogConfig private(private val config: Config) extends ConfigSection {
  def logLevel: String = config.getString("logLevel")

  def loggerFactoryClass: Class[_ <: LoggerFactory] = {
    Utils.getClassFor[LoggerFactory](
      Thread.currentThread.getContextClassLoader,
      config.getString("loggerFactory")
    ).get
  }
} 
开发者ID:defvar,项目名称:knot,代码行数:21,代码来源:LogConfig.scala


示例20: WSConfigParser

//设置package包名称以及导入依赖的类
package play.api.libs.ws

import javax.inject.{ Inject, Provider, Singleton }

import com.typesafe.config.{ Config, ConfigException }
import com.typesafe.sslconfig.ssl.SSLConfigParser
import com.typesafe.sslconfig.util.EnrichedConfig

import scala.concurrent.duration.Duration


@Singleton
class WSConfigParser @Inject() (config: Config, classLoader: ClassLoader) extends Provider[WSClientConfig] {

  def parse(): WSClientConfig = {
    val wsConfig = config.getConfig("play.ws")

    val connectionTimeout = Duration(wsConfig.getString("timeout.connection"))
    val idleTimeout = Duration(wsConfig.getString("timeout.idle"))
    val requestTimeout = Duration(wsConfig.getString("timeout.request"))

    val followRedirects = wsConfig.getBoolean("followRedirects")
    val useProxyProperties = wsConfig.getBoolean("useProxyProperties")

    val userAgent = {
      try {
        Some(wsConfig.getString("useragent"))
      } catch {
        case e: ConfigException.Null =>
          None
      }
    }

    val compressionEnabled = wsConfig.getBoolean("compressionEnabled")

    val sslConfig = new SSLConfigParser(EnrichedConfig(wsConfig.getConfig("ssl")), classLoader).parse()

    WSClientConfig(
      connectionTimeout = connectionTimeout,
      idleTimeout = idleTimeout,
      requestTimeout = requestTimeout,
      followRedirects = followRedirects,
      useProxyProperties = useProxyProperties,
      userAgent = userAgent,
      compressionEnabled = compressionEnabled,
      ssl = sslConfig
    )
  }

  override lazy val get: WSClientConfig = parse()
} 
开发者ID:playframework,项目名称:play-ws,代码行数:52,代码来源:WSConfigParser.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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