本文整理汇总了Scala中javax.servlet.DispatcherType类的典型用法代码示例。如果您正苦于以下问题:Scala DispatcherType类的具体用法?Scala DispatcherType怎么用?Scala DispatcherType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DispatcherType类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: MyConfiguration
//设置package包名称以及导入依赖的类
package com.nakamura
import java.util
import javax.servlet.{DispatcherType, FilterRegistration}
import com.datasift.dropwizard.scala.ScalaBundle
import com.nakamura.camara.deputados.{DeputadosResource, DeputadosService}
import io.dropwizard.setup.{Bootstrap, Environment}
import io.dropwizard.{Application, Configuration}
import org.apache.spark.sql.SparkSession
import org.eclipse.jetty.servlets.CrossOriginFilter
import org.eclipse.jetty.servlets.CrossOriginFilter._
import org.hibernate.validator.constraints.NotEmpty
import scala.concurrent.ExecutionContext
class MyConfiguration extends Configuration {
@NotEmpty
val template = "foo"
}
class App extends Application[MyConfiguration] {
override def getName: String = "Camara"
private val logger = org.log4s.getLogger
logger.info(s"Initializing App.")
val spark = SparkSession
.builder()
.appName("Camara")
.master("local[*]")
.getOrCreate()
implicit val ec = ExecutionContext.global
override def initialize(bootstrap: Bootstrap[MyConfiguration]) {
bootstrap.addBundle(new ScalaBundle)
}
override def run(configuration: MyConfiguration, environment: Environment) {
val deputadosService = new DeputadosService(spark)
val deputadosResource = new DeputadosResource(deputadosService, ec)
environment.jersey.register(deputadosResource)
val filter: FilterRegistration.Dynamic = environment.servlets().addFilter(
"CamaraAbertaCORS", classOf[CrossOriginFilter])
filter.addMappingForUrlPatterns(util.EnumSet.of(DispatcherType.REQUEST),
false ,
"/deputados/fetch/*")
filter.setInitParameter(ALLOWED_METHODS_PARAM, "GET")
filter.setInitParameter(ALLOWED_ORIGINS_PARAM, "https?://localhost*,,*.akionakamura.github.io")
filter.setInitParameter(ALLOWED_HEADERS_PARAM, "Content-Type,Authorization")
}
}
object App extends App {
final def main(args: Array[String]) {
run(args: _*)
}
}
开发者ID:akionakamura,项目名称:camara,代码行数:61,代码来源:App.scala
示例2: Web
//设置package包名称以及导入依赖的类
import java.io.File
import java.util
import java.util.Locale
import javax.servlet.DispatcherType
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.FilterHolder
import org.eclipse.jetty.util.resource.{Resource, ResourceCollection}
import org.eclipse.jetty.webapp.WebAppContext
import refpay.RefPayPlan
import unfiltered.filter.Plan
import scala.util.Properties
object Web extends App{
Locale.setDefault(new Locale("no_NO"))
val port = Properties.envOrElse("PORT", "9998").toInt
val resources = new ResourceCollection(
Resource.newResource(new File("src/main/webapp"))
)
val server = new Server(port)
val context = new WebAppContext()
// context.setContextPath("/api")
context.setBaseResource(resources)
registerPlan(new RefPayPlan, "Dommerbetaling", context)
server.setHandler(context)
server.setSendDateHeader(true)
server.setStopAtShutdown(true)
server.start()
def registerPlan(plan: Plan, name: String, context: WebAppContext) {
val holder = new FilterHolder(plan)
holder.setName(name)
context.addFilter(holder, "/*", util.EnumSet.of(DispatcherType.REQUEST,DispatcherType.ASYNC,DispatcherType.ERROR,DispatcherType.FORWARD,DispatcherType.INCLUDE))
}
}
开发者ID:magott,项目名称:refpay,代码行数:43,代码来源:Web.scala
注:本文中的javax.servlet.DispatcherType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论