uk.ac.ic.doc.automed.p2p.gui
Class PeerApplication

java.lang.Object
  extended by uk.ac.ic.doc.automed.p2p.gui.PeerApplication

public class PeerApplication
extends java.lang.Object

Author:
Charis TODO To change the template for this generated type comment go to Window - Preferences - Java - Code Style - Code Templates

Field Summary
(package private)  AllSchemasFrame allSchemas
           
private  PeerCache cache
           
private  SchemaDescription currentSchema
           
(package private)  Gui gui
           
private static java.lang.String localHostName
           
protected  LoginFrame loginFrame
           
(package private)  MySchemasFrame mySchemas
           
private  ProgressConsole pc
           
private  AutoMedPeer peer
           
(package private)  SchemaInfoFrame schemaInfo
           
(package private)  boolean standalone
           
protected  PeerStateHandler stateHandler
           
 
Constructor Summary
PeerApplication()
          Equivalent to PeerApplication(null,true)
PeerApplication(AutoMedPeer peer)
          Start peer app with a peer
PeerApplication(Gui gui, boolean standalone)
          Create a GUI application to access the P2P system.
 
Method Summary
 void advertizePath(SchemaDescription publicSchema)
           
 void broker(PeerDescription peerDesc)
          Ask a peer to act as a broker for a query, executing the query against its local data sources, and those of any other peers that the peer knows about that implement public schemas of that peer.
 void broker(PeerDescription peerDesc, java.lang.String schema, java.lang.String query)
           
 void close()
          Close the AutoMedPeer, and allow to register as a new peer
protected  void doLogin(java.lang.String domain, java.lang.String name, java.util.Properties options)
           
 AutoMedPeer getAutoMedPeer()
          Return the AutoMedPeer this application provides a UI for.
private  java.lang.String getCurrentSchemaTitle()
           
 Gui getGUI()
           
 java.util.Collection getObjectsFor(MainFrame frame)
           
 void getPathway(PeerDescription peer)
           
 PeerCache getPeerCache()
          Return the reference to PeerCache object which stores peer data
 void getSchema(SchemaDescription schema)
          Edited by MDLE on 19/10/2005 to also query associated models if required
 void getSourcePath(PeerDescription peerDesc)
          Get the pathway from a peer between a public schema and any named schema at that peer.
 PeerStateHandler getStateHandler()
          Return the peer-wise state handler object.
 java.lang.String getTitleFor(MainFrame frame)
           
static UserActionResult getTool(java.lang.Object[] o)
          Method for the AutoMed GUI to call to launch the P2P system.
protected  void initPeer(java.lang.String name, PeerStateHandler stateHandler)
          Intialise peer by creating a singleton object to be used throughout the application
This method is only invoked by LoginFrame and not by outside classes.
 boolean isStandAlone()
           
 void joinNetwork()
           
 void launchGui()
           
 void launchLoginFrame()
           
 void launchMainFrame()
           
 void loggedIn()
          The application has now logged in to the Directory, so enter "running" state where communication with Directory can be made.
static void main(java.lang.String[] args)
           
 void publishSchema()
           
private  void publishSchema(java.lang.String schema, java.lang.String description)
           
 void query(PeerDescription peerDesc)
          Run a query on a peer.
private  void query(PeerDescription peerDesc, java.lang.String schema, java.lang.String query)
           
 void refreshFor(MainFrame frame)
           
private  void requestSchema(PeerDescription peerDes, java.lang.String fromSchema, java.lang.String toSchema)
           
 void setGui(Gui gui)
          Set a GUI object
 void showAllSchemas()
           
 void showSchema(SchemaDescription schema)
           
 void wrap(PeerDescription peerDesc)
          Store the details of a PeerDescription as an AccessMethod in the local repository.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

loginFrame

protected LoginFrame loginFrame

mySchemas

MySchemasFrame mySchemas

allSchemas

AllSchemasFrame allSchemas

schemaInfo

SchemaInfoFrame schemaInfo

stateHandler

protected PeerStateHandler stateHandler

currentSchema

private SchemaDescription currentSchema

gui

Gui gui

peer

private AutoMedPeer peer

cache

private PeerCache cache

pc

private ProgressConsole pc

standalone

boolean standalone

localHostName

private static java.lang.String localHostName
Constructor Detail

PeerApplication

public PeerApplication()
Equivalent to PeerApplication(null,true)


PeerApplication

public PeerApplication(Gui gui,
                       boolean standalone)
Create a GUI application to access the P2P system.

Parameters:
gui - An AutoMed
standalone - When set to true, the application is designed to run alone, and has extra buttons to allow its different windows to open each other, and also run the AutoMed GUI. Normally the gui being non-null implies this parameter is false.

PeerApplication

public PeerApplication(AutoMedPeer peer)
Start peer app with a peer

Method Detail

initPeer

protected void initPeer(java.lang.String name,
                        PeerStateHandler stateHandler)
                 throws P2PException,
                        java.io.IOException,
                        AutoMedException
Intialise peer by creating a singleton object to be used throughout the application
This method is only invoked by LoginFrame and not by outside classes. Use constructor to create a pplication with a new AutoMedPeer object

Throws:
P2PException
java.io.IOException
AutoMedException

doLogin

protected void doLogin(java.lang.String domain,
                       java.lang.String name,
                       java.util.Properties options)
                throws AutoMedException
Throws:
AutoMedException

getAutoMedPeer

public AutoMedPeer getAutoMedPeer()
Return the AutoMedPeer this application provides a UI for. The peer will only be returned once the user has logged in to both the local P2PRegistry and global P2PDirectory


getPeerCache

public PeerCache getPeerCache()
Return the reference to PeerCache object which stores peer data


close

public void close()
Close the AutoMedPeer, and allow to register as a new peer


getGUI

public Gui getGUI()

isStandAlone

public boolean isStandAlone()

setGui

public void setGui(Gui gui)
Set a GUI object


launchLoginFrame

public void launchLoginFrame()

launchMainFrame

public void launchMainFrame()

loggedIn

public void loggedIn()
              throws AutoMedException
The application has now logged in to the Directory, so enter "running" state where communication with Directory can be made.

Throws:
AutoMedException

main

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

getObjectsFor

public java.util.Collection getObjectsFor(MainFrame frame)
Parameters:
frame -
Returns:

getTitleFor

public java.lang.String getTitleFor(MainFrame frame)
Parameters:
frame -
Returns:

getStateHandler

public PeerStateHandler getStateHandler()
Return the peer-wise state handler object. Create one if it not already exists


getCurrentSchemaTitle

private java.lang.String getCurrentSchemaTitle()

refreshFor

public void refreshFor(MainFrame frame)

showSchema

public void showSchema(SchemaDescription schema)
Parameters:
schema -

showAllSchemas

public void showAllSchemas()

launchGui

public void launchGui()

advertizePath

public void advertizePath(SchemaDescription publicSchema)

publishSchema

public void publishSchema()

publishSchema

private void publishSchema(java.lang.String schema,
                           java.lang.String description)

getSchema

public void getSchema(SchemaDescription schema)
Edited by MDLE on 19/10/2005 to also query associated models if required

Parameters:
schema -

broker

public void broker(PeerDescription peerDesc,
                   java.lang.String schema,
                   java.lang.String query)

broker

public void broker(PeerDescription peerDesc)
Ask a peer to act as a broker for a query, executing the query against its local data sources, and those of any other peers that the peer knows about that implement public schemas of that peer.

Parameters:
peerDesc - the Peer on which the broker query should start at

query

public void query(PeerDescription peerDesc)
Run a query on a peer.

Parameters:
peerDesc - The description of the peer on which to run the query.

query

private void query(PeerDescription peerDesc,
                   java.lang.String schema,
                   java.lang.String query)

wrap

public void wrap(PeerDescription peerDesc)
Store the details of a PeerDescription as an AccessMethod in the local repository. This makes the peer available as as data source for the query processor in the local repository.


getSourcePath

public void getSourcePath(PeerDescription peerDesc)
Get the pathway from a peer between a public schema and any named schema at that peer.

Parameters:
peerDesc - peer to retrieve path from public schema to data sources.

getPathway

public void getPathway(PeerDescription peer)
Parameters:
peer -

requestSchema

private void requestSchema(PeerDescription peerDes,
                           java.lang.String fromSchema,
                           java.lang.String toSchema)

getTool

public static UserActionResult getTool(java.lang.Object[] o)
Method for the AutoMed GUI to call to launch the P2P system.


joinNetwork

public void joinNetwork()
                 throws AutoMedException
Throws:
AutoMedException