• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

listen to events from a servlet in an embedded tomcat

 
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
here is my situation:
- i have a desktop application in which i use a ListenerHelper class to handle events.
-my desktop app uses embedded tomcat server and runs a servlet in that embedded container.
-i want my servlet to notify my desktop client once it executes the doGet() method.

what design pattern to use in such a situation? and how to structure my listener and event handling cleanly to address communication between client and embedded servlet?

thanks
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well you have two applications. The desktop application and the web application. You can have them communicate by sending messages to each other using a message server or you can create one or more web services and have them communicate with the web services.

Keep in mind that Java servlets are designed for Presentation elements. They shouldn't be coded to send external messages outside of the web container. This should be implemented in a business object.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jimmy Clark wrote:Well you have two applications. The desktop application and the web application. You can have them communicate by sending messages to each other using a message server or you can create one or more web services and have them communicate with the web services.

Keep in mind that Java servlets are designed for Presentation elements. They shouldn't be coded to send external messages outside of the web container. This should be implemented in a business object.



i did some research & found that using an http://www.eventbus.org/ would be a good solution. what you think of the eventBus design pattern?
I don't want to augment my application complexity with extra webservices or server messages. the embeded web app will be used for a small task in whole application and want it to stay as simple as possible.

can you talle if i have my servlet publish eventbus event would be a clean solution?
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think anything about the "eventBus" design pattern. I never heard of it and am not interested in it.

I don't want to augment my application complexity with extra webservices or server messages. the embeded web app will be used for a small task in whole application and want it to stay as simple as possible.



It is unclear why you want to have a small web application anyway, since it will only be used for a small task. A better design would be to move the functionality of the web application into the desktop application. Your current design sounds confusing and overly complicated.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my application needs to authenticate user with Google oauth. this can only be done on the web.
 
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yahya Elyasse wrote:-i want my servlet to notify my desktop client once it executes the doGet() method.



But that's just the plain old HTTP request and response process. Your desktop client would send an HTTP request to that servlet and wait for it to send a response. Which it would do naturally as part of the doGet() method. I don't see any need to drag in anything more than that.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Yahya Elyasse wrote:-i want my servlet to notify my desktop client once it executes the doGet() method.



But that's just the plain old HTTP request and response process. Your desktop client would send an HTTP request to that servlet and wait for it to send a response. Which it would do naturally as part of the doGet() method. I don't see any need to drag in anything more than that.


the issue is when to send servlet http request from client? before invoking my embedded web browser? . b/c the oauth process is done in many steps and it calls many servlets untill last callback servlet.
so if i send a http request to my callback servlet . it will wait untill my callback servlet is done and then return to client? i though http client request returns immediately. so if i call my callback servlet before oauth process is done it will returns nothing ! and i can't know exactly when the callback servlet will be called by Google service.
i hope i explained well the issue. it is about doing oauth process in an embeded server and try notifying client when process is done.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

my application needs to authenticate user with Google oauth. this can only be done on the web.



The desktop application can send a HTTP request and can receive the response directly. There is no need to create a separate web application simply to send a single HTTP request.

The application can wait for a response in the background and continue processing. Or, it can wait in the foreground and not do anything until it recieves the response.

And maybe if there are more requirements for Internet activity, then it seems like it should not be a desktop application but a 100% web application.
 
Paul Clapham
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jimmy Clark wrote:

my application needs to authenticate user with Google oauth. this can only be done on the web.



The desktop application can send a HTTP request and can receive the response directly. There is no need to create a separate web application simply to send a single HTTP request.



I was going to say exactly that. But then I did some googling and I found Using OAuth with the Google Data APIs, which said this:

Google wrote:Note: Though the OAuth protocol supports the desktop/installed application use case, Google only supports OAuth for web applications.



So I didn't say that.

However this note really means "Sure, you can try using OAuth from your desktop app, but you're on your own, buddy. Don't ask us for help." So if I were a beginner I would take it seriously; although what we see is that a beginner can't work around this restriction anyway.
 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jimmy Clark wrote:

my application needs to authenticate user with Google oauth. this can only be done on the web.



The desktop application can send a HTTP request and can receive the response directly. There is no need to create a separate web application simply to send a single HTTP request.

The application can wait for a response in the background and continue processing. Or, it can wait in the foreground and not do anything until it recieves the response.

And maybe if there are more requirements for Internet activity, then it seems like it should not be a desktop application but a 100% web application.


it seems you have no Idea about oauth. user should interactively grant access to Google scopes . can we do Grant feature using HTTP requests?!!

maybe before giving your opinion try reading about how google oauth works:
http://code.google.com/apis/accounts/docs/OAuth.html
http://code.google.com/apis/accounts/docs/OAuthForInstalledApps.html

 
Yahya Elyasse
Ranch Hand
Posts: 510
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Clapham wrote:

Jimmy Clark wrote:

my application needs to authenticate user with Google oauth. this can only be done on the web.



The desktop application can send a HTTP request and can receive the response directly. There is no need to create a separate web application simply to send a single HTTP request.



I was going to say exactly that. But then I did some googling and I found Using OAuth with the Google Data APIs, which said this:

Google wrote:Note: Though the OAuth protocol supports the desktop/installed application use case, Google only supports OAuth for web applications.



So I didn't say that.

However this note really means "Sure, you can try using OAuth from your desktop app, but you're on your own, buddy. Don't ask us for help." So if I were a beginner I would take it seriously; although what we see is that a beginner can't work around this restriction anyway.


beginner?!! you and your other mate are insulting me al through this thread and i don't know why?

I don't need help from such people who are disrespectful and more over don't know what they are talking about. your opinions are misleading and reveal your ignorance regarding google oauth.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Note: Though the OAuth protocol supports the desktop/installed application use case, Google only supports OAuth for web applications.





Interesting. I wonder how the Google application (OAuth) can distinguish between a HTTP Request sent from a "web application on a web server" and a HTTP Request sent from a desktop application.
 
Paul Clapham
Sheriff
Posts: 28411
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Yahya Elyasse wrote:beginner?!! you and your other mate are insulting me al through this thread and i don't know why?

I don't need help from such people who are disrespectful and more over don't know what they are talking about. your opinions are misleading and reveal your ignorance regarding google oauth.



I meant no disrespect when I referred to you as a "beginner". Your question about servlets seemed to indicate that you were a beginner in servlets, as far as I could see. So if you considered that as an insult, then I apologize. For myself, of course. Jimmy Clark isn't my "mate" in any way but I don't see anything to complain about in his posts.

As for my ignorance regarding OAuth, there's no question about that. Everything I know about it is what I googled this afternoon.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic