7 Replies Latest reply on Aug 22, 2013 7:29 AM by edewit

    HELP : Errai CDI Decoupled for Mobile Clients

    chaluwa

      I need guidance on how to approach a design issue for my app. Its a GWT mobile app (Touch4j), and is supposed to have a chat tool that will allow 2 or more mobile users to communicate.

       

      The issue / question is, how can the mobile app be decoupled from the CDI-powered chat relay server, such that the relay server-app can be deployed online (say openshift) and will recieve / broadcast messages coming from the mobile client which will run entirely on the mobile device.

       

      Since the mobile app is a HTML5-based app (Touch4j), and limited with browser's same origin policy, I don't know if we may have to rely on REST-based CDI (JAX-RS).

       

      What I think we need (please advice and correct)

      1. GWT project for chat relay service. define jax-rs interfaces in shared package and implement them in server package to push meaages with CDI Events

      2  Use the classes from shared package above with Errai's Caller<T> factory to post chat messages and then consume responses with @Obseves methods

       

      Can someone do a CDI Events sample with javx-rs ?

        • 1. Re: HELP : Errai CDI Decoupled for Mobile Clients
          edewit

          Hi Charles,

           

          So why is your app decouled from the "CDI-powered chat relay server" are you not planning on using Touch4j together with Errai for the client? Because if you would use Errai on the client and the server it would be a lot easier to develop a chat client. You can use a broadcast event so that all connected clients are informed who is there. I also don't see why the "same origin policy" would be a problem in this case as the clients will only talk to the server and the server will relay the message. Hope that helps.

           

          Cheers,

               Erik Jan

          • 2. Re: HELP : Errai CDI Decoupled for Mobile Clients
            chaluwa

            Thanks for this prompt response. I am grateful.

            Maybe am confused over nothing, but my point is simple. An Errai app (like every other GWT app) has a server-side (chat-relay in my case) and a client-side (Touch4j  UI). When his app (a singlle war file) gets deployed to the server (opnenshift in our case), we'll have he relay-service ready for use, but how can the mobile app (Touch4j client part of the same single app that got deployed) be dowloaded and insalled on mobile devices.

             

            My thinking is to have them as separate GWT / Errai projects. Maybe a core (defines jax-rs interfaces in shared package), a server-side that will be deployed to OpenShift (recieves CDI messages from clients and broadcastst to oher clients via REST URLs if possible), and then the mobile client (uses classes from shared package of core to post messages via REST too) which can then be packaged and deployed to App stores (Google Play e.t.c)

             

            If this is correct, the question posed now is if CDI can enable this sort of cross-app messaging via RESTful endpoints, and how it can be done. I am looking at the Errai sample here : https://github.com/errai/errai-tutorial/archive/master.zip it appears its possible. Please advice.

             

            Thanks again.

            • 3. Re: HELP : Errai CDI Decoupled for Mobile Clients
              edewit

              Hi Charles,

               

              Right, so you don't need 2 seperate projects per se. GWT projects on the client are just javascript and html, when you want them as an downloadable / installable application you can use cordova this is a native application that wraps a brower window. To be able to use that with Errai we have a maven plugin that you can install and then maven will create an installable app of your war project. You will have to supply it with an url of the server so that the client can connect. But then you can use events, jpa sync and the bus like any other Errai project.

               

              Hope this answers your question,

               

                   Erik Jan

              • 4. Re: HELP : Errai CDI Decoupled for Mobile Clients
                chaluwa

                Yes, that's right. I just created a project with the Errai-Cordova archetype from http://goo.gl/xZrfB6, but importing it into eclipse has not been successfull. I am getting error markers on the first two lines of the pom.xm file.

                • 5. Re: HELP : Errai CDI Decoupled for Mobile Clients
                  edewit

                  Hi Charles,

                   

                  The errai-tutorial that you had before is also already setup for mobile. I think that that is a much nicer starting point.

                   

                  Cheers,

                       Erik Jan

                  • 6. Re: HELP : Errai CDI Decoupled for Mobile Clients
                    chaluwa

                    Thanks, that was very helpful. But I am having trouble with it already. The error paste is here : http://ur1.ca/f5wmx

                    • 7. Re: HELP : Errai CDI Decoupled for Mobile Clients
                      edewit

                      Hi Charles,

                       

                      If you add the jsr305 to your pom?

                       

                          <dependency>

                            <groupId>com.google.code.findbugs</groupId>

                            <artifactId>jsr305</artifactId>

                            <version>1.3.9</version>

                          </dependency>