Hello Adam,

Thursday, July 19, 2001, 7:05:59 PM, you wrote:

AY> The main reason I am concerned is that I saw this happen in ATG: 
AY>  Processing logic moves from Java code to XML.  The problem is that it 
AY> becomes much harder to isolate a particular  Bug.  Unit testing is 
AY> allmost impossible.  My suggestion is that if you want to make it easy 
AY> to do List/Add/Delete functionality, make helper classes to do it. While 
AY> I've been using JBoss for my Object-Relational mapping, many people have 
AY> written classes that wrap a table/query etc.  

May be you are right. But imagine common situation - you are needs to
list rows from DB table by the JSP page. So with struts you are place
call to the database or to the DAO to the Action and forward to the
page. And such operation (write simple call to the JDBC source to
execute query and retrieve values) you are needs to perform for every
simple query. I think that such processing logic is more than standart
and make it part of code is superfluous.
For example - experienced developer write processor code to process
calls to the JDBC data source and ordinal developer with help of DBA
write command tag and place it to the appropriate action. After that
he can place tags to retrieve data from objects and not write complex
code with calls to the exteranl datasource.

AY> The design pattern that best reflects what you are trying to do is the 
AY> template method (Design Patterns, Go4, p325).  You want to separate the 
AY> flow logic from what happens at each step of the way.

AY> void teplateMethod(){
AY>    step1();
AY>    step2();
AY>    if (success(step3()){
AY>       step4();
AY>    }
AY> }

AY> Pretty easy to do in Java, and keeps the code clean.

No problem. Commands can be used from java code. Developer can find
all needed Processors and Commands and perform call to the processor
for the any count of Commands. He can change logic of applications but
he don't need to change standart operations under application data.

AY> One of the key issues you have to deal with in coding is where does 
AY> coding leave off and configuration begin.  I tend to err on the side of 
AY> codeing:  Abstract methods that must be defined to use the class 
AY> correctly.  At the other extreme is the Interpreter pattern.

I don't want to code all Processors and Commands, no. I want to build
framework to use Processors and Commands, specified by class name.
Everybody can write its own Processor or Command and use it with
CommandService. I think JDBC Processor is not single choice to perform
processing. There are - RowSet Processor, XML Processor, Castor
Processor, etc.

AY> One thing I really like about struts is the ability to have one place 
AY> that you define your Components.  

AY> The way my make file works, there is not really a big benefit to doing 
AY> something late bound that does not force a recompile since I end up 
AY> doing a complete redeploy for any changes.  (JBoss with embedded 
AY> Tomcat).  This pushes the focus to building unit tests that run before 
AY> the deploy stage.  Any logic in the XML file makes this more difficult. 
AY>  Granted, it is just another way to develop.

Yes, I agree with you... It is difficalt to perform unit tests with
it.

AY> Adam


AY> 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>
>>>> 
>>>>
>>>>
>>
>>
>>
>>




-- 
Best regards,
 Oleg                            mailto:[EMAIL PROTECTED]


Reply via email to