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