本文整理了Java中org.glassfish.jersey.server.model.AnnotatedMethod.getParameterAnnotations()
方法的一些代码示例,展示了AnnotatedMethod.getParameterAnnotations()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AnnotatedMethod.getParameterAnnotations()
方法的具体详情如下:
包路径:org.glassfish.jersey.server.model.AnnotatedMethod
类名称:AnnotatedMethod
方法名:getParameterAnnotations
[英]Get method parameter annotations.
[中]获取方法参数注释。
代码示例来源:origin: dropwizard/dropwizard
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
final Class<?>[] parameterTypes = am.getParameterTypes();
final Type[] parameterGenericTypes = am.getGenericParameterTypes();
代码示例来源:origin: jersey/jersey
for (Annotation[] paramAnns : method.getParameterAnnotations()) {
for (Annotation ann : paramAnns) {
if (Objects.equals(ann.annotationType(), QueryParam.class)) {
代码示例来源:origin: jersey/jersey
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
}
}
}
for (Class<?> paramType : am.getParameterTypes()) {
if (SseEventSink.class.equals(paramType)) {
resourceMethodBuilder.sse();
}
}
}
代码示例来源:origin: jersey/jersey
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
}
}
}
for (Class<?> paramType : am.getParameterTypes()) {
if (SseEventSink.class.equals(paramType)) {
resourceMethodBuilder.sse();
}
}
}
代码示例来源:origin: dropwizard/dropwizard
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
final Class<?>[] parameterTypes = am.getParameterTypes();
// First, check for any @Auth annotations on the method.
for (int i = 0; i < parameterAnnotations.length; i++) {
for (final Annotation annotation : parameterAnnotations[i]) {
if (annotation instanceof Auth) {
// Optional auth requires that a concrete AuthFilter be provided.
if (parameterTypes[i].equals(Optional.class) && authFilter != null) {
context.register(new WebApplicationExceptionCatchingFilter(authFilter));
return;
} else {
registerAuthFilter(context);
return;
}
}
}
}
// Second, check for any authorization annotations on the class or method.
// Note that @DenyAll shouldn't be attached to classes.
final boolean annotationOnClass = (resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class) != null) ||
(resourceInfo.getResourceClass().getAnnotation(PermitAll.class) != null);
final boolean annotationOnMethod = am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) ||
am.isAnnotationPresent(PermitAll.class);
if (annotationOnClass || annotationOnMethod) {
registerAuthFilter(context);
}
}
代码示例来源: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: org.glassfish.jersey.core/jersey-server
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
}
}
}
for (Class<?> paramType : am.getParameterTypes()) {
if (SseEventSink.class.equals(paramType)) {
resourceMethodBuilder.sse();
}
}
}
代码示例来源:origin: org.glassfish.jersey.core/jersey-server
/**
* 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: hstaudacher/osgi-jax-rs-connector
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
return;
}
}
}
}
代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
return;
}
}
}
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
return;
}
}
}
}
代码示例来源:origin: io.dropwizard/dropwizard-auth
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
final Class<?>[] parameterTypes = am.getParameterTypes();
final Type[] parameterGenericTypes = am.getGenericParameterTypes();
代码示例来源:origin: org.glassfish.jersey.bundles/jaxrs-ri
private static void introspectAsyncFeatures(AnnotatedMethod am, ResourceMethod.Builder resourceMethodBuilder) {
if (am.isAnnotationPresent(ManagedAsync.class)) {
resourceMethodBuilder.managedAsync();
}
for (Annotation[] annotations : am.getParameterAnnotations()) {
for (Annotation annotation : annotations) {
if (annotation.annotationType() == Suspended.class) {
resourceMethodBuilder.suspended(AsyncResponse.NO_TIMEOUT, TimeUnit.MILLISECONDS);
}
}
}
for (Class<?> paramType : am.getParameterTypes()) {
if (SseEventSink.class.equals(paramType)) {
resourceMethodBuilder.sse();
}
}
}
代码示例来源:origin: dropwizard/dropwizard-java8
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
if (am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) ||
am.isAnnotationPresent(PermitAll.class)) {
context.register(authFilter);
} else {
for (Annotation[] annotations : parameterAnnotations) {
for (Annotation annotation : annotations) {
if (annotation instanceof Auth) {
context.register(authFilter);
return;
}
}
}
}
}
}
代码示例来源:origin: hstaudacher/osgi-jax-rs-connector
/**
* 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: io.dropwizard/dropwizard-auth
@Override
public void configure(ResourceInfo resourceInfo, FeatureContext context) {
final AnnotatedMethod am = new AnnotatedMethod(resourceInfo.getResourceMethod());
final Annotation[][] parameterAnnotations = am.getParameterAnnotations();
final Class<?>[] parameterTypes = am.getParameterTypes();
// First, check for any @Auth annotations on the method.
for (int i = 0; i < parameterAnnotations.length; i++) {
for (final Annotation annotation : parameterAnnotations[i]) {
if (annotation instanceof Auth) {
// Optional auth requires that a concrete AuthFilter be provided.
if (parameterTypes[i].equals(Optional.class) && authFilter != null) {
context.register(new WebApplicationExceptionCatchingFilter(authFilter));
return;
} else {
registerAuthFilter(context);
return;
}
}
}
}
// Second, check for any authorization annotations on the class or method.
// Note that @DenyAll shouldn't be attached to classes.
final boolean annotationOnClass = (resourceInfo.getResourceClass().getAnnotation(RolesAllowed.class) != null) ||
(resourceInfo.getResourceClass().getAnnotation(PermitAll.class) != null);
final boolean annotationOnMethod = am.isAnnotationPresent(RolesAllowed.class) || am.isAnnotationPresent(DenyAll.class) ||
am.isAnnotationPresent(PermitAll.class);
if (annotationOnClass || annotationOnMethod) {
registerAuthFilter(context);
}
}
代码示例来源:origin: org.glassfish.jersey.bundles/jaxrs-ri
/**
* 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: com.eclipsesource.jaxrs/jersey-all
/**
* 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: hstaudacher/osgi-jax-rs-connector
/**
* 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());
}
内容来源于网络,如有侵权,请联系作者删除!