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

Scala Context类代码示例

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

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



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

示例1: CustomApplicationLoader

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

import play.api.ApplicationLoader
import play.api.Configuration
import play.api.inject._
import play.api.inject.guice._
import play.api.ApplicationLoader.Context
import com.typesafe.config.ConfigFactory
import play.api.Mode._
import play.Logger

class CustomApplicationLoader extends GuiceApplicationLoader {

  override protected def builder(context: Context): GuiceApplicationBuilder = {
    val builder = initialBuilder.in(context.environment).overrides(overrides(context): _*)
    context.environment.mode match {
      case Prod => {
        // start mode
        val prodConf = Configuration(ConfigFactory.load("prod.conf"))
        builder.loadConfig(prodConf ++ context.initialConfiguration)
      }
      case Dev => {
        Logger.error("*** Custom Loader DEV****")
        // run mode
        val devConf = Configuration(ConfigFactory.load("dev.conf"))
        builder.loadConfig(devConf ++ context.initialConfiguration)
      }
      case Test => {
        Logger.error("*** Custom Loader TEST ****")
        // test mode
        val testConf = Configuration(ConfigFactory.load("test.conf"))
        builder.loadConfig(testConf ++ context.initialConfiguration)
      }
    }
  }
} 
开发者ID:Driox,项目名称:play-app-seed,代码行数:37,代码来源:CustomApplicationLoader.scala


示例2: MyApplicationLoader

//设置package包名称以及导入依赖的类
import dao.CroissantDAO
import jobs.GmailJob
import play.api._
import play.api.ApplicationLoader.Context
import router.Routes
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.libs.mailer._
import play.api.i18n.I18nComponents
import play.modules.reactivemongo.{ReactiveMongoApiFromContext, ReactiveMongoComponents}
import services.OauthProvider
import utils.{Mailer, Settings}


class MyApplicationLoader extends ApplicationLoader {
  def load(context: Context) = {
    LoggerConfigurator(context.environment.classLoader).foreach(_.configure(context.environment))
    new MyComponents(context).application
  }
}

class MyComponents(context: Context) extends ReactiveMongoApiFromContext(context)
  with I18nComponents
  with AhcWSComponents
  with MailerComponents
  with ReactiveMongoComponents {

  implicit val ec = actorSystem.dispatcher

  val settings = new Settings(configuration)
  val mailer = new Mailer(settings, mailerClient)

  val croissantDAO = new CroissantDAO(settings, mailer, reactiveMongoApi)
  val oauthProvider = new OauthProvider(settings, wsClient)
  //val gmailJob = new GmailJob(wsClient, actorSystem, settings, mailer, croissantDAO)

  lazy val router = new Routes(
    httpErrorHandler,
    new controllers.CroissantController(settings, messagesApi, mailer, croissantDAO),
    new controllers.AdminCroissantController(settings, messagesApi, mailer, croissantDAO),
    new controllers.OauthController(oauthProvider),
    new controllers.Assets(httpErrorHandler)
  )
} 
开发者ID:denis-mludek,项目名称:zencroissants,代码行数:44,代码来源:MyApplicationLoader.scala


示例3: WebApp

//设置package包名称以及导入依赖的类
import org.culture.OrgId
import play.api.ApplicationLoader.Context
import play.api._
import play.api.mvc.Results._
import play.api.mvc._
import play.api.routing.Router
import play.api.routing.sird._
import wiring.Components

class WebApp extends ApplicationLoader {

  private val components = new Components
  import components._

  def load(context: Context) =
    new BuiltInComponentsFromContext(context) {

      val router = Router.from {

        case GET(p"/badge/${long(orgId)}.svg") =>
          Action.async {
            badgeBuilder.get(OrgId(orgId)).map { badge =>
              Ok.chunked(badge.body).as("image/svg+xml;charset=utf-8")
            }
          }

      }
    }.application

} 
开发者ID:lloydmeta,项目名称:reculture-shields,代码行数:31,代码来源:WebApp.scala


示例4: AppLoader

//设置package包名称以及导入依赖的类
import models.{AuthorizeStoreCache, PendingContentStoreCache}
import play.api.ApplicationLoader.Context
import play.api.cache.EhCacheComponents
import play.api.mvc.EssentialFilter
import play.api.routing.Router
import play.api._
import play.filters.gzip.GzipFilter
import router.Routes

class AppLoader extends ApplicationLoader {
  override def load(context: Context): Application = {
    LoggerConfigurator(context.environment.classLoader)
      .foreach(_.configure(context.environment))
    new AppComponents(context).application
  }
}

class AppComponents(context: Context)
    extends BuiltInComponentsFromContext(context)
    with EhCacheComponents {

  implicit val executionContext =
    play.api.libs.concurrent.Execution.Implicits.defaultContext
  implicit lazy val authorizeStoreCache = AuthorizeStoreCache(
    cacheApi("authorizeStore"))
  implicit lazy val pendingConsentStoreCache = PendingContentStoreCache(
    cacheApi("pendingConsentStore"))
  implicit val config = configuration.underlying

  lazy val applicationController = new controllers.Application
  lazy val assets                = new controllers.Assets(httpErrorHandler)

  // Routes is a generated class
  override def router: Router =
    new Routes(httpErrorHandler, applicationController, assets)

  val gzipFilter = new GzipFilter(shouldGzip = (request, response) => {
    val contentType = response.header.headers.get("Content-Type")
    contentType.exists(_.startsWith("text/html")) ||
    request.path.endsWith("jsroutes.js")
  })

  override lazy val httpFilters: Seq[EssentialFilter] = Seq(gzipFilter)
} 
开发者ID:zalando-incubator,项目名称:OAuth2-mock-play,代码行数:45,代码来源:AppLoader.scala


示例5: AppLoader

//设置package包名称以及导入依赖的类
import java.io.Closeable
import javax.sql.DataSource

import controllers.UsersController
import io.getquill._
import play.api.ApplicationLoader.Context
import play.api._
import play.api.db.evolutions.Evolutions
import play.api.db.{DBComponents, HikariCPComponents}
import play.api.inject.{Injector, NewInstanceInjector, SimpleInjector}
import play.api.routing.Router
import play.api.routing.sird._
import models.{Users}

class AppLoader extends ApplicationLoader {
  override def load(context: Context): Application = new BuiltInComponentsFromContext(context) with DBComponents with HikariCPComponents {

    lazy val db = new H2JdbcContext[SnakeCase](dbApi.database("default").dataSource.asInstanceOf[DataSource with Closeable])


    lazy val users = new Users(db)
    lazy val usersController = new UsersController(users)

    val router = Router.from {
      case GET(p"/users/${long(id)}")    => usersController.get(id)
      case POST(p"/users")               => usersController.create
      case DELETE(p"/users/${long(id)}") => usersController.delete(id)
      case PUT(p"/users/${long(id)}")    => usersController.update(id)
    }

    override lazy val injector: Injector =
      new SimpleInjector(NewInstanceInjector) + users + router + cookieSigner + csrfTokenSigner + httpConfiguration + tempFileCreator + global

    Evolutions.applyEvolutions(dbApi.database("default"))

  }.application
} 
开发者ID:getquill,项目名称:play-quill-jdbc,代码行数:38,代码来源:AppLoader.scala


示例6: WebGateway

//设置package包名称以及导入依赖的类
import com.lightbend.lagom.scaladsl.api.{ServiceAcl, ServiceInfo}
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.softwaremill.macwire._
import controllers.{Assets, Main}
import ogr.wex.cmsfs.monitor.api.MonitorService
import org.wex.cmsfs.lagom.service.discovery.Common
import org.wex.cmsfs.lagom.service.discovery.consul.ConsulServiceLocatorComponents
import play.api.ApplicationLoader.Context
import play.api.i18n.I18nComponents
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.{ApplicationLoader, BuiltInComponentsFromContext, Mode}
import router.Routes

import scala.collection.immutable
import scala.concurrent.ExecutionContext

abstract class WebGateway(context: Context) extends BuiltInComponentsFromContext(context)
  with I18nComponents
  with AhcWSComponents
  with LagomServiceClientComponents {

  override lazy val serviceInfo: ServiceInfo = ServiceInfo(
    "web-gateway",
    Map(
      "web-gateway" -> immutable.Seq(ServiceAcl.forPathRegex("(?!/api/).*"))
    )
  )
  override implicit lazy val executionContext: ExecutionContext = actorSystem.dispatcher
  override lazy val router = {
    val prefix = "/"
    wire[Routes]
  }

  lazy val monitorService = serviceClient.implement[MonitorService]
  lazy val main = wire[Main]
  lazy val assets = wire[Assets]
}

class WebGatewayLoader extends ApplicationLoader {
  override def load(context: Context) = {
    Common.loaderEnvironment(context)
    println(context.environment.mode)

    context.environment.mode match {
      case Mode.Dev =>
        new WebGateway(context) with LagomDevModeComponents {}.application
      case _ =>
        new WebGateway(context) with ConsulServiceLocatorComponents {}.application
    }
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:53,代码来源:Loader.scala


示例7: Common

//设置package包名称以及导入依赖的类
package org.wex.cmsfs.lagom.service.discovery

import com.lightbend.lagom.scaladsl.server.LagomApplicationContext
import play.api.ApplicationLoader.Context
import play.api.LoggerConfigurator

object Common {
  def loaderEnvironment(context: LagomApplicationContext): Unit = {
    val environment = context.playContext.environment
    LoggerConfigurator(environment.classLoader).foreach(_.configure(environment))
  }

  def loaderEnvironment(context: Context): Unit = {
    val environment = context.environment
    LoggerConfigurator(environment.classLoader).foreach(_.configure(environment))
  }
} 
开发者ID:shinhwagk,项目名称:cmsfs,代码行数:18,代码来源:Common.scala


示例8: AppLoader

//设置package包名称以及导入依赖的类
package org.andrewconner.spot

import _root_.controllers.Assets
import com.softwaremill.macwire._
import org.andrewconner.spot.core.time.Clock
import org.andrewconner.spot.modules._
import play.api.ApplicationLoader.Context
import play.api._
import play.api.libs.ws.WSClient
import play.api.libs.ws.ahc.AhcWSClient
import play.api.routing.Router

import scala.concurrent.ExecutionContext

class AppLoader extends ApplicationLoader {
  def load(context: Context) = {
    (new BuiltInComponentsFromContext(context) with AppComponents).application
  }
}

trait AppComponents
    extends BuiltInComponents
    with PlayAppModule
    with DatabaseModule // Database injection
    with DaoModule
    with ControllerModule // Application controllers
    with CmdrModule
    with CredentialsModule {

  implicit val ec: ExecutionContext = play.api.libs.concurrent.Execution.defaultContext // scala.concurrent.ExecutionContext.Implicits.global
  implicit val clock: Clock = new Clock()

  lazy val assets: Assets = wire[Assets]
  val prefix: String = "/"
  lazy val router: Router = wire[_root_.router.Routes].withPrefix(prefix)

  implicit val wsClient: WSClient = AhcWSClient()
  appShutdown.onStopAsync(wsClient.close())

} 
开发者ID:andrewconner,项目名称:spotsy,代码行数:41,代码来源:AppLoader.scala


示例9: MyApplicationLoader

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

import com.typesafe.config.ConfigFactory
import com.typesafe.scalalogging.{ LazyLogging, StrictLogging }
import controllers.Assets
import play.api.{ Application, BuiltInComponentsFromContext, Configuration, _ }
import play.api.libs.ws.ahc.AhcWSComponents
import my.samples.controllers.MyApplicationController
import play.api.ApplicationLoader.Context
import play.api.routing.Router
import router.Routes
import scala.concurrent.Future

// compile time DI for loading the play application
final class MyApplicationLoader extends ApplicationLoader with LazyLogging {

  override def load(context: Context): Application = {
    val configuration = Configuration(ConfigFactory.load())

    val newContext = context.copy(initialConfiguration = configuration)
    LoggerConfigurator(newContext.environment.classLoader)
      .foreach(_.configure(newContext.environment))

    new MyApp(newContext).application
  }
}
class MyApp(context: Context)
    extends BuiltInComponentsFromContext(context) with AhcWSComponents with StrictLogging {

  implicit val s = monix.execution.Scheduler.Implicits.global

  def stop(bindings: AppBindings) = {
    logger.info("stopping application")
    bindings.globalChannel.publishChannel.onComplete()
  }

  def start = {
    logger.info("starting application")
    AppBindings(actorSystem, materializer)
  }

  // 1. create the dependencies that will be injected
  lazy val appBindings = start

  // 2. inject the dependencies into the controllers
  lazy val applicationController = new MyApplicationController(appBindings)
  lazy val assets = new Assets(httpErrorHandler)
  override def router: Router = new Routes(
    httpErrorHandler, applicationController, assets
  )

  // 3. add the shutdown hook to properly dispose all connections
  applicationLifecycle.addStopHook { () => Future(stop(appBindings)) }
} 
开发者ID:joesan,项目名称:monix-samples,代码行数:55,代码来源:MyApplicationLoader.scala


示例10: AppLoader

//设置package包名称以及导入依赖的类
import java.io.Closeable
import javax.sql.DataSource

import controllers.MainController
import io.getquill._
import models.Services
import unus.db._
import unus.helpers.Conf
import unus.model.FeatureBuilder
import unus.stage.{BlockerCacher, DatabaseBackup, PatientCacher, PatientDatabase}
import org.flywaydb.play.FlywayPlayComponents
import play.api.ApplicationLoader.Context
import play.api._
import play.api.db.{DBComponents, HikariCPComponents}
import play.api.inject.{Injector, NewInstanceInjector, SimpleInjector}
import play.api.routing.Router
import play.filters.csrf._
import router.Routes

class AppLoader extends ApplicationLoader {
  override def load(context: Context): Application = new BuiltInComponentsFromContext(context)
    with DBComponents with HikariCPComponents  with CSRFComponents
    with FlywayPlayComponents with play.filters.HttpFiltersComponents with _root_.controllers.AssetsComponents {

    lazy val db = new PostgresJdbcContext[PostgresEscape](dbApi.database("default").dataSource.asInstanceOf[DataSource with Closeable])

    lazy val services = new Services(db)
    lazy val patientCacher = new PatientCacher
    lazy val repo = new Repository(db)
    lazy val blockerCachers = Conf.blockers.map(new BlockerCacher(repo, patientCacher.value, _))
    lazy val features =  Conf.features
    lazy val controller = new MainController(services, repo, patientCacher, blockerCachers, features)(controllerComponents)

    lazy val router: Router = new Routes(httpErrorHandler, controller)

    

    override lazy val injector: Injector =
      new SimpleInjector(NewInstanceInjector) + cookieSigner + csrfTokenSigner + httpConfiguration + tempFileCreator + router

    override lazy val httpFilters = Seq(csrfFilter)

    flywayPlayInitializer

    new PatientDatabase(repo, patientCacher).run()

    if(services.getLabelCount == 0) {
      new DatabaseBackup[Label]("Label").load()
    }

    if(services.getBlockedRowCount == 0) {
      new DatabaseBackup[BlockedRow]("BlockedRow").load()
    }

  }.application
} 
开发者ID:mindfulmachines,项目名称:unus,代码行数:57,代码来源:AppLoader.scala


示例11: Boot

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

import controllers.DevicesController
import play.api.ApplicationLoader.Context
import play.api.db.evolutions.EvolutionsComponents
import play.api.db.slick.evolutions.SlickEvolutionsComponents
import play.api.db.slick.{DbName, DefaultSlickApi}
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext}
import play.filters.HttpFiltersComponents
import router.Routes
import services.DataSource
import slick.basic.DatabaseConfig
import services.DataSourceJdbc
import slick.jdbc.JdbcProfile

class Boot extends ApplicationLoader {
  def load(context: Context): Application = {
    val components = new BootComponents(context)
    components.applicationEvolutions // Run the evolutions
    components.application
  }
}

class BootComponents(context: Context)
  extends BuiltInComponentsFromContext(context)
    with HttpFiltersComponents
    with controllers.AssetsComponents
    with EvolutionsComponents
    with SlickEvolutionsComponents {

  override def api: DefaultSlickApi = new DefaultSlickApi(environment, configuration, applicationLifecycle)
  private[this] val defaultDBName: DbName = DbName("devices")
  private[this] val dbConfig: DatabaseConfig[JdbcProfile] = slickApi.dbConfig[JdbcProfile](defaultDBName)

  // TODO put this into config
  private[this] val dbPoolSize = 10
  private[this] lazy val dataSource: DataSource = new DataSourceJdbc(dbConfig, dbPoolSize)
  private[this] lazy val devicesController: DevicesController = new DevicesController(controllerComponents, dataSource)
  override lazy val router: Routes = new Routes(httpErrorHandler, devicesController, assets)
} 
开发者ID:openada,项目名称:adaweather,代码行数:41,代码来源:Boot.scala


示例12: BootstrapLoader

//设置package包名称以及导入依赖的类
import controllers.UserController
import dao.UserDao
import play.api.ApplicationLoader.Context
import play.api.db.evolutions.{DynamicEvolutions, EvolutionsComponents}
import play.api.db.slick.{DbName, DatabaseConfigProvider, SlickComponents}
import play.api.db.slick.evolutions.SlickEvolutionsComponents
import play.api.i18n.{DefaultLangs, DefaultMessagesApi, MessagesApi}
import play.api.routing.Router
import play.api._
import router._
import slick.driver.JdbcProfile

class BootstrapLoader extends ApplicationLoader {
  override def load(context: Context): Application = {
    Logger.configure(context.environment)
    new ApplicationComponents(context).application
  }
}

class ApplicationComponents(context: Context) extends BuiltInComponentsFromContext(context)
  with SlickComponents with SlickEvolutionsComponents with EvolutionsComponents {

  lazy val messagesApi: MessagesApi = new DefaultMessagesApi(environment, configuration, new DefaultLangs(configuration))
  
  lazy val dbConfig = api.dbConfig[JdbcProfile](DbName("default"))
  lazy val userDao = new UserDao(dbConfig)

  lazy val applicationController = new controllers.Application()
  lazy val assets = new controllers.Assets(httpErrorHandler)
  lazy val webAssets = new controllers.WebJarAssets(httpErrorHandler, configuration, environment)
  lazy val userController = new UserController(messagesApi, userDao = userDao)

  override def router: Router = new Routes(
    httpErrorHandler,
    applicationController,
    userController,
    assets,
    webAssets
  )

  // This is required by EvolutionsComponents
  lazy val dynamicEvolutions = new DynamicEvolutions

  def onStart() = {
    // applicationEvolutions is a val and requires evolution
    applicationEvolutions
  }

  onStart()
} 
开发者ID:cloudwicklabs,项目名称:play-cloudwickone-slick-template,代码行数:51,代码来源:BootstrapLoader.scala


示例13: AppComponent

//设置package包名称以及导入依赖的类
import com.typesafe.config.Config
import controllers.{ OAuthGitHubController, TEAHubController, UIController }
import play.api.{ Application, ApplicationLoader, BuiltInComponentsFromContext, LoggerConfigurator }
import play.api.ApplicationLoader.Context
import play.api.cache.EhCacheComponents
import play.api.libs.ws.ahc.AhcWSClient
import play.api.i18n._
import services.impl.{ ApiGitHubService, ApiOAuthGitHubService, ApiTogglService }
import scala.concurrent.{ ExecutionContext, Future }
import router.Routes


class AppComponent(context: Context)(implicit val ec: ExecutionContext) extends BuiltInComponentsFromContext(context)
    with EhCacheComponents with I18nComponents {

  val config: Config = context.initialConfiguration.underlying
  val wsClient = AhcWSClient()

  lazy val oauthGitHubService = new ApiOAuthGitHubService(config, wsClient)
  lazy val oauthGitHubController = new OAuthGitHubController(oauthGitHubService)
  lazy val gitHubService = new ApiGitHubService(wsClient)
  lazy val togglService = new ApiTogglService(wsClient)
  lazy val teahubController = new TEAHubController(togglService, gitHubService, defaultCacheApi)
  lazy val assetsController = new controllers.Assets(httpErrorHandler)
  lazy val uiController = new UIController(messagesApi, defaultCacheApi, teahubController)(ec)

  lazy val router = new Routes(
    httpErrorHandler,
    oauthGitHubController,
    uiController,
    teahubController,
    assetsController
  )

  applicationLifecycle.addStopHook(() => Future.successful(wsClient.close))
} 
开发者ID:lunatech-labs,项目名称:teahub,代码行数:37,代码来源:AppLoader.scala


示例14: ApplicationLoader

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

import play.api.ApplicationLoader.Context
import play.api.{BuiltInComponentsFromContext, LoggerConfigurator}
import play.api.inject.{Injector, NewInstanceInjector, SimpleInjector}
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.libs.concurrent.Execution.Implicits.defaultContext
import play.api.routing.Router

import clients._
import controllers._
import router.Routes

class ApplicationLoader extends play.api.ApplicationLoader {

  def load(context: Context) = {
    new ApplicationComponents(context)
      with DefaultClientComponents
  }.application

}

class ApplicationComponents(context: Context)
  extends BuiltInComponentsFromContext(context)
  with AhcWSComponents
{

  self: ClientComponents =>

  LoggerConfigurator(context.environment.classLoader).foreach { loggerConfigurator =>
    loggerConfigurator.configure(context.environment)
  }

  lazy val router: Router = new Routes(
    httpErrorHandler,
    new UserController(userClient)
  )

  override lazy val injector: Injector = new SimpleInjector(NewInstanceInjector) +
    router + crypto + httpConfiguration + wsApi + global

} 
开发者ID:EVENFinancial,项目名称:play-compile-time-di-example,代码行数:43,代码来源:Application.scala


示例15: TestUserClient

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

import scala.concurrent.{ExecutionContext, Future}
import play.api.{ApplicationLoader, Environment}
import play.api.ApplicationLoader.Context

import clients._
import init.ApplicationComponents
import models.User

class TestUserClient(
  users: (Int, User)*
) extends UserClient {

  private val usersMap = Map(users:_*)

  def getUser(id: Int)(implicit ec: ExecutionContext): Future[Option[User]] = {
    Future.successful(usersMap.get(id))
  }

}

class TestApplicationComponents(
  context: Context = ApplicationLoader.createContext(Environment.simple()),
  val userClient: UserClient
) extends ApplicationComponents(context)
  with ClientComponents 
开发者ID:EVENFinancial,项目名称:play-compile-time-di-example,代码行数:28,代码来源:Helpers.scala


示例16: GriffinApiLoader

//设置package包名称以及导入依赖的类
import com.softwaremill.macwire._
import controllers.Assets
import filters.LoggingFilter
import play.api.ApplicationLoader.Context
import play.api._
import play.api.i18n._
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.mvc.EssentialFilter
import play.api.routing.Router
import play.filters.cors.{CORSConfig, CORSFilter}
import router.Routes
import services.ServicesModule



class GriffinApiLoader extends ApplicationLoader {
  def load(context: Context): Application = new GriffinComponents(context).application
}


class GriffinComponents(context: Context)
  extends BuiltInComponentsFromContext(context)
    with ServicesModule
    with I18nComponents
    with AhcWSComponents
{
  // set up logger
  LoggerConfigurator(context.environment.classLoader).foreach {
    _.configure(context.environment)
  }

  lazy val assets: Assets = wire[Assets]
  lazy val router: Router = {
    // add the prefix string in local scope for the Routes constructor
    val prefix: String = "/"
    wire[Routes]
  }

  lazy val corsFilter = CORSFilter(CORSConfig.fromConfiguration(configuration))

  lazy val loggingFilter = new LoggingFilter
  lazy val filters = wire[Filters]

  override lazy val httpFilters: Seq[EssentialFilter] =
    Seq(loggingFilter,corsFilter)

} 
开发者ID:yarshad,项目名称:griffin-api,代码行数:48,代码来源:GriffinApiLoader.scala


示例17: WebGateway

//设置package包名称以及导入依赖的类
import com.example.auction.bidding.api.BiddingService
import com.example.auction.item.api.ItemService
import com.example.auction.user.api.UserService
import com.lightbend.lagom.scaladsl.api.{ ServiceAcl, ServiceInfo }
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.softwaremill.macwire._
import com.typesafe.conductr.bundlelib.lagom.scaladsl.ConductRApplicationComponents
import controllers.{ Assets, ItemController, Main, ProfileController }
import play.api.ApplicationLoader.Context
import play.api.i18n.I18nComponents
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.{ ApplicationLoader, BuiltInComponentsFromContext, Mode }
import router.Routes

import scala.collection.immutable
import scala.concurrent.ExecutionContext

abstract class WebGateway(context: Context) extends BuiltInComponentsFromContext(context)
  with I18nComponents
  with AhcWSComponents
  with LagomServiceClientComponents {

  override lazy val serviceInfo: ServiceInfo = ServiceInfo(
    "web-gateway",
    Map(
      "web-gateway" -> immutable.Seq(ServiceAcl.forPathRegex("(?!/api/).*"))
    )
  )
  override implicit lazy val executionContext: ExecutionContext = actorSystem.dispatcher
  override lazy val router = {
    val prefix = "/"
    wire[Routes]
  }

  lazy val userService = serviceClient.implement[UserService]
  lazy val itemService = serviceClient.implement[ItemService]
  lazy val biddingService = serviceClient.implement[BiddingService]

  lazy val main = wire[Main]
  lazy val itemController = wire[ItemController]
  lazy val profileController = wire[ProfileController]
  lazy val assets = wire[Assets]
}

class WebGatewayLoader extends ApplicationLoader {
  override def load(context: Context) = context.environment.mode match {
    case Mode.Dev =>
      (new WebGateway(context) with LagomDevModeComponents).application
    case _ =>
      (new WebGateway(context) with ConductRApplicationComponents).application
  }
} 
开发者ID:lagom,项目名称:online-auction-scala,代码行数:54,代码来源:Loader.scala


示例18: AppApplicationLoader

//设置package包名称以及导入依赖的类
import com.softwaremill.macwire._
import controllers._
import play.api.ApplicationLoader.Context
import play.api._
import play.api.i18n._
import play.api.routing.Router
import router.Routes
import modules._

import scala.concurrent.ExecutionContext


class AppApplicationLoader extends ApplicationLoader {
  def load(context: Context): Application = {
    (new BuiltInComponentsFromContext(context) with AppComponents).application
  }
}

trait AppComponents extends BuiltInComponents
    with I18nComponents
    with DatabaseModule
    with ControllerModule
    with DaoModule
{

  implicit val ec: ExecutionContext = scala.concurrent.ExecutionContext.Implicits.global
  lazy val assets: Assets = wire[Assets]
  lazy val router: Router = {
    lazy val prefix = "/"
    wire[Routes]
  }

  lazy val mainController = wire[MainController]

//  def userDao: UserDao
} 
开发者ID:greven77,项目名称:PlaySlickTest,代码行数:37,代码来源:AppApplicationLoader.scala


示例19: Loader

//设置package包名称以及导入依赖的类
package com.thoughtworks.microbuilder.tutorial.organizationBff

import com.thoughtworks.microbuilder.play.{RpcEntry, PlayOutgoingJsonService, RpcController}
import com.thoughtworks.microbuilder.tutorial.githubSdk.proxy.MicrobuilderOutgoingProxyFactory._
import com.thoughtworks.microbuilder.tutorial.githubSdk.proxy.MicrobuilderRouteConfigurationFactory._
import com.thoughtworks.microbuilder.tutorial.organizationBffSdk.proxy.MicrobuilderIncomingProxyFactory._
import com.thoughtworks.microbuilder.tutorial.organizationBffSdk.proxy.MicrobuilderRouteConfigurationFactory._
import com.thoughtworks.microbuilder.tutorial.githubSdk.rpc.IOrganizationService
import com.thoughtworks.microbuilder.tutorial.organizationBffSdk.rpc.IOrganizationBffService
import play.api.libs.ws.ning.NingWSComponents
import play.api.{BuiltInComponentsFromContext, Application, ApplicationLoader}
import play.api.ApplicationLoader.Context
import router.Routes


class Loader extends ApplicationLoader {
  override def load(context: Context): Application = {

    val components = new BuiltInComponentsFromContext(context) with NingWSComponents {
      implicit def executionContext = actorSystem.dispatcher

      lazy val organizationService = PlayOutgoingJsonService.newProxy[IOrganizationService]("https://api.github.com/", wsApi)

      lazy val bffService = new OrganizationBffService(organizationService)

      lazy val rpcController = new RpcController(Seq(RpcEntry.implementedBy[IOrganizationBffService](bffService)))

      override lazy val router = new Routes(httpErrorHandler, rpcController)
    }

    components.application
  }
} 
开发者ID:Atry,项目名称:organization-bff,代码行数:34,代码来源:Loader.scala


示例20: ExampleApplicationLoader

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

import _root_.controllers.AssetsComponents
import authentication.AuthenticationsComponents
import be.objectify.deadbolt.scala.ActionBuilders
import play.api.ApplicationLoader.Context
import play.api._
import play.api.db.evolutions.{DynamicEvolutions, EvolutionsComponents}
import play.api.db.slick._
import play.api.db.slick.evolutions.SlickEvolutionsComponents
import play.api.i18n._
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.routing.Router
import play.filters.HttpFiltersComponents
import slick.basic.{BasicProfile, DatabaseConfig}
import users.UsersComponents

class ExampleApplicationLoader extends ApplicationLoader {
  def load(context: Context): Application = new ExampleComponents(context).application
}

class ExampleComponents(context: Context) extends BuiltInComponentsFromContext(context)
  with SlickComponents
  with SlickEvolutionsComponents
  with AssetsComponents
  with I18nComponents
  with HttpFiltersComponents
  with EvolutionsComponents
  with AhcWSComponents
  with AuthenticationsComponents
  with UsersComponents {

  override lazy val slickApi: SlickApi =
    new DefaultSlickApi(environment, configuration, applicationLifecycle)(executionContext)

  override lazy val databaseConfigProvider: DatabaseConfigProvider = new DatabaseConfigProvider {
    def get[P <: BasicProfile]: DatabaseConfig[P] = slickApi.dbConfig[P](DbName("default"))
  }

  override lazy val dynamicEvolutions: DynamicEvolutions = new DynamicEvolutions

  def onStart(): Unit = {
    // applicationEvolutions is a val and requires evaluation
    applicationEvolutions
  }

  onStart()

  // set up logger
  LoggerConfigurator(context.environment.classLoader).foreach {
    _.configure(context.environment, context.initialConfiguration, Map.empty)
  }

  lazy val actionBuilders: ActionBuilders = createActionBuilders(playBodyParsers)

  lazy val router: Router = Router.from(userRoutes.orElse(authenticationRoutes))

} 
开发者ID:Dasiu,项目名称:play-framework-scala-example-project,代码行数:59,代码来源:ExampleApplicationLoader.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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