My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package org.jogre.common;

import java.util.ConcurrentModificationException;

import nanoxml.XMLElement;

import org.jogre.common.comm.ITransmittable;

/**
* Represents client/server communication over an arbitrary low-level protocol,
* such as sockets or http
*/
public interface MessageBus {

/**
* Represents logic that knows how to deal with incoming messages.
*/
public static interface MessageParser {

/**
* Handles an incoming snippet of XML data
*
* @param message Communication as an XML object.
* @throws TransmissionException This is thrown if there is a problem parsing the String.
*/
public abstract void parse (XMLElement message) throws TransmissionException;

/**
* This method is called to properly clean up after a client.
*/
public abstract void cleanup ();

}

/**
* Send a ITransmittable object to the outgoing channel of this
* communication. Depending on the concrete implementation, this can
* be synchronous or asynchronous.
*
* @param transObject the object that should be sent out.
*/
public abstract void send(ITransmittable transObject);

/**
* Signals that the communication via this channel is over.
* Initiates any cleanup that might be necessary. Once this has happened,
* the object becomes unusable -- it is undefined how calls to it would
* behave!
*/
public abstract void close();

/**
* Connects the message bus with a MessageParser and initiates communication.
* If the MessageBus implementation requires to start any internal
* threading, this is where that action is kicked off.
* @exception ConcurrentModificationException if the method is called more than once
*/
public abstract void open(final MessageParser parser);

}
Show details Hide details

Change log

r15 by schefflerjens on May 20, 2009   Diff
Refactoring: extract interface from
AbstractConnectionThread
(MessageBus.MessageParser).

Go to: 
Project members, sign in to write a code review

Older revisions

r13 by schefflerjens on May 20, 2009   Diff
refactoring: extract interface
"MessageBus"
All revisions of this file

File info

Size: 1809 bytes, 60 lines
Hosted by Google Code