<div dir="ltr">Hi Alessio,<div><br></div><div>thanks a lot for your help merging the pull request.</div><div><br></div><div>I already created a custom ResourceClassProcessor for the MVC 1.0 reference implementation Ozark which automatically adds @Produces(&quot;text/html&quot;) to all MVC controllers. </div><div><br></div><div>See the corresponding code here:</div><div><br></div><div><a href="https://github.com/chkal/ozark/tree/15920a07429b71a15fab8ae19e8e9cad50bba355/resteasy/src/main/java/org/mvcspec/ozark/resteasy/metadata">https://github.com/chkal/ozark/tree/15920a07429b71a15fab8ae19e8e9cad50bba355/resteasy/src/main/java/org/mvcspec/ozark/resteasy/metadata</a><br></div><div><br></div><div>Would this be a proof of concept as you mention it?</div><div><br></div><div>Christian</div><div><br></div><div><br></div></div><br><br><div class="gmail_quote"><div dir="ltr">Am Fr., 16. März 2018 um 17:20 Uhr schrieb Alessio Soldano &lt;<a href="mailto:asoldano@redhat.com">asoldano@redhat.com</a>&gt;:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div>OK, for the records, I&#39;ve just merged <a href="https://github.com/resteasy/Resteasy/pull/1449" target="_blank">https://github.com/resteasy/Resteasy/pull/1449</a> , which basically includes the changes Christian proposed.<br></div>Now I think we need either a proof of concept of the integration this was needed for or a bit of test coverage for the spi.<br></div>Christian, is this something you can provide too?<br></div>Thanks<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jan 11, 2018 at 7:03 AM, Christian Kaltepoth <span dir="ltr">&lt;<a href="mailto:christian@kaltepoth.de" target="_blank">christian@kaltepoth.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Alessio,<div><br></div><div>thanks a lot for the feedback. I&#39;m not sure if spending time on keeping the old <span style="font-size:12.8px">ResourceBuilder API (the static methods) is worth the effort, because it is used just in 2-3 places IIRC. But I&#39;ll have a look at this while working on the PR.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I&#39;ll try to split my work into a few PR so they are easier to review. </span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Thanks a lot</span></div><span class="m_3315405566992007006HOEnZb"><font color="#888888"><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Christian</span></div></font></span></div><div class="m_3315405566992007006HOEnZb"><div class="m_3315405566992007006h5"><div class="gmail_extra"><br><div class="gmail_quote">2018-01-10 15:18 GMT+01:00 Alessio Soldano <span dir="ltr">&lt;<a href="mailto:asoldano@redhat.com" target="_blank">asoldano@redhat.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>Hi Christian,<br></div>first of all sorry for the late reply, long XMas break.<br></div>Your proposal makes sense to me. For better backward compatibility, it might be worth having the new ResourceBuilder actually named (slightly) differently or in a subpackage, and let the static methods in the old ResourceBuilder delegate to a given (default) new builder. But we can also work on this as a second step.<br></div>Thanks for your proposal, I&#39;d be glad to review your PR.<br></div>Cheers<span class="m_3315405566992007006m_-1129449376474318913HOEnZb"><font color="#888888"><br></font></span></div><span class="m_3315405566992007006m_-1129449376474318913HOEnZb"><font color="#888888">Alessio<br></font></span></div><div class="m_3315405566992007006m_-1129449376474318913HOEnZb"><div class="m_3315405566992007006m_-1129449376474318913h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Dec 24, 2017 at 9:45 AM, Christian Kaltepoth <span dir="ltr">&lt;<a href="mailto:christian@kaltepoth.de" target="_blank">christian@kaltepoth.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Alessio,<div><br></div><div>sorry for the delayed response. I finally found some time to have a deeper look at this. I would like to describe my idea, so I can get feedback before starting the implementation.</div><div><br></div><div><br></div><div>To recap what I&#39;m trying to achieve: Basically the idea is to create a SPI which allows to alter the metadata of resource classes. I came up with the following interface for such a SPI:</div><div><br></div><div><font face="monospace, monospace">    public interface ResourceClassProcessor {</font></div><div><font face="monospace, monospace">        ResourceClass process( ResourceClass clazz );</font></div><div><font face="monospace, monospace">    }<br></font></div><div><br></div><div>IMO this interface provides most flexibility. The idea is similar to what CDI provides with <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AnnotatedType.html" target="_blank">AnnotatedType</a>. Implementations of the new SPI can either return the provided class (if they don&#39;t want to change it) or they can return a new instance, typically something that wraps the original class and changes only a few methods.</div><div><br></div><div>Integrating this SPI requires two refactorings of the existing code base, but I really think that this will improve the overall structure of the metadata handling:</div><div><ul><li>Currently <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata/ResourceClass.java" target="_blank">ResourceClass</a>, <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata/ResourceMethod.java" target="_blank">ResourceMethod</a>, etc. are classes with protected fields which are directly accessed by the <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata/ResourceBuilder.java" target="_blank">ResourceBuilder</a>. The first required refactoring would be to extract interfaces from these classes so that we get an interface ResourceClass with a default implementation DefaultResourceClass. Same for ResourceMethod, etc. This will allow other implementations of these interfaces later on.</li><li>Currently <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata/ResourceBuilder.java" target="_blank">ResourceBuilder</a> has only static methods to build ResourceClasse instances. This makes it difficult to &quot;configure&quot; this builder with such processors. Therefore, I would like to refactor the builder from a &quot;utility class&quot; with static methods to something that can be instantiated and therefore also be configured. I think <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyProviderFactory.java" target="_blank">ResteasyProviderFactory</a> would be a good place to create such a builder _once_ and then provide it to all components that want to use it.</li></ul>With these refactorings integrating the new SPI should be easy. <a href="https://github.com/resteasy/Resteasy/blob/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/ResteasyProviderFactory.java" target="_blank">ResteasyProviderFactory</a> could lookup the SPI implementations using the default provider mechanism. The processors will then be feed into the ResourceBuilder when creating it. The ResourceBuilder can then build the metadata for classes from annotations (as it is done today) and after that apply all ResourceClassProcessors before returning the ResourceClass to the other components (like the registry). This will ensure that the processors are applied consistently.</div><div><br></div><div>I think the two refactorings mentioned above a worth the effort because they improve the overall structure of the <a href="https://github.com/resteasy/Resteasy/tree/master/resteasy-jaxrs/src/main/java/org/jboss/resteasy/spi/metadata" target="_blank">metadata package</a> and provides much more flexibility in the future. And they also allow integrate the new SPI very easily.</div><div><br></div><div><br></div><div>What do you think? If you agree that the refactorings are a good thing, I will start to work on them and provide a pull request.</div><span class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041HOEnZb"><font color="#888888"><div><br></div><div>Christian</div><div><br></div><div><br></div></font></span></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041h5">2017-09-27 22:25 GMT+02:00 Alessio Soldano <span dir="ltr">&lt;<a href="mailto:asoldano@redhat.com" target="_blank">asoldano@redhat.com</a>&gt;</span>:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041h5"><div dir="ltr">Forwarding to the list :-)<div><div class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041m_-6895987643897632294h5"><br><br><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Alessio Soldano</b> <span dir="ltr">&lt;<a href="mailto:asoldano@redhat.com" target="_blank">asoldano@redhat.com</a>&gt;</span><br>Date: Wed, Sep 27, 2017 at 10:24 PM<br>Subject: Re: [resteasy-dev] SPI to add JAX-RS annotations dynamically<br>To: Christian Kaltepoth &lt;<a href="mailto:christian@kaltepoth.de" target="_blank">christian@kaltepoth.de</a>&gt;<br><br><br><div dir="ltr">Hi Christian,<br><div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Wed, Sep 27, 2017 at 9:19 PM, Christian Kaltepoth <span dir="ltr">&lt;<a href="mailto:christian@kaltepoth.de" target="_blank">christian@kaltepoth.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div>sorry for the delayed response. I agree that if some SPI would allow to modify the builders, it should be done before the resource is registered in the resource factory. Do you think such a SPI would be useful for others?</div></div></blockquote><div><br></div></span><div>Probably yes, but your scenario might even be enough to justify it.<br></div><span><div> </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div> I would be happy to contribute some code if it improves portability between RESTEasy and the MVC RI.</div></div></blockquote><div><br></div></span><div>Sure, feel free to work on that and send a PR.<br></div><span><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks for pointing me to the resteasy-cdi integration. I&#39;ll have a deeper look at it in the next days.</div></div></blockquote><div><br></div></span><div>OK, good, I hope that can offer some idea for integrating.</div><div><br></div><div>Cheers</div><span class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041m_-6895987643897632294m_4720272789294461365HOEnZb"><font color="#888888"><div>Alessio</div></font></span></div><br></div></div></div>
</div><br></div></div></div></div>
<br></div></div><span>_______________________________________________<br>
resteasy-dev mailing list<br>
<a href="mailto:resteasy-dev@lists.jboss.org" target="_blank">resteasy-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/resteasy-dev" rel="noreferrer" target="_blank">https://lists.jboss.org/mailman/listinfo/resteasy-dev</a><br>
<br></span></blockquote></div><span><br><br clear="all"><div><br></div>-- <br><div class="m_3315405566992007006m_-1129449376474318913m_5383674214532487041m_-6895987643897632294gmail_signature" data-smartmail="gmail_signature"><div>Christian Kaltepoth</div><div>Blog: <a href="http://blog.kaltepoth.de/" target="_blank">http://blog.kaltepoth.de/</a></div><div>Twitter: <a href="http://twitter.com/chkal" target="_blank">http://twitter.com/chkal</a></div><div>GitHub: <a href="https://github.com/chkal" target="_blank">https://github.com/chkal</a></div><div><br></div></div>
</span></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="m_3315405566992007006m_-1129449376474318913gmail_signature" data-smartmail="gmail_signature"><div>Christian Kaltepoth</div><div>Blog: <a href="http://blog.kaltepoth.de/" target="_blank">http://blog.kaltepoth.de/</a></div><div>Twitter: <a href="http://twitter.com/chkal" target="_blank">http://twitter.com/chkal</a></div><div>GitHub: <a href="https://github.com/chkal" target="_blank">https://github.com/chkal</a></div><div><br></div></div>
</div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="m_3315405566992007006gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div class="m_3315405566992007006sig-container" id="m_3315405566992007006standard-target">
<p class="m_3315405566992007006fullname-container" style="font-weight:bold;margin:0;padding:0;font-size:14px;text-transform:uppercase;margin-bottom:0"><span class="m_3315405566992007006firstname-container">Alessio</span> <span class="m_3315405566992007006lastname-container">Soldano</span></p>
<p class="m_3315405566992007006position-container" style="font-weight:normal;font-size:10px;margin:0px 0px 4px;text-transform:uppercase"><span class="m_3315405566992007006position">Associate Manager</span><span class="m_3315405566992007006cert" style="font-weight:normal;color:#aaa;margin:0"></span></p>
<p class="m_3315405566992007006legal-container" style="font-weight:normal;margin:0;font-size:10px;color:#999"><a class="m_3315405566992007006redhat-anchor" style="color:#0088ce;font-size:10px;margin:0;text-decoration:none;font-family:&#39;overpass&#39;,sans-serif" href="https://www.redhat.com" target="_blank">Red Hat <span><br><br></span></a></p>




<table border="0"><tbody><tr><td width="100px"><a href="https://red.ht/sig" target="_blank"> <img src="https://www.redhat.com/files/brand/email/sig-redhat.png" width="90" height="auto"></a> </td>
</tr></tbody></table>

</div></div></div>
</div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div>Christian Kaltepoth</div><div>Blog: <a href="http://blog.kaltepoth.de/" target="_blank">http://blog.kaltepoth.de/</a></div><div>Twitter: <a href="http://twitter.com/chkal" target="_blank">http://twitter.com/chkal</a></div><div>GitHub: <a href="https://github.com/chkal" target="_blank">https://github.com/chkal</a></div><div><br></div></div>