wood burning stoves 2.0*
The moose likes EJB and other Java EE Technologies and the fly likes message-driven bean to wrap legacy applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "message-driven bean to wrap legacy applications" Watch "message-driven bean to wrap legacy applications" New topic
Author

message-driven bean to wrap legacy applications

Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
Hi,
Please help me to use message-driven bean to wrap a web application (wriiten with CGI). I know how to implement call side message-driven beans. But I do not know how to wrap the legacy application.
Using message-driven beans is supposed to make the integration effort easy.
Please help me on how to connect the message-driven bean to the legacy system. I do not know the implementation on this side.
Thanks
Ruilin
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
No, Ruilin, MDB's are NOT supposed to make this kind of thing easy. The assumption is that you have an underlying Message Oriented Middleware (MOM) that the legacy application is already enabled for. You don't. Therefore MDB's won't do squat for you. If the program was already enabled to communicate with a MOM (like MQSeries) then it would be easy.
If this thing is a CGI it sounds like you're going to have to do the old "screen-scraping" thing -- establish a URLConnection to the CGI and parse what comes back. Now my recommendation is that you not do this in an EJB -- the EJB spec won't help you here...
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
Kyle,
Thanks a lots.
The book "Developing Enterprise Java Applications with J2EE and UML" states: Message-driven beans can also be used to wrap legacy applications to make the integration effort easier. But the book did not elaborated more. I guess the book assumes a MOM in place.
How easy is to implement a MOM - MQSeries and enable the legacy Web App ?
Thanks again
Ruilin
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Geez. I hate high-level books like that that go off and make unqualified statements...
It's often a big, hairy deal to add a messaging infrastructure to an applciation that wasn't built around one. What you're talking about is a web app -- it was probably built only to handle a web-based UI. Therefore, the screen-scraping approach is probably your only option.
But, I'd need to know more about what you're trying to do to assess the effort involved. So, what technology was the old app built in (what language), what database does it use, etc... All of these questions bear on the question as to how hard it would be to add a MOM into the mix.
Kyle
Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
Kyle,
My legacy system was developed using Perl, HTML, CGI and an Oracle database. I do not want to rewrite it and just want to connect it from my Java application client.
How much to buy a MOM ? How much work required to implement ?
Thanks
Ruilin
Laojar Chuger
Ranch Hand

Joined: Dec 20, 2000
Posts: 111
One thing is not clear here. Can EJB call jni?
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Ruilin,
You can't just wrap it. You either rewrite it to support a MOM and then you can use JMS, or your use the screen-scraping approach I described earlier. It looks to me like you're going to have to do screen scraping. Since it's PERL then I strongly doubt that you can even get a MOM to work with it.
Laojar,
In general, no, EJB's can't call JNI. But why do you care?
Kyle
[ February 13, 2002: Message edited by: Kyle Brown ]
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
By the way, an alternative to using JMS and a MOM that might work better would be web services -- it still requires a rewrite of your Perl application, but I know that SOAP libraries for Perl exist...
Kyle
Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
Kyle,
Thanks for the inf.
I will use appletContext.showDocument(URL+Data) to
get to view information and to do some transaction even.
Or I may use URL, URLConnection object to view and do some transaction.
With the above methods, I will not be able to navigate the legacy Web-app.
Please elaborate.
Thanks again for further comments
Ruilin
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
Ruilin,
You can't use appletContext in a Java application -- it's only available in an applet.
The URLConnection way of doing things is the only way you can do it. You navigate simply by sending GET or POST requests to the application. Do a JavaRanch search for "Applet connecting to Servlet" (EVEN THOUGH YOU ARE NOT USING APPLETS) and you'll find dozens of code samples of how to send an HTTP GET or POST request from a URLConnection.
It doesn't matter what's on the other end (a servlet or a CGI) they both respond back the same way, with HTML through HTTP. You can navigate through a web app the same way a browser does -- to navigate a link send a GET, and to submit a form send a POST. You might want to do a google search for a quick tutorial on HTTP, and then check out a Java networking book for a section on using HttpURLConnection.
Kyle
[ February 13, 2002: Message edited by: Kyle Brown ]
Ruilin Yang
Ranch Hand

Joined: Jan 06, 2002
Posts: 150
Kyle,
Thanks for your great inf and help. I appreciate very much.
Regards,
Ruilin
Tiger Scott
Ranch Hand

Joined: Mar 01, 2001
Posts: 223
Kyle,
1. Do you have any examples of screen scraping?
2. What/where are the PERL libraries for SOAP?
I may have to deal with a similar situation of interfacing with a CGI/PHP kind of an app.
TIA
Sanjay
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: message-driven bean to wrap legacy applications