Search in sources :

Example 1 with PluggableFactoryLoader

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");
    }
}
Also used : SystemOutMessageLogger(org.apache.qpid.server.logging.SystemOutMessageLogger) MessageLogger(org.apache.qpid.server.logging.MessageLogger) LoggingMessageLogger(org.apache.qpid.server.logging.LoggingMessageLogger) LoggingMessageLogger(org.apache.qpid.server.logging.LoggingMessageLogger) SystemConfigFactory(org.apache.qpid.server.plugin.SystemConfigFactory) PluggableFactoryLoader(org.apache.qpid.server.plugin.PluggableFactoryLoader)

Example 2 with PluggableFactoryLoader

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);
    }
}
Also used : IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) ConfigurationSecretEncrypterFactory(org.apache.qpid.server.plugin.ConfigurationSecretEncrypterFactory) PluggableFactoryLoader(org.apache.qpid.server.plugin.PluggableFactoryLoader)

Example 3 with PluggableFactoryLoader

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;
}
Also used : SystemConfig(org.apache.qpid.server.model.SystemConfig) AbstractSystemConfig(org.apache.qpid.server.model.AbstractSystemConfig) DurableConfigurationStore(org.apache.qpid.server.store.DurableConfigurationStore) HashMap(java.util.HashMap) EventLogger(org.apache.qpid.server.logging.EventLogger) SystemConfigFactory(org.apache.qpid.server.plugin.SystemConfigFactory) ConfiguredObject(org.apache.qpid.server.model.ConfiguredObject) ConfiguredObjectRecord(org.apache.qpid.server.store.ConfiguredObjectRecord) PluggableFactoryLoader(org.apache.qpid.server.plugin.PluggableFactoryLoader)

Aggregations

PluggableFactoryLoader (org.apache.qpid.server.plugin.PluggableFactoryLoader)3 SystemConfigFactory (org.apache.qpid.server.plugin.SystemConfigFactory)2 HashMap (java.util.HashMap)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 EventLogger (org.apache.qpid.server.logging.EventLogger)1 LoggingMessageLogger (org.apache.qpid.server.logging.LoggingMessageLogger)1 MessageLogger (org.apache.qpid.server.logging.MessageLogger)1 SystemOutMessageLogger (org.apache.qpid.server.logging.SystemOutMessageLogger)1 AbstractSystemConfig (org.apache.qpid.server.model.AbstractSystemConfig)1 ConfiguredObject (org.apache.qpid.server.model.ConfiguredObject)1 SystemConfig (org.apache.qpid.server.model.SystemConfig)1 ConfigurationSecretEncrypterFactory (org.apache.qpid.server.plugin.ConfigurationSecretEncrypterFactory)1 ConfiguredObjectRecord (org.apache.qpid.server.store.ConfiguredObjectRecord)1 DurableConfigurationStore (org.apache.qpid.server.store.DurableConfigurationStore)1