|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.extra.Xfile
public class Xfile
This class is used to transfer files between Java Virtual Machines. This class normally resides in the codebase of both the client, and the server. A client invokes only the static fetch method. This will implicitly use the open and nextBlock methods on the server Xfile object, to complete the transfer. A server simply instantiates, and remotes an Xfile object, to enable file transfers. For threadsafety; a server should give each client a unique instance of this class.
Note: this object will try to send any file the client requests, therefore it should either be used by trusted clients, or with access priviliges appropriately locked down. Another option is to override the open method in a subclass, to check the requested resource against an approved list, throwing an exception if not.
Field Summary | |
---|---|
static boolean |
remoteInvoke
This field can allow the static fetch method to be invoked by a remote client. |
Constructor Summary | |
---|---|
Xfile(int maxBlock)
The constructor simply sets the maximum transfer block size. |
Method Summary | |
---|---|
static void |
fetch(java.lang.Object item,
java.lang.String source,
java.lang.String dest)
This is the only method used by clients, it fetches the file from the specified source, and saves it to the specified destination. |
byte[] |
nextBlock()
This method is called by the client's static fetch method, to request subsequent blocks of the file, until the transfer is complete. |
void |
open(java.lang.String source)
This method is called by the client's static fetch method, to open a resource on a remote Java Virtual Machine. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static boolean remoteInvoke
Constructor Detail |
---|
public Xfile(int maxBlock)
maxBlock
- The largest possible block to return from the
nextBlock method. It is suggested not to exceed 64k bytes.
java.lang.IllegalArgumentException
- if the max block argument is
less than 256 bytes, or greater than 1MB.Method Detail |
---|
public void open(java.lang.String source) throws java.io.IOException
source
- The resource to be loaded, typically the path and name
of the file on the server's local filesystem.
java.io.IOException
- If the specified resource does not exist, or
cannot be opened.public byte[] nextBlock() throws java.io.IOException
java.io.IOException
- If a stream is not currently open, or if a read,
or close error occurred.public static void fetch(java.lang.Object item, java.lang.String source, java.lang.String dest) throws java.lang.Exception
As a special case; the source and/or destination arguments can be URLs.
For example:
item
- The object, presumably a remote reference to an Xfile
object, with which to fetch the resource.source
- The file resource, typically the path and name of the
file in the server's local filesystem, to be transferred.dest
- The resource, typically the path and name of the file
in the clients's local filesystem, in which to transfer the data.
If the destination is local, and the path does not exist, it will
attempt to create it automatically.
java.io.IOException
- If the source is invalid, the destination
is invalid, or either could not be opened. If the destination
already exists, it will be overwritten.
java.rmi.RemoteException
- If a remote method invocation,
involved in the data transfer, fails.
java.lang.IllegalAccessException
- If this method is being invoked by a
remote JVM, and remote invocation has not been enabled.
java.lang.Exception
- By the remote JVM, if the operation is not
supported.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |