@Test public void testNonCaching() { sut.useCachingConnectionFactory = false; ConnectionFactory result = (ConnectionFactory) sut.postProcessAfterInitialization(connectionFactory, "mock"); assertThat(result, not(instanceOf(CachingConnectionFactory.class))); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ConnectionFactory) { UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter(); adapter.setTargetConnectionFactory((ConnectionFactory) bean); adapter.setUsername(username); adapter.setPassword(password); if (useCachingConnectionFactory) { return new CachingConnectionFactory(adapter); } return adapter; } return bean; }
ConnectionFactoryDecoratingPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ConnectionFactory) { UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter(); adapter.setTargetConnectionFactory((ConnectionFactory) bean); adapter.setUsername(username); adapter.setPassword(password); if (useCachingConnectionFactory) { return new CachingConnectionFactory(adapter); } return adapter; } return bean; } }
ConnectionFactoryDecoratingPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ConnectionFactory) { UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter(); adapter.setTargetConnectionFactory((ConnectionFactory) bean); adapter.setUsername(username); adapter.setPassword(password); if (useCachingConnectionFactory) { return new CachingConnectionFactory(adapter); } return adapter; } return bean; }  }
ConnectionFactoryDecoratingPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ConnectionFactory) { UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter(); adapter.setTargetConnectionFactory((ConnectionFactory) bean); adapter.setUsername(username); adapter.setPassword(password); if (useCachingConnectionFactory) { return new CachingConnectionFactory(adapter); } return adapter; } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName); }
ConnectionFactoryDecoratingPostProcessor implements BeanPostProcessor { @Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof ConnectionFactory) { UserCredentialsConnectionFactoryAdapter adapter = new UserCredentialsConnectionFactoryAdapter(); adapter.setTargetConnectionFactory((ConnectionFactory) bean); adapter.setUsername(username); adapter.setPassword(password); if (useCachingConnectionFactory) { return new CachingConnectionFactory(adapter); } return adapter; } return bean; }  @Override Object postProcessBeforeInitialization(Object bean, String beanName); @Override Object postProcessAfterInitialization(Object bean, String beanName);  }