Search in sources :

Example 1 with StoreConfigurationChangeListener

use of org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener in project qpid-broker-j by apache.

the class VirtualHostTest method setUp.

@Before
public void setUp() throws Exception {
    _broker = BrokerTestHelper.createBrokerMock();
    _taskExecutor = new CurrentThreadTaskExecutor();
    _taskExecutor.start();
    when(_broker.getTaskExecutor()).thenReturn(_taskExecutor);
    when(_broker.getChildExecutor()).thenReturn(_taskExecutor);
    Principal systemPrincipal = ((SystemPrincipalSource) _broker).getSystemPrincipal();
    _virtualHostNode = BrokerTestHelper.mockWithSystemPrincipalAndAccessControl(VirtualHostNode.class, systemPrincipal, _mockAccessControl);
    when(_virtualHostNode.getParent()).thenReturn(_broker);
    when(_virtualHostNode.getCategoryClass()).thenReturn(VirtualHostNode.class);
    when(_virtualHostNode.isDurable()).thenReturn(true);
    _configStore = mock(DurableConfigurationStore.class);
    _storeConfigurationChangeListener = new StoreConfigurationChangeListener(_configStore);
    when(_virtualHostNode.getConfigurationStore()).thenReturn(_configStore);
    // Virtualhost needs the EventLogger from the SystemContext.
    when(_virtualHostNode.getParent()).thenReturn(_broker);
    ConfiguredObjectFactory objectFactory = _broker.getObjectFactory();
    when(_virtualHostNode.getModel()).thenReturn(objectFactory.getModel());
    when(_virtualHostNode.getTaskExecutor()).thenReturn(_taskExecutor);
    when(_virtualHostNode.getChildExecutor()).thenReturn(_taskExecutor);
    _preferenceStore = mock(PreferenceStore.class);
    when(_virtualHostNode.createPreferenceStore()).thenReturn(_preferenceStore);
}
Also used : DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) CurrentThreadTaskExecutor(org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor) Principal(java.security.Principal) AuthenticatedPrincipal(org.apache.qpid.server.security.auth.AuthenticatedPrincipal) PreferenceStore(org.apache.qpid.server.store.preferences.PreferenceStore) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener) Before(org.junit.Before)

Example 2 with StoreConfigurationChangeListener

use of org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener in project qpid-broker-j by apache.

the class BrokerStoreUpgraderAndRecoverer method upgradeAndRecover.

@Override
public Broker<?> upgradeAndRecover(List<ConfiguredObjectRecord> records) {
    final DurableConfigurationStore store = _systemConfig.getConfigurationStore();
    List<ConfiguredObjectRecord> upgradedRecords = upgrade(store, records);
    new GenericRecoverer(_systemConfig).recover(upgradedRecords, false);
    final StoreConfigurationChangeListener configChangeListener = new StoreConfigurationChangeListener(store);
    applyRecursively(_systemConfig.getContainer(Broker.class), new RecursiveAction<ConfiguredObject<?>>() {

        @Override
        public void performAction(final ConfiguredObject<?> object) {
            object.addChangeListener(configChangeListener);
        }

        @Override
        public boolean applyToChildren(ConfiguredObject<?> object) {
            return !object.managesChildStorage();
        }
    });
    return _systemConfig.getContainer(Broker.class);
}
Also used : Broker(org.apache.qpid.server.model.Broker) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) StoreConfigurationChangeListener(org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener)

Example 3 with StoreConfigurationChangeListener

use of org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener 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

StoreConfigurationChangeListener (org.apache.qpid.server.configuration.store.StoreConfigurationChangeListener)3 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)2 Principal (java.security.Principal)1 CurrentThreadTaskExecutor (org.apache.qpid.server.configuration.updater.CurrentThreadTaskExecutor)1 AbstractConfigurationChangeListener (org.apache.qpid.server.model.AbstractConfigurationChangeListener)1 AbstractConfiguredObject (org.apache.qpid.server.model.AbstractConfiguredObject)1 Broker (org.apache.qpid.server.model.Broker)1 VirtualHost (org.apache.qpid.server.model.VirtualHost)1 VirtualHostNode (org.apache.qpid.server.model.VirtualHostNode)1 AuthenticatedPrincipal (org.apache.qpid.server.security.auth.AuthenticatedPrincipal)1 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1 PreferenceStore (org.apache.qpid.server.store.preferences.PreferenceStore)1 Before (org.junit.Before)1