Search in sources :

Example 31 with MessageSelector

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());
        }
    }
}
Also used : Iterator(java.util.Iterator) MessageSelector(com.swiftmq.ms.MessageSelector) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap)

Aggregations

MessageSelector (com.swiftmq.ms.MessageSelector)31 InvalidSelectorException (javax.jms.InvalidSelectorException)11 QueueImpl (com.swiftmq.jms.QueueImpl)9 InvalidDestinationException (javax.jms.InvalidDestinationException)8 JMSException (javax.jms.JMSException)8 Entity (com.swiftmq.mgmt.Entity)7 Property (com.swiftmq.mgmt.Property)7 MessageImpl (com.swiftmq.jms.MessageImpl)5 TopicImpl (com.swiftmq.jms.TopicImpl)4 IllegalStateException (javax.jms.IllegalStateException)4 QueueReceiver (com.swiftmq.swiftlet.queue.QueueReceiver)3 JobException (com.swiftmq.swiftlet.scheduler.JobException)3 Iterator (java.util.Iterator)3 Map (java.util.Map)3 Message (com.swiftmq.impl.streams.comp.message.Message)2 QueueMessageProcessor (com.swiftmq.impl.streams.processor.QueueMessageProcessor)2 EntityRemoveException (com.swiftmq.mgmt.EntityRemoveException)2 ActiveLogin (com.swiftmq.swiftlet.auth.ActiveLogin)2 AuthenticationException (com.swiftmq.swiftlet.auth.AuthenticationException)2 AbstractQueue (com.swiftmq.swiftlet.queue.AbstractQueue)2