Skip to content

Commit

Permalink
Rename handler -> sequence observer
Browse files Browse the repository at this point in the history
  • Loading branch information
chanikag committed Aug 22, 2023
1 parent c274867 commit db17d33
Showing 1 changed file with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public class SequenceFlowObserversLoader {
private static Log log = LogFactory.getLog(SequenceFlowObserversLoader.class);

public static List<SequenceFlowObserver> loadObservers() {
List<SequenceFlowObserver> handlers = new ArrayList<>();
List<SequenceFlowObserver> observers = new ArrayList<>();
OMElement observersConfig =
MiscellaneousUtil.loadXMLConfig(SynapseConstants.SEQUENCE_OBSERVERS_FILE);
if (observersConfig != null) {

if (!ROOT_Q.equals(observersConfig.getQName())) {
handleException("Invalid handler configuration file");
handleException("Invalid sequence observer configuration file");
}

Iterator iterator = observersConfig.getChildrenWithName(OBSERVER_Q);
Expand All @@ -58,42 +58,42 @@ public static List<SequenceFlowObserver> loadObservers() {
if (observerElem.getAttribute(NAME_ATT) != null) {
name = observerElem.getAttributeValue(NAME_ATT);
} else {
handleException("Name not defined in one or more handlers");
handleException("Name not defined in one or more sequence observer");
}

if (observerElem.getAttribute(CLASS_Q) != null) {
String className = observerElem.getAttributeValue(CLASS_Q);
if (!"".equals(className)) {
SequenceFlowObserver observer = createObserver(className);
if (observer != null) {
handlers.add(observer);
observers.add(observer);
observer.setName(name);
}
} else {
handleException("Class name is null for handle name : " + name);
handleException("Class name is null for sequence observer name : " + name);
}
} else {
handleException("Class name not defined for handler named : " + name);
handleException("Class name not defined for sequence observer named : " + name);
}

}
}
return handlers;
return observers;
}

private static SequenceFlowObserver createObserver(String classFQName) {
Object obj = null;
try {
obj = Class.forName(classFQName).newInstance();
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
handleException("Error creating Handler for class name : " + classFQName, e);
handleException("Error creating Sequence observer for class name : " + classFQName, e);
}

if (obj instanceof SequenceFlowObserver) {
return (SequenceFlowObserver) obj;
} else {
handleException("Error creating Handler. The Handler should be of type " +
"org.apache.synapse.Handler");
handleException("Error creating Sequence observer. The Sequence observer should be of type " +
"org.apache.synapse.SequenceFlowObserver");
}
return null;
}
Expand Down

0 comments on commit db17d33

Please sign in to comment.