views:

238

answers:

3

I need to have a business logic running inside Glassfish 2.1 Appserver, which listens for inbound TCP connections and serves them. I feel that this kind of task is not really fit inside the appserver - maybe I should publish web service interfaces, etc, but I can't, at least not directly for the client.

The client will connect to my app via TCP, and will exchange plain-text commands and responses.

Do I need an external mediator program which translates the client TCP to rmi calls? Or does J2EE have native support for listening on sockets and doing direct I/O on them?

Thank you!

+1  A: 

JavaEE has no explicit support for raw socket communication, but in principle there's nothing to stop you using java.net.Socket directly. Glassfish may potentially block this, if the security manager is configured to restrict socket access, but that shouldn't be the case unless it's been explicitly configured that way.

skaffman
+2  A: 

JCA 1.5 is the standard solution for this kind of tasks, but it's not the easiest part of JEE, and you won't find tons of examples to get you started. You could have a look at lifecycle modules if you don't mind a Glassfish specific solution, and JAFS, an ftp server that can be embedded in the 'fish probably contains a lot of inspiration to get you started.

fvu
Thank you, the lifecycle module seems fine for now, and maybe will try JCA later.
ron
A: 

You could also consider using BPEL - the openesb solution has bpel modules for listening via sockets.

Michael Wiles