Skip to content

Commit f106800

Browse files
author
freeman
committed
重构一番 0.0
1 parent 1d6465f commit f106800

File tree

8 files changed

+28
-16
lines changed

8 files changed

+28
-16
lines changed

gd-cluster/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<version>1.2.17</version>
4747
</dependency>
4848

49+
4950
</dependencies>
5051

5152
</project>

gd-cluster/src/main/java/io/goudai/cluster/util/MethodUtil.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010
public class MethodUtil {
1111

1212

13-
1413
public static Set<String> getMethods(String interfaceName) throws ClassNotFoundException {
15-
Set<String> methods = new HashSet<>();
16-
Arrays.asList(Class.forName(interfaceName).getMethods()).forEach(method -> methods.add(method.getName()));
17-
return methods;
14+
return getMethods(Class.forName(interfaceName));
1815
}
1916

2017
public static Set<String> getMethods(Class<?> interfaceClass) {
2118
Set<String> methods = new HashSet<>();
22-
Arrays.asList(interfaceClass.getMethods()).forEach(method -> methods.add(method.getName()));
19+
Arrays.asList(interfaceClass.getMethods()).stream().map(m -> m.getName()).forEach(methods::add);
2320
return methods;
2421
}
2522
}

gd-commons/pom.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@
1919

2020
<dependencies>
2121
<dependency>
22-
<groupId>junit</groupId>
23-
<artifactId>junit</artifactId>
24-
<version>3.8.1</version>
25-
<scope>test</scope>
22+
<groupId>org.apache.commons</groupId>
23+
<artifactId>commons-pool2</artifactId>
2624
</dependency>
2725
</dependencies>
2826
</project>

gd-commons/src/main/java/io/goudai/commons/pool/impl/Commons2Pool.java renamed to gd-commons/src/main/java/io/goudai/commons/pool/impl/CommonsPool2Impl.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
/**
99
* Created by freeman on 2016/1/30.
1010
*/
11-
public class Commons2Pool<T> implements Pool<T> {
11+
public class CommonsPool2Impl<T> implements Pool<T> {
1212
private GenericObjectPool<T> pool;
1313
private GenericObjectPoolConfig config;
1414
private PooledObjectFactory<T> factory;
1515

1616

17-
public Commons2Pool(GenericObjectPoolConfig config, PooledObjectFactory<T> factory) {
17+
public CommonsPool2Impl(GenericObjectPoolConfig config, PooledObjectFactory<T> factory) {
1818
this.pool = new GenericObjectPool<T>(factory, config);
1919
this.factory = factory;
2020
this.config = config;
@@ -34,4 +34,8 @@ public void returnObject(T o) {
3434
public void destroy() {
3535
this.pool.close();
3636
}
37+
38+
public static void main(String[] args) {
39+
final CommonsPool2Impl<Object> objectCommonsPool2 = new CommonsPool2Impl<>(null,null);
40+
}
3741
}

gd-net/pom.xml

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@
2929
<artifactId>gd-commons</artifactId>
3030
<version>1.0-SNAPSHOT</version>
3131
</dependency>
32+
<dependency>
33+
<groupId>org.slf4j</groupId>
34+
<artifactId>slf4j-api</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.projectlombok</groupId>
38+
<artifactId>lombok</artifactId>
39+
</dependency>
3240

3341
</dependencies>
3442
</project>

gd-registry/pom.xml

+4
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
<artifactId>gd-commons</artifactId>
3434
<version>1.0-SNAPSHOT</version>
3535
</dependency>
36+
<dependency>
37+
<groupId>org.projectlombok</groupId>
38+
<artifactId>lombok</artifactId>
39+
</dependency>
3640
<dependency>
3741
<groupId>junit</groupId>
3842
<artifactId>junit</artifactId>

gd-rpc/src/main/java/io/goudai/rpc/invoker/SingleInvoker.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.goudai.rpc.invoker;
22

33
import io.goudai.commons.pool.Pool;
4-
import io.goudai.commons.pool.impl.Commons2Pool;
4+
import io.goudai.commons.pool.impl.CommonsPool2Impl;
55
import io.goudai.rpc.exception.RpcException;
66
import io.goudai.rpc.model.Request;
77
import io.goudai.rpc.model.Response;
@@ -21,12 +21,12 @@ public SingleInvoker(PooledObjectFactory<RequestSession> objectFactory) {
2121
config.setMaxIdle(100);
2222
config.setMaxTotal(100);
2323
// config.setTestOnReturn(true);
24-
this.requestSessionPool = new Commons2Pool<>(config, objectFactory);
24+
this.requestSessionPool = new CommonsPool2Impl<>(config, objectFactory);
2525
}
2626

2727
public SingleInvoker(PooledObjectFactory<RequestSession> objectFactory, GenericObjectPoolConfig config) {
2828
config.setTestOnReturn(true);
29-
this.requestSessionPool = new Commons2Pool<>(config, objectFactory);
29+
this.requestSessionPool = new CommonsPool2Impl<>(config, objectFactory);
3030
}
3131

3232

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<properties>
2424
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2525
</properties>
26-
26+
<dependencyManagement>
2727
<dependencies>
2828
<dependency>
2929
<groupId>org.slf4j</groupId>
@@ -53,7 +53,7 @@
5353
</dependency>
5454

5555
</dependencies>
56-
56+
</dependencyManagement>
5757
<build>
5858
<plugins>
5959
<plugin>

0 commit comments

Comments
 (0)