Information Technology Reference
In-Depth Information
Object marshalling strategies
Object marshalling strategies are used to configure our persistent KIE session to understand
that specific objects are going to be persisted or loaded into the KIE session in a very spe-
cific way. By default, the persistent KIE session will try to serialize every object in the
working memory, process variables, and task inputs and outputs to a series of byte arrays.
However, if you have a specific way of storing certain objects in a data storage, you can
use a persistence strategy to let the KIE session know how to persist such objects. This is a
very common way of simplifying interaction- and domain-based monitoring of the process
engine. To be able to provide such functionality, the Drools and jBPM6 API define an in-
terface called ObjectMarshallingStrategy to specify different strategies of storing
your model:
public interface ObjectMarshallingStrategy {
boolean accept(Object object);
void write(ObjectOutputStream os, Object object);
Object read(ObjectInputStream os);
byte[] marshal( Context context, ObjectOutputStream os,
Object object);
Object unmarshal( Context context, ObjectInputStream is,
byte[] object, ClassLoader classloader
);
Context createContext();
}
The implementations are rather simple. The accept method will determine whether a
specific object is suitable for the specific persistence strategy. If accepted, writing and read-
ing the objects will involve two things:
• Storing or reading an ID or any other way of referencing the object in the provided
byte array
• Reading and/or writing the object in a specific persistence strategy
There are a few implementations provided and they are ready to be utilized. The Serial-
izablePlaceholderResolverStrategy implementation is the one used by de-
fault, and it simply attempts to write the full object to the byte array. The JPAPlace-
holderResolverStrategy implementation is used to read objects from a JPA data-
base. It only stores the ID in the byte array, and it doesn't store the objects if something
changes. We extend it in the testProcessModelStorage method of the JPAPer-
Search WWH ::




Custom Search