1 /*
2 * SymmetricDS is an open source database synchronization solution.
3 *
4 * Copyright (C) Chris Henson <chenson42@users.sourceforge.net>
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20 package org.jumpmind.symmetric.examples;
21
22 import java.net.InetAddress;
23 import java.net.UnknownHostException;
24
25 import org.jumpmind.symmetric.SymmetricEngine;
26 import org.jumpmind.symmetric.config.IRuntimeConfig;
27
28 public class CustomRuntimeConfig {
29
30 /***
31 * Setup runtime properties in code before starting the engine.
32 */
33 public static void main(String[] args) throws Exception {
34 System.setProperty("symmetric.runtime.configuration.class", MyRuntimeConfig.class.getName());
35 SymmetricEngine engine = new SymmetricEngine();
36 engine.start();
37 }
38
39 class MyRuntimeConfig implements IRuntimeConfig {
40
41 public String getExternalId() {
42 return getHostName();
43 }
44
45 public String getMyUrl() {
46 return "http://" + getHostName() + "/sync";
47 }
48
49 public String getNodeGroupId() {
50 return "remote-db";
51 }
52
53 public String getRegistrationUrl() {
54 return "http://mycompany.com/sync";
55 }
56
57 public String getSchemaVersion() {
58 return "5.0.0";
59 }
60
61 private String getHostName() {
62 try {
63 return InetAddress.getLocalHost().getHostName();
64 } catch (UnknownHostException e) {
65 return "localhost";
66 }
67 }
68 }
69
70 }