users@glassfish.java.net

Re: How to create a SocketServer?

From: Steven Siebert <smsiebe_at_gmail.com>
Date: Tue, 8 Jun 2010 07:25:41 -0400

I agree it's probably blocking the thread. Try adding bean thread
management to your SLSB:

@ConcurrencyManagement(ConcurrencyManagementType.BEAN) //added to your
class annotations

Once you do this, you'll be free to spawn new threads within that SLSB that
won't block the GF main thread.

Cheers,

S

On Sun, Jun 6, 2010 at 8:15 AM, <glassfish_at_javadesktop.org> wrote:

> I need to create a socket server to listen to port messages from inside of
> Glassfish.
> If I write something simple like the code below, it freezes Glassfish
> during the deployment of the app.
> What is the safe way to implement this functionality?
>
> @Singleton
> @Startup
> public class MySocketServer {
> ServerSocket serverSocket = null;
> @PostConstruct
> private void init() {
> try {
> serverSocket = new ServerSocket(SOCKET_PORT);
> } catch (IOException ex) {
> System.err.println(ex.getMessage());
> }
> //...
> }
> }
> [Message sent by forum member 'denisz']
>
> http://forums.java.net/jive/thread.jspa?messageID=472989
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>