use of org.apache.qpid.server.model.ConfiguredObject 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.model.ConfiguredObject 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();
}
}
}
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class JsonFilePreferenceStoreFactoryService method createInstance.
@Override
public PreferenceStore createInstance(final ConfiguredObject<?> parent, final Map<String, Object> preferenceStoreAttributes) {
final Object path = preferenceStoreAttributes.get(PATH);
if (path == null || !(path instanceof String)) {
throw new IllegalConfigurationException("JsonFilePreferenceStore requires path");
}
final String posixFilePermissions = parent.getContextValue(String.class, SystemConfig.POSIX_FILE_PERMISSIONS);
return new JsonFilePreferenceStore((String) path, posixFilePermissions);
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class ConfiguredObjectRecordConverter method loadChild.
private Collection<NameToIdResolver> loadChild(final Class<? extends ConfiguredObject> clazz, final Map<String, Object> data, final Class<? extends ConfiguredObject> parentClass, final UUID parentId, final Map<UUID, ConfiguredObjectRecord> records) {
String idStr = (String) data.remove("id");
final UUID id = idStr == null ? UUID.randomUUID() : UUID.fromString(idStr);
final String type = clazz.getSimpleName();
Map<String, UUID> parentMap = new HashMap<>();
Collection<Class<? extends ConfiguredObject>> childClasses = _model.getChildTypes(clazz);
List<NameToIdResolver> requiringResolution = new ArrayList<>();
for (Class<? extends ConfiguredObject> childClass : childClasses) {
final String childType = childClass.getSimpleName();
String singularName = childType.toLowerCase();
String attrName = singularName + (singularName.endsWith("s") ? "es" : "s");
Object children = data.remove(attrName);
if (children != null) {
if (children instanceof Collection) {
for (Object child : (Collection) children) {
if (child instanceof Map) {
requiringResolution.addAll(loadChild(childClass, (Map) child, clazz, id, records));
}
}
}
}
}
if (parentId != null) {
parentMap.put(parentClass.getSimpleName(), parentId);
}
records.put(id, new ConfiguredObjectRecordImpl(id, type, data, parentMap));
return requiringResolution;
}
use of org.apache.qpid.server.model.ConfiguredObject in project qpid-broker-j by apache.
the class AncestorAttributeResolverTest method testResolveAncestorAttributeOfTypeConfiguredObject.
@Test
public void testResolveAncestorAttributeOfTypeConfiguredObject() throws Exception {
Map<String, Object> carAttributes = new HashMap<>();
carAttributes.put(ConfiguredObject.NAME, CAR_NAME);
carAttributes.put(ConfiguredObject.TYPE, TestKitCarImpl.TEST_KITCAR_TYPE);
carAttributes.put("alternateEngine", _engine);
_car = _model.getObjectFactory().create(TestCar.class, carAttributes, null);
_ancestorAttributeResolver = new AncestorAttributeResolver(_car);
String actual = _ancestorAttributeResolver.resolve("ancestor:testcar:alternateEngine", null);
assertEquals("Unexpected resolved ancestor attribute of type ConfiguredObject", _engine.getId().toString(), actual);
}
Aggregations