View Javadoc
1 package net.sourceforge.backpedal.impl.server; 2 3 import net.mikehogan.veggie.exceptions.VeggieSystemException; 4 import net.mikehogan.veggie.sql.Sql; 5 import net.sourceforge.backpedal.api.core.BackpedalStatementStack; 6 import net.sourceforge.backpedal.api.db.ConnectionFactory; 7 import net.sourceforge.backpedal.api.server.Dispatcher; 8 import net.sourceforge.backpedal.api.server.ServerControl; 9 10 import java.sql.Connection; 11 import java.sql.SQLException; 12 13 public class DispatcherImpl implements Dispatcher { 14 private final ServerControl serverControl; 15 private final BackpedalStatementStack statementStack; 16 private final ConnectionFactory connectionFactory; 17 18 public DispatcherImpl(final ServerControl serverControl, 19 final BackpedalStatementStack statementStack, 20 final ConnectionFactory connectionFactory) { 21 this.serverControl = serverControl; 22 this.statementStack = statementStack; 23 this.connectionFactory = connectionFactory; 24 } 25 26 public void dispatch(String command) { 27 if ("backpedal".equalsIgnoreCase(command)) { 28 Connection connection = null; 29 try { 30 connection = connectionFactory.getConnection(); 31 connection.setAutoCommit(false); 32 statementStack.backpedal(connection); 33 connection.commit(); 34 } 35 catch ( SQLException ex ) { 36 throw new VeggieSystemException("Exception during backpedal",ex); 37 } finally { 38 Sql.close(connection); 39 } 40 } else if ("stop".equalsIgnoreCase(command)) { 41 serverControl.stopRunning(); 42 } 43 } 44 }

This page was automatically generated by Maven