Package org.drools.core.io.impl
Class UrlResource
- java.lang.Object
-
- org.drools.core.io.impl.BaseResource
-
- org.drools.core.io.impl.UrlResource
-
- All Implemented Interfaces:
Externalizable
,Serializable
,InternalResource
,org.kie.api.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
-
Fields inherited from class org.drools.core.io.impl.BaseResource
bytes
-
-
Constructor Summary
Constructors Constructor Description UrlResource()
UrlResource(String path)
UrlResource(String path, String encoding)
UrlResource(URL url)
UrlResource(URL url, String encoding)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
This implementation compares the underlying URL references.String
getBasicAuthentication()
String
getEncoding()
File
getFile()
InputStream
getInputStream()
This implementation opens an InputStream for the given URL.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.kie.api.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.core.io.impl.BaseResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, getSourcePath, getTargetPath, setCategories, setConfiguration, setDescription, setResourceType, setSourcePath, setTargetPath
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.drools.core.io.internal.InternalResource
addCategory, getBytes, getCategories, getConfiguration, getDescription, getResourceType, setCategories, setConfiguration, setDescription, setResourceType
-
-
-
-
Method Detail
-
writeExternal
public void writeExternal(ObjectOutput out) throws IOException
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classBaseResource
- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classBaseResource
- Throws:
IOException
ClassNotFoundException
-
getEncoding
public String getEncoding()
- Specified by:
getEncoding
in interfaceInternalResource
-
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 tofalse
, mainly to avoid jar file locking on Windows.- Specified by:
getInputStream
in interfaceorg.kie.api.io.Resource
- Throws:
IOException
- See Also:
URL.openConnection()
,URLConnection.setUseCaches(boolean)
,URLConnection.getInputStream()
-
getReader
public Reader getReader() throws IOException
- Specified by:
getReader
in interfaceorg.kie.api.io.Resource
- Throws:
IOException
-
getURL
public URL getURL() throws IOException
- Specified by:
getURL
in interfaceInternalResource
- Throws:
IOException
-
hasURL
public boolean hasURL()
- Specified by:
hasURL
in interfaceInternalResource
-
getFile
public File getFile() throws IOException
- Throws:
IOException
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectory
in interfaceInternalResource
-
listResources
public Collection<org.kie.api.io.Resource> listResources()
- Specified by:
listResources
in interfaceInternalResource
-
equals
public boolean equals(Object obj)
This implementation compares the underlying URL references.- Overrides:
equals
in classBaseResource
-
hashCode
public int hashCode()
This implementation returns the hash code of the underlying URL reference.- Overrides:
hashCode
in classBaseResource
-
toString
public String toString()
- Overrides:
toString
in classBaseResource
-
-