use of org.apache.qpid.server.plugin.PluggableFactoryLoader in project qpid-broker-j by apache.
the class SystemLauncher method startupImpl.
private void startupImpl(Map<String, Object> systemConfigAttributes) throws Exception {
populateSystemPropertiesFromDefaults((String) systemConfigAttributes.get(SystemConfig.INITIAL_SYSTEM_PROPERTIES_LOCATION));
String storeType = (String) systemConfigAttributes.get(SystemConfig.TYPE);
// Create the RootLogger to be used during broker operation
boolean statusUpdatesEnabled = Boolean.parseBoolean(System.getProperty(SystemConfig.PROPERTY_STATUS_UPDATES, "true"));
MessageLogger messageLogger = new LoggingMessageLogger(statusUpdatesEnabled);
_eventLogger.setMessageLogger(messageLogger);
PluggableFactoryLoader<SystemConfigFactory> configFactoryLoader = new PluggableFactoryLoader<>(SystemConfigFactory.class);
SystemConfigFactory configFactory = configFactoryLoader.get(storeType);
if (configFactory == null) {
LOGGER.error("Unknown config store type '" + storeType + "', only the following types are supported: " + configFactoryLoader.getSupportedTypes());
throw new IllegalArgumentException("Unknown config store type '" + storeType + "', only the following types are supported: " + configFactoryLoader.getSupportedTypes());
}
_taskExecutor.start();
_systemConfig = configFactory.newInstance(_taskExecutor, _eventLogger, _systemPrincipal, systemConfigAttributes);
_systemConfig.setOnContainerResolveTask(new Runnable() {
@Override
public void run() {
_listener.onContainerResolve(_systemConfig);
}
});
_systemConfig.setOnContainerCloseTask(new Runnable() {
@Override
public void run() {
_listener.onContainerClose(_systemConfig);
}
});
_systemConfig.open();
if (_systemConfig.getContainer().getState() == State.ERRORED) {
throw new RuntimeException("Closing due to errors");
}
}
use of org.apache.qpid.server.plugin.PluggableFactoryLoader in project qpid-broker-j by apache.
the class AbstractContainer method updateEncrypter.
private void updateEncrypter(final String encryptionProviderType) {
if (encryptionProviderType != null && !"".equals(encryptionProviderType.trim())) {
PluggableFactoryLoader<ConfigurationSecretEncrypterFactory> factoryLoader = new PluggableFactoryLoader<>(ConfigurationSecretEncrypterFactory.class);
ConfigurationSecretEncrypterFactory factory = factoryLoader.get(encryptionProviderType);
if (factory == null) {
throw new IllegalConfigurationException("Unknown Configuration Secret Encryption method " + encryptionProviderType);
}
setEncrypter(factory.createEncrypter(this));
} else {
setEncrypter(null);
}
}
use of org.apache.qpid.server.plugin.PluggableFactoryLoader in project qpid-broker-j by apache.
the class TestBrokerConfiguration method save.
public boolean save(File configFile) {
Map<String, Object> attributes = new HashMap<>();
attributes.put("storePath", configFile.getAbsolutePath());
SystemConfigFactory configFactory = (new PluggableFactoryLoader<>(SystemConfigFactory.class)).get(_storeType);
attributes.put(SystemConfig.STARTUP_LOGGED_TO_SYSTEM_OUT, false);
attributes.put(ConfiguredObject.DESIRED_STATE, State.QUIESCED);
final SystemConfig parentObject = configFactory.newInstance(_taskExecutor, mock(EventLogger.class), null, attributes);
parentObject.open();
DurableConfigurationStore configurationStore = parentObject.getConfigurationStore();
configurationStore.closeConfigurationStore();
final List<ConfiguredObjectRecord> records = getConfiguredObjectRecords();
configurationStore.init(parentObject);
clearStore(configurationStore);
configurationStore.update(true, records.toArray(new ConfiguredObjectRecord[records.size()]));
configurationStore.closeConfigurationStore();
parentObject.close();
return true;
}
Aggregations