use of org.kie.internal.runtime.conf.ObjectModel in project jbpm by kiegroup.
the class DeploymentDescriptorMerger method merge.
public DeploymentDescriptor merge(DeploymentDescriptor master, DeploymentDescriptor slave, MergeMode mode) {
if (master == null || slave == null) {
throw new IllegalArgumentException("Descriptors to merge must be provided");
}
DeploymentDescriptor merged = null;
DeploymentDescriptorBuilder builder = master.getBuilder();
builder.setBuildHandler(new MergeModeBuildHandler(mode));
switch(mode) {
case KEEP_ALL:
// do nothing as master wins
merged = master;
break;
case OVERRIDE_ALL:
// do nothing as slave wins
merged = slave;
break;
case OVERRIDE_EMPTY:
builder.auditMode(slave.getAuditMode());
builder.auditPersistenceUnit(slave.getAuditPersistenceUnit());
builder.persistenceMode(slave.getPersistenceMode());
builder.persistenceUnit(slave.getPersistenceUnit());
builder.runtimeStrategy(slave.getRuntimeStrategy());
builder.setConfiguration(slave.getConfiguration());
builder.setEnvironmentEntries(slave.getEnvironmentEntries());
builder.setEventListeners(slave.getEventListeners());
builder.setGlobals(slave.getGlobals());
builder.setMarshalingStrategies(slave.getMarshallingStrategies());
builder.setTaskEventListeners(slave.getTaskEventListeners());
builder.setWorkItemHandlers(slave.getWorkItemHandlers());
builder.setRequiredRoles(slave.getRequiredRoles());
builder.setClasses(slave.getClasses());
builder.setLimitSerializationClasses(slave.getLimitSerializationClasses());
merged = builder.get();
break;
case MERGE_COLLECTIONS:
builder.auditMode(slave.getAuditMode());
builder.auditPersistenceUnit(slave.getAuditPersistenceUnit());
builder.persistenceMode(slave.getPersistenceMode());
builder.persistenceUnit(slave.getPersistenceUnit());
builder.runtimeStrategy(slave.getRuntimeStrategy());
for (ObjectModel model : slave.getEventListeners()) {
builder.addEventListener(model);
}
for (ObjectModel model : slave.getMarshallingStrategies()) {
builder.addMarshalingStrategy(model);
}
for (ObjectModel model : slave.getTaskEventListeners()) {
builder.addTaskEventListener(model);
}
for (NamedObjectModel model : slave.getConfiguration()) {
builder.addConfiguration(model);
}
for (NamedObjectModel model : slave.getEnvironmentEntries()) {
builder.addEnvironmentEntry(model);
}
for (NamedObjectModel model : slave.getGlobals()) {
builder.addGlobal(model);
}
for (NamedObjectModel model : slave.getWorkItemHandlers()) {
builder.addWorkItemHandler(model);
}
for (String requiredRole : slave.getRequiredRoles()) {
builder.addRequiredRole(requiredRole);
}
for (String clazz : slave.getClasses()) {
builder.addClass(clazz);
}
Boolean slaveLimit = slave.getLimitSerializationClasses();
Boolean masterLimit = master.getLimitSerializationClasses();
if (slaveLimit != null && masterLimit != null && (!slaveLimit || !masterLimit)) {
builder.setLimitSerializationClasses(false);
}
merged = builder.get();
break;
default:
break;
}
return merged;
}
Aggregations