|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectpeer2me.framework.Framework
public class Framework
Applications using the Peer2Me framework will interact mostly with this class. After this class is instanciated, it creates an instance of Session, initializes the Log, sets the Frame- workSubscriber and the FileHandler. This class will provide methods for most operations within the framework, beeing the link between the application and the Peer2Me framework.
Method Summary | |
---|---|
void |
clean()
Cleans up resources used by the framework. |
Group |
createGroup(java.lang.String name)
This method creates a new Group and adds it to
the groupcollection session. |
Group |
createGroup(java.lang.String name,
Node[] nodes)
This method creates a Group and adds it to
the session. |
Node[] |
getAllNodes()
Gets all the discovered nodes Calling on the corresponding method in Session . |
Node[] |
getAllNodes(Group group)
Gets alle the nodes in the given group. |
FileHandler |
getFileHandler()
Gets a reference of FileHandler |
Group |
getGroup(java.lang.String name)
Gets a Group with the corresponding name. |
Group |
getGroupAt(int index)
Gets the Group at the given index in the collection of
groups in session. |
Group[] |
getGroups()
Gets all the groups. |
static Framework |
getInstance(java.lang.String groupName,
java.lang.String serviceName,
Network network,
boolean activatePing,
FrameworkSubscriber frameworkSubscriber)
This method will create a new or get an existing instance of Framework. |
Node |
getLocalNode()
Returns the local node |
Log |
getLog()
Gets a reference to Log |
Node |
getNode(int index,
Group group)
Gets the Node at the given index
in the given Group . |
Node |
getNode(java.lang.String address)
Gets a Node based on an address
Calling on the corresponding method in
Session . |
Session |
getSession()
Gets a reference to Session |
void |
initialize()
This method initializes the framework, calling on initialize() in Session |
void |
messagePartReceived(java.lang.String messageID,
int part,
int total)
This method is called whenever new MessagePart is received. |
void |
messageReceived(Message message)
This method is called whenever a new Message is received. |
void |
moveNode(Node node,
Group from,
Group to)
Moves a Node from one Group
to another. |
void |
nodeFound(Node node)
This method is called whenever a new Node is discovered. |
void |
nodeLost(Node node)
This method is called whenever a new Node is lost or abscent. |
void |
removeGroup(int index)
Removes the Group at the given index. |
void |
removeGroup(java.lang.String name)
Removes the Group with the given name. |
void |
removeNode(int index,
Group group)
Removes a Node with the given index from a Group . |
void |
removeNode(Node node,
Group group)
Removes a Node from a Group . |
void |
search()
This methods starts a search for devices and services. |
void |
searchCompleted()
This method is called whenever a search for devices and services is finished. |
void |
sendMessage(Message message)
Passes on a Message to Session . |
void |
setFileHandler(FileHandler fileHandler)
Sets a reference of FileHandler |
void |
setframeworkSubscriber(FrameworkSubscriber frameworkSubscriber)
Sets the frameworksubscriber |
void |
setReceivedFilesFolder(java.lang.String path)
Sets the path of the default folder in which received files are stored. |
java.lang.String |
whoAmI()
A simple method which returns a friendly String with
the name and address of the local node. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static Framework getInstance(java.lang.String groupName, java.lang.String serviceName, Network network, boolean activatePing, FrameworkSubscriber frameworkSubscriber)
FrameworkSubscriber
groupName
- the name of the default groupserviceName
- the name of the service: serviceIDnetwork
- the network to be usedactivatePing
- sets if ping-functionality should be usedframeworkSubscriber
- the frameworksubscriber
public void clean()
public Session getSession()
Session
public Log getLog()
Log
public void initialize()
initialize()
in Session
public void search() throws FrameworkNotInitializedException
search()
in
Session
FrameworkNotInitializedException
public Group[] getGroups()
Session
public Group getGroupAt(int index) throws GroupNotFoundException
Group
at the given index in the collection of
groups in session. Throws an exception if the group is not found.
Calling on the corresponding method in
Session
.
index
- the index of the group
GroupNotFoundException
public Group getGroup(java.lang.String name) throws GroupNotFoundException
Group
with the corresponding name. Throws an exception if
the group is not found.
Calling on the corresponding method in
Session
.
name
- the name of the group
GroupNotFoundException
public Group createGroup(java.lang.String name)
Group
and adds it to
the groupcollection session.
Calling on the corresponding method in
Session
.
name
- name of the group
public Group createGroup(java.lang.String name, Node[] nodes)
Group
and adds it to
the session. Adds also an array of nodes directly.
Calling on the corresponding method in
Session
.
name
- the name of the groupnodes
- the nodes added upon creation of the group
public void removeGroup(int index) throws GroupNotFoundException
Group
at the given index. Will also
remove the nodes in the group if not empty. Throws an exception if the group
is not found.
Calling on the corresponding method in
Session
.
index
- the index of the group
GroupNotFoundException
public void removeGroup(java.lang.String name) throws GroupNotFoundException
Group
with the given name. Will also
remove the nodes in the group if not empty. Throws an exception if the group
is not found.
Calling on the corresponding method in
Session
.
name
- the name of the group
GroupNotFoundException
public Node[] getAllNodes()
Session
.
public Node[] getAllNodes(Group group)
Session
.
group
- the group of the nodes
public Node getNode(java.lang.String address) throws NodeNotFoundException
Node
based on an address
Calling on the corresponding method in
Session
.
address
- the address of the node
NodeNotFoundException
public Node getNode(int index, Group group) throws NodeNotFoundException
Node
at the given index
in the given Group
. Throws an exception if
the node is not found.
Calling on the corresponding method in
Session
.
index
- the index of the nodegroup
- the group of the node
NodeNotFoundException
public void moveNode(Node node, Group from, Group to) throws NodeNotFoundException
Node
from one Group
to another. Will also send a notification to all other nodes about the
movement.
Calling on the corresponding method in
Session
.
node
- the node to movefrom
- the group the node lies into
- the new group of the node
NodeNotFoundException
public void removeNode(int index, Group group) throws NodeNotFoundException
Node
with the given index
from a Group
.
Throws an exception if the node is not found.
Calling on the corresponding method in
Session
.
index
- the index of the nodegroup
- the group of node
NodeNotFoundException
public void removeNode(Node node, Group group)
Node
from a Group
.
Calling on the corresponding method in
Session
.
node
- the node to removegroup
- the group of the nodepublic void setframeworkSubscriber(FrameworkSubscriber frameworkSubscriber)
frameworkSubscriber
- a reference to the frameworksubscriberpublic void nodeFound(Node node)
Node
is discovered.
Uses FrameworkSubscriber
to communicate with the MIDlet.
node
- the node that is foundpublic void nodeLost(Node node)
Node
is lost or abscent.
Uses FrameworkSubscriber
to communicate with the MIDlet.
node
- the node that is lost or abscentpublic void searchCompleted()
FrameworkSubscriber
to communicate with the MIDlet.
public void messageReceived(Message message)
Message
is received.
Uses FrameworkSubscriber
to communicate with the MIDlet.
public void messagePartReceived(java.lang.String messageID, int part, int total)
MessagePart
is received.
This method is useful when creating progressbars etc.
Uses FrameworkSubscriber
to communicate with the MIDlet.
part
- the part received of a totaltotal
- the total number of parts to receivepublic void sendMessage(Message message)
Message
to Session
. Used when sending messages.
Calling on the corresponding method in
Session
.
message
- the message to be sent.public FileHandler getFileHandler()
FileHandler
public void setFileHandler(FileHandler fileHandler)
FileHandler
fileHandler
- the reference of filehandlerpublic void setReceivedFilesFolder(java.lang.String path)
FileHandler
path
- the absolute path of the folderpublic java.lang.String whoAmI()
String
with
the name and address of the local node.
public Node getLocalNode()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |