Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

SOA with jsp-servlet

Thread view: 
ahd292 - 24 Dec 2007 14:38 GMT
Hi
I want to implement e-shopping system(as student project level) and
the architecture that must be used is SOA(service oriented
architectute). but I decided to do this by jsp servlet not web service
because I don't have enough time to learn web service, WSDL, BPEL and
more .

two other systems that my e-shopping system must be communicate with
them are "warehouse" and "bank". those system aren't complex and they
just support me with their services.
bank: validate credit of customer
warehouse: give information of stuff.

now I decide to gather them in one web application with three java
packages as their names.
but I don't now how to make relation with them by this approach,JSP
SERVLET.

does anyone can help me by providing simple application that support
SOA but with jsp-servlet.
Lew - 24 Dec 2007 17:23 GMT
> I want to implement e-shopping system(as student project level) and
> the architecture that must be used is SOA(service oriented
[quoted text clipped - 15 lines]
> does anyone can help me by providing simple application that support
> SOA but with jsp-servlet.

Actually, SOA with servlets and JSPs is standard.

Think of it as the phrase, "service-oriented architecture", not the acronym,
"SOA".  You can write to a service-oriented architecture in BASIC, let alone
Java, let alone using SOAP or BPEL.  The point is to write your components as
services, and have them communicate through a service-to-service communication
layer.

When you do it from a web application, that makes it a web service.  No
mention yet of SOAP.  But now that we have mentioned SOAP, it might be the
fastest way to a fully-functional prototype.

First, write a conventional web app using JSPs, a servlet and Java logic to
invoke a service.  This service will be called by direct function calls from
some logic invoked by the controller servlet.  No SOAP.  But the service class
needs to be independent, preferably defined by an interface with an
implementing class that the client logic cannot see.

Example:

package example.soa.service;
import java.util.Collection;
import example.soa.model.Good; // an interface
public interface WarehouseService
{
  public void stash( Collection <Good> goods );
  public Collection <Good> retrieve();
}

Then you cheat.  You run Java2WSDL over the interface to create a WSDL.
Eclipse and NetBeans both do this automagically for you, I believe.  Otherwise
you get it from the Axis project.  Then you run WSDL2Java over the WSDL to
generate client and proxy stubs for a client.  Next you write a cover class
that invokes the Locator, retrieves a local instance of the interface type
that actually calls the proxy, and then simply calls the methods of the interface.

Finally, you create a client web project that uses the URL of the server web
project to fulfill its logic requests.  The JSP view page(s) can be
near-clones of the JSPs from the server-side "direct" application.  (Change
the titles to confirm that you're viewing from the client.)

I'm waving all sorts of magic wands here.  There is a learning curve, which
the IDEs can help you gloss over.  You have to get all the right JARs into
your project library (deployed WEB-INF/lib/ directory).  Still, about a week
of dedicated practice should get a crude but deployable and runnable prototype
going.

Truth to tell, just constructing the services as independent interfaces with
hidden (i.e., package-private or quieter) implementor classes, preferably
instantiated through a (configurable) factory class, already has you in a
service-oriented architecture.  That's what makes it easy to break up the
calls across a web-app-to-web-app communication gap.  A local class implements
the interface via direct calls, a remote one via proxies and stubs.

Plus you can probably get partial credit for the local implementation of a
true SOA even if you fubar the remote implementation.

Having a working local version lets you know better where a broken remote one
is actually not working.  Sensible separation into layers has already
happened.  You can ask focused questions in Usenet, because remoteness issues
will have been teased away from all others.

One practical basis for SOA is to think, always, interface-wise.

Signature

Lew

Arne Vajhøj - 25 Dec 2007 00:13 GMT
> Actually, SOA with servlets and JSPs is standard.

Servlets are frequently used at the server side/producer for
web services.

I have never seen a JSP page used as such.

Neither should be used for client side/consumer.

> Think of it as the phrase, "service-oriented architecture", not the
> acronym, "SOA".  You can write to a service-oriented architecture in
> BASIC, let alone Java, let alone using SOAP or BPEL.  The point is to
> write your components as services, and have them communicate through a
> service-to-service communication layer.

Yep.

> When you do it from a web application, that makes it a web service.

No.

web application = something for humans with a browser

web service = something for programs (using same technology as web app)

>                                                                     No
> mention yet of SOAP.  But now that we have mentioned SOAP, it might be
> the fastest way to a fully-functional prototype.

SOAP has excellent tools support.

[example of how to do web service in Java removed - I agree with
all that]

> Finally, you create a client web project that uses the URL of the server
> web project to fulfill its logic requests.  The JSP view page(s) can be
> near-clones of the JSPs from the server-side "direct" application.  
> (Change the titles to confirm that you're viewing from the client.)

Typical the web services would be used at a lower/far behind (depending
on how you draw it) layer/tier.

A simple JSP page front end is typical only done for testing.

> Truth to tell, just constructing the services as independent interfaces
> with hidden (i.e., package-private or quieter) implementor classes,
[quoted text clipped - 3 lines]
> local class implements the interface via direct calls, a remote one via
> proxies and stubs.

I would say implementing a good SOA solution is a bit more complex
than that.

Arne
Lew - 25 Dec 2007 04:31 GMT
Lew wrote:
>> Actually, SOA with servlets and JSPs is standard.

> Servlets are frequently used at the server side/producer for
> web services.
>
> I have never seen a JSP page used as such.

By that I simply meant that the JSP is the view side of some application that
drives the use of web services at the back end, where in times past one might
have expected a local application or data store.

You are absolutely correct that automated processes are a strong, perhaps teh
strong use case for web services, but even such processes in the end serve a
reporting or interactive system.  OTOH, many of those have no use for JSP.

The purpose of JSPs to which I alluded upthread was as dashboards for logic
that invoked web services behind the scenes, and that is the
application-to-application layer to which you refer.

> Neither should be used for client side/consumer.

Not directly, I completely agree.  As JSPs are often used as front ends to
large-scale enterprise processes, but of course other front ends also exist,
they might drive processes that in turn use services, including web services.

>> When you do it from a web application, that makes it a web service.

> No.
>
> web application = something for humans with a browser
>
> web service = something for programs (using same technology as web app)

Good point.

> SOAP has excellent tools support.
...
> I would say implementing a good SOA solution is a bit more complex
> than that.

I endorse Arne's comments and corrections.

Signature

Lew

Patrick May - 25 Dec 2007 23:34 GMT
>> I want to implement e-shopping system(as student project level) and
>> the architecture that must be used is SOA(service oriented
[quoted text clipped - 22 lines]
> to write your components as services, and have them communicate
> through a service-to-service communication layer.

    This is an extremely important point:  SOA is not a synonym for
Web Services (SOAP and WSDL).  Web Services are just one, particularly
inelegant, way of implementing an SOA.

    For what the original poster is trying to do, Jini services are a
much better approach.  They are lightweight and easily invocable from
Java servlets.  See http://www.jini.org for details, including several
introductory tutorials.

Regards,

Patrick

------------------------------------------------------------------------
S P Engineering, Inc.  | Large scale, mission-critical, distributed OO
                      | systems design and implementation.
         pjm@spe.com  | (C++, Java, Common Lisp, Jini, middleware, SOA)
ahd292 - 27 Dec 2007 11:09 GMT
Hi
Thanks of your reply posts
By guides of Lew, I began to design my project in Interface-wise form
as he said.

As I said before, my three applications are in one project and with
this I have to divide them in packages same as following structure:
(packages are shown in <>)

<Frontend.Shopping>
 jsps: ....
 <frontend.shopping.Bean>
   C:   Order,Customer
 <frontend.shopping.controller>
   C:   OrderController, CustomerController
 <frontend.shopping.controller.services>
   Servlets:   StuffServiceReciever, BankServiceReciever
 <frontend.shopping.DBHandler>
   C:   OrderDBHandler, CustomerDBHandler

<Services.Bank>
 C: Account, AccountDBHandler
 Interface: AccountValidationService
 C:  AccountValidationServiceImpl
<Service.Warehouse>
 C: Stuff, StuffDBHandler
 Interface: StuffInfoService
 C: StuffInfoServiceImpl

by this Structure when a customer enter term in the searchBox on jsp
page, "StuffServiceReciever" called from that jsp page. now here is
the where we must see the "Service oriented architecture" .
in this Servlet(Controller from MVC) I wrote following statement:

  StuffInfoService Istuff = new StuffInfoServiceImpl();

of course I import it's package. then I use desire methods of Istuff.
1)First I want to Know is this style of relations true or must be
changed?
2)How can I send those recieved info(that maybe in form of array of
Stuufs) to jsp page. if I use javabean and usebean tag then can I send
bean from servlet to jsp?

and about Jini taht Patric suggests, I hava not yet enough time to
deeply find out how can help me and how can relate to Servlets. But If
you believe this is better way can give me some quick start or sample
related to this projects?

thanks very much!
Patrick May - 27 Dec 2007 14:36 GMT
> As I said before, my three applications are in one project and with
> this I have to divide them in packages same as following structure:
[quoted text clipped - 19 lines]
>   Interface: StuffInfoService
>   C: StuffInfoServiceImpl
[ . . . ]
> and about Jini taht Patric suggests, I hava not yet enough time to
> deeply find out how can help me and how can relate to Servlets. But
> If you believe this is better way can give me some quick start or
> sample related to this projects?

    When developing an SOA you should think of the web front end as
just another user interface.  Under no circumstances should you couple
that UI to your database schema.  In the beginning of your design
process you should focus on the behavior associated with your use
cases (or even just a single use case if you're using an agile
methodology).  If a database is required, that will become evident
when designing and implementing particular services.

    Based on your description, it appears that one of your use cases
is Order Stuff.  To order stuff, you need to pass an order for a
particular customer to one or more services that can execute the
order.  This is known as an Order Management System (OMS).  For a
first cut, consider creating a Jini service called
OrderManagementSystem with a method called placeOrder() that takes an
Order object.  This would be arguably bad design for a standalone OO
system, but services are often at a coarser level of granularity than
classes.

    When an order is received by the OrderManagementSystem, it must
be processed via some workflow.  The steps in this workflow may
include customer verification, credit checking, billing, provisioning,
shipping, etc.  Each of these steps should be performed by a separate
service.  The workflow can be mediated by the OrderManagementSystem
service but Jini offers JavaSpaces as another alternative.  A
JavaSpace is a Jini service that is used for collaboration by other
Jini services.  When the OrderManagementSystem service receives an
order, it can write it into a JavaSpace to make it available to the
other services that participate in the workflow.  When the order is
processed or when any exceptions occur, the result is written to the
JavaSpace where it can be picked up and presented to the customer.

    This is obviously a very rough explanation based on very little
information about your requirements.  I hope it gives you a flavor of
how to use Jini to build an SOA.

Regards,

Patrick

------------------------------------------------------------------------
S P Engineering, Inc.  | Large scale, mission-critical, distributed OO
                      | systems design and implementation.
         pjm@spe.com  | (C++, Java, Common Lisp, Jini, middleware, SOA)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.