users@glassfish.java.net

Re: How to invoke Client Callback Handler from EJB3 Session Bean

From: Miroslav Nachev <miro_at_space-comm.com>
Date: Sat, 17 May 2008 15:51:36 +0300

Hi,

I don't know who is decided to restrict Java EE technology to have only
one direction connection (from Client to the Server like old Web/HTML)
but this is extremely stupidity. Before AJAX this was one big benefit
comparing with HTML technology and that benefit is removed by specification.

Can somebody help me how can design and develop custom client-side
callback mechanism for JNLP/Swing Clients? It is good to have similar
mechanism for Web AJAX/HTML Clients also.
At the moment in GlassFish there is login client-side callback mechanism
but I can not understand how works. I know that the used technology for
that is RMI-IIOP but I can not find in the source files for Server and
Client side where are the starting points which I can use as examples.
My need is just how from the server side to invoke client method. What
to do on the server side and how to listen on the client side for such
event.
Can you provide me any help?

When I am ready I would like to commit the code in GlassFish community
to be usable for all and to exists into the next GF releases. This will
be a big benefit comparing with the other Application Servers.


Regards,
Miro.

glassfish_at_javadesktop.org wrote:
> In traditional Java EE applications the client side initiates the actions and passes arguments to the server. What comes back is a return value as with any normal Java method invocation. Servers do not call clients.
>
> Because the server side does not call the client side but merely returns to it, there is (again, in the traditional model) no idea of "passing arguments" from the server to the client.
>
> I'll try to "draw" the difference between your original idea and my suggestion. I'm sure the spacing will look bad but I think you will get the idea
>
> Your idea:
>
> Client EJB
> --- call methodM ------- >
>
> <---- nested callback ------
>
> [app client displays a dialog to get the additional info from the user]
>
> --- return from nested callback -->
>
> <--- return from first call --
>
>
> In your idea, the "nested callback" would pass arguments that tell what added info to get from the user and the "return from nested callback" would return a single object as its return value that contains the added information the user supplied.
>
> As I mentioned earlier the "nested callback" and "return from nested callback" are basically not a supported model in Java EE; servers cannot call clients.
>
> Even in the approach you described, there are two parts to the EJB method: the part that runs before the (unsupported) nested call back to the client, and the part that runs after.
>
> My suggestion is to do divide the EJB methodM into two separate methods, methodA and methodB.
>
> Client EJB
> --- call methodA ----------------------->
>
> <--- return
>
> [ client displays a dialog to collect the new required information from the user ]
>
> ---- call methodB ----------------------->
>
> <--- return ----------------------------------
>
> In this approach the EJB's methodA returns a value is an object that indicates what further information is needed from the user. The app client uses that to display a dialog, collecting the required information. Then the app client invokes methodB on the EJB, passing the new information it just collected from the user.
>
> I know this is not the approach you first had in mind, but I think it will meet your needs while also fitting the Java EE model in which the client calls the server and not the other way around.
> [Message sent by forum member 'tjquinn' (tjquinn)]
>
> http://forums.java.net/jive/thread.jspa?messageID=273419
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>
>
>