P-Grid v2.0a2 API Specification

p2p.basic
Class P2PFactory

java.lang.Object
  extended by p2p.basic.P2PFactory

public abstract class P2PFactory
extends Object

Abstract Factory (GoF) that defines the operations that create various objects of the P2P layer. It is recommended to instantiate such types only through a concrete implementation of this factory to avoid hard-coding direct references to them. This class provides static methods to find concrete factories using the reflection API to further decouple the subsystem from its client.


Constructor Summary
P2PFactory()
           
 
Method Summary
abstract  Message createMessage(byte[] contents)
          Create a Message instance compatible with the P2P implementation.
abstract  P2P createP2P(Properties properties)
          Create the concrete P2P implementation.
abstract  Peer createPeer(InetAddress netAddr, int port)
          Create a Peer instance compatible with the P2P implementation based on the provided information.
abstract  GUID generateGUID()
          Generate a GUID instance compatible with the P2P implementation.
abstract  Key generateKey(Object obj)
          Generate a Key instance compatible with the P2P implementation.
abstract  KeyRange generateKeyRange(Object lowerBound, Object higherBound)
          Generate a KeyRange instance compatible with the P2P implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

P2PFactory

public P2PFactory()
Method Detail

createP2P

public abstract P2P createP2P(Properties properties)
Create the concrete P2P implementation.

Returns:
P2P implementation implementation

generateKey

public abstract Key generateKey(Object obj)
Generate a Key instance compatible with the P2P implementation. Acceptable source object types depend on implementation.

Parameters:
obj - the source object from which to generate the key
Returns:
the generated Key implementation

generateKeyRange

public abstract KeyRange generateKeyRange(Object lowerBound,
                                          Object higherBound)
Generate a KeyRange instance compatible with the P2P implementation. Acceptable source object types depend on implementation.

Parameters:
lowerBound - the source object from which to generate the lower key
lowerBound - the source object from which to generate the higher key
Returns:
the generated Key implementation

generateGUID

public abstract GUID generateGUID()
Generate a GUID instance compatible with the P2P implementation.

Returns:
the generated global unique identifier

createMessage

public abstract Message createMessage(byte[] contents)
Create a Message instance compatible with the P2P implementation.

Parameters:
contents - the binary content to include in the message
Returns:
the Message implementation

createPeer

public abstract Peer createPeer(InetAddress netAddr,
                                int port)
                         throws UnknownHostException
Create a Peer instance compatible with the P2P implementation based on the provided information.

Parameters:
netAddr - the Internet address of the peer
port - the service port number of the peer
Returns:
the Peer implementation
Throws:
UnknownHostException - if the given address is invalid.

P-Grid v2.0a2 API Specification

This is open source software distributed under the terms of the GNU General Public License, a copy of which is included in the file LICENSE. If not you can find the GPL at http://www.gnu.org/copyleft/gpl.txt