org.drools.io.impl
Class UrlResource
java.lang.Object
org.drools.io.impl.BaseResource
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
CACHE_DIR
public static File CACHE_DIR
UrlResource
public UrlResource()
UrlResource
public UrlResource(URL url)
UrlResource
public UrlResource(String path)
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.