[jboss-svn-commits] JBL Code SVN: r24271 - labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sun Dec 7 00:07:05 EST 2008
Author: mark.proctor at jboss.com
Date: 2008-12-07 00:07:05 -0500 (Sun, 07 Dec 2008)
New Revision: 24271
Modified:
labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/UrlResource.java
Log:
JBRULES-1885 Update KnowledgeAgent to use new Resource api
-UrlResource will use file to getlastModified if protocol is file:
JBRULES-1874 Create Resource Framework
JBRULES-1875 Load ChangeSet XML files for multiple resources
Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/UrlResource.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/UrlResource.java 2008-12-07 04:03:33 UTC (rev 24270)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/io/impl/UrlResource.java 2008-12-07 05:07:05 UTC (rev 24271)
@@ -27,9 +27,9 @@
implements
InternalResource,
Externalizable {
- private URL url;
- private long lastRead = -1;
-
+ private URL url;
+ private long lastRead = -1;
+
public UrlResource() {
}
@@ -103,11 +103,26 @@
return true;
}
+ public File getFile() throws IOException {
+ try {
+ return new File( StringUtils.toURI( url.toString() ).getSchemeSpecificPart() );
+ } catch ( Exception e ) {
+ throw new RuntimeException( "Unable to get File for url " + this.url, e);
+ }
+ }
+
public long getLastModified() {
try {
- URLConnection conn = getURL().openConnection();
- long date = conn.getLastModified();
- return date;
+ // use File, as http rounds milliseconds on some machines, this fine level of granularity is only really an issue for testing
+ // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504473
+ if ( "file".equals( url.getProtocol() ) ) {
+ File file = getFile();
+ return file.lastModified();
+ } else {
+ URLConnection conn = getURL().openConnection();
+ long date = conn.getLastModified();
+ return date;
+ }
} catch ( IOException e ) {
throw new RuntimeException( "Unable to get LastMofified for ClasspathResource",
e );
@@ -140,7 +155,7 @@
URL url = getURL();
if ( "file".equals( url.getProtocol() ) ) {
- File dir = new File( StringUtils.toURI( url.toString() ).getSchemeSpecificPart() );
+ File dir = getFile();
List<Resource> resources = new ArrayList<Resource>();
More information about the jboss-svn-commits
mailing list