use of com.swiftmq.ms.MessageSelector in project swiftmq-ce by iitsoftware.
the class ManagementProcessor method register.
public void register() throws Exception {
if (input.getSelector() != null) {
messageSelector = new MessageSelector(input.getSelector());
messageSelector.compile();
}
String[] name = SwiftUtilities.tokenize(input.context(), "/");
if (input.context().equals("/")) {
// Root node
entityList = RouterConfiguration.Singleton();
entityList.addEntityWatchListener(this);
ctx.ctx.mgmtSwiftlet.fireEvent(true);
} else if (name.length == 1) {
// A top-level swiftlet
entity = (Entity) RouterConfiguration.Singleton().getContext(null, name, 0);
if (entity == null)
throw new NullPointerException("CLI context not found: " + input.context());
entityPropWatchListener = new AllPropertyWatchListener(entity).register();
ctx.ctx.mgmtSwiftlet.fireEvent(true);
} else {
// Any other context
String[] context = SwiftUtilities.cutLast(name);
Entity e = (Entity) RouterConfiguration.Singleton().getContext(null, context, 0);
if (e == null)
throw new NullPointerException("CLI context not found: " + input.context());
property = e.getProperty(name[name.length - 1]);
if (property != null) {
// Found a property
propertyValueChanged(property);
property.addPropertyWatchListener(this);
ctx.ctx.mgmtSwiftlet.fireEvent(true);
} else {
// Found an entity
Entity child = e.getEntity(name[name.length - 1]);
if (child != null) {
if (child instanceof EntityList) {
entityList = (EntityList) child;
Map entities = entityList.getEntities();
if (entities != null) {
for (Iterator iter = entities.entrySet().iterator(); iter.hasNext(); ) {
entityAdded(entityList, (Entity) ((Map.Entry) iter.next()).getValue());
}
}
entityList.addEntityWatchListener(this);
ctx.ctx.mgmtSwiftlet.fireEvent(true);
} else {
entity = child;
entityPropWatchListener = new AllPropertyWatchListener(entity).register();
ctx.ctx.mgmtSwiftlet.fireEvent(true);
}
} else
throw new NullPointerException("Nothing found at CLI context: " + input.context());
}
}
}
Aggregations