try {
// Only when specified starter be created and invoked.
if (when != Integer.parseInt(ele.getAttribute("when")))
continue;
IEarlyStarter starter = (IEarlyStarter) ele
.createExecutableExtension("class");
int priority = Integer.parseInt(ele
.getAttribute("priority"));
map.put(starter, priority);
} catch (Exception e) {
// e.printStackTrace();
fwkActivator.log(e);
}
}
}
// Sort starters by their priority integer, the smaller one is be
// invoked at first.
List<IEarlyStarter> starters = new ArrayList<IEarlyStarter>(map
.keySet());
Collections.sort(starters, new Comparator<IEarlyStarter>() {
public int compare(IEarlyStarter o1, IEarlyStarter o2) {
return (map.get(o1) > map.get(o2)) ? -1 : 0;
}
});
for (IEarlyStarter starter : starters) {
try {
starter.start();
} catch (Exception e) {
fwkActivator.log(e);
}
}
}