Skip to content

Commit 5d4a472

Browse files
committed
removed some trailing white space git noticed
1 parent 3b923c7 commit 5d4a472

File tree

4 files changed

+113
-98
lines changed

4 files changed

+113
-98
lines changed

‎pom.xml‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
23
<modelVersion>4.0.0</modelVersion>
34
<groupId>com.googlecode</groupId>
45
<artifactId>hibernate-memcached</artifactId>
@@ -43,7 +44,8 @@
4344

4445
<scm>
4546
<connection>scm:svn:http://hibernate-memcached.googlecode.com/svn/tags/hibernate-memcached-1.0</connection>
46-
<developerConnection>scm:svn:https://hibernate-memcached.googlecode.com/svn/tags/hibernate-memcached-1.0</developerConnection>
47+
<developerConnection>scm:svn:https://hibernate-memcached.googlecode.com/svn/tags/hibernate-memcached-1.0
48+
</developerConnection>
4749
<url>http://code.google.com/p/hibernate-memcached/source/browse/tags/hibernate-memcached-1.0</url>
4850
</scm>
4951

@@ -134,6 +136,19 @@
134136
<artifactId>spy</artifactId>
135137
<version>2.4</version>
136138
</dependency>
139+
140+
<!--
141+
Download the whalin client from http://img.whalin.com/memcached/jdk5/log4j/java_memcached-release_2.0.1.jar
142+
Execute the following mvn command to place it in your local repository
143+
mvn install:install-file -Dfile=java_memcached-release_2.0.1.jar -DgroupId=com.danga -DartifactId=java_memcached -Dversion=2.0.1 -Dpackaging=jar
144+
-->
145+
<dependency>
146+
<groupId>com.danga</groupId>
147+
<artifactId>java_memcached</artifactId>
148+
<version>2.0.1</version>
149+
<scope>provided</scope>
150+
</dependency>
151+
137152
<dependency>
138153
<groupId>org.slf4j</groupId>
139154
<artifactId>slf4j-api</artifactId>

‎src/main/java/com/googlecode/hibernate/memcached/dangamemcached/DangaMemcache.java‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.googlecode.hibernate.memcached.dangamemcached;
22

3-
import java.util.Calendar;
4-
import java.util.Date;
5-
63
import com.danga.MemCached.MemCachedClient;
74
import com.danga.MemCached.SockIOPool;
8-
95
import com.googlecode.hibernate.memcached.Memcache;
10-
116
import org.slf4j.Logger;
127
import org.slf4j.LoggerFactory;
138

9+
import java.util.Calendar;
10+
import java.util.Date;
11+
1412
/**
1513
* DOCUMENT ME!
1614
*
@@ -46,9 +44,9 @@ public Object get(String key) {
4644
public void set(String key, int cacheTimeSeconds, Object o) {
4745
log.debug("MemCachedClient.set({})", key);
4846
try {
49-
Calendar calendar = Calendar.getInstance();
50-
calendar.setTime(new Date());
51-
calendar.add(Calendar.SECOND, cacheTimeSeconds);
47+
Calendar calendar = Calendar.getInstance();
48+
calendar.setTime(new Date());
49+
calendar.add(Calendar.SECOND, cacheTimeSeconds);
5250

5351
memcachedClient.set(key, o, calendar.getTime());
5452
} catch (Exception e) {

‎src/main/java/com/googlecode/hibernate/memcached/dangamemcached/DangaMemcacheClientFactory.java‎

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@
33
import com.danga.MemCached.ErrorHandler;
44
import com.danga.MemCached.MemCachedClient;
55
import com.danga.MemCached.SockIOPool;
6-
76
import com.googlecode.hibernate.memcached.Memcache;
87
import com.googlecode.hibernate.memcached.MemcacheClientFactory;
98
import com.googlecode.hibernate.memcached.PropertiesHelper;
10-
119
import org.hibernate.cache.CacheException;
1210

1311
/**
@@ -33,17 +31,17 @@ public class DangaMemcacheClientFactory implements MemcacheClientFactory {
3331
public static final String PROP_SOCKET_TIMEOUT = PROP_PREFIX + "socketTimeout";
3432
public static final String PROP_SOCKET_CONNECT_TIMEOUT = PROP_PREFIX + "socketConnectTimeout";
3533

36-
public static final boolean DEFAULT_COMPRESS_ENABLE = true;
37-
public static final String DEFAULT_DEFAULT_ENCODING = "UTF-8";
38-
public static final String DEFAULT_POOL_NAME = "default";
39-
public static final String DEFAULT_ERROR_HANDLER = "com.googlecode.hibernate.memcached.dangamemcached.SimpleErrorHandler";
40-
public static final String DEFAULT_SERVERS = "localhost:11211";
41-
public static final int DEFAULT_INIT_CONN = 1;
42-
public static final int DEFAULT_MIN_CONN = 1;
43-
public static final int DEFAULT_MAX_CONN = 10;
44-
public static final int DEFAULT_MAX_IDLE = 1000 * 60 * 5; //5 minutes
45-
public static final int DEFAULT_MAINT_SLEEP = 1000 * 30; //30 seconds
46-
public static final int DEFAULT_SOCKET_TIMEOUT = 1000 * 30; //30 seconds
34+
public static final boolean DEFAULT_COMPRESS_ENABLE = true;
35+
public static final String DEFAULT_DEFAULT_ENCODING = "UTF-8";
36+
public static final String DEFAULT_POOL_NAME = "default";
37+
public static final String DEFAULT_ERROR_HANDLER = "com.googlecode.hibernate.memcached.dangamemcached.SimpleErrorHandler";
38+
public static final String DEFAULT_SERVERS = "localhost:11211";
39+
public static final int DEFAULT_INIT_CONN = 1;
40+
public static final int DEFAULT_MIN_CONN = 1;
41+
public static final int DEFAULT_MAX_CONN = 10;
42+
public static final int DEFAULT_MAX_IDLE = 1000 * 60 * 5; //5 minutes
43+
public static final int DEFAULT_MAINT_SLEEP = 1000 * 30; //30 seconds
44+
public static final int DEFAULT_SOCKET_TIMEOUT = 1000 * 30; //30 seconds
4745
public static final int DEFAULT_SOCKET_CONNECT_TIMEOUT = 1000 * 3; //3 seconds
4846

4947
private PropertiesHelper properties;
@@ -55,37 +53,37 @@ public DangaMemcacheClientFactory(PropertiesHelper properties) {
5553
public Memcache createMemcacheClient() throws Exception {
5654
String poolName = getPoolName();
5755

58-
// grab an instance of our connection pool
59-
SockIOPool pool = SockIOPool.getInstance( poolName );
56+
// grab an instance of our connection pool
57+
SockIOPool pool = SockIOPool.getInstance(poolName);
6058

61-
// set the servers and the weights
62-
pool.setServers( getServers() );
63-
pool.setWeights( getWeights() );
59+
// set the servers and the weights
60+
pool.setServers(getServers());
61+
pool.setWeights(getWeights());
6462

65-
// set some basic pool settings
66-
pool.setInitConn( getInitConn() );
67-
pool.setMinConn( getMinConn() );
68-
pool.setMaxConn( getMaxConn() );
69-
pool.setMaxIdle( getMaxIdle() );
63+
// set some basic pool settings
64+
pool.setInitConn(getInitConn());
65+
pool.setMinConn(getMinConn());
66+
pool.setMaxConn(getMaxConn());
67+
pool.setMaxIdle(getMaxIdle());
7068

71-
// set the sleep for the maint thread
72-
// it will wake up every x seconds and
73-
// maintain the pool size
74-
pool.setMaintSleep( getMaintSleep() );
69+
// set the sleep for the maint thread
70+
// it will wake up every x seconds and
71+
// maintain the pool size
72+
pool.setMaintSleep(getMaintSleep());
7573

76-
// set some TCP settings
77-
pool.setNagle( false );
78-
pool.setSocketTO( getSocketTimeout() );
79-
pool.setSocketConnectTO( getSocketConnectTimeout() );
74+
// set some TCP settings
75+
pool.setNagle(false);
76+
pool.setSocketTO(getSocketTimeout());
77+
pool.setSocketConnectTO(getSocketConnectTimeout());
8078

81-
// initialize the connection pool
82-
pool.initialize();
79+
// initialize the connection pool
80+
pool.initialize();
8381

8482
MemCachedClient client =
85-
new MemCachedClient(
86-
getClassLoader(),
87-
getErrorHandler(),
88-
poolName);
83+
new MemCachedClient(
84+
getClassLoader(),
85+
getErrorHandler(),
86+
poolName);
8987
client.setCompressEnable(isCompressEnable());
9088
client.setDefaultEncoding(getDefaultEncoding());
9189

@@ -109,25 +107,22 @@ public String getPoolName() {
109107
}
110108

111109
public ErrorHandler getErrorHandler() {
112-
String errorHandlerName =
113-
properties.get(PROP_ERROR_HANDLER, DEFAULT_ERROR_HANDLER);
110+
String errorHandlerName =
111+
properties.get(PROP_ERROR_HANDLER, DEFAULT_ERROR_HANDLER);
114112

115113
ErrorHandler errorHandler;
116114
try {
117-
errorHandler =
118-
(ErrorHandler)Class.forName(errorHandlerName).newInstance();
119-
} catch(ClassNotFoundException e) {
115+
errorHandler =
116+
(ErrorHandler) Class.forName(errorHandlerName).newInstance();
117+
} catch (ClassNotFoundException e) {
120118
throw new CacheException(
121119
"Unable to find error handler class [" + errorHandlerName + "]");
122-
} catch(IllegalAccessException e) {
120+
} catch (IllegalAccessException e) {
123121
throw new CacheException(
124-
"Illegally access error handler class [" + errorHandlerName + "]");
125-
} catch(InstantiationException e) {
122+
"Illegally accessed error handler class [" + errorHandlerName + "]");
123+
} catch (InstantiationException e) {
126124
throw new CacheException(
127125
"Failed to instantiate error handler class [" + errorHandlerName + "]");
128-
} catch(ClassCastException e) {
129-
throw new CacheException(
130-
"Invalid error handler class [" + errorHandlerName + "]");
131126
}
132127

133128
return errorHandler;
@@ -138,21 +133,21 @@ public String[] getServers() {
138133
}
139134

140135
public Integer[] getWeights() {
141-
String[] servers = getServers();
136+
String[] servers = getServers();
142137
Integer[] weights = new Integer[servers.length];
143138
String weightsValue = properties.get(PROP_WEIGHTS);
144139

145140
if (weightsValue == null || "".equals(weightsValue)) {
146-
for(int i = 0 ; i < weights.length; i++)
147-
weights[i] = new Integer(1);
141+
for (int i = 0; i < weights.length; i++)
142+
weights[i] = 1;
148143
} else {
149144
String[] weightsStrings = weightsValue.split(" ");
150145
if (weightsStrings.length == servers.length) {
151-
for(int i = 0 ; i < weights.length; i++)
152-
weights[i] = new Integer(weightsStrings[i]);
146+
for (int i = 0; i < weights.length; i++)
147+
weights[i] = new Integer(weightsStrings[i]);
153148
} else
154149
throw new CacheException(
155-
"Count of weight number mismatch count of server");
150+
"Count of weight number mismatch count of server");
156151
}
157152

158153
return weights;

‎src/main/java/com/googlecode/hibernate/memcached/dangamemcached/SimpleErrorHandler.java‎

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.danga.MemCached.ErrorHandler;
44
import com.danga.MemCached.MemCachedClient;
5-
65
import org.slf4j.Logger;
76
import org.slf4j.LoggerFactory;
87

@@ -12,37 +11,45 @@
1211
* @author George Wei
1312
*/
1413
public class SimpleErrorHandler implements ErrorHandler {
15-
private static final Logger log = LoggerFactory.getLogger(SimpleErrorHandler.class);
16-
17-
public void handleErrorOnDelete(MemCachedClient client, Throwable error,
18-
String cacheKey) {
19-
log.error("Error on delete cacheKey [{}]: {}", cacheKey, error);
20-
}
21-
22-
public void handleErrorOnFlush(MemCachedClient client, Throwable error) {
23-
log.error("Error on flush: {}", error);
24-
}
25-
26-
public void handleErrorOnGet(MemCachedClient client, Throwable error,
27-
String cacheKey) {
28-
log.error("Error on get cacheKey [{}]: {}", cacheKey, error);
29-
}
30-
31-
public void handleErrorOnGet(MemCachedClient client, Throwable error,
32-
String[] cacheKeys) {
33-
handleErrorOnGet(client, error, new StringBuffer().append(cacheKeys).toString());
34-
}
35-
36-
public void handleErrorOnInit(MemCachedClient client, Throwable error) {
37-
log.error("Error on initialization: {}", error);
38-
}
39-
40-
public void handleErrorOnSet(MemCachedClient client, Throwable error,
41-
String cacheKey) {
42-
log.error("Error on set cacheKey [{}]: {}", cacheKey, error);
43-
}
44-
45-
public void handleErrorOnStats(MemCachedClient client, Throwable error) {
46-
log.error("Error on stats: {}", error);
47-
}
14+
private static final Logger log = LoggerFactory.getLogger(SimpleErrorHandler.class);
15+
16+
public void handleErrorOnDelete(MemCachedClient client, Throwable error,
17+
String cacheKey) {
18+
log.error("Error on delete cacheKey [{}]: {}", cacheKey, error);
19+
}
20+
21+
public void handleErrorOnFlush(MemCachedClient client, Throwable error) {
22+
log.error("Error on flush: {}", error);
23+
}
24+
25+
public void handleErrorOnGet(MemCachedClient client, Throwable error,
26+
String cacheKey) {
27+
log.error("Error on get cacheKey [{}]: {}", cacheKey, error);
28+
}
29+
30+
public void handleErrorOnGet(MemCachedClient client, Throwable error,
31+
String[] cacheKeys) {
32+
StringBuilder keys = new StringBuilder();
33+
for (int i = 0; i < cacheKeys.length; i++) {
34+
String cacheKey = cacheKeys[i];
35+
keys.append(cacheKey);
36+
if (i < cacheKeys.length - 1) {
37+
keys.append(" ");
38+
}
39+
}
40+
handleErrorOnGet(client, error, keys.toString());
41+
}
42+
43+
public void handleErrorOnInit(MemCachedClient client, Throwable error) {
44+
log.error("Error on initialization: {}", error);
45+
}
46+
47+
public void handleErrorOnSet(MemCachedClient client, Throwable error,
48+
String cacheKey) {
49+
log.error("Error on set cacheKey [{}]: {}", cacheKey, error);
50+
}
51+
52+
public void handleErrorOnStats(MemCachedClient client, Throwable error) {
53+
log.error("Error on stats: {}", error);
54+
}
4855
}

0 commit comments

Comments
 (0)