org.drools.io.impl
Class UrlResource

java.lang.Object
  extended by org.drools.io.impl.BaseResource
      extended by org.drools.io.impl.UrlResource
All Implemented Interfaces:
Externalizable, Serializable, InternalResource, org.drools.io.Resource

public class UrlResource
extends BaseResource
implements InternalResource, Externalizable

Borrowed gratuitously from Spring under ASL2.0. Added in local file cache ability for http and https urls. Set the system property: "drools.resource.urlcache" to a directory which can be written to and read from as a cache - so remote resources will be cached with last known good copies.

See Also:
Serialized Form

Field Summary
static File CACHE_DIR
           
 
Constructor Summary
UrlResource()
           
UrlResource(String path)
           
UrlResource(URL url)
           
 
Method Summary
 boolean equals(Object obj)
          This implementation compares the underlying URL references.
 String getBasicAuthentication()
           
 File getFile()
           
 InputStream getInputStream()
          This implementation opens an InputStream for the given URL.
 long getLastModified()
           
 long getLastRead()
           
 String getPassword()
           
 Reader getReader()
           
 URL getURL()
           
 String getUsername()
           
 int hashCode()
          This implementation returns the hash code of the underlying URL reference.
 boolean hasURL()
           
 boolean isDirectory()
           
 Collection<org.drools.io.Resource> listResources()
           
 void readExternal(ObjectInput in)
           
 void setBasicAuthentication(String basicAuthentication)
           
 void setPassword(String password)
           
 void setUsername(String username)
           
 String toString()
           
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class org.drools.io.impl.BaseResource
getConfiguration, getResourceType, setConfiguration, setResourceType
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.drools.io.internal.InternalResource
getConfiguration, getResourceType, setConfiguration, setResourceType
 

Field Detail

CACHE_DIR

public static File CACHE_DIR
Constructor Detail

UrlResource

public UrlResource()

UrlResource

public UrlResource(URL url)

UrlResource

public UrlResource(String path)
Method Detail

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

getBasicAuthentication

public String getBasicAuthentication()

setBasicAuthentication

public void setBasicAuthentication(String basicAuthentication)

getUsername

public String getUsername()

setUsername

public void setUsername(String username)

getPassword

public String getPassword()

setPassword

public void setPassword(String password)

getInputStream

public InputStream getInputStream()
                           throws IOException
This implementation opens an InputStream for the given URL. It sets the "UseCaches" flag to false, mainly to avoid jar file locking on Windows.

Specified by:
getInputStream in interface org.drools.io.Resource
Throws:
IOException
See Also:
URL.openConnection(), URLConnection.setUseCaches(boolean), URLConnection.getInputStream()

getReader

public Reader getReader()
                 throws IOException
Specified by:
getReader in interface org.drools.io.Resource
Throws:
IOException

getURL

public URL getURL()
           throws IOException
Specified by:
getURL in interface InternalResource
Throws:
IOException

hasURL

public boolean hasURL()
Specified by:
hasURL in interface InternalResource

getFile

public File getFile()
             throws IOException
Throws:
IOException

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface InternalResource

getLastRead

public long getLastRead()
Specified by:
getLastRead in interface InternalResource

isDirectory

public boolean isDirectory()
Specified by:
isDirectory in interface InternalResource

listResources

public Collection<org.drools.io.Resource> listResources()
Specified by:
listResources in interface InternalResource

equals

public boolean equals(Object obj)
This implementation compares the underlying URL references.

Overrides:
equals in class Object

hashCode

public int hashCode()
This implementation returns the hash code of the underlying URL reference.

Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2001-2013 JBoss Inc.. All Rights Reserved.