The main reason I am concerned is that I saw this happen in ATG:
Processing logic moves from Java code to XML. The problem is that it
becomes much harder to isolate a particular Bug. Unit testing is
allmost impossible. My suggestion is that if you want to make it easy
to do List/Add/Delete functionality, make helper classes to do it. While
I've been using JBoss for my Object-Relational mapping, many people have
written classes that wrap a table/query etc.
The design pattern that best reflects what you are trying to do is the
template method (Design Patterns, Go4, p325). You want to separate the
flow logic from what happens at each step of the way.
void teplateMethod(){
step1();
step2();
if (success(step3()){
step4();
}
}
Pretty easy to do in Java, and keeps the code clean.
One of the key issues you have to deal with in coding is where does
coding leave off and configuration begin. I tend to err on the side of
codeing: Abstract methods that must be defined to use the class
correctly. At the other extreme is the Interpreter pattern.
One thing I really like about struts is the ability to have one place
that you define your Components.
The way my make file works, there is not really a big benefit to doing
something late bound that does not force a recompile since I end up
doing a complete redeploy for any changes. (JBoss with embedded
Tomcat). This pushes the focus to building unit tests that run before
the deploy stage. Any logic in the XML file makes this more difficult.
Granted, it is just another way to develop.
Adam
Oleg V Alexeev wrote:
>Hello Adam,
>
>Wednesday, July 18, 2001, 8:51:58 PM, you wrote:
>
>AY> This sounds like the pipeline/chain setup from ATG. My one concern is
>AY> that you will end up with convoluted processing logic in the xml.
>
>Main idea is to describe commands in XML and let to manipulate such
>blocks without code recompilation.
>
>AY> Iwould recomend that this type of processing stay in the java code. I
>AY> also would be a little wary of the SQL code migrating into the XML.
>
>Why? It can be useful for small projects with insert/update/delete
>logic only.
>
>AY> If this is related to the idea of chaining actions we talked about
>AY> before, it may be better to provide an API inside of the Action object
>AY> Forward to another action. Although What I would like to see is the
>AY> ability of a Action object to take a collection of Form's. While I
>AY> typically would use two (The previopus pages form and the next pages
>AY> form) I could see needing another.
>
>
>AY> Oleg V Alexeev wrote:
>
>>>Hello struts-dev,
>>>
>>> This day I start to build new service for ServiceManager -
>>> CommandService. It would be based on FactoryService (early published
>>> as BeanFactory).
>>>
>>> FactoryService (as BeanFactory) build on base of Abstract Factory
>>> pattern. So its idea is to generate beans and store it to the some
>>> context. Now I found such approach as limited.
>>>
>>> CommandService idea is based on Command pattern. There are two
>>> entity types on playground - Command and Processor. Processor's
>>> missing is to perform Command and prepare predefined count of result
>>> objects. Every action can contain list of calls to the Processors
>>> with appropriate Commands. The most simple way to pass results from
>>> on Porcessor to another is to perfom processing and store result in
>>> some context (request, session, etc.). More flexible way is to
>>> write nested calls to the Processors with appropriate Commands. And
>>> generally all this stuff (set of Processors and
>>> Commands) can be used to build some kind of scripting in
>>> struts-config.xml with BSF framework.
>>>
>>> Example of service manager config in struts-config -
>>>
>>> <service-manager>
>>> <process-registrations>
>>> <process-registration name="preprocess"/>
>>> </process-registrations>
>>> <service-registrations>
>>> <service-registration
>>> name="command"
>>> type="org.apache.struts.service.command.CommandService"
>>> useDigester="true">
>>> <command-service>
>>> <processors>
>>> <processor name="jdbcUpdate" type="some.package.Class">
>>> <result
>>> name="totalUpdated"
>>> type="java.lang.Integer"/>
>>> </processor>
>>> </processors>
>>> <commands>
>>> <command
>>> name="createUser"
>>> command="insert into rb.user( name ) values ( ? )">
>>> <processors>
>>> <processor name="jdbcUpdate"/>
>>> </processors>
>>> <parameter
>>> name="method"
>>> type="java.lang.String"
>>> value="preparedStatement"/>
>>> <parameter
>>> name="userName"
>>> type="java.lang.String"/>
>>> </command>
>>> </commands>
>>> </command-service>
>>> </service-registrations>
>>> </service-manager>
>>>
>>> <action-mappings>
>>> <action path="/user/insert"
>>> type="some.package.Action"
>>> name="userForm"
>>> input="/WEB-INF/jsp/userEdit.jsp">
>>> <perform-command name="createUser"/>
>>> <forward name="success" path="/WEB-INF/jsp/userList.jsp"/>
>>> </action>
>>> </action-mappings>
>>>
>>>
>>>
>
>
>
>