Search in sources :

Example 16 with AbstractConfigurationChangeListener

use of org.apache.qpid.server.model.AbstractConfigurationChangeListener in project qpid-broker-j by apache.

the class VirtualHostStoreUpgraderAndRecoverer method recover.

private void recover(final ConfiguredObject<?> recoveryRoot, final DurableConfigurationStore durableConfigurationStore, final List<ConfiguredObjectRecord> records, final boolean isNew) {
    new GenericRecoverer(recoveryRoot).recover(records, isNew);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(durableConfigurationStore);
    if (_virtualHostNode.getVirtualHost() != null) {
        applyRecursively(_virtualHostNode.getVirtualHost(), new RecursiveAction<ConfiguredObject<?>>() {

            @Override
            public boolean applyToChildren(final ConfiguredObject<?> object) {
                return object.isDurable();
            }

            @Override
            public void performAction(final ConfiguredObject<?> object) {
                object.addChangeListener(configChangeListener);
            }
        });
    }
    if (recoveryRoot instanceof VirtualHostNode) {
        _virtualHostNode.addChangeListener(new AbstractConfigurationChangeListener() {

            @Override
            public void childAdded(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    applyRecursively(child, new RecursiveAction<ConfiguredObject<?>>() {

                        @Override
                        public boolean applyToChildren(final ConfiguredObject<?> object) {
                            return object.isDurable();
                        }

                        @Override
                        public void performAction(final ConfiguredObject<?> object) {
                            if (object.isDurable()) {
                                durableConfigurationStore.update(true, object.asObjectRecord());
                                object.addChangeListener(configChangeListener);
                            }
                        }
                    });
                }
            }

            @Override
            public void childRemoved(final ConfiguredObject<?> object, final ConfiguredObject<?> child) {
                if (child instanceof VirtualHost) {
                    child.removeChangeListener(configChangeListener);
                }
            }
        });
        if (isNew) {
            if (_virtualHostNode instanceof AbstractConfiguredObject) {
                ((AbstractConfiguredObject) _virtualHostNode).forceUpdateAllSecureAttributes();
            }
        }
    }
}
Also used : AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) AbstractConfiguredObject(org.apache.qpid.server.model.AbstractConfiguredObject) VirtualHost(org.apache.qpid.server.model.VirtualHost) VirtualHostNode(org.apache.qpid.server.model.VirtualHostNode) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener) AbstractConfigurationChangeListener(org.apache.qpid.server.model.AbstractConfigurationChangeListener)

Aggregations

AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)16 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)12 State (org.apache.qpid.server.model.State)9 CountDownLatch (java.util.concurrent.CountDownLatch)6 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)5 Durability (com.sleepycat.je.Durability)3 File (java.io.File)3 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)3 ConfigurationChangeListener (org.apache.qpid.server.model.ConfigurationChangeListener)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 LinkedHashMap (java.util.LinkedHashMap)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)2 StoreConfigurationChangeListener (org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener)1 Broker (org.apache.qpid.server.model.Broker)1 ConfiguredObjectFinder (org.apache.qpid.server.model.ConfiguredObjectFinder)1 IllegalStateTransitionException (org.apache.qpid.server.model.IllegalStateTransitionException)1 RemoteReplicationNode (org.apache.qpid.server.model.RemoteReplicationNode)1 TrustStore (org.apache.qpid.server.model.TrustStore)1