本文整理了Java中org.glassfish.jersey.server.model.AnnotatedMethod.getAnnotation()
方法的一些代码示例,展示了AnnotatedMethod.getAnnotation()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedMethod.getAnnotation()
方法的具体详情如下:
包路径:org.glassfish.jersey.server.model.AnnotatedMethod
类名称:AnnotatedMethod
方法名:getAnnotation
暂无
代码示例来源:origin: jersey/jersey
@Override
public boolean keep(AnnotatedMethod m) {
return m.getAnnotation(annotation) == null;
}
});
代码示例来源:origin: jersey/jersey
private void addSubResourceMethods(
final Resource.Builder resourceBuilder,
final MethodList methodList,
final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
final boolean encodedParameters,
final List<MediaType> defaultConsumedTypes,
final List<MediaType> defaultProducedTypes,
final Collection<Class<? extends Annotation>> defaultNameBindings,
final boolean extended
) {
for (AnnotatedMethod am : methodList.withMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
Resource.Builder childResourceBuilder = resourceBuilder.addChildResource(am.getAnnotation(Path.class).value());
ResourceMethod.Builder methodBuilder =
childResourceBuilder.addMethod(am.getMetaMethodAnnotations(HttpMethod.class).get(0).value())
.consumes(resolveConsumedTypes(am, defaultConsumedTypes))
.produces(resolveProducedTypes(am, defaultProducedTypes))
.encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
.nameBindings(defaultNameBindings)
.nameBindings(am.getAnnotations())
.handledBy(handlerClass, am.getMethod())
.handlingMethod(am.getDeclaredMethod())
.handlerParameters(resourceClassParameters)
.extended(extended || am.isAnnotationPresent(ExtendedResource.class));
introspectAsyncFeatures(am, methodBuilder);
}
}
代码示例来源:origin: jersey/jersey
@Override
public boolean keep(AnnotatedMethod m) {
return m.getAnnotation(annotation) == null;
}
});
代码示例来源:origin: jersey/jersey
private void addSubResourceMethods(
final Resource.Builder resourceBuilder,
final MethodList methodList,
final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
final boolean encodedParameters,
final List<MediaType> defaultConsumedTypes,
final List<MediaType> defaultProducedTypes,
final Collection<Class<? extends Annotation>> defaultNameBindings,
final boolean extended
) {
for (AnnotatedMethod am : methodList.withMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
Resource.Builder childResourceBuilder = resourceBuilder.addChildResource(am.getAnnotation(Path.class).value());
ResourceMethod.Builder methodBuilder =
childResourceBuilder.addMethod(am.getMetaMethodAnnotations(HttpMethod.class).get(0).value())
.consumes(resolveConsumedTypes(am, defaultConsumedTypes))
.produces(resolveProducedTypes(am, defaultProducedTypes))
.encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
.nameBindings(defaultNameBindings)
.nameBindings(am.getAnnotations())
.handledBy(handlerClass, am.getMethod())
.handlingMethod(am.getDeclaredMethod())
.handlerParameters(resourceClassParameters)
.extended(extended || am.isAnnotationPresent(ExtendedResource.class));
introspectAsyncFeatures(am, methodBuilder);
}
}
代码示例来源:origin: jersey/jersey
@Override
public boolean keep(AnnotatedMethod m) {
return m.getAnnotation(annotation) != null;
}
});
代码示例来源:origin: jersey/jersey
@Override
public boolean keep(AnnotatedMethod m) {
return m.getAnnotation(annotation) != null;
}
});
代码示例来源:origin: dropwizard/dropwizard
@Override
public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
// check to see if it has cache control annotation
final CacheControl cc = am.getAnnotation(CacheControl.class);
if (cc != null) {
configuration.register(new CacheControlledResponseFilter(cc));
}
}
代码示例来源:origin: jersey/jersey
private static List<MediaType> resolveProducedTypes(final AnnotatedMethod am, final List<MediaType> defaultProducedTypes) {
// Override default types if the annotation is present on the method
if (am.isAnnotationPresent(Produces.class)) {
return extractMediaTypes(am.getAnnotation(Produces.class));
}
return defaultProducedTypes;
}
代码示例来源:origin: jersey/jersey
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) {
// Override default types if the annotation is present on the method
if (am.isAnnotationPresent(Consumes.class)) {
return extractMediaTypes(am.getAnnotation(Consumes.class));
}
return defaultConsumedTypes;
}
代码示例来源:origin: jersey/jersey
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) {
// Override default types if the annotation is present on the method
if (am.isAnnotationPresent(Consumes.class)) {
return extractMediaTypes(am.getAnnotation(Consumes.class));
}
return defaultConsumedTypes;
}
代码示例来源:origin: jersey/jersey
private static List<MediaType> resolveProducedTypes(final AnnotatedMethod am, final List<MediaType> defaultProducedTypes) {
// Override default types if the annotation is present on the method
if (am.isAnnotationPresent(Produces.class)) {
return extractMediaTypes(am.getAnnotation(Produces.class));
}
return defaultProducedTypes;
}
代码示例来源:origin: apache/drill
@Override
public void configure(final ResourceInfo resourceInfo,
final FeatureContext configuration) {
AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
// RolesAllowed on the method takes precedence over PermitAll
RolesAllowed ra = am.getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(AuthCheckFilter.INSTANCE);
return;
}
// PermitAll takes precedence over RolesAllowed on the class
if (am.isAnnotationPresent(PermitAll.class)) {
// Do nothing.
return;
}
// RolesAllowed on the class takes precedence over PermitAll
ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(AuthCheckFilter.INSTANCE);
}
}
代码示例来源:origin: jersey/jersey
builder.append(template);
Path methodPath = method.getAnnotation(Path.class);
if (methodPath != null) {
String methodTemplate = methodPath.value();
代码示例来源:origin: jersey/jersey
@Override
public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
// DenyAll on the method take precedence over RolesAllowed and PermitAll
if (am.isAnnotationPresent(DenyAll.class)) {
configuration.register(new RolesAllowedRequestFilter());
return;
}
// RolesAllowed on the method takes precedence over PermitAll
RolesAllowed ra = am.getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(new RolesAllowedRequestFilter(ra.value()));
return;
}
// PermitAll takes precedence over RolesAllowed on the class
if (am.isAnnotationPresent(PermitAll.class)) {
// Do nothing.
return;
}
// DenyAll can't be attached to classes
// RolesAllowed on the class takes precedence over PermitAll
ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(new RolesAllowedRequestFilter(ra.value()));
}
}
代码示例来源:origin: jersey/jersey
@Override
public void configure(final ResourceInfo resourceInfo, final FeatureContext configuration) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
// DenyAll on the method take precedence over RolesAllowed and PermitAll
if (am.isAnnotationPresent(DenyAll.class)) {
configuration.register(new RolesAllowedRequestFilter());
return;
}
// RolesAllowed on the method takes precedence over PermitAll
RolesAllowed ra = am.getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(new RolesAllowedRequestFilter(ra.value()));
return;
}
// PermitAll takes precedence over RolesAllowed on the class
if (am.isAnnotationPresent(PermitAll.class)) {
// Do nothing.
return;
}
// DenyAll can't be attached to classes
// RolesAllowed on the class takes precedence over PermitAll
ra = resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class);
if (ra != null) {
configuration.register(new RolesAllowedRequestFilter(ra.value()));
}
}
代码示例来源:origin: jersey/jersey
/**
* Create a list of parameter models for a given Java method handling a resource
* method, sub-resource method or a sub-resource locator.
*
* @param concreteClass concrete resource method handler implementation class.
* @param declaringClass the class declaring the handling Java method.
* @param javaMethod Java method handling a resource method, sub-resource
* method or a sub-resource locator.
* @param keepEncoded set to {@code true} to disable automatic decoding
* of all the method parameters. (See {@link Encoded}.
* @return a list of handling method parameter models.
*/
public static List<Parameter> create(
Class concreteClass,
Class declaringClass,
Method javaMethod,
boolean keepEncoded) {
AnnotatedMethod method = new AnnotatedMethod(javaMethod);
return create(
concreteClass, declaringClass,
((null != method.getAnnotation(Encoded.class)) || keepEncoded),
method.getParameterTypes(),
method.getGenericParameterTypes(),
method.getParameterAnnotations());
}
代码示例来源:origin: jersey/jersey
/**
* Create a list of parameter models for a given Java method handling a resource
* method, sub-resource method or a sub-resource locator.
*
* @param concreteClass concrete resource method handler implementation class.
* @param declaringClass the class declaring the handling Java method.
* @param javaMethod Java method handling a resource method, sub-resource
* method or a sub-resource locator.
* @param keepEncoded set to {@code true} to disable automatic decoding
* of all the method parameters. (See {@link Encoded}.
* @return a list of handling method parameter models.
*/
public static List<Parameter> create(
Class concreteClass,
Class declaringClass,
Method javaMethod,
boolean keepEncoded) {
AnnotatedMethod method = new AnnotatedMethod(javaMethod);
return create(
concreteClass, declaringClass,
((null != method.getAnnotation(Encoded.class)) || keepEncoded),
method.getParameterTypes(),
method.getGenericParameterTypes(),
method.getParameterAnnotations());
}
代码示例来源:origin: jersey/jersey
private void addSubResourceLocators(
final Resource.Builder resourceBuilder,
final MethodList methodList,
final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
final boolean encodedParameters,
final boolean extended) {
for (AnnotatedMethod am : methodList.withoutMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
final String path = am.getAnnotation(Path.class).value();
Resource.Builder builder = resourceBuilder;
if (path != null && !path.isEmpty() && !"/".equals(path)) {
builder = resourceBuilder.addChildResource(path);
}
builder.addMethod()
.encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
.handledBy(handlerClass, am.getMethod())
.handlingMethod(am.getDeclaredMethod())
.handlerParameters(resourceClassParameters)
.extended(extended || am.isAnnotationPresent(ExtendedResource.class));
}
}
}
代码示例来源:origin: jersey/jersey
private void addSubResourceLocators(
final Resource.Builder resourceBuilder,
final MethodList methodList,
final List<Parameter> resourceClassParameters, // parameters derived from fields and setters on the resource class
final boolean encodedParameters,
final boolean extended) {
for (AnnotatedMethod am : methodList.withoutMetaAnnotation(HttpMethod.class).withAnnotation(Path.class)) {
final String path = am.getAnnotation(Path.class).value();
Resource.Builder builder = resourceBuilder;
if (path != null && !path.isEmpty() && !"/".equals(path)) {
builder = resourceBuilder.addChildResource(path);
}
builder.addMethod()
.encodedParameters(encodedParameters || am.isAnnotationPresent(Encoded.class))
.handledBy(handlerClass, am.getMethod())
.handlingMethod(am.getDeclaredMethod())
.handlerParameters(resourceClassParameters)
.extended(extended || am.isAnnotationPresent(ExtendedResource.class));
}
}
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
private static List<MediaType> resolveConsumedTypes(final AnnotatedMethod am, final List<MediaType> defaultConsumedTypes) {
// Override default types if the annotation is present on the method
if (am.isAnnotationPresent(Consumes.class)) {
return extractMediaTypes(am.getAnnotation(Consumes.class));
}
return defaultConsumedTypes;
}
内容来源于网络,如有侵权,请联系作者删除!