Coverage report

  %line %branch
net.sf.infrared.aspects.jdbc.p6spy.InfraREDP6PreparedStatementWithVariables
0% 
0% 

 1  
 package net.sf.infrared.aspects.jdbc.p6spy;
 2  
 
 3  
 /* 
 4  
  * Copyright 2005 Tavant Technologies and Contributors
 5  
  * 
 6  
  * Licensed under the Apache License, Version 2.0 (the "License")
 7  
  * you may not use this file except in compliance with the License.
 8  
  * You may obtain a copy of the License at
 9  
  *
 10  
  *     http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing, software
 13  
  * distributed under the License is distributed on an "AS IS" BASIS,
 14  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 15  
  * See the License for the specific language governing permissions and
 16  
  * limitations under the License.
 17  
  * 
 18  
  *
 19  
  *
 20  
  * Original Author:  chetan.mehrotra (Tavant Technologies)
 21  
  *
 22  
  */
 23  
 
 24  
 
 25  
 import java.sql.PreparedStatement;
 26  
 import java.sql.ResultSet;
 27  
 import java.sql.SQLException;
 28  
 
 29  
 import net.sf.infrared.agent.MonitorFactory;
 30  
 import net.sf.infrared.aspects.jdbc.SqlExecuteContext;
 31  
 import net.sf.infrared.base.model.ExecutionTimer;
 32  
 import net.sf.infrared.base.model.ExecutionContext;
 33  
 import net.sf.infrared.agent.StatisticsCollector;
 34  
 
 35  
 import com.p6spy.engine.spy.P6Connection;
 36  
 import com.p6spy.engine.spy.P6PreparedStatement;
 37  
 import com.p6spy.engine.spy.P6Statement;
 38  
 
 39  
 /**
 40  
  * @author chetan.mehrotra
 41  
  * @date Dec 15, 2005
 42  
  * @version $Revision: 1.1 $ 
 43  
  */
 44  
 public class InfraREDP6PreparedStatementWithVariables extends P6PreparedStatement { 
 45  
     protected InfraREDP6Factory factory;
 46  
 	
 47  
     private ExecutionContext executeCtx;
 48  
 	
 49  
     public InfraREDP6PreparedStatementWithVariables(InfraREDP6Factory infraP6Factory, 
 50  
             PreparedStatement real, P6Connection conn, String sql) {
 51  0
 	super(infraP6Factory, real, conn,sql);
 52  0
 	this.factory = infraP6Factory;		
 53  0
     }
 54  
 	
 55  
 	
 56  
 /*    public void addBatch() throws SQLException {
 57  
         statementQuery = getQueryFromPreparedStatement();
 58  
         SqlExecuteContext executeCtx = factory.getSqlContext(
 59  
          		getQueryFromPreparedStatement()).getExecuteContext();
 60  
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 61  
         try {
 62  
             prepStmtPassthru.addBatch();
 63  
         }
 64  
         finally {
 65  
         	MonitorFactory.getFacade().recordExecutionEnd(timer);
 66  
         }
 67  
     } */
 68  
     
 69  
     public boolean execute() throws SQLException {
 70  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement());
 71  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 72  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer); 
 73  
         
 74  
         try {
 75  0
             return prepStmtPassthru.execute();
 76  
         } finally {
 77  0
         	    MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 78  
         }
 79  
     }
 80  
     
 81  
     public ResultSet executeQuery() throws SQLException {
 82  0
     	ResultSet resultSet = null; 
 83  0
     	SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement());
 84  0
          ExecutionTimer timer = new ExecutionTimer(executeCtx);         
 85  0
          StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 86  
          try {             
 87  0
              resultSet = prepStmtPassthru.executeQuery();
 88  
          } finally {
 89  0
              MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 90  0
          }
 91  0
          return factory.getResultSet(resultSet, getP6Statement(), preparedQuery,  getQueryFromPreparedStatement());
 92  
     }
 93  
     
 94  
     public int executeUpdate() throws SQLException {
 95  
     	int returnValue;
 96  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(getQueryFromPreparedStatement());
 97  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 98  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 99  
         try {            
 100  0
             returnValue = prepStmtPassthru.executeUpdate();
 101  
         } finally {
 102  0
             MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 103  0
         }
 104  0
         return class="keyword">returnValue;
 105  
     }
 106  
     
 107  
     // ---------------------------------------------------------------------------------------
 108  
     // we need to override the same methods that P6SLogStatement overrides because we don't have
 109  
     // multiple inheritance.  considering the alternatives (delegation), it seems cleaner
 110  
     // to just override the methods.  to understand why this is true, realize
 111  
     // P6LogPreparedStatement inherits from P6PreparedStatement which inherits from P6Statement,
 112  
     // so P6LogPreparedStatement never inherits from P6LogStatement and therefore it does not
 113  
     // inherit any of the functionality we define in P6LogStatement.
 114  
     // ---------------------------------------------------------------------------------------
 115  
     
 116  
     public boolean execute(String p0) throws java.sql.SQLException {
 117  0
     	 statementQuery = p0;
 118  0
          SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 119  0
          ExecutionTimer timer = new ExecutionTimer(executeCtx);
 120  0
          StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 121  
          try {             
 122  0
              return passthru.execute(p0);
 123  
          } finally {
 124  0
              MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 125  
          }
 126  
     }
 127  
     
 128  
     // Since JDK 1.4
 129  
     public boolean execute(String p0, int p1) throws java.sql.SQLException {
 130  0
         statementQuery = p0;
 131  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 132  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 133  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 134  
         try {            
 135  0
             return passthru.execute(p0, p1);
 136  
         } finally {
 137  0
             MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 138  
         }
 139  
     }
 140  
     
 141  
     // Since JDK 1.4
 142  
     public boolean execute(String p0, int p1[]) throws java.sql.SQLException {
 143  0
     	statementQuery = p0;
 144  0
     	 SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 145  0
          ExecutionTimer timer = new ExecutionTimer(executeCtx);
 146  0
          StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 147  
          try {             
 148  0
              return passthru.execute(p0, p1);
 149  
          } finally {
 150  0
              MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 151  
          }
 152  
     }
 153  
     
 154  
     // Since JDK 1.4
 155  
     public boolean execute(String p0, String p1[]) throws java.sql.SQLException {
 156  0
         statementQuery = p0;
 157  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 158  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 159  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 160  
         try {        	
 161  0
             return passthru.execute(p0, p1);
 162  
         }
 163  
         finally {
 164  0
         	 MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 165  
         }
 166  
     }
 167  
     
 168  
     public ResultSet executeQuery(String p0) throws java.sql.SQLException {
 169  
     	ResultSet resultSet;
 170  0
     	statementQuery = p0;
 171  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 172  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 173  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);          
 174  
           try {              
 175  0
               resultSet = passthru.executeQuery(p0);
 176  
           } finally {
 177  0
               MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 178  0
           }
 179  0
           return factory.getResultSet(resultSet, getP6Statement(), p0, p0);
 180  
     }
 181  
     
 182  
     public int executeUpdate(String p0) throws java.sql.SQLException {
 183  0
         statementQuery = p0;
 184  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 185  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 186  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 187  
         try {            
 188  0
             return passthru.executeUpdate(p0);
 189  
         } finally {
 190  0
             MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 191  
         }
 192  
     }
 193  
     
 194  
     // Since JDK 1.4
 195  
     public int executeUpdate(String p0, class="keyword">int p1) throws java.sql.SQLException {
 196  0
         statementQuery = p0;
 197  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 198  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 199  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 200  
         try {            
 201  0
             return passthru.executeUpdate(p0, p1);
 202  
         } finally {
 203  0
             MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 204  
         }
 205  
     }
 206  
     
 207  
     // Since JDK 1.4
 208  
     public int executeUpdate(String p0, class="keyword">int p1[]) throws java.sql.SQLException {
 209  0
         statementQuery = p0;
 210  0
         SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 211  0
         ExecutionTimer timer = new ExecutionTimer(executeCtx);
 212  0
         StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 213  
         try {        	
 214  0
             return(passthru.executeUpdate(p0, p1));
 215  
         }
 216  
         finally {
 217  0
         	 MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 218  
         }
 219  
     }
 220  
     
 221  
     // Since JDK 1.4
 222  
     public int executeUpdate(String p0, String p1[]) throws java.sql.SQLException {
 223  
     	  int returnValue;
 224  0
     	  statementQuery = p0;
 225  0
     	  SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 226  0
           ExecutionTimer timer = new ExecutionTimer(executeCtx);
 227  0
           StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 228  
           try {              
 229  0
               returnValue = passthru.executeUpdate(p0,p1);
 230  
           } finally {
 231  0
               MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 232  0
           }
 233  0
           return class="keyword">returnValue;
 234  
     }
 235  
     
 236  
 //    public void addBatch(String p0) throws java.sql.SQLException {
 237  
 //        statementQuery = p0;
 238  
 //        SqlExecuteContext executeCtx = factory.getSqlContext(statementQuery).getExecuteContext();
 239  
 //        ExecutionTimer timer = new ExecutionTimer(executeCtx);
 240  
 //        StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 241  
 //        try {        	 
 242  
 //            passthru.addBatch(p0);
 243  
 //        }
 244  
 //        finally {
 245  
 //        	MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 246  
 //        }
 247  
 //    }
 248  
     
 249  
     public int[] executeBatch() throws java.sql.SQLException {
 250  0
     	 if(statementQuery == null) {
 251  0
              return passthru.executeBatch(); 
 252  
          }
 253  0
          SqlExecuteContext executeCtx = factory.getExecuteContext(statementQuery);
 254  0
          ExecutionTimer timer = new ExecutionTimer(executeCtx);
 255  0
          StatisticsCollector col = MonitorFactory.getFacade().recordExecutionBegin(timer);
 256  
         try {        	 
 257  0
             return(passthru.executeBatch());
 258  
         }
 259  
         finally {
 260  0
         	MonitorFactory.getFacade().recordExecutionEnd(timer, col);
 261  
         }
 262  
     }
 263  
 	
 264  
     protected P6Statement getP6Statement() {
 265  0
         return this;
 266  
     }
 267  
 }
 268  
 

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.