<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi Galder,<br>
    <br>
    as HotRod protocol is portable and this functionality will be
    eventually implemented in other languages, how is the marshalling of
    parameters to the factory supposed to work?<br>
    <br>
    Radim<br>
    <div class="moz-forward-container"><br>
      <br>
      -------- Original Message --------
      <table class="moz-email-headers-table" border="0" cellpadding="0"
        cellspacing="0">
        <tbody>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
            </th>
            <td>Infinispan</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
            <td>Thu, 21 Aug 2014 04:09:47 +0000</td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
            <td>Infinispan <a class="moz-txt-link-rfc2396E" href="mailto:manik.surtani@gmail.com">&lt;manik.surtani@gmail.com&gt;</a></td>
          </tr>
          <tr>
            <th align="RIGHT" nowrap="nowrap" valign="BASELINE">To: </th>
            <td><a class="moz-txt-link-abbreviated" href="mailto:rvansa@redhat.com">rvansa@redhat.com</a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <title>Infinispan</title>
      <style type="text/css">

                        h1 a:hover {background-color:#888;color:#fff ! important;}

                        div#emailbody table#itemcontentlist tr td div ul {
                                        list-style-type:square;
                                        padding-left:1em;
                        }
        
                        div#emailbody table#itemcontentlist tr td div blockquote {
                                padding-left:6px;
                                border-left: 6px solid #dadada;
                                margin-left:1em;
                        }
        
                        div#emailbody table#itemcontentlist tr td div li {
                                margin-bottom:1em;
                                margin-left:1em;
                        }


                        table#itemcontentlist tr td a:link, table#itemcontentlist tr td a:visited, table#itemcontentlist tr td a:active, ul#summarylist li a {
                                color:#000099;
                                font-weight:bold;
                                text-decoration:none;
                        }       

                        img {border:none;}


                </style>
      <div xmlns="http://www.w3.org/1999/xhtml" id="emailbody"
        style="margin:0
2em;font-family:Georgia,Helvetica,Arial,Sans-Serif;line-height:140%;font-size:13px;color:#000000;">
        <table style="border:0;padding:0;margin:0;width:100%">
          <tbody>
            <tr>
              <td style="vertical-align:top" width="99%">
                <h1 style="margin:0;padding-bottom:6px;">
                  <a moz-do-not-send="true"
style="color:#888;font-size:22px;font-family:Arial,Helvetica,Sans-Serif;font-weight:normal;text-decoration:none;"
                    href="http://blog.infinispan.org/"
                    title="(http://blog.infinispan.org/)">Infinispan</a>
                </h1>
              </td>
              <td width="1%">
                <br>
              </td>
            </tr>
          </tbody>
        </table>
        <hr style="border:1px solid #ccc;padding:0;margin:0">
        <table id="itemcontentlist">
          <tbody>
            <tr xmlns="">
              <td style="margin-bottom:0;line-height:1.4em;">
                <p style="margin:1em 0 3px 0;">
                  <a moz-do-not-send="true" name="1"
                    style="font-family:Arial,Helvetica,Sans-Serif;font-size:18px;"
href="http://feedproxy.google.com/%7Er/Infinispan/%7E3/CmE_v40pVRk/hot-rod-remote-events-2-filtering-events.html?utm_source=feedburner&amp;utm_medium=email">Hot
                    Rod Remote Events #2: Filtering events</a>
                </p>
                <p style="font-size:13px;color:#555;margin:9px 0 3px
0;font-family:Georgia,Helvetica,Arial,Sans-Serif;line-height:140%;font-size:13px;"><span>Posted:</span>
                  20 Aug 2014 08:19 AM PDT</p>
                <div
style="margin:0;font-family:Georgia,Helvetica,Arial,Sans-Serif;line-height:140%;font-size:13px;color:#000000;">
                  <div dir="ltr" style="text-align: left;" trbidi="on">This
                    blog post is the second in a series that looks at
                    the forthcoming Hot Rod Remote Events functionality
                    included in Infinispan 7.0. In the <a
                      moz-do-not-send="true"
href="http://blog.infinispan.org/2014/08/hot-rod-remote-events-1-getting-started.html">first
                      blog post</a> we looked at how to get started
                    receiving remote events from Hot Rod servers. This
                    time we are going to focus on how to filter events
                    directly in the server.<br>
                    <br>
                    Sending events to remote clients has a cost which
                    increases as the number of clients. The more clients
                    register remote listeners, the more events the
                    server has to send. This cost also goes up as the
                    number of modifications are executed against the
                    cache. The more cache modifications, the more events
                    that need to be sent.<br>
                    <br>
                    A way to reduce this cost is by filtering the events
                    to send server-side. If at the server level custom
                    code decides that clients are not interested in a
                    particular event, the event does not even need to
                    leave the server, improving the overall performance
                    of the system.<br>
                    <br>
                    Remote event filters are created by implementing a <span
                      style="font-family: Courier New, Courier,
                      monospace;">org.infinispan.filter.KeyValueFilterFactory</span>
                    class. Each factory must have a name associated to
                    it via the <span style="font-family: Courier New,
                      Courier, monospace;">org.infinispan.filter.NamedFactory</span>
                    annotation.<br>
                    <br>
                    When a listener is added, we can provide the name of
                    a key value filter factory to use with this
                    listener, and when the listener is added, the server
                    will look up the factory and invoke <span
                      style="font-family: Courier New, Courier,
                      monospace;">getKeyValueFilter</span> method to get
                    a <span style="font-family: Courier New, Courier,
                      monospace;">org.infinispan.filter.KeyValueFilter</span>
                    class instance to filter events server side.<br>
                    <br>
                    Filtering can be done based on key or value
                    information, and even based on cached entry
                    metadata. Here's a sample implementation which will
                    filter key "2" out of the events sent to clients:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/ba110fc0444078ac4754.js"></script>
                    Plugging the server with this key value filter
                    requires deploying this filter factory (and
                    associated filter class) within a jar file including
                    a service definition inside the <span
                      style="font-family: Courier New, Courier,
                      monospace;">META-INF/services/org.infinispan.filter.KeyValueFilterFactory</span>
                    file:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/d4c478881af7bab3000c.js"></script>
                    With the server plugged with the filter, the next
                    step is adding a remote client listener that will
                    use this filter. For this example, we'll extend
                    the EventLogListener implementation provided in the
                    <a moz-do-not-send="true"
href="http://blog.infinispan.org/2014/08/hot-rod-remote-events-1-getting-started.html">first
                      blog post</a> in the series and we override the <span
                      style="font-family: Courier New, Courier,
                      monospace;">@ClientListener</span> annotation to
                    indicate the filter factory to use with this
                    listener:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/60c97cf7133b997dfbe1.js"></script>
                    Next, we add the listener via the RemoteCache API
                    and we execute some operations against the remote
                    cache:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/2aa09739dac717e50311.js"></script>
                    <br>
                    <div><br>
                    </div>
                    <div>If we checkout the system output we'll see that
                      the client receives events for all keys except
                      those that have been filtered:</div>
                    <div><br>
                    </div>
                    <script src="https://gist.github.com/galderz/c03aa7cb60add9e4ec3b.js"></script>
                    Finally, with Hot Rod remote events we have tried to
                    provide additional flexibility at the client side,
                    which is why when adding client listeners, users can
                    provide parameters to the filter factory so that
                    filter instances with different behaviours can be
                    generated out of a single filter factory based on
                    client side information. To show this in action, we
                    are going to enhance the filter factory above so
                    that instead of filtering on a statically given key,
                    it can filter dynamically based on the key provided
                    when adding the listener. Here's the revised
                    version:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/257e1f39f2dce672cca8.js"></script>
                    Finally, here's how we can now filter by "3" instead
                    of "2":<br>
                    <br>
                    <script src="https://gist.github.com/galderz/f40138daa19ffbf2e7b5.js"></script>
                    And the output:<br>
                    <br>
                    <script src="https://gist.github.com/galderz/7d6d4a92a17783e044dd.js"></script>
                    <br>
                    To summarise, we've seen how Hot Rod remote events
                    can be filtered providing key/value filter factories
                    that can create instances that filter which events
                    are sent to clients, and how these filters can act
                    on client provided information.<br>
                    <br>
                    In the next blog post, we'll look at how to
                    customize remote events in order to reduce the
                    amount of information sent to the clients, or on the
                    contrary, provide even more information to our
                    clients.<br>
                    <br>
                    Cheers,<br>
                    Galder</div>
                  <img moz-do-not-send="true"
src="http://feeds.feedburner.com/%7Er/Infinispan/%7E4/CmE_v40pVRk?utm_source=feedburner&amp;utm_medium=email"
                    height="1" width="1"></div>
              </td>
            </tr>
          </tbody>
        </table>
        <table style="border-top:1px solid
          #999;padding-top:4px;margin-top:1.5em;width:100%" id="footer">
          <tbody>
            <tr>
              <td
                style="text-align:left;font-family:Helvetica,Arial,Sans-Serif;font-size:11px;margin:0
                6px 1.2em 0;color:#333;">You are subscribed to email
                updates from <a moz-do-not-send="true"
                  href="http://blog.infinispan.org/">Infinispan</a>
                <br>
                To stop receiving these emails, you may <a
                  moz-do-not-send="true"
href="http://feedburner.google.com/fb/a/mailunsubscribe?k=oCjJAXg1MUgjCxUM7TkP1l_V4vo">unsubscribe
                  now</a>.</td>
              <td
                style="font-family:Helvetica,Arial,Sans-Serif;font-size:11px;margin:0
                6px 1.2em
                0;color:#333;text-align:right;vertical-align:top">Email
                delivery powered by Google</td>
            </tr>
            <tr>
              <td colspan="2"
                style="text-align:left;font-family:Helvetica,Arial,Sans-Serif;font-size:11px;margin:0
                6px 1.2em 0;color:#333;">Google Inc., 20 West Kinzie,
                Chicago IL USA 60610</td>
            </tr>
          </tbody>
        </table>
      </div>
      <br>
    </div>
    <br>
  </body>
</html>