protected Templates getAnnotationTemplates(Annotation[] anns) {
   Templates t = null;
   XSLTTransform ann = AnnotationUtils.getAnnotation(anns, XSLTTransform.class);
   if (ann != null) {
     t = annotationTemplates.get(ann.value());
   }
   return t;
 }
Esempio n. 2
0
 private void addXslProcessingInstruction(Marshaller ms, MediaType mt, XSLTTransform ann)
     throws Exception {
   if (ann.type() == XSLTTransform.TransformType.CLIENT
       || ann.type() == XSLTTransform.TransformType.BOTH && ann.mediaTypes().length > 0) {
     for (String s : ann.mediaTypes()) {
       if (mt.isCompatible(JAXRSUtils.toMediaType(s))) {
         return;
       }
     }
     String absRef = resolveXMLResourceURI(ann.value());
     String xslPi = "<?xml-stylesheet type=\"text/xsl\" href=\"" + absRef + "\"?>";
     setXmlPiProperty(ms, xslPi);
   }
 }
 protected XSLTTransform getXsltTransformAnn(Annotation[] anns, MediaType mt) {
   XSLTTransform ann = AnnotationUtils.getAnnotation(anns, XSLTTransform.class);
   if (ann != null && ann.type() != XSLTTransform.TransformType.CLIENT) {
     if (ann.mediaTypes().length > 0) {
       for (String s : ann.mediaTypes()) {
         if (mt.isCompatible(JAXRSUtils.toMediaType(s))) {
           return ann;
         }
       }
       return null;
     }
     return ann;
   }
   return null;
 }
 protected Templates getTemplatesFromAnnotation(Class<?> cls, Annotation[] anns, MediaType mt) {
   Templates t = null;
   XSLTTransform ann = getXsltTransformAnn(anns, mt);
   if (ann != null) {
     t = annotationTemplates.get(ann.value());
     if (t == null || refreshTemplates) {
       String path = ann.value();
       final String cp = "classpath:";
       if (!path.startsWith(cp)) {
         path = cp + path;
       }
       t = createTemplates(path);
       if (t == null) {
         createTemplates(ClassLoaderUtils.getResource(ann.value(), cls));
       }
       if (t != null) {
         annotationTemplates.put(ann.value(), t);
       }
     }
   }
   return t;
 }