<div dir="ltr"><div style><span style="font-family:arial,sans-serif;font-size:13px">&gt;Have you researched on using CDI interceptors for this?</span><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div>
<div style><font face="arial, sans-serif">No, I&#39;ve not looked at a solution that involved CDI interceptors for this.</font></div><div style><br></div><div style><font face="arial, sans-serif">&gt;</font><span style="font-family:arial,sans-serif;font-size:13px">So what about injecting pagination info via CDI?</span></div>
<div style><span style="font-family:arial,sans-serif;font-size:13px">I think that it makes sense for users to be able to simply use their existing classes with AeroGear Controller by configuring their routes and not have to touch existing code. This is what I liked about liked with Bruno&#39;s suggestion. Using any of the suggestions here, and my previous suggestion with having a specific response type, all have this disadvantage. But this might just be wishful thinking and we might simply discover that this is required when more functionality is added hence might as well do this now. </span></div>
<div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px">&gt;</span><span style="font-family:arial,sans-serif;font-size:13px">Another option would be to have the method receiving the PaginationInfo</span></div>
<span style="font-family:arial,sans-serif;font-size:13px">&gt;parameter, which would eliminate the need for annotations and stuff - if</span><br style="font-family:arial,sans-serif;font-size:13px"><span style="font-family:arial,sans-serif;font-size:13px">&gt;you put the parameter on the signature, the response will be wrapped</span><br style="font-family:arial,sans-serif;font-size:13px">
<span style="font-family:arial,sans-serif;font-size:13px">&gt;automagically.</span><div style><font face="arial, sans-serif">I that case I think it makes more sense to go with a solution of having a specific return type on the method. The information in PaginationInfo would already be available to the target endpoint methods as parameters (offset/limit) and it would use something like was suggested earlier in this thread. I just think that might be more clear about what is actually going on.</font></div>
<div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">I&#39;ll start looking into using an CDI interceptor solution and see how this would work. I&#39;ll also take a look at the other approach with using PaginationInfo. As we don&#39;t have much time here it would be great if we as a team can decide on one solution by the end of today (2012-0122). </span></div>
<div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px">&gt;</span><span style="font-family:arial,sans-serif;font-size:13px">We already got rid of total :)</span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">Glad to hear that :)</span></div>
<div style><br></div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div style><span style="font-family:arial,sans-serif;font-size:13px">  </span></div>
</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 22 January 2013 00:04, Douglas Campos <span dir="ltr">&lt;<a href="mailto:qmx@qmx.me" target="_blank">qmx@qmx.me</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">On Sun, Jan 20, 2013 at 07:29:41AM -0800, danielbevenius wrote:<br>
&gt; I&#39;ve been thinking about this and needed to make an update to the controller<br>
&gt; as I hade neglected to support returning query parameters in link headers,<br>
&gt; other than those used for paging.<br>
&gt;<br>
&gt; I&#39;ve looked into Bruno&#39;s original suggestion and think it has a huge<br>
&gt; advantage in that the target endpoint class does not have to be changed, and<br>
&gt; can simply return a List&lt;?&gt;.<br>
&gt;<br>
&gt; route()<br>
&gt;       .from(&quot;/cars&quot;)<br>
&gt;       .on(RequestMethod.GET)<br>
&gt;       .produces(MediaType.JSON)<br>
&gt;       .paged().offset())<br>
&gt;       .to(Cars.class).findCarsBy(param(&quot;offset&quot;, &quot;0&quot;), param(&quot;color&quot;),<br>
&gt; param(&quot;limit&quot;, &quot;10&quot;));<br>
&gt;<br>
&gt; For cases where the parameters &#39;offset&#39; and &#39;limit&#39; are named differently<br>
&gt; they could be configurable:<br>
&gt; route()<br>
&gt;       .from(&quot;/cars&quot;)<br>
&gt;       .on(RequestMethod.GET)<br>
&gt;       .produces(MediaType.JSON)<br>
&gt;       .paged().offset(&quot;myoffset&quot;).limitParamName(&quot;mylimit&quot;)<br>
&gt;       .to(Cars.class).findCarsBy(param(&quot;offset&quot;, &quot;0&quot;), param(&quot;color&quot;),<br>
&gt; param(&quot;limit&quot;, &quot;10&quot;));<br>
</div>Well, I&#39;m not a fan of putting the pagination info on the routes<br>
themselves. Have you researched on using CDI interceptors for this? as<br>
it&#39;s clearly an infrastructure concern.<br>
<br>
So what about injecting pagination info via CDI? This means that we&#39;ll<br>
need to use instance variables on the Controller class, and decorate it<br>
during instantiation. The paging support could be enabled by using an<br>
annotation on the controller method (@Paginated), and the CDI extension<br>
would take care of wrapping the response/putting the headers<br>
accordingly.<br>
<br>
public class Cars {<br>
<br>
        private PaginationInfo paginationInfo;<br>
<br>
  @Paginated<br>
        public List&lt;Car&gt; list() {<br>
                // fetch offset/limit from this.paginationInfo<br>
        }<br>
}<br>
<br>
The response would be decorated with the appropriate links.<br>
<br>
Another option would be to have the method receiving the PaginationInfo<br>
parameter, which would eliminate the need for annotations and stuff - if<br>
you put the parameter on the signature, the response will be wrapped<br>
automagically.<br>
<br>
Thoughts?<br>
<div class="im"><br>
&gt; For now, I&#39;ve just ignored support for a total as I think we need more time<br>
&gt; to investigate a proper solution for it, if we think it should be supported<br>
&gt; at all. The problem with having a callback is that in some situations, like<br>
&gt; the one above, that callback would also have to take a query parameter(s) so<br>
&gt; we&#39;d need to do more work that like it initial idea were it would be<br>
&gt; possible to simply specify a name of a no-args method that returned an<br>
&gt; int/long.<br>
</div>We already got rid of total :)<br>
<br>
-- qmx<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
aerogear-dev mailing list<br>
<a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
</div></div></blockquote></div><br></div>