use of java.lang.annotation.Annotation in project jersey by jersey.
the class IntrospectionModeller method doCreateResourceBuilder.
private Resource.Builder doCreateResourceBuilder() {
if (!disableValidation) {
checkForNonPublicMethodIssues();
}
final Class<?> annotatedResourceClass = ModelHelper.getAnnotatedResourceClass(handlerClass);
final Path rPathAnnotation = annotatedResourceClass.getAnnotation(Path.class);
final boolean keepEncodedParams = (null != annotatedResourceClass.getAnnotation(Encoded.class));
final List<MediaType> defaultConsumedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Consumes.class));
final List<MediaType> defaultProducedTypes = extractMediaTypes(annotatedResourceClass.getAnnotation(Produces.class));
final Collection<Class<? extends Annotation>> defaultNameBindings = ReflectionHelper.getAnnotationTypes(annotatedResourceClass, NameBinding.class);
final MethodList methodList = new MethodList(handlerClass);
final List<Parameter> resourceClassParameters = new LinkedList<>();
checkResourceClassSetters(methodList, keepEncodedParams, resourceClassParameters);
checkResourceClassFields(keepEncodedParams, InvocableValidator.isSingleton(handlerClass), resourceClassParameters);
Resource.Builder resourceBuilder;
if (null != rPathAnnotation) {
resourceBuilder = Resource.builder(rPathAnnotation.value());
} else {
resourceBuilder = Resource.builder();
}
boolean extended = false;
if (handlerClass.isAnnotationPresent(ExtendedResource.class)) {
resourceBuilder.extended(true);
extended = true;
}
resourceBuilder.name(handlerClass.getName());
addResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
addSubResourceMethods(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, defaultConsumedTypes, defaultProducedTypes, defaultNameBindings, extended);
addSubResourceLocators(resourceBuilder, methodList, resourceClassParameters, keepEncodedParams, extended);
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.finest(LocalizationMessages.NEW_AR_CREATED_BY_INTROSPECTION_MODELER(resourceBuilder.toString()));
}
return resourceBuilder;
}
use of java.lang.annotation.Annotation in project jersey by jersey.
the class JaxbStringReaderProviderTest method stringReaderDoesNotReadExternalDtds.
@Test
public void stringReaderDoesNotReadExternalDtds() {
Provider<SAXParserFactory> saxParserFactoryProvider = new Provider<SAXParserFactory>() {
final SaxParserFactoryInjectionProvider spf = new SaxParserFactoryInjectionProvider(new CommonConfig(RuntimeType.SERVER, ComponentBag.INCLUDE_ALL));
@Override
public SAXParserFactory get() {
return spf.get();
}
};
JaxbStringReaderProvider.RootElementProvider provider = new JaxbStringReaderProvider.RootElementProvider(saxParserFactoryProvider, new Providers() {
@Override
public <T> MessageBodyReader<T> getMessageBodyReader(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return null;
}
@Override
public <T> MessageBodyWriter<T> getMessageBodyWriter(Class<T> type, Type genericType, Annotation[] annotations, MediaType mediaType) {
return null;
}
@Override
public <T extends Throwable> ExceptionMapper<T> getExceptionMapper(Class<T> type) {
return null;
}
@Override
public <T> ContextResolver<T> getContextResolver(Class<T> contextType, MediaType mediaType) {
return null;
}
});
String content = "<!DOCTYPE x SYSTEM 'file:///no-such-file'> <rootObject/>";
provider.getConverter(RootObject.class, null, null).fromString(content);
}
use of java.lang.annotation.Annotation in project jersey by jersey.
the class JsonEntityFilteringClientTest method testEntityAnnotationsDefaultView.
@Test
public void testEntityAnnotationsDefaultView() throws Exception {
final OneFilteringOnClassEntity entity = target().request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE, new Annotation[] { new DefaultFilteringScope() }), OneFilteringOnClassEntity.class);
_testEmptyEntity(entity);
}
use of java.lang.annotation.Annotation in project jersey by jersey.
the class JsonEntityFilteringClientTest method testEntityAnnotationsInvalidView.
@Test
public void testEntityAnnotationsInvalidView() throws Exception {
final OneFilteringOnClassEntity entity = target().request().post(Entity.entity(OneFilteringOnClassEntity.INSTANCE, MediaType.APPLICATION_JSON_TYPE, new Annotation[] { CustomAnnotationLiteral.INSTANCE }), OneFilteringOnClassEntity.class);
_testEmptyEntity(entity);
}
use of java.lang.annotation.Annotation in project flink by apache.
the class UdfAnalyzerTest method compareAnalyzerResultWithAnnotationsDualInputWithKeys.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void compareAnalyzerResultWithAnnotationsDualInputWithKeys(Class<?> baseClass, Class<?> clazz, String in1, String in2, String out, String[] keys1, String[] keys2) {
final TypeInformation<?> in1Type = TypeInfoParser.parse(in1);
final TypeInformation<?> in2Type = TypeInfoParser.parse(in2);
final TypeInformation<?> outType = TypeInfoParser.parse(out);
// expected
final Set<Annotation> annotations = FunctionAnnotation.readDualForwardAnnotations(clazz);
final DualInputSemanticProperties expected = SemanticPropUtil.getSemanticPropsDual(annotations, in1Type, in2Type, outType);
// actual
final UdfAnalyzer ua = new UdfAnalyzer(baseClass, clazz, "operator", in1Type, in2Type, outType, (keys1 == null) ? null : new Keys.ExpressionKeys(keys1, in1Type), (keys2 == null) ? null : new Keys.ExpressionKeys(keys2, in2Type), true);
ua.analyze();
final DualInputSemanticProperties actual = (DualInputSemanticProperties) ua.getSemanticProperties();
assertEquals(expected.toString(), actual.toString());
}
Aggregations