private String getDefaultURI() { // default brokerURI return "vm://" + config.getConfiguration(JMSConfiguration.INSTANCE_NAME_KEY) + "?create=false&waitForStart=5000"; }
@Override protected Object handleObjectGet() throws Exception { return config.getConfigurations(); }
@Override public boolean override(JMSConfiguration config) throws IOException { return config.override(CONFIGDIR_KEY, JMSConfiguration.getConfigPathDir().toString()); }
@Override public void initDefaults(JMSConfiguration config) throws IOException { config.putConfiguration(CONFIGDIR_KEY, JMSConfiguration.getConfigPathDir().toString()); }
private void init() throws IOException { try { loadConfig(); if (configuration.isEmpty()) { initDefaults(); boolean override = override(); if (exts != null) { for (JMSConfigurationExt ext : exts) { storeConfig(); initDefaults(); storeConfig(); } catch (IOException e) { LOGGER.severe("Unable to store properties");
private void init() { max = Integer.parseInt(config.getConfiguration( ConnectionConfiguration.CONNECTION_RETRY_KEY).toString()); maxWait = Long.parseLong(config.getConfiguration( ConnectionConfiguration.CONNECTION_MAXWAIT_KEY).toString()); if (!isEmbeddedBrokerStarted()) { try { if (!startEmbeddedBroker(config.getConfigurations())) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe("Unable to start the embedded brokerURI, force status to disabled"); config.putConfiguration( ConnectionConfiguration.CONNECTION_KEY, ConnectionConfigurationStatus.disabled LOGGER.log(Level.SEVERE, e.getMessage(), e); config.putConfiguration( ConnectionConfiguration.CONNECTION_KEY, ConnectionConfigurationStatus.disabled.toString()); config.storeConfig(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e);
@Override public void initDefaults(JMSConfiguration config) throws IOException { String url = null; config.putConfiguration(TOPIC_NAME_KEY, url != null ? url : DEFAULT_TOPIC_NAME); config.putConfiguration(DURABLE_KEY, url != null ? url : DEFAULT_DURABLE_NAME); }
@Override public void onApplicationEvent(ContextRefreshedEvent event) { if (event.getApplicationContext() == applicationContext) { final String startString = config .getConfiguration(ConnectionConfiguration.CONNECTION_KEY); if (startString != null && startString.equals(ConnectionConfigurationStatus.enabled.toString())) { if (!connect()) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe("Unable to connect to the broker, force connection status to disabled"); } // change configuration status config.putConfiguration(ConnectionConfiguration.CONNECTION_KEY, ConnectionConfigurationStatus.disabled.toString()); // store changes to the configuration try { config.storeConfig(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } } } } }
final String value = props.get(key).toString(); config.putConfiguration(key.toString(), value); final Object oldValue = config.getConfiguration(k); if (props.get(k).equals(oldValue)) continue;
/** * Override the global config dir * @throws IOException */ @PostConstruct private void init() throws IOException { // check for override File baseDir=null; final String baseDirPath = JMSConfiguration.getOverride(CONFIGDIR_KEY); // if no override try to load from the GeoServer loader if (baseDirPath != null) { baseDir = new File(baseDirPath); } else { baseDir = loader.getBaseDirectory(); if (baseDir != null) { baseDir = new File(baseDir, "cluster"); } } if (baseDir != null) { if (!baseDir.exists() && !baseDir.mkdirs()) { throw new IOException("Unable to create directory: " + baseDir); } } JMSConfiguration.setConfigPathDir(baseDir); }
@Override public void afterPropertiesSet() throws Exception { File properties = new File(config.getConfiguration(EmbeddedBrokerConfiguration.EMBEDDED_BROKER_PROPERTIES_KEY).toString()); if (!properties.isAbsolute() && !properties.isFile()) { // try to resolve as absolute properties = new File(JMSConfiguration.getConfigPathDir(),properties.getPath()); // copy the defaults InputStream inputStream = null; try{ inputStream = defaults.getInputStream(); IOUtils.copy(inputStream, properties); }finally{ if(inputStream!=null){ org.apache.commons.io.IOUtils.closeQuietly(inputStream); } } } final Resource res = new FileSystemResource(properties); super.setLocation(res); // make sure the activemq.base is set to a valuable default final Properties props=new Properties(); props.setProperty("activemq.base", (String)config.getConfiguration("CLUSTER_CONFIG_DIR")); props.setProperty("instanceName", (String)config.getConfiguration("instanceName")); setProperties(props); }
public void save() throws IOException { config.storeConfig(); } }
/** * check if instance name is changed since last application boot, if so set the overridden value into configuration and returns true */ public final boolean override(String nameKey, Object defaultVal) { boolean override = false; final String ovrName = getOverride(nameKey); if (ovrName != null) { final String name = configuration.getProperty(nameKey); if (name != null && !name.equals(ovrName)) { override = true; } configuration.put(nameKey, ovrName); } else { final String name = configuration.getProperty(nameKey); // no configuration found setup defaults and return override==true if (name == null) { override = true; configuration.put(nameKey, defaultVal); } } return override; }
private void init() throws IOException { try { loadConfig(); if (configuration.isEmpty()) { initDefaults(); storeConfig(); boolean override = override(); if (exts != null) { for (JMSConfigurationExt ext : exts) { storeConfig(); initDefaults(); storeConfig(); } catch (IOException e) { LOGGER.severe("Unable to store properties");
@Override public void initDefaults(JMSConfiguration config) { config.putConfiguration(TOGGLE_MASTER_KEY, DEFAULT_MASTER_STATUS); config.putConfiguration(TOGGLE_SLAVE_KEY, DEFAULT_SLAVE_STATUS); }
@Override public void onApplicationEvent(ContextRefreshedEvent event) { if (event.getApplicationContext() == applicationContext) { final String startString = config.getConfiguration(ConnectionConfiguration.CONNECTION_KEY); if (startString != null && startString.equals(ConnectionConfigurationStatus.enabled.toString())) { if (!connect()) { if (LOGGER.isLoggable(Level.SEVERE)) { LOGGER.severe( "Unable to connect to the broker, force connection status to disabled"); } // change configuration status config.putConfiguration( ConnectionConfiguration.CONNECTION_KEY, ConnectionConfigurationStatus.disabled.toString()); // store changes to the configuration try { config.storeConfig(); } catch (IOException e) { LOGGER.log(Level.SEVERE, e.getMessage(), e); } } } } } }
@Override public void onSubmit() { try { getConfig().storeConfig(); fp.info("Configuration saved"); } catch (IOException e) { if (LOGGER.isLoggable(java.util.logging.Level.SEVERE)) LOGGER.severe(e.getLocalizedMessage()); fp.error(e.getLocalizedMessage()); } } };
/** * check if instance name is changed since last application boot, if so set the overridden value * into configuration and returns true */ public final boolean override(String nameKey, Object defaultVal) { boolean override = false; final String ovrName = getOverride(nameKey); if (ovrName != null) { final String name = configuration.getProperty(nameKey); if (name != null && !name.equals(ovrName)) { override = true; } configuration.put(nameKey, ovrName); } else { final String name = configuration.getProperty(nameKey); // no configuration found setup defaults and return override==true if (name == null) { override = true; configuration.put(nameKey, defaultVal); } } return override; }
@Override public void initDefaults(JMSConfiguration config) throws IOException { config.putConfiguration(READ_ONLY_KEY, DEFAULT_READ_ONLY_VALUE); }