edu.UCL.xmiddle
Class SimpleManager

java.lang.Object
  |
  +--edu.UCL.xmiddle.SimpleManager
All Implemented Interfaces:
Manager

public class SimpleManager
extends java.lang.Object
implements Manager

This is the API that XMIDDLE presents to the application developer. All middleware functionalities can be accessed by the developer from here. In other words this class provides a high level view of XMIDDLE


Field Summary
 
Fields inherited from interface edu.UCL.xmiddle.framework.Manager
CONNECTED, DISCONNECTED
 
Constructor Summary
SimpleManager()
           
 
Method Summary
 void addHostListener(Host host, HostListener application)
          Adds a HostListener object for the given Host object.
 void addHostListener(HostListener application)
          Adds a HostListener object.
 void addHostListenerPrimID(java.lang.Object primID, HostListener application)
          Adds a HostListener object for the Host object identified by the given primary ID.
 void addHostListenerSecID(java.lang.Object secID, HostListener application)
          Adds a HostListener object for the Host object identified by the given primary ID.
 void close(org.w3c.dom.Element element, java.lang.Integer appID)
          Commits the changes performed on the given Element.
 boolean connect()
          Connects to the network.
 void deleteApplication(java.lang.Integer param1)
          Currently not implemented
 void disconnect()
          Disconnects from the network.
 void exit()
          Terminates the middleware services.
 boolean export(org.w3c.dom.Element element, java.lang.Integer appID)
          Starts exporting the given element.
 boolean export(java.lang.String path, java.lang.Integer appID)
          Starts exporting the given element.
 java.util.Enumeration getExports()
          Returns the ExportList.
 java.util.Enumeration getHosts()
          Returns the list of the hosts that are currently in reach.
static SimpleManager getInstance()
          Returns an instance of the SimpleManager object.
 java.util.Enumeration getLinkedBy()
          Returns the LinkedBy table.
 java.util.Enumeration getLinkedFrom()
          Returns the LinkedFrom table.
 java.lang.Object getPrimaryID()
          Returns the primary ID of the local host.
 ApplicationProfile getProfile(java.lang.Integer appID)
          Returns the profile of the application with the given ID.
 java.lang.Object getSecondary()
          Returns the secondary ID of the local host.
 java.lang.Object getSecondaryID()
          Returns the secondary ID of the local host.
 boolean getStatus()
          Returns the connection status (CONNECTED or DISCONNECTED).
 void init()
          Initialises a new XMIDDLE session.
 void link(Host host, java.lang.Integer appID, java.lang.String remoteExport, java.lang.Integer localAppID, org.w3c.dom.Element localRoot)
          Links to a remote element (mounting of a sub-tree exported by another host).
 org.w3c.dom.Element open(java.lang.String path, java.lang.Integer appID)
          Retrieves a sub-tree identified by the given XPath expression.
 void print(java.lang.String param1)
          Not implemented (should print debugging info)
 void println(java.lang.String param1)
          Not implemented (should print debugging info)
 void queue(java.lang.Object[] param1)
          Queues a protocol request to the Localhost thread.
 java.lang.Integer registerApplication(XApp app)
          Registers a new application to the middleware.
 void registerProtocol(java.lang.String className, java.lang.String protocolName)
          Registers a new protocol as available to the middleware.
 void removeHostListener(Host host, HostListener application)
          Removes the given HostListener object, referring to the given host.
 void removeHostListener(HostListener application)
          Removes the given HostListener object.
 void removeHostListenerPrimID(java.lang.Object primID, HostListener application)
          Removes the given HostListener object, referring to the given host identified by the given primary ID.
 void removeHostListenerSecID(java.lang.Object secID, HostListener application)
          Removes the given HostListener object, referring to the given host identified by the given secondary ID.
 void resume()
          Not implemented
 void send(Data param1)
          Sends a data packet to another host.
 void suspend()
          Not implemented
 void sync(Host host, java.lang.Integer origAppID, java.lang.String origPath, java.lang.Integer localAppID, java.lang.String localPath)
          Synchronizes (reconciles) our data with the given Host.
 void unexport(org.w3c.dom.Element element, java.lang.Integer appID)
          Stops exporting the given element.
 void unexport(java.lang.String path, java.lang.Integer appID)
          Stops exporting the given element.
 void unlink(org.w3c.dom.Element element, java.lang.Integer appID)
          Stops linking to the specified element of the specified ID.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleManager

public SimpleManager()
Method Detail

addHostListener

public void addHostListener(HostListener application)
Adds a HostListener object.

Specified by:
addHostListener in interface Manager
Parameters:
application - the object to be notified.

addHostListener

public void addHostListener(Host host,
                            HostListener application)
Adds a HostListener object for the given Host object.

Specified by:
addHostListener in interface Manager
Parameters:
host - the host that needs a Host Listener .
application - the host listener

addHostListenerPrimID

public void addHostListenerPrimID(java.lang.Object primID,
                                  HostListener application)
Adds a HostListener object for the Host object identified by the given primary ID.

Specified by:
addHostListenerPrimID in interface Manager
Parameters:
primID - the primary ID of the host
application - the host listener.

addHostListenerSecID

public void addHostListenerSecID(java.lang.Object secID,
                                 HostListener application)
Adds a HostListener object for the Host object identified by the given primary ID.

Specified by:
addHostListenerSecID in interface Manager
Parameters:
application - the host listener
secID - The host, identified (NOT uniquely) by its secondary ID.

removeHostListener

public void removeHostListener(HostListener application)
Removes the given HostListener object.

Specified by:
removeHostListener in interface Manager
Parameters:
application - the host listener

removeHostListener

public void removeHostListener(Host host,
                               HostListener application)
Removes the given HostListener object, referring to the given host.

Specified by:
removeHostListener in interface Manager
Parameters:
host - the host
application - the host listener

removeHostListenerPrimID

public void removeHostListenerPrimID(java.lang.Object primID,
                                     HostListener application)
Removes the given HostListener object, referring to the given host identified by the given primary ID.

Specified by:
removeHostListenerPrimID in interface Manager
Parameters:
primID - the primaryID of the host
application - the host listener

removeHostListenerSecID

public void removeHostListenerSecID(java.lang.Object secID,
                                    HostListener application)
Removes the given HostListener object, referring to the given host identified by the given secondary ID.

Specified by:
removeHostListenerSecID in interface Manager
Parameters:
secID - the secondary ID of the host
application - the host listener

deleteApplication

public void deleteApplication(java.lang.Integer param1)
Currently not implemented

Specified by:
deleteApplication in interface Manager
Parameters:
param1 -

getProfile

public ApplicationProfile getProfile(java.lang.Integer appID)
Returns the profile of the application with the given ID.

Specified by:
getProfile in interface Manager
Parameters:
appID - the ID of the application the profile of which is requested
Returns:
the profile of the application with the given ID

registerApplication

public java.lang.Integer registerApplication(XApp app)
Registers a new application to the middleware.

Specified by:
registerApplication in interface Manager
Parameters:
app - the application to be registered
Returns:
the applicationID assigned to the application just registered

registerProtocol

public void registerProtocol(java.lang.String className,
                             java.lang.String protocolName)
Registers a new protocol as available to the middleware.

Specified by:
registerProtocol in interface Manager
Parameters:
className - the absolute class name of the protocol (which must extend edu.UCL.xmiddle.framework.lib.protocols.Protocol
protocolName - the unique name by which this protocol is identified

getLinkedFrom

public java.util.Enumeration getLinkedFrom()
Returns the LinkedFrom table.

Specified by:
getLinkedFrom in interface Manager
Returns:
the LinkedFrom table

getLinkedBy

public java.util.Enumeration getLinkedBy()
Returns the LinkedBy table.

Specified by:
getLinkedBy in interface Manager
Returns:
the LinkedBy table

getExports

public java.util.Enumeration getExports()
Returns the ExportList.

Specified by:
getExports in interface Manager
Returns:
the ExportList

unlink

public void unlink(org.w3c.dom.Element element,
                   java.lang.Integer appID)
Stops linking to the specified element of the specified ID. Note that this does not delete the element.

Specified by:
unlink in interface Manager
Parameters:
appID - the application ID on the tree of which this element resides

link

public void link(Host host,
                 java.lang.Integer appID,
                 java.lang.String remoteExport,
                 java.lang.Integer localAppID,
                 org.w3c.dom.Element localRoot)
Links to a remote element (mounting of a sub-tree exported by another host).

Specified by:
link in interface Manager
Parameters:
host - the host on which the (exported) element resides
appID - the application ID of the remote application exporting the element
remoteExport - the exported element itself as advertised by the application
localAppID - the local application ID on the tree of which we want the linked element to reside
localRoot - the local root element under which the linked element will be placed

sync

public void sync(Host host,
                 java.lang.Integer origAppID,
                 java.lang.String origPath,
                 java.lang.Integer localAppID,
                 java.lang.String localPath)
Synchronizes (reconciles) our data with the given Host.

Specified by:
sync in interface Manager
Parameters:
host - the host on which the element resides.
localAppID - the application ID on the localhost.
localPath - the path name on the localhost.

queue

public void queue(java.lang.Object[] param1)
Queues a protocol request to the Localhost thread.

Specified by:
queue in interface Manager
Parameters:
param1 - the request, as an Object[] value

send

public void send(Data param1)
Sends a data packet to another host.

Specified by:
send in interface Manager
Parameters:
param1 - the Data packet to send

unexport

public void unexport(org.w3c.dom.Element element,
                     java.lang.Integer appID)
Stops exporting the given element.

Specified by:
unexport in interface Manager
Parameters:
element - the element to stop exporting
appID - the application ID to which this element belongs

unexport

public void unexport(java.lang.String path,
                     java.lang.Integer appID)
Stops exporting the given element.

Specified by:
unexport in interface Manager
Parameters:
path - the element to stop exporting (as XPath)
appID - the application ID to which this element belongs

export

public boolean export(org.w3c.dom.Element element,
                      java.lang.Integer appID)
Starts exporting the given element. This will also create version 0 of the element.

Specified by:
export in interface Manager
Parameters:
element - the element to export
appID - the ID of the application under the tree of which the given element resides
Returns:
true if the operation succeded or false otherwise.

export

public boolean export(java.lang.String path,
                      java.lang.Integer appID)
Starts exporting the given element. This will also create version 0 of the element.

Specified by:
export in interface Manager
Parameters:
path - the element to be exported (XPath)
appID - the ID of the application under the tree of which the given element resides
Returns:
true if the operation succeded or false otherwise.

getStatus

public boolean getStatus()
Returns the connection status (CONNECTED or DISCONNECTED).

Specified by:
getStatus in interface Manager
Returns:
CONNECTED or DISCONNECTED

disconnect

public void disconnect()
Disconnects from the network.

Specified by:
disconnect in interface Manager

connect

public boolean connect()
Connects to the network.

Specified by:
connect in interface Manager
Returns:
true if the operation was successful or false otherwise

getHosts

public java.util.Enumeration getHosts()
Returns the list of the hosts that are currently in reach.

Specified by:
getHosts in interface Manager
Returns:
an enumeration of UDPHosts currently in reach

close

public void close(org.w3c.dom.Element element,
                  java.lang.Integer appID)
Commits the changes performed on the given Element.

Specified by:
close in interface Manager
Parameters:
element - The element to "close"
appID - The ID of the application under the tree of which the given element resides.

open

public org.w3c.dom.Element open(java.lang.String path,
                                java.lang.Integer appID)
Retrieves a sub-tree identified by the given XPath expression.

Specified by:
open in interface Manager
Parameters:
appID - the id of the application under the tree of which the given element resides
path - an xpath expression describing the element to open.
Returns:
the element identified by the given XPath expression or NULL if the operation failed (invalid XPath, etc)

getPrimaryID

public java.lang.Object getPrimaryID()
Returns the primary ID of the local host.

Specified by:
getPrimaryID in interface Manager

getSecondary

public java.lang.Object getSecondary()
Returns the secondary ID of the local host.


getSecondaryID

public java.lang.Object getSecondaryID()
Returns the secondary ID of the local host.

Specified by:
getSecondaryID in interface Manager

println

public void println(java.lang.String param1)
Not implemented (should print debugging info)

Specified by:
println in interface Manager
Parameters:
param1 -

print

public void print(java.lang.String param1)
Not implemented (should print debugging info)

Specified by:
print in interface Manager
Parameters:
param1 -

exit

public void exit()
Terminates the middleware services.

Specified by:
exit in interface Manager

resume

public void resume()
Not implemented

Specified by:
resume in interface Manager

suspend

public void suspend()
Not implemented

Specified by:
suspend in interface Manager

init

public void init()
Initialises a new XMIDDLE session.

Specified by:
init in interface Manager

getInstance

public static SimpleManager getInstance()
Returns an instance of the SimpleManager object.

Returns:
an instance of the SimpleManager object