Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a couple of examples to start with.
- Loading branch information
Showing
2 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
symmetric/src/test/java/org/jumpmind/symmetric/examples/CustomRuntimeConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* SymmetricDS is an open source database synchronization solution. | ||
* | ||
* Copyright (C) Chris Henson <chenson42@users.sourceforge.net> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.jumpmind.symmetric.examples; | ||
|
||
import java.net.InetAddress; | ||
import java.net.UnknownHostException; | ||
|
||
import org.jumpmind.symmetric.SymmetricEngine; | ||
import org.jumpmind.symmetric.config.IRuntimeConfig; | ||
|
||
public class CustomRuntimeConfig { | ||
|
||
/** | ||
* Setup runtime properties in code before starting the engine. | ||
*/ | ||
public static void main(String[] args) throws Exception { | ||
System.setProperty("symmetric.runtime.configuration.class", MyRuntimeConfig.class.getName()); | ||
SymmetricEngine engine = new SymmetricEngine(); | ||
engine.start(); | ||
} | ||
|
||
class MyRuntimeConfig implements IRuntimeConfig { | ||
|
||
public String getExternalId() { | ||
return getHostName(); | ||
} | ||
|
||
public String getMyUrl() { | ||
return "http://" + getHostName() + "/snc"; | ||
} | ||
|
||
public String getNodeGroupId() { | ||
return "remote-db"; | ||
} | ||
|
||
public String getRegistrationUrl() { | ||
return "http://mycompany.com/sync"; | ||
} | ||
|
||
public String getSchemaVersion() { | ||
return "5.0.0"; | ||
} | ||
|
||
private String getHostName() { | ||
try { | ||
return InetAddress.getLocalHost().getHostName(); | ||
} catch (UnknownHostException e) { | ||
return "localhost"; | ||
} | ||
} | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
symmetric/src/test/java/org/jumpmind/symmetric/examples/StartSymmetricEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* SymmetricDS is an open source database synchronization solution. | ||
* | ||
* Copyright (C) Chris Henson <chenson42@users.sourceforge.net> | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
package org.jumpmind.symmetric.examples; | ||
|
||
import org.jumpmind.symmetric.SymmetricEngine; | ||
|
||
public class StartSymmetricEngine { | ||
|
||
/** | ||
* Start an engine that is configured by two properties files. One is packaged with the application and contains overridden properties that are specific to the | ||
* application. The other is found in the application's working directory. It can be used to setup environment specific properties. | ||
*/ | ||
public static void main(String[] args) throws Exception { | ||
String workingDirectory = System.getProperty("user.dir"); | ||
|
||
SymmetricEngine engine = new SymmetricEngine("classpath://my-symmetric-application.properties", "file://" | ||
+ workingDirectory + "/my-symmetric-environment.properties"); | ||
|
||
// this will create the database, sync triggers, start jobs running | ||
engine.start(); | ||
} | ||
|
||
} |