org.springframework.session.data.redis.config.ConfigureRedisAction Java Examples

The following examples show how to use org.springframework.session.data.redis.config.ConfigureRedisAction. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RedisHttpSessionConfiguration.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@Override
public void afterPropertiesSet() {
	if (this.configure == ConfigureRedisAction.NO_OP) {
		return;
	}
	RedisConnection connection = this.connectionFactory.getConnection();
	try {
		this.configure.configure(connection);
	}
	finally {
		try {
			connection.close();
		}
		catch (Exception ex) {
			LogFactory.getLog(getClass()).error("Error closing RedisConnection", ex);
		}
	}
}
 
Example #2
Source File: RedisHttpSessionConfigurationMockTests.java    From spring-session with Apache License 2.0 6 votes vote down vote up
@Test
void enableRedisKeyspaceNotificationsInitializerAfterPropertiesSetWhenExceptionThenCloseConnection() {
	ConfigureRedisAction action = mock(ConfigureRedisAction.class);
	willThrow(new RuntimeException()).given(action).configure(this.connection);

	EnableRedisKeyspaceNotificationsInitializer init = new EnableRedisKeyspaceNotificationsInitializer(this.factory,
			action);

	try {
		init.afterPropertiesSet();
		failBecauseExceptionWasNotThrown(Throwable.class);
	}
	catch (Throwable success) {
	}

	verify(this.connection).close();
}
 
Example #3
Source File: RedisHttpSessionConfigurationMockTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void enableRedisKeyspaceNotificationsInitializerAfterPropertiesSetWhenNoOpThenNoInteractionWithConnectionFactory() {
	EnableRedisKeyspaceNotificationsInitializer init = new EnableRedisKeyspaceNotificationsInitializer(this.factory,
			ConfigureRedisAction.NO_OP);

	init.afterPropertiesSet();

	verifyZeroInteractions(this.factory);
}
 
Example #4
Source File: RedisHttpSessionConfigurationMockTests.java    From spring-session with Apache License 2.0 5 votes vote down vote up
@Test
void enableRedisKeyspaceNotificationsInitializerAfterPropertiesSetWhenNoExceptionThenCloseConnection() {
	ConfigureRedisAction action = mock(ConfigureRedisAction.class);

	EnableRedisKeyspaceNotificationsInitializer init = new EnableRedisKeyspaceNotificationsInitializer(this.factory,
			action);

	init.afterPropertiesSet();

	verify(this.connection).close();
}
 
Example #5
Source File: RedisSpringSessionConfiguration.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
public static ConfigureRedisAction configureRedisAction()
{
    return ConfigureRedisAction.NO_OP;
}
 
Example #6
Source File: RedisConfiguration.java    From find with MIT License 4 votes vote down vote up
@Bean
public ConfigureRedisAction configureRedisAction() {
    // The config action might not be available in a secure redis (eg: Azure)
    return configService.getConfig().getRedis().getAutoConfigure() ? new ConfigureNotifyKeyspaceEventsAction() : ConfigureRedisAction.NO_OP;
}
 
Example #7
Source File: RedisHttpSessionConfigurationNoOpConfigureRedisActionTests.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Bean
ConfigureRedisAction configureRedisAction() {
	return ConfigureRedisAction.NO_OP;
}
 
Example #8
Source File: RedisHttpSessionConfiguration.java    From spring-session with Apache License 2.0 4 votes vote down vote up
EnableRedisKeyspaceNotificationsInitializer(RedisConnectionFactory connectionFactory,
		ConfigureRedisAction configure) {
	this.connectionFactory = connectionFactory;
	this.configure = configure;
}
 
Example #9
Source File: RedisHttpSessionConfigurationNoOpConfigureRedisActionTests.java    From spring-session with Apache License 2.0 4 votes vote down vote up
@Bean
ConfigureRedisAction configureRedisAction() {
	return ConfigureRedisAction.NO_OP;
}
 
Example #10
Source File: SecurityConfig.java    From vics with MIT License 2 votes vote down vote up
/**
 * Prevents spring from trying to configure redis on startup.  By default in some environments (AWS)
 * redis disables remote connections from updating config, which can cause startup to fail as spring
 * can't configure redis.
 */
@Bean
public static ConfigureRedisAction configureRedisAction() {
    return ConfigureRedisAction.NO_OP;
}
 
Example #11
Source File: RedisHttpSessionConfiguration.java    From spring-session with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the action to perform for configuring Redis.
 * @param configureRedisAction the configureRedis to set. The default is
 * {@link ConfigureNotifyKeyspaceEventsAction}.
 */
@Autowired(required = false)
public void setConfigureRedisAction(ConfigureRedisAction configureRedisAction) {
	this.configureRedisAction = configureRedisAction;
}