Commits

Anonymous committed 8d25ccd

Fixed ear build
Added propertyset to register API

  • Participants
  • Parent commits a147444

Comments (0)

Files changed (12)

 <project name="workflow" default="jar" basedir=".">
 
+  <property name="test.compile.version" value="1.5"/>
   <property name="src.test" location="src/test"/>
   <property name="jar.manifest" value="src/etc/deployment/ejb/manifest.txt" />
   
     <property name="src.client" value="${src}/designer"/>
     <property name="src.etc" value="${src}/etc"/>
     <property name="src.webapp" value="${src}/webapp"/>
-    <property name="propertyset.jar" value="propertyset-1.4.jar"/>
+    <property name="propertyset.version" value="1.4"/>
+    <property name="propertyset.jar" value="propertyset-${propertyset.version}.jar"/>
+    <property name="propertyset-ejb.jar" value="propertyset-ejb-${propertyset.version}.jar"/>
     <property name="oscore.jar" value="oscore-2.2.2.jar"/>
     <property name="build.client" value="${build}/designer"/>
 
     </delete>
   </target>
 
+  <target name="test" depends="clover-check, test-compile" description="run tests">
+      <taskdef resource="testngtasks" classpathref="junit.cp"/>
+      <mkdir dir="${dist.docs}/testng"/>
+      <testng haltonfailure="true" outputdir="${dist.docs}/testng" classpathref="junit.cp">
+          <jvmarg value="-Djava.awt.headless=true"/>
+          <xmlfileset dir="${src.test}" includes="testng.xml"/>
+      </testng>
+  </target>
+  
   <target name="ejbdoclet" depends="init">
     <ejbdoclet ejbspec="2.0" verbose="false" destdir="${src.java}">
       <fileset dir="${src.java}">
       <fileset dir="${src.java}">
         <include name="**/*.java"/>
       </fileset>
-      <fileset dir="${src.test}">
-        <include name="**/*.java" />
-      </fileset>
     </jalopy>
     <copy todir="${build.java}/META-INF">
       <fileset dir="${docs}">
     <war warfile="${dist}/${name}-${version}-example.war" webxml="${src.webapp}/WEB-INF/web.xml">
       <fileset dir="${src.webapp}">
         <exclude name="WEB-INF/web.xml" />
+        <exclude name="**/*.iml" />
       </fileset>
       <lib dir="${lib.optional}">
         <include name="osuser-1.0-dev-2Feb05.jar" />
 
   <target name="example-ear" depends="jar" description="Build ear application using the EJB store">
     <mkdir dir="${build}/tmp/lib"/>
-    <war warfile="${build}/tmp/${name}-${version}-example.war" webxml="${src.etc}/example/web.xml">
-      <fileset dir="${src.webapp}"/>
+    <mkdir dir="${dist}" />
+    <war warfile="${build}/tmp/${name}-${version}-example.war" webxml="${src.webapp}/WEB-INF/web.xml">
+      <fileset dir="${src.webapp}">
+        <exclude name="**/*.iml" />
+        <exclude name="WEB-INF/web.xml" />
+      </fileset>
+      <lib dir="${lib.optional}/xfire"/>
     </war>
     <copy file="${build}/${name}-${version}.jar" tofile="${build}/tmp/${name}-${version}-example.jar"/>
     <!-- note that we add these files to the jarfile for ease of deployment. In a real environment, the config files
     would be in a separate dir and added appropriately to the classpath -->
     <copy file="${src.etc}/example/osworkflow-ejb.xml" tofile="${build}/tmp/osworkflow.xml"/>
-    <copy file="${src.etc}/example/workflows.xml" todir="${build}/tmp"/>
-    <copy file="${src.etc}/example/example.xml" todir="${build}/tmp"/>
+    <copy file="${src.webapp}/WEB-INF/classes/workflows.xml" todir="${build}/tmp"/>
+    <copy file="${src.webapp}/WEB-INF/classes/example.xml" todir="${build}/tmp"/>
     <touch file="${build}/tmp/${name}-${version}-example.jar" millis="500"/>
     <jar file="${build}/tmp/${name}-${version}-example.jar" update="true" basedir="${build}/tmp">
       <include name="*.xml"/>
     </jar>
     <copy file="${lib.core}/${oscore.jar}" todir="${build}/tmp"/>
-    <copy file="${lib.core}/${propertyset.jar}" todir="${build}/tmp"/>
+    <copy file="${lib.core}/${propertyset.jar}" todir="${build}/tmp/lib"/>
+    <copy file="${lib.optional}/${propertyset-ejb.jar}" todir="${build}/tmp"/>
     <copy file="${lib.core}/commons-logging.jar" todir="${build}/tmp/lib"/>
     <copy file="${lib.optional}/osuser-1.0-dev-2Feb05.jar" todir="${build}/tmp/lib"/>
     <copy file="${lib.optional}/quartz.jar" todir="${build}/tmp/lib"/>
     <copy file="${lib.optional}/bsh-1.2b7.jar" todir="${build}/tmp/lib"/>
     <!-- update the manifests of the other ejb modules -->
     <touch file="${build}/tmp/${oscore.jar}" millis="500"/>
-    <touch file="${build}/tmp/${propertyset.jar}" millis="500"/>
+    <touch file="${build}/tmp/${propertyset-ejb.jar}" millis="500"/>
     <jar jarfile="${build}/tmp/${oscore.jar}" update="true" manifest="${src.etc}/deployment/ejb/manifest.txt"/>
-    <jar jarfile="${build}/tmp/${propertyset.jar}" update="true" manifest="${src.etc}/deployment/ejb/manifest.txt"/>
+    <jar jarfile="${build}/tmp/${propertyset-ejb.jar}" update="true" manifest="${src.etc}/deployment/ejb/manifest.txt"/>
     <filter token="oscore.jar" value="${oscore.jar}"/>
-    <filter token="propertyset.jar" value="${propertyset.jar}"/>
+    <filter token="propertyset-ejb.jar" value="${propertyset-ejb.jar}"/>
     <filter token="version" value="${version}"/>
     <filter token="name" value="${name}"/>
     <copy file="${src.etc}/example/application.xml" todir="${build}/" filtering="true" />

File src/etc/deployment/ejb/manifest.txt

-Class-Path: lib/bsh-1.2b7.jar lib/GLUE-STD.jar lib/quartz.jar lib/osuser-1.0-dev-2Feb05.jar propertyset-1.4.jar lib/commons-logging.jar oscore-2.2.2.jar
+Class-Path: lib/bsh-1.2b7.jar lib/GLUE-STD.jar lib/quartz.jar lib/osuser-1.0-dev-2Feb05.jar lib/propertyset-1.4.jar lib/commons-logging.jar oscore-2.2.2.jar
 

File src/etc/example/application.xml

 		</web>
 	</module>
 	<module>
-		<ejb>@propertyset.jar@</ejb>
+		<ejb>@propertyset-ejb.jar@</ejb>
 	</module>
   <module>
 		<ejb>@oscore.jar@</ejb>

File src/java/com/opensymphony/workflow/AbstractWorkflow.java

             Map transientVars = (inputs == null) ? new HashMap() : new HashMap(inputs);
             Collection currentSteps = store.findCurrentSteps(id);
 
-            populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(0), currentSteps);
+            populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(0), currentSteps, ps);
 
             // get global actions
             List globalActions = wf.getGlobalActions();
             PropertySet ps = store.getPropertySet(id);
             Map transientVars = (inputs == null) ? new HashMap() : new HashMap(inputs);
             Collection currentSteps = store.findCurrentSteps(id);
-            populateTransientMap(entry, transientVars, wf.getRegisters(), null, currentSteps);
+            populateTransientMap(entry, transientVars, wf.getRegisters(), null, currentSteps, ps);
 
             List s = new ArrayList();
 
         }
 
         try {
-            populateTransientMap(mockEntry, transientVars, Collections.EMPTY_LIST, new Integer(initialAction), Collections.EMPTY_LIST);
+            populateTransientMap(mockEntry, transientVars, Collections.EMPTY_LIST, new Integer(initialAction), Collections.EMPTY_LIST, ps);
 
             return canInitialize(workflowName, initialAction, transientVars, ps);
         } catch (InvalidActionException e) {
             transientVars.putAll(inputs);
         }
 
-        populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(actionId), currentSteps);
+        populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(actionId), currentSteps, ps);
 
         boolean validAction = false;
 
 
         PropertySet ps = store.getPropertySet(id);
         Map transientVars = new HashMap();
-        populateTransientMap(entry, transientVars, wf.getRegisters(), null, store.findCurrentSteps(id));
+        populateTransientMap(entry, transientVars, wf.getRegisters(), null, store.findCurrentSteps(id), ps);
         executeFunction(wf.getTriggerFunction(triggerId), transientVars, ps);
     }
 
             transientVars.putAll(inputs);
         }
 
-        populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(initialAction), Collections.EMPTY_LIST);
+        populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(initialAction), Collections.EMPTY_LIST, ps);
 
         if (!canInitialize(workflowName, initialAction, transientVars, ps)) {
             context.setRollbackOnly();
             Map transientVars = (inputs == null) ? new HashMap() : new HashMap(inputs);
             Collection currentSteps = store.findCurrentSteps(id);
 
-            populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(0), currentSteps);
+            populateTransientMap(entry, transientVars, wf.getRegisters(), new Integer(0), currentSteps, ps);
 
             // get global actions
             List globalActions = wf.getGlobalActions();
         return passesConditions(descriptor.getType(), descriptor.getConditions(), transientVars, ps, currentStepId);
     }
 
-    protected void populateTransientMap(WorkflowEntry entry, Map transientVars, List registers, Integer actionId, Collection currentSteps) throws WorkflowException {
+    protected void populateTransientMap(WorkflowEntry entry, Map transientVars, List registers, Integer actionId, Collection currentSteps, PropertySet ps) throws WorkflowException {
         transientVars.put("context", context);
         transientVars.put("entry", entry);
         transientVars.put("store", getPersistence());
             }
 
             try {
-                transientVars.put(register.getVariableName(), r.registerVariable(context, entry, args));
+                transientVars.put(register.getVariableName(), r.registerVariable(context, entry, args, ps));
             } catch (Exception e) {
                 context.setRollbackOnly();
 

File src/java/com/opensymphony/workflow/Register.java

  */
 package com.opensymphony.workflow;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
 import java.util.Map;
  * Interface that must be implemented for workflow registers to behave properly.
  *
  * @author <a href="mailto:plightbo@hotmail.com">Patrick Lightbody</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public interface Register {
     //~ Methods ////////////////////////////////////////////////////////////////
      * before the workflow has been initialised
      * @param args Map of arguments as set in the workflow descriptor
 
+     * @param ps
      * @return the object to bind to the variable map for this workflow instance
      */
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException;
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException;
 }

File src/java/com/opensymphony/workflow/RegisterRemote.java

  */
 package com.opensymphony.workflow;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
 import java.rmi.Remote;
  * bean would then implement this interface in order for a register to be successfully registered.
  *
  * @author <a href="mailto:hani@formicary.net">Hani Suleiman</a>
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
  */
 public interface RegisterRemote extends Remote {
     //~ Methods ////////////////////////////////////////////////////////////////
      * @return An object which is now exposed as a register to the rest of the workflow
      * @throws RemoteException
      */
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws RemoteException;
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws RemoteException;
 }

File src/java/com/opensymphony/workflow/util/LogRegister.java

  */
 package com.opensymphony.workflow.util;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.util.TextUtils;
 
 import com.opensymphony.workflow.Register;
     //~ Methods ////////////////////////////////////////////////////////////////
 
     /**
-     * @see com.opensymphony.workflow.Register#registerVariable(WorkflowContext, WorkflowEntry, Map)
+     * @see com.opensymphony.workflow.Register#registerVariable(com.opensymphony.workflow.WorkflowContext,com.opensymphony.workflow.spi.WorkflowEntry,java.util.Map,PropertySet)
      */
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) {
         String workflowname = "unknown";
         long workflow_id = -1;
 

File src/java/com/opensymphony/workflow/util/beanshell/BeanShellRegister.java

 import bsh.Interpreter;
 import bsh.TargetError;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.*;
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.util.Map;
 
 
 /**
- *
- *
+ * A register that executes a beanshell script when invoked.
  * @author Hani
  */
 public class BeanShellRegister implements Register {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    private static final Log log = LogFactory.getLog(BeanShellRegister.class);
-
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {
         String script = (String) args.get(AbstractWorkflow.BSH_SCRIPT);
 
         Interpreter i = new Interpreter();
 
             i.set("entry", entry);
             i.set("context", context);
+            i.set("propertySet", ps);
 
-            Object o = i.eval(script);
-
-            return o;
+            return i.eval(script);
         } catch (TargetError targetError) {
             if (targetError.getTarget() instanceof WorkflowException) {
                 throw (WorkflowException) targetError.getTarget();

File src/java/com/opensymphony/workflow/util/bsf/BSFRegister.java

  */
 package com.opensymphony.workflow.util.bsf;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.util.TextUtils;
 
 import com.opensymphony.workflow.*;
 
 
 /**
+ * Register that invokes a BSF script.
+ * args parameter is expected to contain the follow arguments:
  *
+ * <li>{@link AbstractWorkflow#BSF_LANGUAGE}: The language of the script
+ * <li>{@link AbstractWorkflow#BSF_SOURCE}: The source of the script
+ * <li>{@link AbstractWorkflow#BSF_ROW}: The row of the script
+ * <li>{@link AbstractWorkflow#BSF_COL}: The column of the script
  *
  * @author $Author: hani $
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 public class BSFRegister implements Register {
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {
         String language = (String) args.get(AbstractWorkflow.BSF_LANGUAGE);
         String source = (String) args.get(AbstractWorkflow.BSF_SOURCE);
         int row = TextUtils.parseInt((String) args.get(AbstractWorkflow.BSF_ROW));
             mgr.setClassLoader(loader);
         }
 
+        mgr.registerBean("propertySet", ps);
         mgr.registerBean("entry", entry);
         mgr.registerBean("context", context);
 
         try {
             BSFEngine engine = mgr.loadScriptingEngine(language);
-            Object o = engine.eval(source, row, col, script);
 
-            return o;
+            return engine.eval(source, row, col, script);
         } catch (BSFException e) {
             String message = "Could not get object registered in to variable map";
             throw new WorkflowException(message, e);

File src/java/com/opensymphony/workflow/util/ejb/local/LocalEJBRegister.java

  */
 package com.opensymphony.workflow.util.ejb.local;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.AbstractWorkflow;
 import com.opensymphony.workflow.Register;
 import com.opensymphony.workflow.WorkflowContext;
 import com.opensymphony.workflow.WorkflowException;
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.lang.reflect.Method;
 
 import java.util.Map;
  * the JNDI location of the session bean.
  *
  * @author $Author: hani $
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
  */
 public class LocalEJBRegister implements Register {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    private static final Log log = LogFactory.getLog(LocalEJBRegister.class);
-
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {
         String ejbLocation = (String) args.get(AbstractWorkflow.EJB_LOCATION);
-        Register sessionBean = null;
+        Register sessionBean;
 
         try {
             EJBLocalHome home = (EJBLocalHome) PortableRemoteObject.narrow(new InitialContext().lookup(ejbLocation), EJBLocalHome.class);
             throw new WorkflowException(message, e);
         }
 
-        return sessionBean.registerVariable(context, entry, args);
+        return sessionBean.registerVariable(context, entry, args, ps);
     }
 }

File src/java/com/opensymphony/workflow/util/ejb/remote/RemoteEJBRegister.java

  */
 package com.opensymphony.workflow.util.ejb.remote;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.*;
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
  * the user specified as 'testuser'.
  *
  * @author $Author: hani $
- * @version $Revision: 1.3 $
+ * @version $Revision: 1.4 $
  */
 public class RemoteEJBRegister implements Register {
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {
         String ejbLocation = (String) args.get(AbstractWorkflow.EJB_LOCATION);
-        RegisterRemote sessionBean;
         Hashtable env = null;
         Iterator iter = args.entrySet().iterator();
 
             }
         }
 
+        RegisterRemote sessionBean;
+
         try {
             EJBHome home = (EJBHome) PortableRemoteObject.narrow(new InitialContext(env).lookup(ejbLocation), javax.ejb.EJBHome.class);
             Method create = home.getClass().getMethod("create", new Class[0]);
         }
 
         try {
-            return sessionBean.registerVariable(context, entry, args);
+            return sessionBean.registerVariable(context, entry, args, ps);
         } catch (RemoteException e) {
             String message = "Remote exception while executing remote EJB register: " + ejbLocation;
             throw new WorkflowException(message, e);

File src/java/com/opensymphony/workflow/util/jndi/JNDIRegister.java

  */
 package com.opensymphony.workflow.util.jndi;
 
+import com.opensymphony.module.propertyset.PropertySet;
+
 import com.opensymphony.workflow.*;
 import com.opensymphony.workflow.spi.WorkflowEntry;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import java.util.Map;
 
 import javax.naming.InitialContext;
 
 
 /**
- *
- *
+ * Invoke a register registred in JNDI.
+ * Args must contain a {@link AbstractWorkflow#JNDI_LOCATION} key.
  * @author $Author: hani $
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
  */
 public class JNDIRegister implements Register {
-    //~ Static fields/initializers /////////////////////////////////////////////
-
-    private static final Log log = LogFactory.getLog(JNDIRegister.class);
-
     //~ Methods ////////////////////////////////////////////////////////////////
 
-    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args) throws WorkflowException {
+    public Object registerVariable(WorkflowContext context, WorkflowEntry entry, Map args, PropertySet ps) throws WorkflowException {
         String location = (String) args.get(AbstractWorkflow.JNDI_LOCATION);
 
         if (location == null) {
             throw new WorkflowException(message, e);
         }
 
-        return r.registerVariable(context, entry, args);
+        return r.registerVariable(context, entry, args, ps);
     }
 }