3 Replies Latest reply on Oct 1, 2008 12:16 PM by joe freeman

    Are ProcessDefinitions singletons or prototypes?

    joe freeman Newbie

      ProcessDefinitions are the description of a process and the ProcessInstance holds the runtime state. Does this mean ProcessDefinitions can be shared across all users's process instances?

      We're using serialization for in-memory-cache persistence and we're trying to figure out if we can disconnect the process definitions before serialization and reconnect them after deserialization.

        • 1. Re: Are ProcessDefinitions singletons or prototypes?
          Alejandro Guizar Master

          All process instances share the process definition they were created with. Creating a process instance adds a reference to the common process definition as opposed to creating a copy of the process definition.

          • 2. Re: Are ProcessDefinitions singletons or prototypes?
            joe freeman Newbie

            Yes, our research made us think that also. The current serialization serializes the process definition with the process instance so you end up with multiple copies when you deserialize it. We'd really like to change the serialization so that it writes out the process definition name and version when serializing and then restores the process definition by looking up the name and version using the ProcessState default subprocess resolver.

            We had thought of subclassing process definition so that it would do this as part of a readReplace() method but the use of ProcessDefinition class is hard coded into the jpdl xml reader so there is no way to replace it with a different class. Process Definition should be an interface or the definition instantiation code should get the process definition class from a factory or from the configuration files.

            Instead, when we write out process instances, we remove the process definitions from the process instances and put the name of the definitions on the transients map on the process instance. (Note that it's called transients but its still serialized) After we read the process instances back in, we walk the process instance tree attaching the process definitions based on the name previously in the transients map.

            We probably serialize BPM instances 1.5 million times per day so the savings can add up.

            • 3. Node thread safety issue
              joe freeman Newbie

              The Node class has a potential deadlock condition in getLeavingTransitionsMap() if multiple users attempt to leave the same node at the same time. The leavingTransitionMap.put() method isn't thread safe so multiple threads can deadlock there.

              Other configuration methods are not thread safe but they don't matter because they are only called one time at startup.