Skip to content

Commit 2d6f505

Browse files
jxblumrwinch
authored andcommitted
Update to Spring Data Hopper
Fixes gh-470
1 parent 7c616a1 commit 2d6f505

File tree

20 files changed

+228
-195
lines changed

20 files changed

+228
-195
lines changed

docs/src/integration-test/java/docs/http/HttpSessionGemFireIndexingITests.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ CacheFactoryBean gemfireCache() {
115115
CacheFactoryBean gemfireCache = new CacheFactoryBean();
116116

117117
gemfireCache.setClose(true);
118-
gemfireCache.setLazyInitialize(false);
119118
gemfireCache.setProperties(gemfireProperties());
120-
gemfireCache.setUseBeanFactoryLocator(false);
121119

122120
return gemfireCache;
123121
}

docs/src/integration-test/java/docs/http/gemfire/indexablesessionattributes/GemFireHttpSessionConfig.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ CacheFactoryBean gemfireCache() {
5050
CacheFactoryBean gemfireCache = new CacheFactoryBean();
5151

5252
gemfireCache.setClose(true);
53-
gemfireCache.setLazyInitialize(false);
5453
gemfireCache.setProperties(gemfireProperties());
55-
gemfireCache.setUseBeanFactoryLocator(false);
5654

5755
return gemfireCache;
5856
}

gradle.properties

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jspApiVersion=2.0
55
servletApiVersion=3.0.1
66
jstlelVersion=1.2.5
77
version=1.2.0.BUILD-SNAPSHOT
8-
springDataRedisVersion=1.6.2.RELEASE
8+
springDataRedisVersion=1.7.1.RELEASE
99
junitVersion=4.12
1010
gebVersion=0.13.1
1111
mockitoVersion=1.10.19
@@ -14,11 +14,11 @@ seleniumVersion=2.52.0
1414
springSecurityVersion=4.0.3.RELEASE
1515
springVersion=4.2.5.RELEASE
1616
httpClientVersion=4.5.1
17-
jedisVersion=2.7.3
17+
jedisVersion=2.8.1
1818
h2Version=1.4.191
19-
springDataMongoVersion=1.8.2.RELEASE
19+
springDataMongoVersion=1.9.1.RELEASE
2020
springShellVersion=1.1.0.RELEASE
21-
springDataGemFireVersion=1.7.4.RELEASE
21+
springDataGemFireVersion=1.8.1.RELEASE
2222
assertjVersion=2.3.0
2323
spockVersion=1.0-groovy-2.4
2424
jstlVersion=1.2.1

samples/httpsession-gemfire-clientserver-xml/src/main/java/sample/Application.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
public class Application {
2828

2929
public static void main(final String[] args) {
30-
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(
31-
Application.class);
30+
AnnotationConfigApplicationContext context =
31+
new AnnotationConfigApplicationContext(Application.class);
3232
context.registerShutdownHook();
3333
}
3434
}

samples/httpsession-gemfire-clientserver-xml/src/main/java/sample/GemFireCacheServerReadyBeanPostProcessor.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,32 @@ public class GemFireCacheServerReadyBeanPostProcessor implements BeanPostProcess
5151

5252
// tag::class[]
5353
static {
54-
ClientMembership
55-
.registerClientMembershipListener(new ClientMembershipListenerAdapter() {
56-
public void memberJoined(final ClientMembershipEvent event) {
57-
if (!event.isClient()) {
58-
latch.countDown();
59-
}
54+
ClientMembership.registerClientMembershipListener(
55+
new ClientMembershipListenerAdapter() {
56+
public void memberJoined(final ClientMembershipEvent event) {
57+
if (!event.isClient()) {
58+
latch.countDown();
6059
}
61-
});
60+
}
61+
});
6262
}
6363

6464
@SuppressWarnings("all")
6565
@Resource(name = "applicationProperties")
6666
private Properties applicationProperties;
6767

68-
public Object postProcessBeforeInitialization(Object bean, String beanName)
69-
throws BeansException {
68+
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
7069
if (bean instanceof PoolFactoryBean || bean instanceof Pool) {
7170
String host = getServerHost(DEFAULT_SERVER_HOST);
7271
Assert.isTrue(waitForCacheServerToStart(host, this.port),
73-
String.format(
74-
"GemFire Server failed to start [host: '%1$s', port: %2$d]%n",
75-
host, this.port));
72+
String.format("GemFire Server failed to start [host: '%1$s', port: %2$d]%n",
73+
host, this.port));
7674
}
7775

7876
return bean;
7977
}
8078

81-
public Object postProcessAfterInitialization(Object bean, String beanName)
82-
throws BeansException {
79+
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
8380
if (bean instanceof PoolFactoryBean || bean instanceof Pool) {
8481
try {
8582
latch.await(DEFAULT_WAIT_DURATION, TimeUnit.MILLISECONDS);
@@ -157,4 +154,5 @@ boolean waitOnCondition(Condition condition, long duration) {
157154

158155
return condition.evaluate();
159156
}
157+
160158
}

samples/httpsession-gemfire-clientserver-xml/src/main/webapp/WEB-INF/spring/session-client.xml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
<prop key="log-level">${sample.httpsession.gemfire.log-level:warning}</prop>
3636
</util:properties>
3737

38+
<gfe:client-cache properties-ref="gemfireProperties"/>
39+
3840
<!--7-->
3941
<gfe:pool free-connection-timeout="5000"
4042
keep-alive="false"
@@ -47,9 +49,6 @@
4749
<gfe:server host="${application.gemfire.client-server.host}"
4850
port="${spring.session.data.gemfire.port:${application.gemfire.client-server.port}}"/>
4951
</gfe:pool>
50-
51-
<gfe:client-cache properties-ref="gemfireProperties"
52-
use-bean-factory-locator="false"/>
5352
<!-- end::beans[] -->
5453

5554
</beans>

samples/httpsession-gemfire-clientserver-xml/src/main/webapp/WEB-INF/web.xml

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@
99
<!-- tag::context-param[] -->
1010
<context-param>
1111
<param-name>contextConfigLocation</param-name>
12-
<param-value>
13-
/WEB-INF/spring/session-client.xml
14-
</param-value>
12+
<param-value>/WEB-INF/spring/session-client.xml</param-value>
1513
</context-param>
1614
<!-- end::context-param[] -->
1715

@@ -23,9 +21,9 @@
2321
<filter-mapping>
2422
<filter-name>springSessionRepositoryFilter</filter-name>
2523
<url-pattern>/*</url-pattern>
26-
<dispatcher>REQUEST</dispatcher>
27-
<dispatcher>ERROR</dispatcher>
28-
<dispatcher>ASYNC</dispatcher>
24+
<dispatcher>REQUEST</dispatcher>
25+
<dispatcher>ERROR</dispatcher>
26+
<dispatcher>ASYNC</dispatcher>
2927
</filter-mapping>
3028
<!-- end::springSessionRepositoryFilter[] -->
3129

@@ -36,9 +34,7 @@
3634
-->
3735
<!-- tag::listeners[] -->
3836
<listener>
39-
<listener-class>
40-
org.springframework.web.context.ContextLoaderListener
41-
</listener-class>
37+
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
4238
</listener>
4339
<!-- end::listeners[] -->
4440

samples/httpsession-gemfire-clientserver/src/main/java/sample/ClientConfig.java

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
3737
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
3838
import org.springframework.data.gemfire.client.PoolFactoryBean;
39-
import org.springframework.data.gemfire.config.GemfireConstants;
4039
import org.springframework.data.gemfire.support.ConnectionEndpoint;
4140
import org.springframework.session.data.gemfire.config.annotation.web.http.EnableGemFireHttpSession;
4241
import org.springframework.session.data.gemfire.support.GemFireUtils;
@@ -52,17 +51,20 @@ public class ClientConfig {
5251
static final CountDownLatch latch = new CountDownLatch(1);
5352

5453
static {
55-
System.setProperty("gemfire.log-level",
56-
System.getProperty("sample.httpsession.gemfire.log-level", "warning"));
57-
58-
ClientMembership
59-
.registerClientMembershipListener(new ClientMembershipListenerAdapter() {
60-
public void memberJoined(ClientMembershipEvent event) {
61-
if (!event.isClient()) {
62-
latch.countDown();
63-
}
54+
System.setProperty("gemfire.log-level", logLevel());
55+
56+
ClientMembership.registerClientMembershipListener(
57+
new ClientMembershipListenerAdapter() {
58+
public void memberJoined(ClientMembershipEvent event) {
59+
if (!event.isClient()) {
60+
latch.countDown();
6461
}
65-
});
62+
}
63+
});
64+
}
65+
66+
private static String logLevel() {
67+
return System.getProperty("sample.httpsession.gemfire.log-level", "warning");
6668
}
6769

6870
@Bean
@@ -75,14 +77,22 @@ Properties gemfireProperties() { // <2>
7577
return new Properties();
7678
}
7779

78-
@Bean(name = GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME)
80+
@Bean
81+
ClientCacheFactoryBean gemfireCache() { // <4>
82+
ClientCacheFactoryBean clientCacheFactory = new ClientCacheFactoryBean();
83+
84+
clientCacheFactory.setClose(true);
85+
clientCacheFactory.setProperties(gemfireProperties());
86+
87+
return clientCacheFactory;
88+
}
89+
90+
@Bean
7991
PoolFactoryBean gemfirePool(// <3>
80-
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT
81-
+ "}") int port) {
92+
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT + "}") int port) {
8293

8394
PoolFactoryBean poolFactory = new PoolFactoryBean();
8495

85-
poolFactory.setName(GemfireConstants.DEFAULT_GEMFIRE_POOL_NAME);
8696
poolFactory.setFreeConnectionTimeout(5000); // 5 seconds
8797
poolFactory.setKeepAlive(false);
8898
poolFactory.setMaxConnections(ServerConfig.MAX_CONNECTIONS);
@@ -92,46 +102,29 @@ PoolFactoryBean gemfirePool(// <3>
92102
poolFactory.setSubscriptionEnabled(true);
93103
poolFactory.setThreadLocalConnections(false);
94104

95-
poolFactory.setServerEndpoints(Collections.singletonList(
96-
new ConnectionEndpoint(ServerConfig.SERVER_HOSTNAME, port)));
105+
poolFactory.setServers(Collections.singletonList(
106+
new ConnectionEndpoint(ServerConfig.SERVER_HOSTNAME, port)));
97107

98108
return poolFactory;
99109
}
100110

101-
@Bean
102-
ClientCacheFactoryBean gemfireCache(Pool gemfirePool) { // <4>
103-
ClientCacheFactoryBean clientCacheFactory = new ClientCacheFactoryBean();
104-
105-
clientCacheFactory.setClose(true);
106-
clientCacheFactory.setProperties(gemfireProperties());
107-
clientCacheFactory.setPool(gemfirePool);
108-
clientCacheFactory.setUseBeanFactoryLocator(false);
109-
110-
return clientCacheFactory;
111-
}
112-
113111
@Bean
114112
BeanPostProcessor gemfireCacheServerReadyBeanPostProcessor(// <5>
115-
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT
116-
+ "}") final int port) {
113+
@Value("${spring.session.data.gemfire.port:" + ServerConfig.SERVER_PORT + "}") final int port) {
117114

118115
return new BeanPostProcessor() {
119116

120-
public Object postProcessBeforeInitialization(Object bean, String beanName)
121-
throws BeansException {
117+
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
122118
if (bean instanceof PoolFactoryBean || bean instanceof Pool) {
123-
Assert.isTrue(
124-
waitForCacheServerToStart(ServerConfig.SERVER_HOSTNAME, port),
125-
String.format(
126-
"GemFire Server failed to start [hostname: %1$s, port: %2$d]",
127-
ServerConfig.SERVER_HOSTNAME, port));
119+
Assert.isTrue(waitForCacheServerToStart(ServerConfig.SERVER_HOSTNAME, port),
120+
String.format("GemFire Server failed to start [hostname: %1$s, port: %2$d]",
121+
ServerConfig.SERVER_HOSTNAME, port));
128122
}
129123

130124
return bean;
131125
}
132126

133-
public Object postProcessAfterInitialization(Object bean, String beanName)
134-
throws BeansException {
127+
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
135128
if (bean instanceof PoolFactoryBean || bean instanceof Pool) {
136129
try {
137130
latch.await(DEFAULT_WAIT_DURATION, TimeUnit.MILLISECONDS);
@@ -206,4 +199,5 @@ boolean waitOnCondition(Condition condition, long duration) {
206199

207200
return condition.evaluate();
208201
}
202+
209203
}

samples/httpsession-gemfire-clientserver/src/main/java/sample/ServerConfig.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,23 @@ Properties gemfireProperties() { // <2>
4949

5050
gemfireProperties.setProperty("name", "GemFireClientServerHttpSessionSample");
5151
gemfireProperties.setProperty("mcast-port", "0");
52-
gemfireProperties.setProperty("log-level",
53-
System.getProperty("sample.httpsession.gemfire.log-level", "warning"));
52+
gemfireProperties.setProperty("log-level", logLevel());
5453
gemfireProperties.setProperty("jmx-manager", "true");
5554
gemfireProperties.setProperty("jmx-manager-start", "true");
5655

5756
return gemfireProperties;
5857
}
5958

59+
private String logLevel() {
60+
return System.getProperty("sample.httpsession.gemfire.log-level", "warning");
61+
}
62+
6063
@Bean
6164
CacheFactoryBean gemfireCache() { // <3>
6265
CacheFactoryBean gemfireCache = new CacheFactoryBean();
6366

67+
gemfireCache.setClose(true);
6468
gemfireCache.setProperties(gemfireProperties());
65-
gemfireCache.setUseBeanFactoryLocator(false);
6669

6770
return gemfireCache;
6871
}
@@ -76,6 +79,7 @@ CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache, // <4>
7679
cacheServerFactory.setAutoStartup(true);
7780
cacheServerFactory.setBindAddress(SERVER_HOSTNAME);
7881
cacheServerFactory.setCache(gemfireCache);
82+
cacheServerFactory.setHostNameForClients(SERVER_HOSTNAME);
7983
cacheServerFactory.setMaxConnections(MAX_CONNECTIONS);
8084
cacheServerFactory.setPort(port);
8185

@@ -86,5 +90,6 @@ CacheServerFactoryBean gemfireCacheServer(Cache gemfireCache, // <4>
8690
public static void main(final String[] args) throws IOException { // <5>
8791
new AnnotationConfigApplicationContext(ServerConfig.class).registerShutdownHook();
8892
}
93+
8994
}
9095
// end::class[]

samples/httpsession-gemfire-p2p/src/main/java/sample/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Properties gemfireProperties() { // <2>
4444
CacheFactoryBean gemfireCache() { // <3>
4545
CacheFactoryBean gemfireCache = new CacheFactoryBean();
4646

47+
gemfireCache.setClose(true);
4748
gemfireCache.setProperties(gemfireProperties());
48-
gemfireCache.setUseBeanFactoryLocator(false);
4949

5050
return gemfireCache;
5151
}

0 commit comments

Comments
 (0)