* Gets an Environment.
* @param overrides any overrides
* @return the Environment
*/
public static Environment getEnvironment(Map<String, Object> overrides) {
Environment env = KieServices.Factory.get().newEnvironment();
// set the object marshalling strategies
List<ObjectMarshallingStrategy> new_oms = new ArrayList<ObjectMarshallingStrategy>();
new_oms.add(new SerializerObjectMarshallingStrategy(SerializerFactory.create(FormatType.JSON, null, true)));
ObjectMarshallingStrategy[] old_oms = (ObjectMarshallingStrategy[])env.get(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES);
if (old_oms != null) {
for (int i=0; i < old_oms.length; i++) {
if (old_oms[i] != null) {
new_oms.add(old_oms[i]);
}
}
}
env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new_oms.toArray(new ObjectMarshallingStrategy[new_oms.size()]));
// apply any overrides
if (overrides != null) {
for (Map.Entry<String, Object> entry : overrides.entrySet()) {
env.set(entry.getKey(), entry.getValue());
}
}
return env;
}