[ 
https://issues.apache.org/jira/browse/CXF-5854?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14173459#comment-14173459
 ] 

Vjacheslav Borisov commented on CXF-5854:
-----------------------------------------

I am still using this crappy fix to implement this feature. May be it worth 
implementing?

{code:title=XSLTJaxbProvider2.java|borderStyle=solid}
@Provider
public class XSLTJaxbProvider2 extends XSLTJaxbProvider {

    private static final String PARENTCLASS = 
"org.apache.cxf.jaxrs.provider.XSLTJaxbProvider";

    private boolean refreshTemplates = false;

    /**
     * Set the value of refreshTemplates
     *
     * @param refreshTemplates new value of refreshTemplates
     */
    public void setRefreshTemplates(boolean refreshTemplates) {
        this.refreshTemplates = refreshTemplates;
    }

    private void setAnnotationTemplates(Object value) {
        Field field = BeanTool.getFieldFromClass(PARENTCLASS, 
"annotationTemplates");
        field.setAccessible(true);
        try {
            field.set(this, value);
        } catch (IllegalArgumentException | IllegalAccessException ex) {
            throw new RuntimeException(ex);
        }
    }

    @Override
    public boolean isWriteable(Class type, Type genericType, Annotation[] anns, 
MediaType mt) {
        if (refreshTemplates) {
            setAnnotationTemplates(new ConcurrentHashMap<String, Templates>());
        }
        return super.isWriteable(type, genericType, anns, mt); //To change body 
of generated methods, choose Tools | Templates.
    }
}
{code}

> Add property "refreshTemplates" to XSLTJaxbProvider
> ---------------------------------------------------
>
>                 Key: CXF-5854
>                 URL: https://issues.apache.org/jira/browse/CXF-5854
>             Project: CXF
>          Issue Type: Improvement
>          Components: JAX-RS
>    Affects Versions: 3.0.0
>            Reporter: Vjacheslav Borisov
>            Priority: Minor
>
> Netbeans has feature named "Deploy on save" 
> http://wiki.netbeans.org/FaqDeployOnSave, which allows to compile classes and 
> copy static resources to web root "on save".
> But this is not works with XSLTJaxbProvider, which caches internally its 
> templates and XSLTJaxbProvider does not see changed resources.
> This can be "fixed" using parameter like "refreshTemplates", which, if set to 
> true,
> cleans all loaded templates on each request. This can be useful and save lot 
> of time in development environment.
> {code:title=XSLTJaxbProvider.java|borderStyle=solid}
> public class XSLTJaxbProvider<T> extends JAXBElementProvider<T> {
>     public boolean isWriteable(Class type, Type genericType, Annotation[] 
> anns, MediaType mt) {
> /* cut */
>         if (refreshTemplates) {
>             annotationTemplates=new ConcurrentHashMap<String, Templates>();
>            //refresh other types of templates
>         }
> /* cut */
>     }
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to