Aleksandar Lazic wrote:
If so, as soon as the messageReceived() method can have access to this
connection, then you are all set.

Hm I thought to use the session object but I can use a singelton object
from the 'xml-class', maybe this is the better way ;-)
Storing the reference into the session is ok. Otherwise, you don't have to use a singleton, it's enough to initialize your handler correctly, by passing a reference to the application. Remember that the application will create the network layer (containing the server and the handler), and it can initialize this part as you want. Your code can be like that :

init application
init backend connection (with pooling if needed) -> Connection instance is created
init server ( Connection Instance )

you store the connection instance as a field in your handler :

class MyHandler extends IoHandlerAdapter {
 private MyConnectionToBackend cnx;

 public MyHandler( MyConnectionToBackend cnx ) {
   this.cnx = cnx;
 }

 messageReceived( blah ) {
   ...
   cnx.send( blah );
 }
}

You are done.

--
--
cordialement, regards,
Emmanuel Lécharny
www.iktek.com
directory.apache.org


Reply via email to