1 30 package com.genimen.djeneric.tools.scriptengine.core.nodes; 31 32 import com.genimen.djeneric.language.Messages; 33 import com.genimen.djeneric.repository.exceptions.DjenericException; 34 import com.genimen.djeneric.tools.scriptengine.core.DjScriptParserEngine; 35 import com.genimen.djeneric.tools.scriptengine.core.SimpleNode; 36 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionException; 37 import com.genimen.djeneric.tools.scriptengine.core.util.DjScriptExecutionTimeScope; 38 39 public class TransactionalStatementNode extends SimpleNode 40 { 41 String _command; 42 43 public TransactionalStatementNode(int i) 44 { 45 super(i); 46 } 47 48 public TransactionalStatementNode(DjScriptParserEngine p, int i) 49 { 50 super(p, i); 51 } 52 53 public String getName() 54 { 55 return "transactional"; 56 } 57 58 public String toString() 59 { 60 return getName(); 61 } 62 63 public void execute(DjScriptExecutionTimeScope context) throws DjScriptExecutionException 64 { 65 try 66 { 67 if ("commit".equals(getCommand())) context.getSession().commit(); 68 else if ("rollback".equals(getCommand())) context.getSession().reset(); 69 else throw new DjScriptExecutionException(Messages 70 .getString("TransactionalStatementNode.UnsupportedTransactionalStatement", getCommand()), this); 71 } 72 catch (DjenericException dje) 73 { 74 throw new DjScriptExecutionException(dje, this); 75 } 76 } 77 78 public String getCommand() 79 { 80 return _command; 81 } 82 83 public void setCommand(String command) 84 { 85 _command = command; 86 } 87 88 } | Popular Tags |