<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <br>
    On 14/03/2012 17:34, Mauricio Salatino wrote:
    <blockquote
cite="mid:CANzbnyV6vYe4wAQnqL1Yi9nhQs+Pv9tByTHW7SzU4kWTH11hBA@mail.gmail.com"
      type="cite">Oh that looks like a cool way to standardize how all
      the threads inside drools are being created.&nbsp;
      <div>Do you have already identified where this new approach must
        be applied? The rule times are also implementing this approach?&nbsp;</div>
      <div>Cheers<br>
      </div>
    </blockquote>
    Just a reminder to people to re-read this email "api's, factories
    and services ":<br>
<a class="moz-txt-link-freetext" href="http://drools.46999.n3.nabble.com/api-s-factories-and-services-td3790118.html">http://drools.46999.n3.nabble.com/api-s-factories-and-services-td3790118.html</a><br>
    <br>
    So we can start to standardise how our factories and services work,
    so we get the best of our container interoprability - like spring,
    osgi etc.<br>
    <br>
    Mark<br>
    <blockquote
cite="mid:CANzbnyV6vYe4wAQnqL1Yi9nhQs+Pv9tByTHW7SzU4kWTH11hBA@mail.gmail.com"
      type="cite">
      <div><br>
        <div class="gmail_quote">On Wed, Mar 14, 2012 at 5:27 PM, Mario
          Fusco <span dir="ltr">&lt;<a moz-do-not-send="true"
              href="mailto:mario.fusco@gmail.com">mario.fusco@gmail.com</a>&gt;</span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0
            .8ex;border-left:1px #ccc solid;padding-left:1ex">
            Hi all,<br>
            <br>
            following the suggestions of Mark on how to create a new
            Service I just pushed a new one named ExecutorProvider. The
            idea here is that we should never manually create and start
            Threads in the Drools code because this is inefficient and
            event worse is not portable in many enterprise environments.
            In this way it will be possible to provide different
            implementations of this Service that could work with J2EE,
            Spring or other similar managed environments.<br>
            <br>
            The ExecutorProvider is defined as it follows:<br>
            <br>
            public interface ExecutorProvider extends Service {<br>
            &nbsp;&nbsp;&nbsp; Executor getExecutor();<br>
            &nbsp;&nbsp;&nbsp; &lt;T&gt; CompletionService&lt;T&gt;
            getCompletionService();<br>
            }<br>
            <br>
            I am already using it to make the jitting compilation of my
            MvelConstraint an asynchronous process and also to replace
            the Threads used in the KnowledgeAgentImpl and
            ResourceChangeScannerImpl. For instance in the
            KnowledgeAgentImpl I replaced this code:<br>
            <br>
            this.thread = new Thread( this.changeSetNotificationDetector
            );<br>
            this.thread.start();<br>
            <br>
            with this one:<br>
            <br>
            this.notificationDetectorExecutor =<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ExecutorProviderFactory.getExecutorProvider().&lt;Boolean&gt;getCompletionService()<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            .submit(this.changeSetNotificationDetector, true);<br>
            <br>
            where the notificationDetectorExecutor is a Future so I can
            stop its execution with:<br>
            <br>
            this.notificationDetectorExecutor.cancel(true);<br>
            <br>
            instead of doing:<br>
            <br>
            this.thread.interrupt();<br>
            <br>
            Also note that, at the moment, the ExecutorService
            internally used in the ExecutorProviderImpl (the only
            ExecutorProvider implementation currently available) always
            uses daemon Threads, so the JVM won't be prevented to
            terminate if there are some of them still running.<span
              class="HOEnZb"><font color="#888888"><br>
                <br>
                Mario<br>
              </font></span><br>
            _______________________________________________<br>
            rules-dev mailing list<br>
            <a moz-do-not-send="true"
              href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
            <a moz-do-not-send="true"
              href="https://lists.jboss.org/mailman/listinfo/rules-dev"
              target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
            <br>
          </blockquote>
        </div>
        <br>
        <br clear="all">
        <div><br>
        </div>
        -- <br>
        &nbsp;- MyJourney @ <a moz-do-not-send="true"
          href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a>
        <div>&nbsp;- Co-Founder @ <a moz-do-not-send="true"
            href="http://www.jugargentina.org" target="_blank">http://www.jugargentina.org</a><br>
          &nbsp;- Co-Founder @ <a moz-do-not-send="true"
            href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
          &nbsp;<br>
          &nbsp;- Salatino "Salaboy" Mauricio -</div>
        <br>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
rules-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/rules-dev">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>