本文整理了Java中javax.ws.rs.ext.Provider.<init>()
方法的一些代码示例,展示了Provider.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Provider.<init>()
方法的具体详情如下:
包路径:javax.ws.rs.ext.Provider
类名称:Provider
方法名:<init>
暂无
代码示例来源:origin: dropwizard/dropwizard
@Provider
@Produces(MediaType.WILDCARD)
public class OptionalIntMessageBodyWriter implements MessageBodyWriter<OptionalInt> {
// Jersey ignores this
@Override
public long getSize(OptionalInt entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return -1;
}
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return OptionalInt.class.isAssignableFrom(type);
}
@Override
public void writeTo(OptionalInt entity,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException {
if (!entity.isPresent()) {
throw EmptyOptionalException.INSTANCE;
}
entityStream.write(Integer.toString(entity.getAsInt()).getBytes(StandardCharsets.US_ASCII));
}
}
代码示例来源:origin: jersey/jersey
@Provider
@Consumes("text/plain")
@Produces("text/plain")
public static class TextPlain extends ClipboardDataProvider {
@Override
public void writeTo(final Object t, final Class type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType, final MultivaluedMap httpHeaders, final OutputStream entityStream)
throws IOException, WebApplicationException {
entityStream.write(t.toString().getBytes(MessageUtils.getCharset(mediaType)));
}
@Override
public Object readFrom(final Class type, final Type genericType, final Annotation[] annotations,
final MediaType mediaType, final MultivaluedMap httpHeaders, final InputStream entityStream)
throws IOException, WebApplicationException {
return new ClipboardData(readStringFromStream(entityStream, MessageUtils.getCharset(mediaType)));
}
}
代码示例来源:origin: Netflix/conductor
@Provider
public class WebAppExceptionMapper implements ExceptionMapper<WebApplicationException> {
@Context
private UriInfo uriInfo;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Produces("application/atom+*")
@Consumes("application/atom+*")
public class AtomEntryProvider implements MessageBodyReader<Entry>, MessageBodyWriter<Entry>
@Context
protected Providers providers;
代码示例来源:origin: dropwizard/dropwizard
@Provider
@Produces({MediaType.TEXT_HTML, MediaType.APPLICATION_XHTML_XML})
public class ViewMessageBodyWriter implements MessageBodyWriter<View> {
@Context
@Nullable
private HttpHeaders headers;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Consumes("multipart/related")
public class MultipartRelatedReader implements
MessageBodyReader<MultipartRelatedInput>
protected @Context Providers workers;
代码示例来源:origin: apache/hbase
@Provider
@Consumes({Constants.MIMETYPE_PROTOBUF, Constants.MIMETYPE_PROTOBUF_IETF})
@InterfaceAudience.Private
public class ProtobufMessageBodyConsumer
代码示例来源:origin: atomix/atomix
@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
private static class JacksonProvider implements ContextResolver<ObjectMapper> {
private final ObjectMapper mapper;
JacksonProvider(ObjectMapper mapper) {
this.mapper = mapper;
}
@Override
public ObjectMapper getContext(Class<?> type) {
return mapper;
}
}
}
代码示例来源:origin: dropwizard/dropwizard
@Provider
@Produces(MediaType.WILDCARD)
public class OptionalLongMessageBodyWriter implements MessageBodyWriter<OptionalLong> {
// Jersey ignores this
@Override
public long getSize(OptionalLong entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return -1;
}
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return OptionalLong.class.isAssignableFrom(type);
}
@Override
public void writeTo(OptionalLong entity,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException {
if (!entity.isPresent()) {
throw EmptyOptionalException.INSTANCE;
}
entityStream.write(Long.toString(entity.getAsLong()).getBytes(StandardCharsets.US_ASCII));
}
}
代码示例来源:origin: resteasy/Resteasy
@Provider
@Produces("application/atom+*")
@Consumes("application/atom+*")
public class AtomFeedProvider implements MessageBodyReader<Feed>, MessageBodyWriter<Feed>
@Context
protected Providers providers;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Produces("text/plain")
public class PKCS7SignatureTextWriter implements MessageBodyWriter<SignedOutput>
@Context
protected Providers providers;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Consumes("multipart/*")
public class MultipartReader implements MessageBodyReader<MultipartInput>
protected @Context Providers workers;
代码示例来源:origin: scouter-project/scouter
/**
* Created by Gun Lee(gunlee01@gmail.com) on 2017. 8. 25.
*/
@Provider
@Slf4j
public class ValidationExceptionMapper implements ExceptionMapper<javax.validation.ValidationException> {
@Context
UriInfo uriInfo;
@Override
public Response toResponse(javax.validation.ValidationException e) {
final StringBuilder strBuilder = new StringBuilder("[ValidationException] ");
for (ConstraintViolation<?> cv : ((ConstraintViolationException) e).getConstraintViolations()) {
strBuilder.append(cv.getPropertyPath().toString() + " " + cv.getMessage());
}
CommonResultView resultView = CommonResultView.fail(400, 400, strBuilder.toString(), null);
return Response.status(resultView.getStatus())
.type(MediaType.APPLICATION_JSON)
.entity(resultView).build();
}
}
代码示例来源:origin: resteasy/Resteasy
@Provider
@Consumes("multipart/signed")
public class MultipartSignedReader implements MessageBodyReader<SignedInput>
代码示例来源:origin: jenkinsci/gitlab-plugin
/**
* @author Robin Müller
*/
@Provider
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public class JacksonConfig implements ContextResolver<ObjectMapper> {
public ObjectMapper getContext(Class<?> type) {
return new ObjectMapper()
.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
}
}
代码示例来源:origin: dropwizard/dropwizard
@Provider
@Produces(MediaType.WILDCARD)
public class OptionalDoubleMessageBodyWriter implements MessageBodyWriter<OptionalDouble> {
// Jersey ignores this
@Override
public long getSize(OptionalDouble entity, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return -1;
}
@Override
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return OptionalDouble.class.isAssignableFrom(type);
}
@Override
public void writeTo(OptionalDouble entity,
Class<?> type,
Type genericType,
Annotation[] annotations,
MediaType mediaType,
MultivaluedMap<String, Object> httpHeaders,
OutputStream entityStream) throws IOException {
if (!entity.isPresent()) {
throw EmptyOptionalException.INSTANCE;
}
entityStream.write(Double.toString(entity.getAsDouble()).getBytes(StandardCharsets.US_ASCII));
}
}
代码示例来源:origin: org.glassfish.jersey.media/jersey-media-json-jackson
@Provider
@Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" JSON variants
@Produces(MediaType.WILDCARD)
public class JacksonJsonProvider
extends ProviderBase<JacksonJsonProvider,
@Context
protected Providers _providers;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Produces("multipart/signed")
public class MultipartSignedWriter implements MessageBodyWriter<SignedOutput>
@Context
protected Providers providers;
代码示例来源:origin: resteasy/Resteasy
@Provider
@Consumes("multipart/related")
public class XopWithMultipartRelatedReader implements MessageBodyReader<Object>
protected @Context Providers workers;
代码示例来源:origin: apache/storm
@Provider
public class AuthorizedUserFilter implements ContainerRequestFilter {
public static IAuthorizer uiAclHandler;
@Context private ResourceInfo resourceInfo;
内容来源于网络,如有侵权,请联系作者删除!