Class NetworkModule
java.lang.Object
|
+--NetworkModule
- public class NetworkModule
- extends java.lang.Object
|
Method Summary |
java.lang.String |
ConnectToJXTA(java.lang.String pipeadvert,
java.lang.String pipename)
|
java.util.Vector |
DeconstructMessage(net.jxta.endpoint.Message m)
|
void |
DeleteAdverts(java.lang.String NodeAdvert)
|
java.lang.String |
FindService(java.lang.String ServiceName)
|
java.lang.String |
GetNodeAdvertisement()
|
java.lang.String |
GetNodePipeAd()
|
java.lang.String |
GetUniqueID()
|
java.lang.String |
LoadAdvert(java.io.InputStream is)
|
net.jxta.endpoint.Message |
ReconstructMessage(java.util.Vector v)
|
boolean |
SendMessage(net.jxta.endpoint.Message mess,
java.lang.String targetpipe)
|
void |
SetTimeout(int timeout,
int attempts)
. |
void |
SetupService(java.lang.String servicename,
java.lang.String servicedescription,
java.lang.String serviceversion,
java.lang.String servicecreator,
java.lang.String serviceurl)
|
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
NetworkModule
public NetworkModule(MessageInterface parent)
The constructor for the NetworkModule takes an object that implements MessageInterface as a parameter. This is used to communicate messages back up to the application.
ConnectToJXTA
public java.lang.String ConnectToJXTA(java.lang.String pipeadvert,
java.lang.String pipename)
- The ConnectToJXTA method initialises the node on the JXTA network. It also
sets up the input pipe for the node and attaches a listener to it.
This method also advertises this nodes pipe to the rest of the JXTA network.
If a pipeadvert is provided then this advert will be used and propogated.
If no pipeadvert is provided then the method will generate one automatically
and use this. In this case it is possible to specify the pipename that
is to be used within the advert.
In both cases the pipeadvert will be returned by the method.
EXAMPLES
1) Calling ConnectToJXTA and using an existing pipe advert
- ConnectToJXTA(MyPipeAd, "");
2) Calling ConnectToJXTA and having a pipe advert created for you. The name
of the pipe is MyPipe
- ConnectToJXTA("", "MyPipe");
In both cases the pipe advert used is returned back to the caller (Allowing
the caller to reuse the pipe advert at a later date).
-
SetTimeout
public void SetTimeout(int timeout,
int attempts)
- Method to set the network timeout for the network module.
timeout presents the timeout time in milliseconds.
attempts represents the number of attempts the network module will make
to successfully make a communication
This method does not have to be used, and by default timeout is set to
3000 and attempts to 10
FindService
public java.lang.String FindService(java.lang.String ServiceName)
- The FindService method searches the JXTA network for a service of the name
ServiceName.
When the service is found, its adverts are returned to the caller.
SendMessage
public boolean SendMessage(net.jxta.endpoint.Message mess,
java.lang.String targetpipe)
- The SendMessage method takes a Message object as a parameter and
sends this object to the pipe specified within the TargetPipeAdvert.
A success report is returned by the method.
GetUniqueID
public java.lang.String GetUniqueID()
- The GetUniqueID method returns the JXTA ID of the node as a String
GetNodeAdvertisement
public java.lang.String GetNodeAdvertisement()
- The GetNodeAdvertisment method returns the JXTA advertisement of the node
as a String. This is the node advertisement rather than the pipe advertisement.
GetNodePipeAd
public java.lang.String GetNodePipeAd()
- The GetNodePipeAd method returns the JXTA pipe advertisement of the node
as a String.
LoadAdvert
public java.lang.String LoadAdvert(java.io.InputStream is)
- The LoadAdvert method is used to load pipe adverts from a given input stream.
This can be used for loading a pipe advert that may be stored as a file or
at a URL location. The pipe advert is returned as a String.
SetupService
public void SetupService(java.lang.String servicename,
java.lang.String servicedescription,
java.lang.String serviceversion,
java.lang.String servicecreator,
java.lang.String serviceurl)
- The SetupService method is used for setuping a service for the node. The
method creates the adverts necessary for the service and progates around the
network. In order to create the advert, the method takes the following parameters.
- ServiceName - the name that it is desired for the service to
possess
ServiceDescription - a brief description of the service
ServiceVersion - the current version of the service
ServiceCreator - who has created this service
ServiceURL - a URL to the services/creators website
DeleteAdverts
public void DeleteAdverts(java.lang.String NodeAdvert)
- The DeleteAdverts method is used to delete a particular advert from the
peers cache.
It takes an advert in a string format (NodeAdvert) and can be used to
delete PEER, GROUP and standard ADVERTISEMENTS from the cache
DeconstructMessage
public java.util.Vector DeconstructMessage(net.jxta.endpoint.Message m)
- This method is used for deconstructiong a JXTA Message object. This may be
necessary if you want to store all the elements of the Message object, as
currently Message objects are not serialisable.
The method creates a vector and stores within it the message elements as
Strings. These are stored as a sequence of element names and element values.
For example,
A Message object may contain the message elements:
TO: James
FROM: John
MESSAGE: Hi, there
The DeconstructMessage would create a vector containing the String elements:
"TO", "James", "FROM", "John",
"MESSAGE", "Hi, there"
ReconstructMessage
public net.jxta.endpoint.Message ReconstructMessage(java.util.Vector v)
- This method is used for reconstructing a JXTA Message object from one that
is represented as Strings within a vector.
The method will read in each String element from the vector in the order
Message Element Name, Message Element Value, Message Element Name, etc
A Message Object is constructed and this is returned by the method.