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

Scala BuiltInComponentsFromContext类代码示例

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

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



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

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


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


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


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


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


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


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


示例8: GrimeyAppLoader

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

import com.grimey.staticpage.StaticPageService
import controllers.{AdminController, HomeController, Assets, StaticPageController}

import play.api.ApplicationLoader.Context
import play.api.routing.Router
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext}
import router.Routes
import play.api.i18n.{DefaultMessagesApi, DefaultLangs, MessagesApi, I18nSupport}
import play.api.Play.current

import scala.concurrent.Future
import scala.concurrent.duration.Duration

class GrimeyAppLoader extends ApplicationLoader {
  override def load(context: Context): Application = new GrimeyAppComponents(context).application
}

class GrimeyAppComponents(context: Context) extends BuiltInComponentsFromContext(context) with I18nSupport {
  val config = current.configuration // Todo: Inject this.

  lazy val db = new GrimeyDatabaseContext(DatabaseContextConfig(
    Duration(config.getString("grimey.db.defaultTimeoutInMs").getOrElse("10000")))).db

  lazy val staticPageService = new StaticPageService(db)

  lazy val homeController = new HomeController()
  lazy val adminController = new AdminController()
  lazy val staticPageController = new StaticPageController(staticPageService, messagesApi())
  lazy val assetsController = new Assets(httpErrorHandler)

  applicationLifecycle.addStopHook(() => Future.successful(db.close()))

  override def router: Router = new Routes(httpErrorHandler, homeController, adminController, staticPageController,
    assetsController)

  override def messagesApi(): MessagesApi = new DefaultMessagesApi(environment, configuration, new DefaultLangs(configuration))
}

case class DatabaseContextConfig(defaultTimeout: Duration) 
开发者ID:CSGrimey,项目名称:grimey-cms-scala,代码行数:42,代码来源:GrimeyAppLoader.scala


示例9: WebGateway

//设置package包名称以及导入依赖的类
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.api.{ServiceAcl, ServiceInfo}
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import play.api.ApplicationLoader.Context
import play.api.{ApplicationLoader, BuiltInComponentsFromContext, Mode}
import play.api.i18n.I18nComponents
import play.api.libs.ws.ahc.AhcWSComponents
import router.Routes
import com.softwaremill.macwire._
import controllers.Assets
import uk.co.turingatemyhamster.shoppinglist.user.api.UserService

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-ui",
    Map(
      "web-ui" -> immutable.Seq(ServiceAcl.forPathRegex("(?!/api/).*"))
    )
  )

  override implicit lazy val executionContext: ExecutionContext = actorSystem.dispatcher

  protected implicit lazy val playConfig = context.initialConfiguration
  protected implicit lazy val playEnv = context.environment

  override lazy val router: Routes = {
    val prefix = "/"
    wire[Routes]
  }

  lazy val userService = serviceClient.implement[UserService]

  lazy val cApplication: controllers.Application = wire[controllers.Application]
  lazy val assets: 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) {
        override def serviceLocator = NoServiceLocator
      }.application
  }
} 
开发者ID:drdozer,项目名称:shoppinglist,代码行数:55,代码来源:Loader.scala


示例10: MyComponents

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

import akka.actor.ActorSystem
import com.svitovyda.configuration.ConfigurationsComponents
import play.api.{ApplicationLoader, BuiltInComponentsFromContext}
import play.api.ApplicationLoader.Context
import play.api.routing.Router
import com.svitovyda.counter.CounterComponents
import com.svitovyda.router.RouterComponents


class MyComponents(context: Context) {
  import MyComponents._

  lazy val counter = new CounterComponents

  lazy val configurations = new ConfigurationsComponents

  lazy val router = new RouterComponents(counter, configurations)

  lazy val play = new Play(context, () => router.router)
}
object MyComponents {

  val actorSystem = ActorSystem()

  class Play(
      context: ApplicationLoader.Context,
      createRouter: () => Router)
    extends BuiltInComponentsFromContext(context) {

    lazy val router: Router = createRouter()
    override lazy val actorSystem: ActorSystem = MyComponents.actorSystem
  }
} 
开发者ID:svitovyda,项目名称:scala-play254,代码行数:36,代码来源:MyComponents.scala


示例11: MockedApplicationLoader

//设置package包名称以及导入依赖的类
import akka.NotUsed
import akka.stream.scaladsl.Flow
import dao.EventDao
import models.{OrderPlaced, UserRecognized}
import play.api.{Application, BuiltInComponentsFromContext}
import play.api.ApplicationLoader.Context
class MockedApplicationLoader
    extends ConferenceManagerApplicationLoader {
  override def load(context: Context): Application =
    new BuiltInComponentsFromContext(context)
    with ConferenceManagerComponents {
      override lazy val orderDao: EventDao[OrderPlaced] =
        new EventDao[OrderPlaced]() {
          override protected def eventStore
            : Flow[String, String, NotUsed] = Flow[String]
        }
      override lazy val userDao: EventDao[UserRecognized] =
        new EventDao[UserRecognized]() {
          override protected def eventStore
            : Flow[String, String, NotUsed] = Flow[String]
        }
    }.application
} 
开发者ID:leanovate,项目名称:contoso-conference-manager,代码行数:24,代码来源:MockedApplicationLoader.scala


示例12: FakeSilhouetteMacwireComponents

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

import controllers.{ Assets, WebJarAssets }

import play.api.BuiltInComponentsFromContext
import play.api.ApplicationLoader.Context
import play.api.cache.EhCacheComponents
import play.api.db.slick.SlickComponents
import play.api.i18n.I18nComponents
import play.api.libs.openid.OpenIDComponents
import play.api.routing.Router
import play.filters.csrf.CSRFComponents
import play.filters.headers.SecurityHeadersComponents
import router.Routes

import com.softwaremill.macwire._
import com.github.jacobono.modules._

class FakeSilhouetteMacwireComponents(context: Context) extends BuiltInComponentsFromContext(context)
    with ControllerModule with UtilModule with UserModule with SilhouetteModule with DAOModule with DatabaseModule
    with MockWsClient with I18nComponents with CSRFComponents with SecurityHeadersComponents
    with SlickComponents with EhCacheComponents with OpenIDComponents {
  lazy val routerOption = None
  override lazy val httpErrorHandler: play.api.http.HttpErrorHandler = errorHandler
  override lazy val httpFilters = filters.filters
  lazy val webJarAssets: WebJarAssets = wire[WebJarAssets]
  lazy val assets: Assets = wire[Assets]
  lazy val router: Router = {
    lazy val prefix = "/"
    wire[Routes]
  }
} 
开发者ID:jacobono,项目名称:silhouette-macwire,代码行数:33,代码来源:FakeSilhouetteMacwireComponents.scala


示例13: Frontend

//设置package包名称以及导入依赖的类
import be.yannickdeturck.lagomshopscala.item.api.ItemService
import be.yannickdeturck.lagomshopscala.order.api.OrderService
import com.lightbend.lagom.scaladsl.api.{ServiceAcl, ServiceInfo, ServiceLocator}
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.internal.client.CircuitBreakerMetricsProviderImpl
import com.lightbend.lagom.scaladsl.api.ServiceLocator.NoServiceLocator
import com.lightbend.lagom.scaladsl.broker.kafka.LagomKafkaClientComponents
import com.softwaremill.macwire._
import controllers.{Assets, DashboardController, ItemController, OrderController}
import play.api.ApplicationLoader.Context
import play.api.i18n.I18nComponents
import play.api.libs.ws.ahc.AhcWSComponents
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext, Mode}
import router.Routes

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


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

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

  lazy val itemService: ItemService = serviceClient.implement[ItemService]
  lazy val itemController: ItemController = wire[ItemController]
  lazy val orderService: OrderService = serviceClient.implement[OrderService]
  lazy val orderController: OrderController = wire[OrderController]
  lazy val dashboardController: DashboardController = wire[DashboardController]
  lazy val assets: Assets = wire[Assets]
}

class FrontendLoader extends ApplicationLoader {
  override def load(context: Context): Application = context.environment.mode match {
    case Mode.Dev =>
      (new Frontend(context) with LagomDevModeComponents).application
    case _ =>
      new Frontend(context) {
        override lazy val circuitBreakerMetricsProvider = new CircuitBreakerMetricsProviderImpl(actorSystem)

        override def serviceLocator: ServiceLocator = NoServiceLocator
      }.application
  }
} 
开发者ID:yannickdeturck,项目名称:lagom-shop-scala,代码行数:59,代码来源:Loader.scala


示例14: AppLoader

//设置package包名称以及导入依赖的类
import components.CassandraRepositoryComponents
import play.api.ApplicationLoader.Context
import play.api.routing.Router
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext}
import router.Routes

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

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

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

  override def router: Router = new Routes(
    httpErrorHandler,
    applicationController,
    assets
  )
} 
开发者ID:manuelkiessling,项目名称:play2-compiletime-cassandra-di,代码行数:23,代码来源:AppLoader.scala


示例15: WebGateway

//设置package包名称以及导入依赖的类
import com.example.counter.api.CounterService
import com.lightbend.lagom.scaladsl.api.{ServiceAcl, ServiceInfo}
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import play.api.{ApplicationLoader, BuiltInComponentsFromContext, Mode}
import play.api.ApplicationLoader.Context
import play.api.i18n.{I18nComponents, MessagesApi}
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._
import controllers.{CounterController, HomeController}
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(
    "front-end",
    Map("front-end" -> immutable.Seq(ServiceAcl.forPathRegex("(?!/api/).*")))
  )
  override implicit lazy val executionContext: ExecutionContext = actorSystem.dispatcher

  implicit lazy val message: MessagesApi = messagesApi

  override lazy val router = {
    val prefix = "/"
    wire[Routes]
  }

  lazy val counterService = serviceClient.implement[CounterService]

  lazy val home = wire[HomeController]
  lazy val counter = wire[CounterController]
}

class WebGatewayLoader extends ApplicationLoader {
  override def load(context: Context) = context.environment.mode match {
    case Mode.Dev => (new WebGateway(context) with LagomDevModeComponents).application
    case _ => throw new Exception("Not ready for deployment yet.")
  }
} 
开发者ID:namelos,项目名称:lagom-spike,代码行数:43,代码来源:Loader.scala


示例16: DapperApplicationLoader

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

import play.api.mvc.EssentialFilter
import play.api.routing.Router
import play.api.{Application, ApplicationLoader, BuiltInComponentsFromContext}
import com.softwaremill.macwire._
import me.dapperware.config.{MongoConfig, Neo4jConfig}
import me.dapperware.controllers.DapperController
import me.dapperware.module.{MongoModule, Neo4jModule}
import me.dapperware.schema.DapperSchemaBuilder
import play.filters.cors.CORSComponents
import router.Routes


class DapperApplicationLoader extends ApplicationLoader {
  override def load(context: ApplicationLoader.Context): Application =
    new DapperComponents(context).application
}

class DapperComponents(context: ApplicationLoader.Context)
  extends BuiltInComponentsFromContext(context)
  with CORSComponents {

  // Configs
  lazy val mongoConfig = wire[MongoConfig]
  lazy val neo4jConfig = wire[Neo4jConfig]

  // DBs
  lazy val mongoModule: MongoModule = wire[MongoModule]
  lazy val neo4jModule: Neo4jModule = wire[Neo4jModule]

  // GraphQL Schema
  lazy val schema = wire[DapperSchemaBuilder]

  // Controllers
  lazy val dapperController = wire[DapperController]


  // Routes
  lazy val router: Router = {
    val prefix = "/"

    wire[Routes]
  }

  override def httpFilters: Seq[EssentialFilter] = Seq(corsFilter)
} 
开发者ID:paulpdaniels,项目名称:play-sangria-starter,代码行数:48,代码来源:DapperApplicationLoader.scala


示例17: MyApplicationLoader

//设置package包名称以及导入依赖的类
import akka.actor.ActorSystem
import play.api.ApplicationLoader.Context
import play.api.libs.ws.WSAPI
import play.api.libs.ws.ning.NingWSComponents
import play.api.{Configuration, Application, ApplicationLoader, BuiltInComponentsFromContext}
import router.Routes
import service.{MyDefaultService, MyService}

class MyApplicationLoader extends ApplicationLoader {
  override def load(context: Context): Application = {
    new environment.ApplicationEnv(context).application
  }
}
package object environment {
  // Environment that contains useful services
  class Env(_application: => Application, val configuration: Configuration, val ws: WSAPI, val akka: ActorSystem, val myService: MyService) {
    def application = _application
  }

  class ApplicationEnv(context: Context)
    extends BuiltInComponentsFromContext(context)
      with NingWSComponents {

    lazy val env = new Env(application, configuration, wsApi, actorSystem, MyDefaultService("geheim"))

    // an injected instance of the application controller
    lazy val applicationController = new controllers.Application(env)
    lazy val assets = new controllers.Assets(httpErrorHandler)

    // routes using injected controllers
    lazy val router = new Routes(httpErrorHandler, applicationController, assets)
  }
} 
开发者ID:bartschuller,项目名称:play-scala-compile-time-di,代码行数:34,代码来源:MyApplicationLoader.scala


示例18: MyApplicationLoader

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

import chat.ChatEngine
import play.api.{ApplicationLoader, BuiltInComponents, BuiltInComponentsFromContext, LoggerConfigurator}
import com.softwaremill.macwire._
import controllers.AssetsComponents
import play.api.inject.DefaultApplicationLifecycle
import play.engineio.EngineIOController
import play.socketio.scaladsl.SocketIOComponents

class MyApplicationLoader extends ApplicationLoader {
  override def load(context: ApplicationLoader.Context) =
    new BuiltInComponentsFromContext(context) with MyApplication {
      LoggerConfigurator.apply(context.environment.classLoader)
        .foreach(_.configure(context.environment))
    }.application
}

trait MyApplication extends BuiltInComponents
  with AssetsComponents
  with SocketIOComponents {

  override def applicationLifecycle: DefaultApplicationLifecycle

  lazy val chatEngine = wire[ChatEngine]
  lazy val engineIOController: EngineIOController = chatEngine.controller

  override lazy val router = {
    val prefix = "/"
    wire[_root_.router.Routes]
  }
  override lazy val httpFilters = Nil
} 
开发者ID:playframework,项目名称:play-socket.io,代码行数:34,代码来源:MyApplicationLoader.scala


示例19: MyApplicationLoader

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

import chat.ChatEngine
import play.api.{ApplicationLoader, BuiltInComponents, BuiltInComponentsFromContext, LoggerConfigurator}
import com.softwaremill.macwire._
import controllers.AssetsComponents
import play.api.inject.DefaultApplicationLifecycle
import play.engineio.{EngineIOComponents, EngineIOController}
import play.socketio.scaladsl.SocketIOComponents

class MyApplicationLoader extends ApplicationLoader {
  override def load(context: ApplicationLoader.Context) =
    new BuiltInComponentsFromContext(context) with MyApplication {
      LoggerConfigurator.apply(context.environment.classLoader)
        .foreach(_.configure(context.environment))
    }.application
}

trait MyApplication extends BuiltInComponents
  with AssetsComponents
  with SocketIOComponents {

  override def applicationLifecycle: DefaultApplicationLifecycle

  lazy val chatEngine = wire[ChatEngine]
  lazy val engineIOController: EngineIOController = chatEngine.controller

  override lazy val router = {
    val prefix = "/"
    wire[_root_.router.Routes]
  }
  override lazy val httpFilters = Nil
} 
开发者ID:playframework,项目名称:play-socket.io,代码行数:34,代码来源:MyApplicationLoader.scala


示例20: Loader

//设置package包名称以及导入依赖的类
import play.api.{ Application, ApplicationLoader, BuiltInComponentsFromContext }
import play.api.libs.ws.ahc.AhcWSComponents
import com.softwaremill.macwire._
import router.Routes
import com.lightbend.lagom.scaladsl.api._
import com.lightbend.lagom.scaladsl.client.LagomServiceClientComponents
import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import scala.collection.immutable

class Loader extends ApplicationLoader {
  def load(context: ApplicationLoader.Context): Application = {
    new BuiltInComponentsFromContext(context)
      with LagomServiceClientComponents
      with AhcWSComponents
      with LagomDevModeComponents
      with controllers.AssetsComponents
    {
      override lazy val serviceInfo = ServiceInfo("p", Map("p" -> immutable.Seq(
        ServiceAcl.forPathRegex("/p"),
        ServiceAcl.forPathRegex("/assets/.*")
      )))
      override lazy val router = {
        val prefix = "/"
        wire[Routes]
      }
      override lazy val httpFilters = Nil
      lazy val applicationController = wire[controllers.Application]
    }.application
  }
} 
开发者ID:lagom,项目名称:lagom,代码行数:31,代码来源:Loader.scala



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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