本文整理汇总了Scala中javax.ws.rs.ext.Provider类的典型用法代码示例。如果您正苦于以下问题:Scala Provider类的具体用法?Scala Provider怎么用?Scala Provider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Provider类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Scala代码示例。
示例1: MappingProvider
//设置package包名称以及导入依赖的类
package works.weave.socks.aws.orders.presentation
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import javax.ws.rs.ext.Provider
import works.weave.socks.aws.orders.ProjectDefaultJacksonMapper
@Provider
@Produces(Array(MediaType.APPLICATION_JSON))
class MappingProvider extends JacksonJaxbJsonProvider {
setMapper(MappingProvider.mapper)
}
object MappingProvider {
val mapper = {
val presentationMapper = ProjectDefaultJacksonMapper.build()
// modify as necessary for presentation purpose
presentationMapper
}
}
示例2: ScalaObjectMapperProvider
//设置package包名称以及导入依赖的类
package org.littlewings.wildflyswarm.jaxrs
import javax.ws.rs.core.MediaType
import javax.ws.rs.ext.{ContextResolver, Provider}
import javax.ws.rs.{Consumes, Produces}
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
@Provider
@Consumes(Array(MediaType.APPLICATION_JSON))
@Produces(Array(MediaType.APPLICATION_JSON))
class ScalaObjectMapperProvider extends ContextResolver[ObjectMapper] {
override def getContext(typ: Class[_]): ObjectMapper = {
val objectMapper = new ObjectMapper
objectMapper.registerModule(DefaultScalaModule)
objectMapper
}
}