You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by joaquim <jo...@dei.uc.pt> on 2000/09/19 20:43:57 UTC

Single class for different actions, SOAP enabling Struts and Best Envinronment in NT/IIS

Hello

What would be the best solution to ship a Struts application for NT?.

I have been prototyping an application for libraries using Struts, am very
happy about it,  but it should run on NT because our target libraries will
have typically a NT server running some pages with IIS.

We could install Tomcat but my impression is that the integration with IIS
is still a bit complicated, and sys administrators can get nervous at the
idea of changing registry settings and all that.

In our team some people are inclined to asp based solutions and the extra
noise from the servlet environment does not eases things.

So what I am looking for is a not too costly, or free solution for reliable
Struts environment on NT/IIS with easy instalation and easy maintenance
(running as a service).

I am considering now:
1-enhydra from luris.com (the standard edition),
2 - Resin, 
3 - Some future Tomcat incarnation if there is something like what I need in
the pipeline (I have used 3.1 but not the nighly ones which probably have
improved IIS integration).

Now the design questions.

Design question 1): Handling more than one mapping in a single class.

After coding a few actions I begin to think that sometimes I could organize
better my code if several close related "actions" could be handled by a
single class. The typical case is the normal "set","get", "delete" actions
associated with a table. There is a bunch of code (checking for user
permissions in the session, getting the connection pool from the application
scope, etc. etc..) that is repeated in each action.
 
So I though of creating a single class for set,get,and delete actions on a
table. I would create three mappings in action.xml file for this class, for
instance "setX.do, getX.do and deleteX.do"

Then inside the method perform I would get the path from the mapping with

String function = mapping.getPath();

do the common stuff

and then switch with and if

if (function.equals("setX") // do the insert or update ...
else if (function.equals("getX") // fectch the thing, etc...
else if (function.equals("deleteX") // delete the thing

Is this a good design pattern, is there a more elegant way to do this?. I
plan to use this lightly in closely related actions and not as a way to put
the all app in a single class of course.

Design question 2) SOAP enabling a Struts application

I am thinking of a way to add SOAP handling to struts. In SOAP a request for
a remote service is done over http with the request parameters coded in an
simple XML format. The result is returned also in XML. In Struts this means
that if the form bean could be populated from a XML request in SOAP format
then an existing action would receive the parameters exactly as if they were
provided by a form. Then it would redirect to an XML producing jsp instead
of the normal html producing JSP. The main code would remain unchanged
(simplifying here because in SOAP sessions are not straightforward because
cookies can not be taken for granted).

The bottom line here that interests me is using the struts framework not
only for web/html applications but also for building services that handle
RPC in xml according to SOAP specs. Then each Web app done with struts is
also a potential RPC server for non browser clients. I am convinced that
this is really easy to do and opens new worlds. I am aware of the new SOAP
project on xml.apache.org but it  is centered on a different need (could
elaborate on that but this is getting too long already).

So before I go forward and plunge in the details and bother you more I want
to know if there is any interest in this, anyone planning something along
these lines any exchange of ideas worth on this topic.

If not I just go ahead and post to the list if something usefull comes out
of my rudimentary efforts.

PS
In case anyone needs a pointer for SOAP see:

 1) http://msdn.microsoft.com/msdnmag/issues/0300/soap/soap.asp

 2) http://msdn.microsoft.com/workshop/xml/articles/xmlmanifesto.asp

3) http://www.develop.com/soap/

-- 
 Joaquim Ramos de Carvalho
Instituto de Historia e Teoria das Ideias / Centro de Informatica e Sistemas
da Universidade de Coimbra. 3049 COIMBRA CODEX PORTUGAL
joaquim@dei.uc.pt