P2PDirectory
Keywords: uk.ac.ic.doc.automed.p2p.directory.P2PDirectory class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## uk.ac.ic.doc.automed.p2p.directory
Class P2PDirectory

    java.lang.Object
      uk.ac.ic.doc.automed.p2p.communication.AbstractRequestListener
          uk.ac.ic.doc.automed.p2p.directory.P2PDirectory

All Implemented Interfaces:
  RequestListener

    public class P2PDirectory

extends AbstractRequestListener

Field Summary
`protected P2PDirectoryRepository` | `repository`
`static boolean` | `SINGLE_HANDLER_PER_EVENT`

Method Summary
`void` | `addEventListener(java.util.EventListener listener)` Register an `EventListener` object
`void` | `addRequestListener(RequestListener listener)` Register a `RequestListener` object to client requests
`void` | `close()`
`java.util.List` | `getAllPeers()` Get all peers from db
`AppToolKit.NodeConfig` | `getConfig()` Return the reference to the configuration file used by the directory service
`static P2PDirectory` | `getDirectoryInstance()` Create a unique instance of directory service from application code
`P2PDirectoryRepository` | `getDirectoryRepository()` Returns the reference to the `P2PDirectoryRepository` instance that is responsible for handling storage for the directory service.
`java.util.List` | `getPathwayAbstractDescriptions(java.lang.String schemaName)` Return a `List` of `PathwayDescription` objects, each representing a pathway abstraction
`PeerDescription` | `getPeerDescription(java.lang.String peerName)` Return reference a PeerDescription object about a registered peer (from the cache) Use this method is you are sure that a peer has successfully been registered
`java.util.List` | `getPeersImplementing(java.lang.String schema)`
`java.util.List` | `getPublicSchema(java.lang.String name)` Look up schema definition from the repository and
`java.util.List` | `getPublicSchemas()`
`boolean` | `getReadyState()` Is the socket server ready to accept requests?
`java.util.List` | `getSchemasImplementedBy(java.lang.String peerName)`
`byte[]` | `handleRequest(byte[] dataReceived, ResponseHandler output)` Handle requests from peers
`void` | `initialiseRepository()` A method that indirectly causes the directory repository to be initialised .
`void` | `loadPeers()` load peers from database
`static void` | `main(java.lang.String[] args)` Start directory from command-line
`boolean` | `peerImplementsSchema(java.lang.String peer, java.lang.String schema)`
`boolean` | `publishModel(java.lang.String name, java.lang.String description, java.lang.String structure)` Store a received model to the directory's repository
`boolean` | `publishModel(java.lang.String name, java.lang.String description, java.lang.String structure, java.lang.String[] schemaNames)` An overloading method of {@link #publishModel(name, description, structure) above.
`SchemaDescription` | `publishSchema(java.lang.String name, java.lang.String description, java.lang.String structure)` Save schema to directory service's registry
`boolean` | `registerPeer(java.lang.String name, java.lang.String url, java.lang.String status, java.lang.String lastUpdate)` dmle 2/11/2005: register peer status as well
`boolean` | `registerPeer(java.lang.String domain, java.lang.String name, java.lang.String url, java.lang.String port, java.lang.String user, java.lang.String pwd, java.lang.String encryption, java.lang.String status, java.lang.String lastUpdate)` Register peer reachability with domain and authentication
`boolean` | `updatePeer(java.lang.String name, java.lang.String url)` Update peer using name and url
`boolean` | `updatePeer(java.lang.String name, java.lang.String url, java.lang.String status, java.lang.String lastUpdate)` Update peer status
`boolean` | `updatePeerAddress(java.lang.String domain, java.lang.String existingAddress, java.lang.String newAddress)` Update peer's address with a new address

Methods inherited from class uk.ac.ic.doc.automed.p2p.communication.AbstractRequestListener
`getRequestMessage, getResponseData, getType, handleRequest, handleRequest, handleRequest, handleUDPRequest, handleUDPRequest, handleUDPRequest`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### repository

    protected P2PDirectoryRepository repository

### SINGLE_HANDLER_PER_EVENT

    public static final boolean SINGLE_HANDLER_PER_EVENT

See Also:
  Constant Field Values

Method Detail

### addRequestListener

    public void addRequestListener(RequestListener listener)

  Register a `RequestListener` object to client requests

### addEventListener

    public void addEventListener(java.util.EventListener listener)

  Register an `EventListener` object

### close

    public void close()

### getDirectoryRepository

    public P2PDirectoryRepository getDirectoryRepository()

  Returns the reference to the `P2PDirectoryRepository` instance that is responsible
  for handling storage for the directory service.

### initialiseRepository

    public void initialiseRepository()
                              throws AutoMedException

  A method that indirectly causes the directory repository to be initialised
  . Classes outside the p2p package should not access this method directly.

  Throws:
    `AutoMedException`

### getReadyState

    public boolean getReadyState()

  Is the socket server ready to accept requests?

### getConfig

    public AppToolKit.NodeConfig getConfig()

  Return the reference to the configuration file used by the directory service

### getAllPeers

    public java.util.List getAllPeers()

  Get all peers from db

### registerPeer

    public boolean registerPeer(java.lang.String name,
                                java.lang.String url,
                                java.lang.String status,
                                java.lang.String lastUpdate)

  dmle 2/11/2005: register peer status as well

### registerPeer

    public boolean registerPeer(java.lang.String domain,
                                java.lang.String name,
                                java.lang.String url,
                                java.lang.String port,
                                java.lang.String user,
                                java.lang.String pwd,
                                java.lang.String encryption,
                                java.lang.String status,
                                java.lang.String lastUpdate)

  Register peer reachability with domain and authentication

### updatePeer

    public boolean updatePeer(java.lang.String name,
                              java.lang.String url,
                              java.lang.String status,
                              java.lang.String lastUpdate)

  Update peer status

### updatePeer

    public boolean updatePeer(java.lang.String name,
                              java.lang.String url)

  Update peer using name and url

### updatePeerAddress

    public boolean updatePeerAddress(java.lang.String domain,
                                     java.lang.String existingAddress,
                                     java.lang.String newAddress)

  Update peer's address with a new address

### peerImplementsSchema

    public boolean peerImplementsSchema(java.lang.String peer,
                                        java.lang.String schema)

### publishSchema

    public SchemaDescription publishSchema(java.lang.String name,
                                           java.lang.String description,
                                           java.lang.String structure)

  Save schema to directory service's registry

  Returns:
    SchemaDescription object if operation succeeded or null if otherwise

### publishModel

    public boolean publishModel(java.lang.String name,
                                java.lang.String description,
                                java.lang.String structure)

  Store a received model to the directory's repository

  Parameters:
    `name` - the model name
    `description` - the model description
    `structure` - the model objects
  Returns:
    `boolean` indicates the result of the operation

### publishModel

    public boolean publishModel(java.lang.String name,
                                java.lang.String description,
                                java.lang.String structure,
                                java.lang.String[] schemaNames)

  An overloading method of {@link #publishModel(name, description, structure) above.

  Parameters:
    `name` - the model name
    `description` - the model description
    `structure` - the model objects
    `schemas` - an array of schema names associated to this model
  Returns:
    `boolean` indicates the result of the operation

### getPublicSchemas

    public java.util.List getPublicSchemas()

### getPathwayAbstractDescriptions

    public java.util.List getPathwayAbstractDescriptions(java.lang.String schemaName)

  Return a `List` of `PathwayDescription` objects, each representing a pathway abstraction

### getPublicSchema

    public java.util.List getPublicSchema(java.lang.String name)

  Look up schema definition from the repository and

### getPeersImplementing

    public java.util.List getPeersImplementing(java.lang.String schema)

### getSchemasImplementedBy

    public java.util.List getSchemasImplementedBy(java.lang.String peerName)

### handleRequest

    public byte[] handleRequest(byte[] dataReceived,
                                ResponseHandler output)
                         throws CommunicationException

  Handle requests from peers

  Specified by:
    `handleRequest` in interface `RequestListener`
  Overrides:
    `handleRequest` in class `AbstractRequestListener`
  Throws:
    `CommunicationException`

### getDirectoryInstance

    public static P2PDirectory getDirectoryInstance()
                                             throws AutoMedException

  Create a unique instance of directory service from application code

  Throws:
    `AutoMedException`

### getPeerDescription

    public PeerDescription getPeerDescription(java.lang.String peerName)

  Return reference a PeerDescription object about a registered peer (from the cache) Use this method is you are sure that a peer has successfully been registered

### loadPeers

    public void loadPeers()

  load peers from database

### main

    public static void main(java.lang.String[] args)
                     throws AutoMedException

  Start directory from command-line

  Throws:
    `AutoMedException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD