Skip to content

Commit

Permalink
0000664: Pass a reference to ISymmetricEngine to the Scripted Router …
Browse files Browse the repository at this point in the history
…so it has access to SymmetricDS services
  • Loading branch information
chenson42 committed Jun 22, 2012
1 parent ee73ec4 commit f5dc04e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Expand Up @@ -25,7 +25,7 @@
import java.util.Map;
import java.util.Set;

import org.jumpmind.symmetric.db.ISymmetricDialect;
import org.jumpmind.symmetric.ISymmetricEngine;
import org.jumpmind.symmetric.model.DataMetaData;
import org.jumpmind.symmetric.model.Node;

Expand All @@ -43,12 +43,12 @@
*/
public class BshDataRouter extends AbstractDataRouter {

protected ISymmetricDialect symmetricDialect;
protected ISymmetricEngine engine;

final String INTERPRETER_KEY = String.format("%d.BshInterpreter", hashCode());

public BshDataRouter(ISymmetricDialect symmetricDialect) {
this.symmetricDialect = symmetricDialect;
public BshDataRouter(ISymmetricEngine engine) {
this.engine = engine;
}

public Set<String> routeToNodes(SimpleRouterContext context, DataMetaData dataMetaData, Set<Node> nodes,
Expand Down Expand Up @@ -108,7 +108,8 @@ protected void bind(Interpreter interpreter, DataMetaData dataMetaData, Set<Node
throws EvalError {
interpreter.set("nodes", nodes);
interpreter.set("targetNodes", targetNodes);
Map<String, Object> params = getDataObjectMap(dataMetaData, symmetricDialect);
interpreter.set("engine", engine);
Map<String, Object> params = getDataObjectMap(dataMetaData, engine.getSymmetricDialect());
if (params != null) {
for (String param : params.keySet()) {
interpreter.set(param, params.get(param));
Expand Down
Expand Up @@ -95,7 +95,7 @@ public RouterService(ISymmetricEngine engine) {

this.routers = new HashMap<String, IDataRouter>();
this.routers.put("configurationChanged", new ConfigurationChangedDataRouter(engine));
this.routers.put("bsh", new BshDataRouter(symmetricDialect));
this.routers.put("bsh", new BshDataRouter(engine));
this.routers.put("subselect", new SubSelectDataRouter(symmetricDialect));
this.routers.put("lookuptable", new LookupTableDataRouter(symmetricDialect));
this.routers.put("default", new DefaultDataRouter());
Expand Down

0 comments on commit f5dc04e

Please sign in to comment.