1 package org.sourceforge.jemm;
2
3 import org.sourceforge.jemm.comm.connection.ConnectionException;
4 import org.sourceforge.jemm.comm.connection.socket.SocketClientConnectionFactory;
5 import org.sourceforge.jemm.database.Database;
6 import org.sourceforge.jemm.database.remote.client.RemoteDatabase;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 public class RemoteStore extends AbstractStore {
29
30 protected final String hostname;
31 protected final int port;
32 protected RemoteDatabase remoteDB;
33
34 public RemoteStore(String hostname,int port) {
35 this(hostname,port,false);
36 }
37
38 public RemoteStore(String hostname,int port,boolean debug) {
39 super(debug);
40 this.hostname = hostname;
41 this.port = port;
42 setup();
43 }
44
45 @Override
46 protected Database createUnderlyingDatabase() {
47 try {
48 SocketClientConnectionFactory clientFactory = new SocketClientConnectionFactory(hostname,port);
49 remoteDB = new RemoteDatabase(clientFactory);
50 return remoteDB;
51 }catch(ConnectionException ce) {
52 throw new JEMMInternalException("Unable to initialise connection to remote server",ce);
53 }
54 }
55
56 @Override
57 protected void shutdownUnderlyingDatabase() {
58 remoteDB.shutdown();
59 }
60 }