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 booleanequals(Object obj)This implementation compares the underlying URL references.StringgetBasicAuthentication()StringgetEncoding()FilegetFile()InputStreamgetInputStream()This implementation opens an InputStream for the given URL.StringgetPassword()ReadergetReader()URLgetURL()StringgetUsername()inthashCode()This implementation returns the hash code of the underlying URL reference.booleanhasURL()booleanisDirectory()Collection<org.kie.api.io.Resource>listResources()voidreadExternal(ObjectInput in)voidsetBasicAuthentication(String basicAuthentication)voidsetPassword(String password)voidsetUsername(String username)StringtoString()voidwriteExternal(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:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classBaseResource- Throws:
IOException
-
readExternal
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classBaseResource- Throws:
IOExceptionClassNotFoundException
-
getEncoding
public String getEncoding()
- Specified by:
getEncodingin 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:
getInputStreamin interfaceorg.kie.api.io.Resource- Throws:
IOException- See Also:
URL.openConnection(),URLConnection.setUseCaches(boolean),URLConnection.getInputStream()
-
getReader
public Reader getReader() throws IOException
- Specified by:
getReaderin interfaceorg.kie.api.io.Resource- Throws:
IOException
-
getURL
public URL getURL() throws IOException
- Specified by:
getURLin interfaceInternalResource- Throws:
IOException
-
hasURL
public boolean hasURL()
- Specified by:
hasURLin interfaceInternalResource
-
getFile
public File getFile() throws IOException
- Throws:
IOException
-
isDirectory
public boolean isDirectory()
- Specified by:
isDirectoryin interfaceInternalResource
-
listResources
public Collection<org.kie.api.io.Resource> listResources()
- Specified by:
listResourcesin interfaceInternalResource
-
equals
public boolean equals(Object obj)
This implementation compares the underlying URL references.- Overrides:
equalsin classBaseResource
-
hashCode
public int hashCode()
This implementation returns the hash code of the underlying URL reference.- Overrides:
hashCodein classBaseResource
-
toString
public String toString()
- Overrides:
toStringin classBaseResource
-
-