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);
}
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);
}
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();
}
}
}
}
Aggregations