3 Replies Latest reply on Mar 7, 2005 12:39 AM by jignesh rangwala

    MVC and a multiple client applictation

    Zephyr Mays Newbie


      I am trying to apply the MVC pattern to an application in which:

      1. Multiple clients (<10) simultaneously connect over the internet to the same server. Clients are typical internet users with a standard web browser.

      2. The server processes requests from any one client, and then updates the view of all clients

      First, is the MVC the best design pattern for this type of application?

      What I've come up with so far is:

      1. The View: a java applet or Java Web Start deployed application. I would like to use the jws option but I'm not sure if the majority of internet users have browsers that support the technology.

      2. The Controller: by definition should manage how the view interacts with the model. This is where my biggest questions are and I'm not sure what technology to leverage. Options I've considered so far are:

      Servlets: this would make sense except firstly, I'm under the impression that servlets are not persistant in that one does not know for sure if they will still be there after a period of inactivity, and secondly I don't know if one servlet can server multiple clients at the same time easily, and lastly if a servlet can initiate communication with a client.

      EJB as controller: I'm not sure EJB's can communicate directly with an applet or application cleint, and I understand this option could be problematic because EJB's use RMI-IIOP to communicate with clients, and RMI-IIOP doesn't react well to firewalls and thus could exclude a good portion of internet users.

      Other: write a custom java class to be the controller?

      3. The model: EJB session bean seems to make the most sense. The clients all connect to the controller which connects one on one to the model for a period of time.

      My questions are:

      1. How should I implement the controller?

      2. Given a controller, how should it communicate with clients? I would like to use plain RMI for client-controller comms, but that depends on the type of controller used.

      3. Are EJB session beans a good choice for the model?

      Thanks in advance for any advise,


        • 1. Re: MVC and a multiple client applictation
          jignesh rangwala Newbie

          lets discuss MVC first.
          There are several Implementation for MVC frame work such as famous Struts and Barcuda. You can also define your own implementation for MVC pattern.

          Now to answer your question, let me tell you one thing, Enterprise JavaBeans are serverside components. Especially Session beans are mainly used to PROCESS BUSINESS LOGIC. Using Session Bean a controller will be not that much productive or usefull, because its better to use them as model where business logic are performed, instead of asking to perform as controller or diverting the request from client to model and back from model to client.

          Servlets are ideally suited to act as a controller. All the big implementation like struts uses servlets as controller - because they can handle multiple client same time and yes you have more facility like using session, listeners etc to do a proper controlling work.

          • 2. Re: MVC and a multiple client applictation
            Zephyr Mays Newbie

            Thanks for the information; it was very helpful.

            I've decided to use a java web start application as the view, and session beans as the model, but the best solution for the controller remains unclear.

            With multiple simultanious client connections who's view must be updated anytime one of them performs an action, plain rmi for communication between the view and the controller seems to be the best choice.

            Does JBoss support rmi?

            If not, can one support the above controller-view requirement with servlets?


            • 3. Re: MVC and a multiple client applictation
              jignesh rangwala Newbie

              Well u can write your own controller. Create ur own controller class that can understand what to do. Define a specific protocol between Server Controller object and client listener object.

              Or use the servlet as a controller but in this case u need to pass the information back and forth using http response and request objects.