totally.., we know that.. but it&#39;s like there will be always a situation where that method will fail.. <br>I think that we can made the assumption for now and then try to find those missing bits.<br><br><br><div class="gmail_quote">
On Sat, Apr 16, 2011 at 11:11 PM, Mark Proctor <span dir="ltr">&lt;<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">


  
    
  
  <div text="#000000" bgcolor="#ffffff"><div class="im">
    On 17/04/2011 02:31, Esteban Aliverti wrote:
    <blockquote type="cite">
      <p>Thanks pablo (aka baunax)!<br>
        I agree that resource -&gt; file: is not always possible. But
        what about resource -&gt; URL? After all, i&#39;m converting
        resources to URLs.</p>
    </blockquote></div>
    The URL will have a pointer to the file inside of the jar.<br>
    <a href="http://www.exampledepot.com/egs/java.net/JarUrl.html" target="_blank">http://www.exampledepot.com/egs/java.net/JarUrl.html</a><br><font color="#888888">
    <br>
    Mark</font><div><div></div><div class="h5"><br>
    <blockquote type="cite">
      <p>Best regards,<br>
      </p>
      <div class="gmail_quote">El abr 16, 2011 5:18 p.m., &quot;Pablo
        Nussembaum&quot; &lt;<a href="mailto:baunax@gmail.com" target="_blank">baunax@gmail.com</a>&gt;
        escribió:<br type="attribution">
        &gt; Sorry &quot;IF I *wasn&#39;t* clear&quot; :-P<br>
        &gt; <br>
        &gt; On 04/16/2011 05:11 PM, Pablo Nussembaum wrote:<br>
        &gt;&gt; Sorry if I was clear. The problem when you do:
        ClassLoader.getResource( &quot;resource.path&quot; ) is the the resource
        can be inside a war the in WEB-INF/classes and the war could be
        NOT exploded in<br>
        &gt;&gt; container that&#39;s is deployed, so the translation to
        something like <a>file://</a> is NOT reliable.<br>
        &gt;&gt;<br>
        &gt;&gt; On 04/16/2011 05:05 PM, Mauricio Salatino wrote:<br>
        &gt;&gt;&gt; I&#39;m still thinking about that mapping and those
        assumptions<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; On Sat, Apr 16, 2011 at 5:05 PM, Mauricio Salatino
        &lt;<a href="mailto:salaboy@gmail.com" target="_blank">salaboy@gmail.com</a>
        &lt;mailto:<a href="mailto:salaboy@gmail.com" target="_blank">salaboy@gmail.com</a>&gt;&gt;
        wrote:<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; Can you? or Can&#39;t you?<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; On Sat, Apr 16, 2011 at 4:24 PM, Pablo Nussembaum
        &lt;<a href="mailto:baunax@gmail.com" target="_blank">baunax@gmail.com</a>
        &lt;mailto:<a href="mailto:baunax@gmail.com" target="_blank">baunax@gmail.com</a>&gt;&gt;
        wrote:<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; Esteban,<br>
        &gt;&gt;&gt; You can assume that a resource that was obtained
        from the classpath exists in your filesystem, for instance it
        can be a file inside a jar or war that are not exploded. In
        other words you<br>
        &gt;&gt;&gt; can&#39;t always convert an URL to <a>&quot;file://&quot;</a>.<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; -- <br>
        &gt;&gt;&gt; Bauna<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; On 04/15/2011 08:52 AM, Esteban Aliverti wrote:<br>
        &gt;&gt;&gt;&gt; Hi Guys,<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; I want to discuss a problem I have found when
        using the combination of knowledge agent + classpathResources.<br>
        &gt;&gt;&gt;&gt; I will try to describe what am I doing first to
        give you some context. <br>
        &gt;&gt;&gt;&gt; I&#39;m deploying drools-camel-server in a Tomcat 7
        container. Inside the WEB-INF/classes directory I have some DRL
        files that I want to use.<br>
        &gt;&gt;&gt;&gt; My knowledge-services.xml file declares the
        following kagent:<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; &lt;drools:kagent id=&quot;kagent1&quot; kbase=&quot;kbase1&quot;
        new-instance=&quot;false&quot;&gt;<br>
        &gt;&gt;&gt;&gt; &lt;drools:resources&gt; <br>
        &gt;&gt;&gt;&gt; &lt;drools:resource type=&quot;DRL&quot;
        source=&quot;*classpath*:simple.drl&quot;/&gt;<br>
        &gt;&gt;&gt;&gt; ... <br>
        &gt;&gt;&gt;&gt; &lt;/drools:resources&gt;<br>
        &gt;&gt;&gt;&gt; &lt;/drools:kagent&gt;<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; When spring parses this configuration file it
        creates a KnowledgeAgent instance with a ChangeSet containing
        all the listed resources.<br>
        &gt;&gt;&gt;&gt; The next step is to start
        ResourceChangeNotifierService and ResourceChangeScannerService.
        <br>
        &gt;&gt;&gt;&gt; So far so good.<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; The problem:<br>
        &gt;&gt;&gt;&gt; The problem I&#39;m having is not directly related
        to drools, but I think it is quite easy to provide a solution
        for the people that is in my same situation.<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; ClassPathResource is the class that represents
        a resource defined as &quot;*classpath:&quot;*<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; This class has 2 important methods:<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; public long getLastModified(){<br>
        &gt;&gt;&gt;&gt; return this.classLoader.getResource( this.path
        ).openConnection().getLastModified();<br>
        &gt;&gt;&gt;&gt; }<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; public InputStream getInputStream(){<br>
        &gt;&gt;&gt;&gt; return this.classLoader.getResourceAsStream(
        this.path );<br>
        &gt;&gt;&gt;&gt; }<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; The first method is used by
        ResourceChangeScannerService to check whether the resource has
        changed or not. It works fine. When the resource in the
        filesystem changes, the scanner detects<br>
        &gt;&gt;&gt;&gt; the change without any problem.<br>
        &gt;&gt;&gt;&gt; The scanner ends up notifying the kagent about
        the change, and the kagent passes the Resource to an instance of
        KnowledgeBuilder. <br>
        &gt;&gt;&gt;&gt; An here is when things fail.<br>
        &gt;&gt;&gt;&gt; The kbuilder uses the second method of
        ClassPathResource (getInputStream()) to get the content of the
        resource. In the case of Tomcat (and probably some other
        environments), it seems that<br>
        &gt;&gt;&gt;&gt; the classloader (Tomcat&#39;s classloader) is using
        a cache. So the InputStream returned doesn&#39;t reflect the current
        state of the resource.<br>
        &gt;&gt;&gt;&gt; Long story short: the agent is notified about a
        change in the resource, but the change is never applied to the
        kbase because the kbuilder is unable to get it :P<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; Solutions:<br>
        &gt;&gt;&gt;&gt; The first solution is not to use classpath
        resources :). You can use just url resources like <a>http://</a> or
        <a>file:/</a>. But honestly, when you have your rules inside your
        webapp, it is much<br>
        &gt;&gt;&gt;&gt; more comfortable and even manageable to avoid
        the use of real paths.<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; What I was thinking about (I already have a
        working prototype) is to create a new Resource type for these
        cases. This resource type will let you define your resources
        present in your<br>
        &gt;&gt;&gt;&gt; classpath as usually but it will translate them
        to URL Resource internally.<br>
        &gt;&gt;&gt;&gt; So, in the example above: <br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; &lt;drools:resource type=&quot;DRL&quot;
        source=&quot;*URLClasspath*:simple.drl&quot;/&gt;<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; is going to be translated (internally and in a
        transparent way) to something like:
        <a>file:/usr/local/apache-tomcat-7/webapps/MyWebapp/WEB-INF/simple.drl</a>.<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; Opinions? <br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; Esteban Aliverti<br>
        &gt;&gt;&gt;&gt; - Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a>
        &lt;<a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a>&gt;<br>
        &gt;&gt;&gt;&gt; - Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt;<br>
        &gt;&gt;&gt;&gt; _______________________________________________<br>
        &gt;&gt;&gt;&gt; rules-dev mailing list<br>
        &gt;&gt;&gt;&gt; <a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
        &lt;mailto:<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>&gt;
        <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; _______________________________________________<br>
        &gt;&gt;&gt; rules-dev mailing list<br>
        &gt;&gt;&gt; <a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
        &lt;mailto:<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>&gt;<br>
        &gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a><br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; -- <br>
        &gt;&gt;&gt; - CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a> <br>
        &gt;&gt;&gt; - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
        &gt;&gt;&gt; - Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
        &gt;&gt;&gt; <br>
        &gt;&gt;&gt; - Salatino &quot;Salaboy&quot; Mauricio -<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt;<br>
        &gt;&gt;&gt; -- <br>
        &gt;&gt;&gt; - CTO @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com</a> <br>
        &gt;&gt;&gt; - MyJourney @ <a href="http://salaboy.wordpress.com" target="_blank">http://salaboy.wordpress.com</a><br>
        &gt;&gt;&gt; - Co-Founder @ <a href="http://www.jbug.com.ar" target="_blank">http://www.jbug.com.ar</a><br>
        &gt;&gt;&gt; <br>
        &gt;&gt;&gt; - Salatino &quot;Salaboy&quot; Mauricio -<br>
      </div>
      <pre><fieldset></fieldset>
_______________________________________________
rules-dev mailing list
<a href="mailto:rules-dev@lists.jboss.org" target="_blank">rules-dev@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-dev</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

<br>_______________________________________________<br>
rules-dev mailing list<br>
<a href="mailto:rules-dev@lists.jboss.org">rules-dev@lists.jboss.org</a><br>
<a 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"><br>-- <br> - CTO @ <a href="http://www.plugtree.com">http://www.plugtree.com</a>  <br> - MyJourney @ <a href="http://salaboy.wordpress.com">http://salaboy.wordpress.com</a><br>
 - Co-Founder @ <a href="http://www.jbug.com.ar">http://www.jbug.com.ar</a><br> <br> - Salatino &quot;Salaboy&quot; Mauricio -<br>