public void setInTemplate(String loc) { inTemplates = createTemplates(loc); }
protected Templates createTemplates(String loc) { try { return createTemplates(ResourceUtils.getResourceURL(loc, this.getBus())); } catch (Exception ex) { LOG.warning("No template can be created : " + ex.getMessage()); } return null; }
protected Templates createTemplatesFromContext() { MessageContext mc = getContext(); if (mc != null) { String template = (String)mc.getContextualProperty(XSLT_TEMPLATE_PROPERTY); if (template != null) { return createTemplates(template); } } return null; }
throws Exception { Templates t = createTemplates(getOutTemplates(anns, mt), outParamsMap, outProperties); if (t == null && supportJaxbOnly) { super.marshalToOutputStream(ms, obj, os, anns, mt); TemplatesImpl ti = (TemplatesImpl)t; th = factory.newTransformerHandler(ti.getTemplates()); this.trySettingProperties(th, ti); Result result = getStreamResult(os, anns, mt); if (systemId != null) { result.setSystemId(systemId); if (getContext() == null) { th.startDocument(); if (getContext() == null) { th.endDocument();
try { Templates t = createTemplates(getInTemplates(anns, mt), inParamsMap, inProperties); if (t == null && supportJaxbOnly) { return super.unmarshalFromInputStream(unmarshaller, is, anns, mt); TemplatesImpl ti = (TemplatesImpl)t; filter = factory.newXMLFilter(ti.getTemplates()); trySettingProperties(filter, ti);
@Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { if (!super.isReadable(type, genericType, anns, mt)) { return false; } if (InjectionUtils.isSupportedCollectionOrArray(type)) { return supportJaxbOnly; } // if the user has set the list of in classes and a given class // is in that list then it can only be handled by the template if (inClassCanBeHandled(type.getName()) || inClassesToHandle == null && !supportJaxbOnly) { return inTemplatesAvailable(type, anns, mt); } return supportJaxbOnly; }
@Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { // JAXB support is required if (!super.isWriteable(type, genericType, anns, mt)) { return false; } if (InjectionUtils.isSupportedCollectionOrArray(type)) { return supportJaxbOnly; } // if the user has set the list of out classes and a given class // is in that list then it can only be handled by the template if (outClassCanBeHandled(type.getName()) || outClassesToHandle == null && !supportJaxbOnly) { return outTemplatesAvailable(type, anns, mt); } return supportJaxbOnly; }
MessageContext mc = getContext(); if (mc != null) { UriInfo ui = mc.getUriInfo(); setTransformParameters(templ, segments.get(segments.size() - 1).getMatrixParameters()); setTransformParameters(templ, ui.getQueryParameters()); templ.setTransformerParameter(ABSOLUTE_PATH_PARAMETER, ui.getAbsolutePath().toString()); templ.setTransformerParameter(RELATIVE_PATH_PARAMETER, ui.getPath());
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; }
@Override protected void marshalToWriter(Marshaller ms, Object obj, XMLStreamWriter writer, Annotation[] anns, MediaType mt) throws Exception { CachedOutputStream out = new CachedOutputStream(); marshalToOutputStream(ms, obj, out, anns, mt); StaxUtils.copy(new StreamSource(out.getInputStream()), writer); }
protected Templates createTemplates(String loc) { try { URL urlStream = ResourceUtils.getResourceURL(loc, this.getBus()); if (urlStream == null) { return null; } Reader r = new BufferedReader( new InputStreamReader(urlStream.openStream(), "UTF-8")); Source source = new StreamSource(r); source.setSystemId(urlStream.toExternalForm()); if (factory == null) { factory = (SAXTransformerFactory)TransformerFactory.newInstance(); if (uriResolver != null) { factory.setURIResolver(uriResolver); } } return factory.newTemplates(source); } catch (Exception ex) { LOG.warning("No template can be created : " + ex.getMessage()); } return null; }
throws Exception { Templates t = createTemplates(getOutTemplates(mt), outParamsMap, outProperties); if (t == null && supportJaxbOnly) { super.marshalToOutputStream(ms, obj, os, mt); TemplatesImpl ti = (TemplatesImpl)t; th = factory.newTransformerHandler(ti.getTemplates()); this.trySettingProperties(th, ti); if (getContext() == null) { th.startDocument(); if (getContext() == null) { th.endDocument();
try { Templates t = createTemplates(getInTemplates(mt), inParamsMap, inProperties); if (t == null && supportJaxbOnly) { return super.unmarshalFromInputStream(unmarshaller, is, mt); TemplatesImpl ti = (TemplatesImpl)t; filter = factory.newXMLFilter(ti.getTemplates()); trySettingProperties(filter, ti);
@Override public boolean isReadable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { if (!super.isReadable(type, genericType, anns, mt)) { return false; } if (InjectionUtils.isSupportedCollectionOrArray(type)) { return supportJaxbOnly; } // if the user has set the list of in classes and a given class // is in that list then it can only be handled by the template if (inClassCanBeHandled(type.getName()) || inClassesToHandle == null && !supportJaxbOnly) { return inTemplatesAvailable(mt); } else { return supportJaxbOnly; } }
@Override public boolean isWriteable(Class<?> type, Type genericType, Annotation[] anns, MediaType mt) { // JAXB support is required if (!super.isWriteable(type, genericType, anns, mt)) { return false; } if (InjectionUtils.isSupportedCollectionOrArray(type)) { return supportJaxbOnly; } // if the user has set the list of out classes and a given class // is in that list then it can only be handled by the template if (outClassCanBeHandled(type.getName()) || outClassesToHandle == null && !supportJaxbOnly) { return outTemplatesAvailable(mt); } else { return supportJaxbOnly; } }
MessageContext mc = getContext(); if (mc != null) { UriInfo ui = mc.getUriInfo(); setTransformParameters(templ, segments.get(segments.size() - 1).getMatrixParameters()); setTransformParameters(templ, ui.getQueryParameters()); templ.setTransformerParameter(ABSOLUTE_PATH_PARAMETER, ui.getAbsolutePath().toString()); templ.setTransformerParameter(RELATIVE_PATH_PARAMETER, ui.getPath());
@Override protected void marshalToWriter(Marshaller ms, Object obj, XMLStreamWriter writer, MediaType mt) throws Exception { CachedOutputStream out = new CachedOutputStream(); marshalToOutputStream(ms, obj, out, mt); StaxUtils.copy(new StreamSource(out.getInputStream()), writer); }
public void setOutTemplate(String loc) { outTemplates = createTemplates(loc); }
public void setOutTemplate(String loc) { outTemplates = createTemplates(loc); }
public void setInTemplate(String loc) { inTemplates = createTemplates(loc); }