[jboss-svn-commits] JBL Code SVN: r12767 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jun 21 22:25:18 EDT 2007


Author: michael.neale at jboss.com
Date: 2007-06-21 22:25:18 -0400 (Thu, 21 Jun 2007)
New Revision: 12767

Added:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/AgentEventListener.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/HttpClient.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleAgent.java
Removed:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleBaseAgent.java
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/DirectoryScanner.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/FileScanner.java
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/URLScanner.java
Log:
JBRULES-752

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/AgentEventListener.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/AgentEventListener.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/AgentEventListener.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -0,0 +1,27 @@
+package org.drools.agent;
+
+/**
+ * This interface is used to provide callback style logging for the agents
+ * async events.
+ * 
+ * @author Michael Neale
+ */
+public interface AgentEventListener {
+
+    /**
+     * For general info messages.
+     */
+    public void info(String message);
+    
+    /**
+     * For a warning (useful when tracking down problems).
+     */
+    public void warning(String message);
+    
+    /**
+     * An exception occurred.
+     */
+    public void exception(Exception e);
+    
+    
+}


Property changes on: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/AgentEventListener.java
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/DirectoryScanner.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/DirectoryScanner.java	2007-06-22 01:52:52 UTC (rev 12766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/DirectoryScanner.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -18,7 +18,7 @@
     private File        dir;
 
     void configure(Properties config) {
-        String d = config.getProperty( RuleBaseAgent.DIRECTORY );
+        String d = config.getProperty( RuleAgent.DIRECTORY );
 
         //now check to see whats in them dir...
         dir = new File( d );

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/FileScanner.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/FileScanner.java	2007-06-22 01:52:52 UTC (rev 12766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/FileScanner.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -35,7 +35,7 @@
      * This takes a list of paths and files (not directories).
      */
     void configure(Properties config) {
-        List paths = RuleBaseAgent.list( config.getProperty( RuleBaseAgent.FILES ) );
+        List paths = RuleAgent.list( config.getProperty( RuleAgent.FILES ) );
         files = new File[paths.size()];
         for ( int i = 0; i < paths.size(); i++ ) {
             File file = new File( (String) paths.get( i ) );

Added: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/HttpClient.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/HttpClient.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/HttpClient.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -0,0 +1,74 @@
+package org.drools.agent;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.ProtocolException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import org.drools.RuntimeDroolsException;
+import org.drools.common.DroolsObjectInputStream;
+import org.drools.rule.Package;
+
+public class HttpClient {
+
+    
+    
+    
+    public HttpClient(String uri) throws Exception {
+        try {
+            
+            checkLastUpdated( uri );
+            URL url = new URL(uri);
+            
+            URLConnection con = url.openConnection();
+            HttpURLConnection httpCon = (HttpURLConnection) con;
+            httpCon.setRequestMethod( "GET" );
+            InputStream in = httpCon.getInputStream();
+            
+            DroolsObjectInputStream oin = new DroolsObjectInputStream(in);
+            Package p = (Package) oin.readObject();
+            in.close();
+            
+            
+            System.err.println(p.getName());
+            
+        } catch ( IOException e ) {
+            throw new RuntimeDroolsException(e);
+        }
+        
+    }
+
+    private void checkLastUpdated(String uri) throws MalformedURLException,
+                                             IOException,
+                                             ProtocolException {
+        URL url = new URL(uri);
+        
+        URLConnection con = url.openConnection();
+        HttpURLConnection httpCon = (HttpURLConnection) con;
+        httpCon.setRequestMethod( "HEAD" );
+        
+        
+        
+        //if this is null, then its not cool
+        System.err.println(httpCon.getHeaderField( "lastModified" ));
+        
+        //can check for '200 OK' to make sure its kosher.
+        System.err.println(httpCon.getHeaderFields());
+        
+        String status = httpCon.getHeaderField( null );
+        
+        
+        System.err.println(status);
+        
+        httpCon.disconnect();
+    }
+    
+    public static void main(String[] args) throws Exception {
+        HttpClient scan = new HttpClient("http://localhost:8888/org.drools.brms.JBRMS/package/com.billasurf.manufacturing.plant/SNAP");
+        
+    }
+    
+}


Property changes on: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/HttpClient.java
___________________________________________________________________
Name: svn:eol-style
   + native

Copied: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleAgent.java (from rev 12762, labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleBaseAgent.java)
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleAgent.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleAgent.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -0,0 +1,272 @@
+package org.drools.agent;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.Timer;
+import java.util.TimerTask;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.RuntimeDroolsException;
+
+/**
+ * This manages a single rulebase, based on the properties given
+ * This one does most of the actual work !
+ *
+ * CONFIG OPTIONS:
+ *  <code>newInstance</code>: means that each time the rules are changed
+ *   a new instance of the rulebase is created (as opposed to updated in place)
+ *   the default is to update in place. DEFAULT: false. If you set this to true, 
+ *   then you will need to call getRuleBase() each time you want to use it. If it is false, 
+ *   then it means you can keep your reference to the rulebase and it will be updated automatically
+ *   (as well as any stateful sessions). 
+ *
+ *  <code>poll</code>The number of seconds to poll for changes. Polling 
+ *  happens in a background thread.
+ *
+ *  <code>file</code>: a space seperated listing of files that make up the 
+ *  packages of the rulebase. Each package can only be in one file. You can't have 
+ *  packages spread across files.
+ *  
+ *  <code>dir</code>: a single file system directory to monitor for packages.
+ *  As with files, each package must be in its own file.
+ * 
+ * @author Michael Neale
+ */
+public class RuleAgent {
+
+    /**
+     * Following are property keys to be used in the property
+     * config file.
+     */
+    public static final String NEW_INSTANCE      = "newInstance";
+    public static final String FILES             = "file";
+    public static final String DIRECTORY         = "dir";
+    public static final String URLS = "url";
+    public static final String POLL_INTERVAL     = "poll";
+    
+    //this is needed for cold starting when BRMS is down (ie only for URL).
+    public static final String LOCAL_URL_CACHE = "localCacheDir";
+
+    /**
+     * Here is where we have a map of providers to the key that appears on the configuration.
+     */
+    private static Map          PACKAGE_PROVIDERS = new HashMap() {
+                                                     {
+                                                         put( FILES,
+                                                              FileScanner.class );
+                                                         put( DIRECTORY,
+                                                              DirectoryScanner.class );
+                                                     }
+                                                 };
+
+    /**
+     * This is true if the rulebase is created anew each time.
+     */
+    private boolean                    newInstance;
+
+    /**
+     * The rule base that is being managed.
+     */
+    private RuleBase           ruleBase;
+
+    /**
+     * The timer that is used to monitor for changes and deal with them. 
+     */
+    private Timer              timer;
+
+    /**
+     * The providers that actually do the work.
+     */
+    ArrayList                  providers;
+
+    private AgentEventListener listener = getDefaultListener();
+    
+    /**
+     * Properties configured to load up packages into a rulebase (and monitor them
+     * for changes).
+     */
+    public RuleAgent(Properties config) {
+        init( config );
+    }
+
+
+
+    private void init(Properties config) {
+
+        boolean newInstance = Boolean.valueOf( config.getProperty( NEW_INSTANCE,
+                                                                   "false" ) ).booleanValue();
+        int secondsToRefresh = Integer.parseInt( config.getProperty( POLL_INTERVAL,
+                                                                     "-1" ) );
+
+        providers = new ArrayList();
+
+        for ( Iterator iter = config.keySet().iterator(); iter.hasNext(); ) {
+            String key = (String) iter.next();
+            PackageProvider prov = getProvider( key,
+                                                config );
+            if ( prov != null ) {
+                providers.add( prov );
+            }
+        }
+
+        configure( newInstance,
+                   providers,
+                   secondsToRefresh );
+    }
+
+    /**
+     * Pass in the name and full path to a config file that is on the classpath.
+     */
+    public RuleAgent(String propsFileName) {
+        init( loadFromProperties( propsFileName ) );
+    }
+
+    Properties loadFromProperties(String propsFileName) {
+        InputStream in = this.getClass().getResourceAsStream( propsFileName );
+        Properties props = new Properties();
+        try {
+            props.load( in );
+            return props;
+
+        } catch ( IOException e ) {
+            throw new RuntimeDroolsException( "Unable to load properties. Needs to be the path and name of a config file on your classpath.",
+                                              e );
+        }
+    }
+
+    /**
+     * Return a configured provider ready to go.
+     */
+    private PackageProvider getProvider(String key,
+                                        Properties config) {
+        if ( !PACKAGE_PROVIDERS.containsKey( key ) ) {
+            return null;
+        }
+        Class clz = (Class) PACKAGE_PROVIDERS.get( key );
+        try {
+            PackageProvider prov = (PackageProvider) clz.newInstance();
+            prov.configure( config );
+            return prov;
+        } catch ( InstantiationException e ) {
+            throw new RuntimeDroolsException( "Unable to load up a package provider for " + key,
+                                              e );
+        } catch ( IllegalAccessException e ) {
+            throw new RuntimeDroolsException( "Unable to load up a package provider for " + key,
+                                              e );
+        }
+    }
+
+    synchronized void configure(boolean newInstance,
+                                final List providers,
+                                int secondsToRefresh) {
+        this.newInstance = newInstance;
+
+        //run it the first time for each.
+        refreshRuleBase();
+
+        if ( secondsToRefresh != -1 ) {
+            int interval = secondsToRefresh * 1000;
+            //now schedule it for polling
+            timer = new Timer( true );
+            timer.schedule( new TimerTask() {
+                                public void run() {
+                                    refreshRuleBase();
+
+                                }
+                            },
+                            interval,
+                            interval );
+        }
+
+    }
+
+    public void refreshRuleBase() {
+        for ( Iterator iter = providers.iterator(); iter.hasNext(); ) {
+            PackageProvider prov = (PackageProvider) iter.next();
+            updateRuleBase( prov );
+        }
+    }
+
+    private synchronized void updateRuleBase(PackageProvider prov) {
+        System.err.println( "SCANNING FOR CHANGE " + prov.toString() );
+        if ( this.newInstance || this.ruleBase == null ) {
+            ruleBase = RuleBaseFactory.newRuleBase();
+        }
+        prov.updateRuleBase( this.ruleBase,
+                             !this.newInstance );
+    }
+
+    /**
+     * Convert a space seperated list into a List of stuff.
+     * @param property
+     * @return
+     */
+    static List list(String property) {
+        if ( property == null ) return Collections.EMPTY_LIST;
+        StringTokenizer st = new StringTokenizer( property,
+                                                  "\n\r\t " );
+        List list = new ArrayList();
+        while ( st.hasMoreTokens() ) {
+            list.add( st.nextToken() );
+        }
+        return list;
+    }
+
+    /**
+     * Return a current rulebase.
+     * Depending on the configuration, this may be a new object each time
+     * the rules are updated.
+     *  
+     */
+    public synchronized RuleBase getRuleBase() {
+        return this.ruleBase;
+    }
+
+    RuleAgent() {
+    }
+
+    /**
+     * Stop the polling (if it is happening)
+     */
+    public void stopPolling() {
+        if ( this.timer != null ) timer.cancel();
+        timer = null;
+    }
+
+    boolean isNewInstance() {
+        return newInstance;
+    }
+
+    boolean isPolling() {
+        return this.timer != null;
+    }
+
+    private AgentEventListener getDefaultListener() {
+
+        return new AgentEventListener() {
+
+            public void exception(Exception e) {
+                e.printStackTrace();
+            }
+
+            public void info(String message) {
+                System.err.println("INFO: " + message);                
+            }
+
+            public void warning(String message) {
+                System.err.println("WARNING: " + message);                
+            }
+            
+        };
+    }
+    
+}

Deleted: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleBaseAgent.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleBaseAgent.java	2007-06-22 01:52:52 UTC (rev 12766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/RuleBaseAgent.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -1,246 +0,0 @@
-package org.drools.agent;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Timer;
-import java.util.TimerTask;
-
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.RuntimeDroolsException;
-
-/**
- * This manages a single rulebase, based on the properties given
- * This one does most of the actual work !
- *
- * CONFIG OPTIONS:
- *  <code>newInstance</code>: means that each time the rules are changed
- *   a new instance of the rulebase is created (as opposed to updated in place)
- *   the default is to update in place. DEFAULT: false. If you set this to true, 
- *   then you will need to call getRuleBase() each time you want to use it. If it is false, 
- *   then it means you can keep your reference to the rulebase and it will be updated automatically
- *   (as well as any stateful sessions). 
- *
- *  <code>poll</code>The number of seconds to poll for changes. Polling 
- *  happens in a background thread.
- *
- *  <code>file</code>: a space seperated listing of files that make up the 
- *  packages of the rulebase. Each package can only be in one file. You can't have 
- *  packages spread across files.
- *  
- *  <code>dir</code>: a single file system directory to monitor for packages.
- *  As with files, each package must be in its own file.
- * 
- * @author Michael Neale
- */
-public class RuleBaseAgent {
-
-    /**
-     * Following are property keys to be used in the property
-     * config file.
-     */
-    public static final String NEW_INSTANCE      = "newInstance";
-    public static final String FILES             = "file";
-    public static final String DIRECTORY         = "dir";
-    //public static final String URIS = "uri";
-    public static final String POLL_INTERVAL     = "poll";
-
-    /**
-     * Here is where we have a map of providers to the key that appears on the configuration.
-     */
-    private static Map          PACKAGE_PROVIDERS = new HashMap() {
-                                                     {
-                                                         put( FILES,
-                                                              FileScanner.class );
-                                                         put( DIRECTORY,
-                                                              DirectoryScanner.class );
-                                                     }
-                                                 };
-
-    /**
-     * This is true if the rulebase is created anew each time.
-     */
-    private boolean                    newInstance;
-
-    /**
-     * The rule base that is being managed.
-     */
-    private RuleBase           ruleBase;
-
-    /**
-     * The timer that is used to monitor for changes and deal with them. 
-     */
-    private Timer              timer;
-
-    /**
-     * The providers that actually do the work.
-     */
-    ArrayList                  providers;
-
-    /**
-     * Properties configured to load up packages into a rulebase (and monitor them
-     * for changes).
-     */
-    public RuleBaseAgent(Properties config) {
-        init( config );
-    }
-
-    private void init(Properties config) {
-
-        boolean newInstance = Boolean.valueOf( config.getProperty( NEW_INSTANCE,
-                                                                   "false" ) ).booleanValue();
-        int secondsToRefresh = Integer.parseInt( config.getProperty( POLL_INTERVAL,
-                                                                     "-1" ) );
-
-        providers = new ArrayList();
-
-        for ( Iterator iter = config.keySet().iterator(); iter.hasNext(); ) {
-            String key = (String) iter.next();
-            PackageProvider prov = getProvider( key,
-                                                config );
-            if ( prov != null ) {
-                providers.add( prov );
-            }
-        }
-
-        configure( newInstance,
-                   providers,
-                   secondsToRefresh );
-    }
-
-    /**
-     * Pass in the name and full path to a config file that is on the classpath.
-     */
-    public RuleBaseAgent(String propsFileName) {
-        init( loadFromProperties( propsFileName ) );
-    }
-
-    Properties loadFromProperties(String propsFileName) {
-        InputStream in = this.getClass().getResourceAsStream( propsFileName );
-        Properties props = new Properties();
-        try {
-            props.load( in );
-            return props;
-
-        } catch ( IOException e ) {
-            throw new RuntimeDroolsException( "Unable to load properties. Needs to be the path and name of a config file on your classpath.",
-                                              e );
-        }
-    }
-
-    /**
-     * Return a configured provider ready to go.
-     */
-    private PackageProvider getProvider(String key,
-                                        Properties config) {
-        if ( !PACKAGE_PROVIDERS.containsKey( key ) ) {
-            return null;
-        }
-        Class clz = (Class) PACKAGE_PROVIDERS.get( key );
-        try {
-            PackageProvider prov = (PackageProvider) clz.newInstance();
-            prov.configure( config );
-            return prov;
-        } catch ( InstantiationException e ) {
-            throw new RuntimeDroolsException( "Unable to load up a package provider for " + key,
-                                              e );
-        } catch ( IllegalAccessException e ) {
-            throw new RuntimeDroolsException( "Unable to load up a package provider for " + key,
-                                              e );
-        }
-    }
-
-    synchronized void configure(boolean newInstance,
-                                final List providers,
-                                int secondsToRefresh) {
-        this.newInstance = newInstance;
-
-        //run it the first time for each.
-        refreshRuleBase();
-
-        if ( secondsToRefresh != -1 ) {
-            int interval = secondsToRefresh * 1000;
-            //now schedule it for polling
-            timer = new Timer( true );
-            timer.schedule( new TimerTask() {
-                                public void run() {
-                                    refreshRuleBase();
-
-                                }
-                            },
-                            interval,
-                            interval );
-        }
-
-    }
-
-    public void refreshRuleBase() {
-        for ( Iterator iter = providers.iterator(); iter.hasNext(); ) {
-            PackageProvider prov = (PackageProvider) iter.next();
-            updateRuleBase( prov );
-        }
-    }
-
-    private synchronized void updateRuleBase(PackageProvider prov) {
-        System.err.println( "SCANNING FOR CHANGE " + prov.toString() );
-        if ( this.newInstance || this.ruleBase == null ) {
-            ruleBase = RuleBaseFactory.newRuleBase();
-        }
-        prov.updateRuleBase( this.ruleBase,
-                             !this.newInstance );
-    }
-
-    /**
-     * Convert a space seperated list into a List of stuff.
-     * @param property
-     * @return
-     */
-    static List list(String property) {
-        if ( property == null ) return Collections.EMPTY_LIST;
-        StringTokenizer st = new StringTokenizer( property,
-                                                  "\n\r\t " );
-        List list = new ArrayList();
-        while ( st.hasMoreTokens() ) {
-            list.add( st.nextToken() );
-        }
-        return list;
-    }
-
-    /**
-     * Return a current rulebase.
-     * Depending on the configuration, this may be a new object each time
-     * the rules are updated.
-     *  
-     */
-    public synchronized RuleBase getRuleBase() {
-        return this.ruleBase;
-    }
-
-    RuleBaseAgent() {
-    }
-
-    /**
-     * Stop the polling (if it is happening)
-     */
-    public void stopPolling() {
-        if ( this.timer != null ) timer.cancel();
-        timer = null;
-    }
-
-    boolean isNewInstance() {
-        return newInstance;
-    }
-
-    boolean isPolling() {
-        return this.timer != null;
-    }
-
-}

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/URLScanner.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/URLScanner.java	2007-06-22 01:52:52 UTC (rev 12766)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/agent/URLScanner.java	2007-06-22 02:25:18 UTC (rev 12767)
@@ -1,67 +1,54 @@
 package org.drools.agent;
 
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
+import java.io.File;
 import java.net.MalformedURLException;
-import java.net.ProtocolException;
 import java.net.URL;
-import java.net.URLConnection;
+import java.util.List;
+import java.util.Properties;
 
+import org.drools.RuleBase;
 import org.drools.RuntimeDroolsException;
-import org.drools.common.DroolsObjectInputStream;
-import org.drools.rule.Package;
 
-public class URLScanner {
 
-    public URLScanner(String uri) throws Exception {
-        try {
-
-            checkLastUpdated( uri );
-            URL url = new URL( uri );
-
-            URLConnection con = url.openConnection();
-            HttpURLConnection httpCon = (HttpURLConnection) con;
-            httpCon.setRequestMethod( "GET" );
-            InputStream in = httpCon.getInputStream();
-
-            DroolsObjectInputStream oin = new DroolsObjectInputStream( in );
-            Package p = (Package) oin.readObject();
-            in.close();
-
-            System.err.println( p.getName() );
-
-        } catch ( IOException e ) {
-            throw new RuntimeDroolsException( e );
+public class URLScanner extends PackageProvider {
+    
+    private List uriList;
+    private File localCacheDir;
+    private URL[] urls;
+    
+    void configure(Properties config) {
+        uriList = RuleAgent.list( config.getProperty( RuleAgent.URLS ) );
+        urls = new URL[uriList.size()];
+        for (int i = 0; i < uriList.size(); i++ ) {
+            String url = (String) uriList.get( i );
+            try {
+                urls[i] = new URL(url);
+            } catch ( MalformedURLException e ) {
+                throw new RuntimeException("The URL " + url + " is not valid.", e);
+            }
         }
+        String localCache = config.getProperty( RuleAgent.LOCAL_URL_CACHE );
+        if (localCache != null) {
+            localCacheDir = new File(localCache);
+            if (!localCacheDir.isDirectory()) {
+                throw new RuntimeDroolsException("The local cache dir " + localCache + " is a file, not a directory.");
+            }
 
+        }
     }
 
-    private void checkLastUpdated(String uri) throws MalformedURLException,
-                                             IOException,
-                                             ProtocolException {
-        URL url = new URL( uri );
-
-        URLConnection con = url.openConnection();
-        HttpURLConnection httpCon = (HttpURLConnection) con;
-        httpCon.setRequestMethod( "HEAD" );
-
-        //if this is null, then its not cool
-        System.err.println( httpCon.getHeaderField( "lastModified" ) );
-
-        //can check for '200 OK' to make sure its kosher.
-        System.err.println( httpCon.getHeaderFields() );
-
-        String status = httpCon.getHeaderField( null );
-
-        System.err.println( status );
-
-        httpCon.disconnect();
+    
+    /**
+     * Return the full url in string form.  
+     */
+    static String getURL(URL u) {
+        return u.getProtocol() + "://" + u.getHost() + ":" + u.getPort()  + u.getPath();
     }
 
-    public static void main(String[] args) throws Exception {
-        URLScanner scan = new URLScanner( "http://localhost:8888/org.drools.brms.JBRMS/package/com.billasurf.manufacturing.plant/SNAP" );
-
+    void updateRuleBase(RuleBase rb, boolean removeExistingPackages) {
+        URL url;
     }
+        
 
+
 }




More information about the jboss-svn-commits mailing list