Search in sources :

Example 1 with PropertyWatchListener

use of com.swiftmq.mgmt.PropertyWatchListener in project swiftmq-ce by iitsoftware.

the class MessageQueue method setQueueController.

void setQueueController(Entity queueController) {
    watchListeners = new ArrayList();
    Property prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE);
    PropertyWatchListener l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            cache.setMaxMessages(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CACHE_SIZE_BYTES_KB);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            cache.setMaxBytesKB(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CLEANUP_INTERVAL);
    prop = queueController.getProperty(QueueManagerImpl.PROP_MESSAGES_MAXIMUM);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setMaxMessages(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_PERSISTENCE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setPersistenceMode(SwiftUtilities.persistenceModeToInt((String) property.getValue()));
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_FLOWCONTROL_QUEUE_SIZE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            int fcQueueSize = ((Integer) property.getValue()).intValue();
            if (fcQueueSize >= 0)
                setFlowController(new FlowControllerImpl(fcQueueSize, ctx.queueManager.getMaxFlowControlDelay()));
            else
                setFlowController(null);
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_ENABLED);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setDuplicateDetectionEnabled(((Boolean) property.getValue()).booleanValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_DUPLICATE_DETECTION_BACKLOG_SIZE);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setDuplicateDetectionBacklogSize(((Integer) property.getValue()).intValue());
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_CONSUMER);
    l = new PropertyWatchListener() {

        public void propertyValueChanged(Property property) {
            setConsumerMode(ctx.consumerModeInt((String) property.getValue()));
        }
    };
    prop.addPropertyWatchListener(l);
    watchListeners.add(new Object[] { prop, l });
    prop = queueController.getProperty(QueueManagerImpl.PROP_MONITOR_ALERT_THRESHOLD);
    if (prop != null) {
        l = new PropertyWatchListener() {

            public void propertyValueChanged(Property property) {
                setMonitorAlertThreshold(((Integer) property.getValue()).intValue());
            }
        };
        prop.addPropertyWatchListener(l);
        watchListeners.add(new Object[] { prop, l });
    }
}
Also used : PropertyWatchListener(com.swiftmq.mgmt.PropertyWatchListener) Property(com.swiftmq.mgmt.Property)

Example 2 with PropertyWatchListener

use of com.swiftmq.mgmt.PropertyWatchListener in project swiftmq-ce by iitsoftware.

the class MessageQueue method removeWatchListeners.

private void removeWatchListeners() {
    if (watchListeners != null) {
        for (int i = 0; i < watchListeners.size(); i++) {
            Object[] obj = (Object[]) watchListeners.get(i);
            Property p = (Property) obj[0];
            PropertyWatchListener l = (PropertyWatchListener) obj[1];
            p.removePropertyWatchListener(l);
        }
        watchListeners = null;
    }
}
Also used : PropertyWatchListener(com.swiftmq.mgmt.PropertyWatchListener) Property(com.swiftmq.mgmt.Property)

Aggregations

Property (com.swiftmq.mgmt.Property)2 PropertyWatchListener (com.swiftmq.mgmt.PropertyWatchListener)2