Example usage for org.apache.commons.configuration.event ConfigurationEvent getPropertyName

List of usage examples for org.apache.commons.configuration.event ConfigurationEvent getPropertyName

Introduction

In this page you can find the example usage for org.apache.commons.configuration.event ConfigurationEvent getPropertyName.

Prototype

public String getPropertyName() 

Source Link

Document

Returns the name of the affected property.

Usage

From source file:gov.nih.nci.security.authentication.LockoutConfigurationListener.java

@Override
public void configurationChanged(ConfigurationEvent event) {

    if (!event.isBeforeUpdate()) {
        // only display events after the modification was done
        LockoutManager lockoutManager = LockoutManager.getInstance();
        if (event.getPropertyName() != null
                && event.getPropertyName().equalsIgnoreCase("PASSWORD_LOCKOUT_TIME")) {
            if (event.getPropertyValue() != null) {
                String[] st = (String[]) event.getPropertyValue();
                lockoutManager.setLockoutTime((Long.parseLong(st[0])));
            }//from  w ww .  j a  v  a2s.co  m
        }
        if (event.getPropertyName() != null && event.getPropertyName().equalsIgnoreCase("ALLOWED_LOGIN_TIME")) {
            if (event.getPropertyValue() != null) {
                String[] st = (String[]) event.getPropertyValue();
                lockoutManager.setAllowedLoginTime(Long.parseLong(st[0]));
            }
        }
        if (event.getPropertyName() != null && event.getPropertyName().equalsIgnoreCase("ALLOWED_ATTEMPTS")) {
            if (event.getPropertyValue() != null) {
                String[] st = (String[]) event.getPropertyValue();
                lockoutManager.setAllowedAttempts(Integer.parseInt(st[0]));
            }
        }
        LockoutManager lockoutManager2 = LockoutManager.getInstance();
    }
}

From source file:hu.netmind.beankeeper.db.impl.ConnectionSourceImpl.java

public void configurationChanged(ConfigurationEvent event) {
    if ("beankeeper.pool.connection_timeout".equals(event.getPropertyName()))
        configurationReload();/*from  w  ww  .j av a2  s . com*/
}

From source file:com.netflix.config.ConcurrentMapConfigurationTest.java

@Test
public void testListeners() {
    ConcurrentMapConfiguration conf = new ConcurrentMapConfiguration();
    final AtomicReference<ConfigurationEvent> eventRef = new AtomicReference<ConfigurationEvent>();
    conf.addConfigurationListener(new ConfigurationListener() {
        @Override/*w  ww .ja v  a 2  s  .co m*/
        public void configurationChanged(ConfigurationEvent arg0) {
            eventRef.set(arg0);
        }

    });
    conf.addProperty("key", "1");
    assertEquals(1, conf.getInt("key"));
    ConfigurationEvent event = eventRef.get();
    assertEquals("key", event.getPropertyName());
    assertEquals("1", event.getPropertyValue());
    assertTrue(conf == event.getSource());
    assertEquals(AbstractConfiguration.EVENT_ADD_PROPERTY, event.getType());
    conf.setProperty("key", "2");
    event = eventRef.get();
    assertEquals("key", event.getPropertyName());
    assertEquals("2", event.getPropertyValue());
    assertTrue(conf == event.getSource());
    assertEquals(AbstractConfiguration.EVENT_SET_PROPERTY, event.getType());
    conf.clearProperty("key");
    event = eventRef.get();
    assertEquals("key", event.getPropertyName());
    assertNull(event.getPropertyValue());
    assertTrue(conf == event.getSource());
    assertEquals(AbstractConfiguration.EVENT_CLEAR_PROPERTY, event.getType());
    conf.clear();
    assertFalse(conf.getKeys().hasNext());
    event = eventRef.get();
    assertTrue(conf == event.getSource());
    assertEquals(AbstractConfiguration.EVENT_CLEAR, event.getType());
}

From source file:it.grid.storm.authz.sa.conf.FileAuthzDBListener.java

/**
 * configurationChanged/*from  www .  j  ava2s  .  co  m*/
 * 
 * @param configurationEvent
 *          ConfigurationEvent
 */
public void configurationChanged(ConfigurationEvent configurationEvent) {

    if (!configurationEvent.isBeforeUpdate()) {
        // only display events after the modification was done
        log.debug("Authz DB File {} is changed!", authzFileName);
        log.debug("  - Type = {}" + configurationEvent.getType());
        if (configurationEvent.getPropertyName() != null) {
            log.debug("Property name = {}", configurationEvent.getPropertyName());
        }
        if (configurationEvent.getPropertyValue() != null) {
            log.debug("Property value = {}", configurationEvent.getPropertyValue());
        }
    }
}

From source file:com.netflix.config.ExpandedConfigurationListenerAdapter.java

/**
 * {@inheritDoc}//w  w w  .  ja  v a 2s . c  o  m
 * @see ConfigurationListener#configurationChanged(ConfigurationEvent)
 */
@SuppressWarnings("unchecked")
@Override
public void configurationChanged(final ConfigurationEvent event) {

    if (pauseListener) {
        return;
    }

    // Grab the event information. Some values may be null.
    final Object source = event.getSource();
    final String name = event.getPropertyName();
    final Object value = event.getPropertyValue();
    final boolean beforeUpdate = event.isBeforeUpdate();

    // Handle the different types.
    switch (event.getType()) {

    // Key identifies node where the Collection of nodes was added, or
    // null if it was at the root.
    case HierarchicalConfiguration.EVENT_ADD_NODES:
    case ConcurrentCompositeConfiguration.EVENT_CONFIGURATION_SOURCE_CHANGED:
        expandedListener.configSourceLoaded(source);
        break;

    // Key identifies the individual property that was added.
    case AbstractConfiguration.EVENT_ADD_PROPERTY:
        expandedListener.addProperty(source, name, value, beforeUpdate);
        break;

    // Entire configuration was cleared.
    case AbstractConfiguration.EVENT_CLEAR:
        expandedListener.clear(source, beforeUpdate);
        break;

    // Key identifies the single property that was cleared.
    case AbstractConfiguration.EVENT_CLEAR_PROPERTY:
        expandedListener.clearProperty(source, name, value, beforeUpdate);
        break;

    // Key identifies the nodes that were removed, along with all its
    // children. Value after update is the List of nodes that were
    // cleared. Before the update, the value is null.
    case HierarchicalConfiguration.EVENT_CLEAR_TREE:
        // Ignore this. We rewrote the clearTree() method below.
        break;

    // The current property set is invalid.
    case CombinedConfiguration.EVENT_COMBINED_INVALIDATE:
        //listener.configSourceLoaded(source);
        break;

    // Key identifies the property that was read.
    case AbstractConfiguration.EVENT_READ_PROPERTY:
        break;

    // Key identifies the property that was set.
    case AbstractConfiguration.EVENT_SET_PROPERTY:
        expandedListener.setProperty(source, name, value, beforeUpdate);
        break;

    default:
        break;
    }
}

From source file:com.jkoolcloud.tnt4j.repository.FileTokenRepository.java

@Override
public void configurationChanged(ConfigurationEvent event) {
    if (event.isBeforeUpdate())
        return;// w ww.ja va  2  s .c o m
    logger.log(OpLevel.DEBUG, "configurationChanged: type={0}, {1}:{2}", event.getType(),
            event.getPropertyName(), event.getPropertyValue());
    switch (event.getType()) {
    case AbstractConfiguration.EVENT_ADD_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_ADD_KEY,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_SET_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_SET_KEY,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_CLEAR_PROPERTY:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(),
                TokenRepository.EVENT_CLEAR_KEY, event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractConfiguration.EVENT_CLEAR:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_CLEAR,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    case AbstractFileConfiguration.EVENT_RELOAD:
        repListener.repositoryChanged(new TokenRepositoryEvent(event.getSource(), TokenRepository.EVENT_RELOAD,
                event.getPropertyName(), event.getPropertyValue(), null));
        break;
    }
}

From source file:hu.netmind.beankeeper.cache.impl.MinimalResultsCache.java

public void configurationChanged(ConfigurationEvent event) {
    if ((event.getPropertyName() != null) && (event.getPropertyName().startsWith("beankeeper.cache")))
        configurationReload();//  ww w  . j av a 2s  . co m
}

From source file:net.pms.encoders.AviSynthFFmpeg.java

@Override
protected JComponent config(String languageLabel) {
    FormLayout layout = new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.EMPTY);/*from   w  w w  . ja v a 2  s. com*/
    builder.opaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString(languageLabel), cc.xyw(2, 1, 1));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"),
            configuration.isFfmpegAviSynthMultithreading());
    multithreading.setContentAreaFilled(false);
    multithreading.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setFfmpegAviSynthMultithreading(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3));

    interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"),
            configuration.getFfmpegAvisynthInterFrame());
    interframe.setContentAreaFilled(false);
    interframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            configuration.setFfmpegAvisynthInterFrame(interframe.isSelected());
            if (configuration.getFfmpegAvisynthInterFrame()) {
                JOptionPane.showMessageDialog(
                        SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()),
                        Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"),
                        JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5));

    interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"),
            configuration.getFfmpegAvisynthInterFrameGPU());
    interframegpu.setContentAreaFilled(false);
    interframegpu.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setFfmpegAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7));

    convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"),
            configuration.getFfmpegAvisynthConvertFps());
    convertfps.setContentAreaFilled(false);
    convertfps.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setFfmpegAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9));

    configuration.addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            if (event.getPropertyName() == null) {
                return;
            }
            if ((!event.isBeforeUpdate())
                    && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) {
                interframegpu.setEnabled(configuration.isGPUAcceleration());
            }
        }
    });

    return builder.getPanel();
}

From source file:hu.netmind.beankeeper.modification.impl.ModificationTrackerImpl.java

public void configurationChanged(ConfigurationEvent event) {
    if ((event.getPropertyName() != null)
            && (event.getPropertyName().startsWith("beankeeper.cache.modification_")))
        configurationReload();//ww  w .  j a  v  a  2  s.c o m
}

From source file:com.twitter.distributedlog.service.stream.limiter.DynamicRequestLimiter.java

public DynamicRequestLimiter(DynamicDistributedLogConfiguration dynConf, StatsLogger statsLogger,
        Feature rateLimitDisabledFeature) {
    final StatsLogger limiterStatsLogger = statsLogger.scope("dynamic");
    this.dynConf = dynConf;
    this.rateLimitDisabledFeature = rateLimitDisabledFeature;
    this.listener = new ConfigurationListener() {
        @Override/*from   ww w.  j  a  v  a2  s  .co m*/
        public void configurationChanged(ConfigurationEvent event) {
            // Note that this method may be called several times if several config options
            // are changed. The effect is harmless except that we create and discard more
            // objects than we need to.
            LOG.debug("Config changed callback invoked with event {} {} {} {}",
                    new Object[] { event.getPropertyName(), event.getPropertyValue(), event.getType(),
                            event.isBeforeUpdate() });
            if (!event.isBeforeUpdate()) {
                limiterStatsLogger.getCounter("config_changed").inc();
                LOG.debug("Rebuilding limiter");
                limiter = build();
            }
        }
    };
    LOG.debug("Registering config changed callback");
    dynConf.addConfigurationListener(listener);
}