PulseAppListener implements ApplicationListener<ApplicationEvent> { public void contextInitialized(ContextRefreshedEvent event) { logger.info(resourceBundle.getString("LOG_MSG_CONTEXT_INITIALIZED")); loadPulseVersionDetails(); logger.info(resourceBundle.getString("LOG_MSG_CHECK_APP_RUNNING_MODE")); if (isEmbedded) { logger.info(resourceBundle.getString("LOG_MSG_APP_RUNNING_EMBEDDED_MODE")); repository.setJmxUseLocator(false); repository.setHost(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST, PulseConstants.GEMFIRE_DEFAULT_HOST)); repository.setPort(System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, PulseConstants.GEMFIRE_DEFAULT_PORT)); repository.setUseSSLManager( Boolean.parseBoolean( System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER))); repository.setUseSSLLocator( Boolean.parseBoolean( System.getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR))); WebApplicationContext applicationContext = (WebApplicationContext) event.getApplicationContext(); ServletContext servletContext = applicationContext.getServletContext(); Object sslProperties = servletContext.getAttribute(GEODE_SSLCONFIG_SERVLET_CONTEXT_PARAM); if (sslProperties instanceof Properties) { repository.setJavaSslProperties((Properties) sslProperties); } } else { logger.info(resourceBundle.getString("LOG_MSG_APP_RUNNING_NONEMBEDDED_MODE")); Properties pulseProperties = propertiesFileLoader.loadProperties(PulseConstants.PULSE_PROPERTIES_FILE, resourceBundle); repository.setJmxUseLocator(Boolean.valueOf( pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_USELOCATOR))); repository.setHost(pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_HOST, PulseConstants.GEMFIRE_DEFAULT_HOST)); repository.setPort(pulseProperties.getProperty(PulseConstants.APPLICATION_PROPERTY_PULSE_PORT, PulseConstants.GEMFIRE_DEFAULT_PORT)); repository.setUseSSLManager(Boolean.parseBoolean(pulseProperties .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, "false"))); repository.setUseSSLLocator(Boolean.parseBoolean(pulseProperties .getProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, "false"))); Properties pulseSecurityProperties = propertiesFileLoader .loadProperties(PulseConstants.PULSE_SECURITY_PROPERTIES_FILE, resourceBundle); if (!pulseSecurityProperties.isEmpty()) { Set<Entry<Object, Object>> entrySet = pulseSecurityProperties.entrySet(); for (Entry<Object, Object> entry : entrySet) { String key = (String) entry.getKey(); if (key.startsWith("javax.net.ssl.")) { String val = (String) entry.getValue(); System.setProperty(key, val); } } repository.setJavaSslProperties(pulseSecurityProperties); } } } @Autowired  PulseAppListener(PulseController pulseController, Repository repository,
      PropertiesFileLoader propertiesLoader);  PulseAppListener(boolean isEmbedded, PropertiesFileLoader propertiesFileLoader,
      PulseController pulseController, Repository repository); @Override void onApplicationEvent(ApplicationEvent event); void contextInitialized(ContextRefreshedEvent event); void contextDestroyed(ContextClosedEvent event);  }
@Test public void embeddedModeDefaultPropertiesRepositoryInitializationTest() { appListener.contextInitialized(contextEvent); Assert.assertEquals(false, repository.getJmxUseLocator()); Assert.assertEquals(false, repository.isUseSSLManager()); Assert.assertEquals(false, repository.isUseSSLLocator()); Assert.assertEquals(PulseConstants.GEMFIRE_DEFAULT_PORT, repository.getPort()); Assert.assertEquals(PulseConstants.GEMFIRE_DEFAULT_HOST, repository.getHost()); }
@Test public void embeddedModeNonDefaultPropertiesRepositoryInitializationTest() { System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_PORT, "9999"); System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_HOST, "nonDefaultBindAddress"); System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_MANAGER, Boolean.TRUE.toString()); System.setProperty(PulseConstants.SYSTEM_PROPERTY_PULSE_USESSL_LOCATOR, Boolean.TRUE.toString()); appListener.contextInitialized(contextEvent); Assert.assertEquals(false, repository.getJmxUseLocator()); Assert.assertEquals(true, repository.isUseSSLManager()); Assert.assertEquals(true, repository.isUseSSLLocator()); Assert.assertEquals("9999", repository.getPort()); Assert.assertEquals("nonDefaultBindAddress", repository.getHost()); }