org.planx.xmlstore.stores
Class RemoteXMLStore

java.lang.Object
  extended by org.planx.xmlstore.stores.RemoteXMLStore
All Implemented Interfaces:
ExecXMLStore<ValueReference>, XMLStore<ValueReference>

public class RemoteXMLStore
extends Object
implements ExecXMLStore<ValueReference>

A direct connection to a remote XMLStore peer. Used for peer-to-peer transfers of data. In general, an application programmer would want to use DistributedXMLStore to get transparent location of data. However, this class is left exposed to application programmers for use in cases where the programmer does not wish to run a local XMLStore peer but rather connect to a remote XMLStore. Note, that in this case all transfers will go through the "gateway" XMLStore peer even though the XMLStore might consist of many XMLStore peers.

See NetworkProtocol for a description of the protocol.

Author:
Henning Niss, Thomas Ambus

Constructor Summary
RemoteXMLStore(InetAddress addr, int port)
           
RemoteXMLStore(InetSocketAddress sockaddr)
           
RemoteXMLStore(String host, int port)
           
 
Method Summary
 void close()
          The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth.
 ValueReference exec(ValueReference code, ValueReference args)
          Execute the code referenced by codeRef supplied with the argument reference by argsRef.
 NameServer<ValueReference> getNameServer()
          Returns the NameServer with the largest scope associated with this XMLStore.
 Node load(ValueReference ref)
          Loads XML data identified by a reference.
 ValueReference save(Node n)
          The subtree rooted at the specified Node is sent to the remote XMLStore and saved there.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RemoteXMLStore

public RemoteXMLStore(String host,
                      int port)
               throws IOException,
                      UnknownHostException
Throws:
IOException
UnknownHostException

RemoteXMLStore

public RemoteXMLStore(InetSocketAddress sockaddr)
               throws IOException
Throws:
IOException

RemoteXMLStore

public RemoteXMLStore(InetAddress addr,
                      int port)
               throws IOException
Throws:
IOException
Method Detail

load

public Node load(ValueReference ref)
          throws IOException
Description copied from interface: XMLStore
Loads XML data identified by a reference. The returned value is semi-structured tree data, represented by a "root node" having 0 or more subtrees each represented by Nodes.

Specified by:
load in interface XMLStore<ValueReference>
Parameters:
ref - the Reference to the data
Returns:
node representing the loaded XML data
Throws:
IOException - if an error occurs during disk, network, etc access
UnknownReferenceException - if the data referenced is not stored in the XMLStore or the Reference is of a type not supported by the XMLStore

save

public ValueReference save(Node n)
                    throws IOException
The subtree rooted at the specified Node is sent to the remote XMLStore and saved there. A Reference to the root is returned.

Specified by:
save in interface XMLStore<ValueReference>
Parameters:
n - representing XML data in the form of semi-structured tree data
Returns:
a reference to the saved node/tree
Throws:
IOException - if an error occurs during disk, network, etc access

getNameServer

public NameServer<ValueReference> getNameServer()
Description copied from interface: XMLStore
Returns the NameServer with the largest scope associated with this XMLStore. That is, an XMLStore that stores data in a distributed setting should return a global NameServer for the XMLStore network in which it participates and not a local NameServer (even though it may also have access to such an entity).

Specified by:
getNameServer in interface XMLStore<ValueReference>

exec

public ValueReference exec(ValueReference code,
                           ValueReference args)
                    throws IOException,
                           ExecException
Description copied from interface: ExecXMLStore
Execute the code referenced by codeRef supplied with the argument reference by argsRef. Returns a reference to the result of the execution.

Specified by:
exec in interface ExecXMLStore<ValueReference>
Parameters:
code - the Reference to a binary node containing class code implementing StoredCode
args - reference to arguments
Returns:
a reference to the result
Throws:
IOException - if an error occurs during loading of code or arguments
ExecException

close

public void close()
           throws IOException
Description copied from interface: XMLStore
The method is used to let the XMLStore properly commit all data to the underlying ressource, release resources, and so forth. Once close has been issued on an XMLStore, the store is no longer available for handling requests. Any subsequent request to the store will result in an exception being thrown. An XMLStore implementation has to ensure that this happens.

Specified by:
close in interface XMLStore<ValueReference>
Throws:
IOException - if it is not possible to properly close the store

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2005 Plan-X. All Rights Reserved.