Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaEE chat application

Tamas Gergely
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I am not sure if this is the right place to ask this, but maybe.
I have experience with c++ and java in general, but not with EE.
I would like to create a web based game, as a first draft it would be a chat apllication.

If this would be server-client aplication (not web based) written in java or c++, I would do the following.
i) have a main() function, and a separate ServerMain class. In the main function I would listen on a socket, accept connections, instantiate from ClientHandler for every new connection (ClientHandler is a thread), pass a reference of ClientHandler to ServerMain.
ii) When client sends a message, ClientHandler reads it, and pushes it to ServerMain. ServerMain decides what to do with (ServerMain and other classes used by it has the server logic), so it can drop the message, send to the output queue of the other ClientHandlers, etc.
Actually I don't really know how to do a same thing in JavaEE. First I created a class for the entry point (a REST interface). This class injects EJB to send it the messages. But I don't know where to put the main logic of the server. I "miss" the ServerMain class from the above example. This class should be created before any client can connect, however web applications seems to be client driven. Also this ServerMain should survive all the clients. Maybe it should be a singleton EJB, and the communication with other EJBs shoulb be done with JMS?
So as you see, I don't know how to start it, what is the best or most common way of doing it in JavaEE?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic