Announcement Announcement Module
No announcement yet.
OSWorkflow integration Page Title Module
Move Remove Collapse
This topic is closed
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • OSWorkflow integration

    I have finally tweaked my application context and Hibernate configuration to enable Open Symphony's OSWorkflow within Spring (i.e. getting a workflow object from the application context and using the Spring-configured session factory). However, what to do next is a little baffling.

    The SpringConfiguration implementation class the comes bundled with OSWorkflow seems less than adequate. For example, the isInitialized method always returns false. This allows me to initialize multiple workflows from the same object. This isn't correct is it? From the way I read the docs, a workflow object (i.e. inherits from AbstractWorkflow) can only be initialized once (i.e. non-singleton). If this is true then, all of the method calls that ask for workflowId seem redundant (like asking me, "Justin, what is your first name.")

    Have those using OSWorkflow in Spring written their own Configuration implementations? Am I missing something here? The OSWorkflow docs and mailing list don't seem quite up to snuff.

    Any help would be much appreciated.

    - Justin Makeig

  • #2
    Re: OSWorkflow integration

    The important method in SpringConfiguration is
     public WorkflowDescriptor getWorkflow(String name) throws FactoryException {
    which does the actual loading of the workflow definitons from the factory used.
    Both the Configuration, WorkflowStore and the WorkflowFactory are singletons.
    I think the isInitialized method in Configuration is only there for backward-compatibility, and not really used anymore (the only place where is used is in AbstractWorkflow#getConfiguration which itself calls Configuration#load(URL). This is now done by the factory implementations so it seems like deprecated code)
    Only the workflow object itself needs to be non-singleton and be configured with the SpringConfiguration ie:
    <bean id="workflowConfiguration"  class="com.opensymphony.workflow.config.SpringConfiguration">
    	<property name="store"><ref local="workflowStore"/></property>
    	<property name="factory"><ref local="workflowFactory"/></property>
      <bean id="workflow" class="......workflow.os.SpringWorkflow" singleton="false">
        <property name="configuration"><ref local="workflowConfiguration"/></property>
    A workflow object (i.e. inherits from AbstractWorkflow) IS NOT the actual workflow ENTRY which is kept in DB table OS_WFENTRY. This workflow object is a kind of manager of Workflow entries. Workflow entries are identified by a workflowId, and you can use the same workflow manager object (the one extending AbstractWorkflow) for triggering actions in several different workflow entries (assuming they use the same workflow definition).
    A workflow manager is associated with a specific workflow definition and a specific user.
    So usually you can keep only 1 workflow manager instance in the HttpSession associated with the logged in user, and getting a new manager (non-singleton) from the appCtx only when a new user is logged in.



    • #3
      Using Spring beans in OSWorkflow FunctionProvider

      Your help has been invaluable. Thanks so much.

      Would you be so kind as to help me with one more thing?

      I don't see how to use Spring-wired beans in functions called from workflow actions. Only the transientVars, args, and propertySet are exposed to extensions of FunctionProvider and these don't have a handle on any Spring-configured beans.

      For example, I've got a Job object. At a specified time, Quartz kicks off the Job's workflow. I store the jobId in the workflow's propertySet. However, without access to the applicationContext I can't look up the Job object when evaluating functions within actions. Is there a way to tell OSWorkflow to instantiate objects from Spring, like a Hibernate interceptor? Am I approaching this incorrectly?

      Thanks again.

      - Justin Makeig


      • #4
        Re: Using Spring beans in OSWorkflow FunctionProvider

        take a carefull look at a previous topic about Osworkflow :

        There is included a SpringWorkflow example which loads objects (Functions/Conditions/Registers) from the appCtx.
        Note that the loading is class-based, so it's not possible to have 2 different beans with the exact same class.
        But it's quite usefull to be used like this:
        <bean id="myFunction" class="org.bla.MyFunction">
            <property name="someService">
               <ref bean="someService"/>
        note that it can either be singleton or not, depends on if your implementation keeps state or not.

        So, you just need to have your org.bla.MyFunction implementing FunctionProvider from OsWorkflow and do your stuff in the execute method, having access to someService or whatever you choose to inject into that bean.

        Then you just need to specify in the workflow definition:
        <function type="class">
        	<arg name="">org.bla.MyFunction</arg>
        	<arg name="someArg">Hello World!</arg>
        The same way can be used for Conditions and Registers.

        Last edited by Rod Johnson; Jan 18th, 2006, 10:28 AM.


        • #5
          Sorry about not reviewing thoroughly. This looks spot on. Thanks again.

          - Justin


          • #6
            I have a very similar issue as listed above however the OSWorkflow API has changed and there is no loadObject(clazz) method on the AbstractWorkflow object (OSWF version 2.8.x).

            I need to have available in my functions, conditions etc... the application context so I can get to my service object which are wired into the application context.

            Thank you in advance for your help.



            • #7
              All set ... thanks.

              For those that want the solution please read the post on the OSWF forum.