Skip to content

Commit 60231fa

Browse files
committed
Finalized version
1 parent 825cd44 commit 60231fa

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

libs/allconfig.jar

14.2 KB
Binary file not shown.

moujinameserver-0.1.0.jar

18.3 KB
Binary file not shown.

pom.xml

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>MoujiNameServer</groupId>
5-
<artifactId>MoujiNameServer</artifactId>
6-
<version>0.0.1-SNAPSHOT</version>
4+
<groupId>org.mouji</groupId>
5+
<artifactId>moujinameserver</artifactId>
6+
<version>0.1.0</version>
7+
<packaging>jar</packaging>
8+
9+
<parent>
10+
<groupId>org.mouji</groupId>
11+
<artifactId>moujiparent</artifactId>
12+
<version>0.1.0</version>
13+
<relativePath>../</relativePath>
14+
</parent>
15+
716
<build>
817
<sourceDirectory>src</sourceDirectory>
918
<plugins>
@@ -23,6 +32,20 @@
2332
</plugins>
2433
</build>
2534
<dependencies>
35+
<dependency>
36+
<groupId>org.mouji</groupId>
37+
<artifactId>moujicommon</artifactId>
38+
<version>0.1.0</version>
39+
<scope>provided</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.mouji</groupId>
43+
<artifactId>moujistub4j</artifactId>
44+
<version>0.1.0</version>
45+
<scope>provided</scope>
46+
</dependency>
47+
48+
2649
<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.aggregate/jetty-all -->
2750
<dependency>
2851
<groupId>org.eclipse.jetty.aggregate</groupId>

src/org/mouji/ns/core/NameServerRunner.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
import org.mouji.common.errors.DatabaseNotSupported;
66
import org.mouji.ns.core.server.NameServer;
77

8-
import com.allConfig.conf.XMLConfig;
8+
import me.salimm.allConfig.types.XMLConfig;
9+
910

1011

1112
public class NameServerRunner {

src/org/mouji/ns/core/db/DBFactory.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
import java.sql.DriverManager;
55
import java.sql.SQLException;
66

7-
import com.allConfig.conf.AbstractConfig;
87

98
import org.mouji.common.db.DBInfo;
109
import org.mouji.common.db.DBUtils;
1110
import org.mouji.common.errors.DatabaseNotSupported;
1211
import org.mouji.common.types.DBType;
1312
import org.mouji.ns.core.constants.Constants;
1413

14+
import me.salimm.allConfig.Config;
15+
import me.salimm.allConfig.errors.PrefixNotANestedConfigException;
16+
1517
/**
1618
*
1719
* DBConnections contains a set of static functions to create connections to
@@ -86,9 +88,10 @@ public static Connection createSQLLiteConnection(String DB_URL, String USER, Str
8688
* @throws ClassNotFoundException
8789
* @throws SQLException
8890
* @throws DatabaseNotSupported
91+
* @throws PrefixNotANestedConfigException
8992
*/
90-
public static DBUtils getDBUtils(AbstractConfig conf)
91-
throws ClassNotFoundException, SQLException, DatabaseNotSupported {
93+
public static DBUtils getDBUtils(Config conf)
94+
throws ClassNotFoundException, SQLException, DatabaseNotSupported, PrefixNotANestedConfigException {
9295
if (conf.getValue(CONF_TAG_NAME_DB_TYPE).equals(DBType.MYSQL.name())) {
9396
return new MySQLUtils();
9497
// } else if
@@ -125,7 +128,7 @@ public static Connection getConnection(DBInfo dbInfo)
125128

126129
}
127130

128-
public static DBInfo getDBInfo(AbstractConfig conf) {
131+
public static DBInfo getDBInfo(Config conf) throws PrefixNotANestedConfigException {
129132
return new DBInfo(conf.getValue(CONF_TAG_NAME_DB_URL), conf.getValue(CONF_TAG_NAME_DB_DBNAME),
130133
conf.getValue(CONF_TAG_NAME_DB_USER), conf.getValue(CONF_TAG_NAME_DB_PASS),
131134
DBType.fromString(conf.getValue(CONF_TAG_NAME_DB_TYPE)));

src/org/mouji/ns/core/rpc/DBBasedNameServer.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.sql.Connection;
66
import java.sql.SQLException;
77

8-
import com.allConfig.conf.AbstractConfig;
98

109
import org.mouji.common.db.DBInfo;
1110
import org.mouji.common.db.DBUtils;
@@ -17,6 +16,9 @@
1716
import org.mouji.common.services.NameServer;
1817
import org.mouji.ns.core.db.DBFactory;
1918

19+
import me.salimm.allConfig.Config;
20+
import me.salimm.allConfig.errors.PrefixNotANestedConfigException;
21+
2022
/**
2123
*
2224
*
@@ -42,17 +44,17 @@ public class DBBasedNameServer implements NameServer {
4244
*/
4345
private ProviderLoadBalancer balancer;
4446

45-
public DBBasedNameServer(AbstractConfig conf, DBUtils dbUtils, String url, int port,
46-
ProviderLoadBalancer balancer) {
47+
public DBBasedNameServer(Config conf, DBUtils dbUtils, String url, int port,
48+
ProviderLoadBalancer balancer) throws PrefixNotANestedConfigException {
4749
this.dbUtils = dbUtils;
4850
this.url = url;
4951
this.port = port;
5052
this.setLoadBalancer(balancer);
5153
this.dbInfo = DBFactory.getDBInfo(conf);
5254
}
5355

54-
public DBBasedNameServer(AbstractConfig conf, DBUtils dbUtils, int port, ProviderLoadBalancer balancer)
55-
throws UnknownHostException {
56+
public DBBasedNameServer(Config conf, DBUtils dbUtils, int port, ProviderLoadBalancer balancer)
57+
throws UnknownHostException, PrefixNotANestedConfigException {
5658
this(conf, dbUtils, Inet4Address.getLocalHost().getHostAddress(), port, balancer);
5759
}
5860

src/org/mouji/ns/core/server/NameServer.java

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

33
import java.sql.Connection;
44
import java.sql.SQLException;
5-
import java.sql.Statement;
65
import java.util.ArrayList;
76

87
import org.mouji.common.db.DBInfo;
@@ -16,7 +15,9 @@
1615
import org.mouji.ns.core.rpc.NameServerServiceProvider;
1716
import org.mouji.stub.java.stubs.ServerStub;
1817

19-
import com.allConfig.conf.AbstractConfig;
18+
import me.salimm.allConfig.Config;
19+
import me.salimm.allConfig.errors.PrefixNotANestedConfigException;
20+
2021

2122
/**
2223
*
@@ -27,11 +28,11 @@
2728
*/
2829
public class NameServer implements Constants {
2930

30-
private AbstractConfig conf;
31+
private Config conf;
3132

3233
private DBUtils dbUtils;
3334

34-
public NameServer(AbstractConfig conf) throws ClassNotFoundException, SQLException, DatabaseNotSupported {
35+
public NameServer(Config conf) throws ClassNotFoundException, SQLException, DatabaseNotSupported, PrefixNotANestedConfigException {
3536
this.conf = conf;
3637
this.dbUtils = DBFactory.getDBUtils(conf);
3738

0 commit comments

Comments
 (0)