001    /**
002     * Copyright 2010-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.common.jdbc.listener;
017    
018    import org.kuali.common.util.PercentCompleteInformer;
019    
020    /**
021     * Thread safe tracking of SQL execution related statistics
022     * 
023     * @deprecated
024     */
025    @Deprecated
026    public class MultiThreadedExecutionListener extends NoOpSqlListener {
027    
028            long aggregateTime;
029            long aggregateUpdateCount;
030            long aggregateSqlCount;
031            long aggregateSqlSize;
032            PercentCompleteInformer informer;
033            boolean trackProgressByUpdateCount;
034    
035            @Override
036            public synchronized void afterExecution(SqlExecutionEvent event) {
037                    this.aggregateTime += event.getStopTimeMillis() - event.getStartTimeMillis();
038            }
039    
040            @Override
041            public synchronized void afterExecuteSql(SqlEvent event) {
042                    this.aggregateUpdateCount += event.getUpdateCount();
043                    this.aggregateSqlCount++;
044                    this.aggregateSqlSize += event.getSql().length();
045                    if (trackProgressByUpdateCount) {
046                            informer.incrementProgress(event.getUpdateCount());
047                    } else {
048                            informer.incrementProgress();
049                    }
050            }
051    
052            public long getAggregateTime() {
053                    return aggregateTime;
054            }
055    
056            public long getAggregateUpdateCount() {
057                    return aggregateUpdateCount;
058            }
059    
060            public PercentCompleteInformer getInformer() {
061                    return informer;
062            }
063    
064            public void setInformer(PercentCompleteInformer informer) {
065                    this.informer = informer;
066            }
067    
068            public boolean isTrackProgressByUpdateCount() {
069                    return trackProgressByUpdateCount;
070            }
071    
072            public void setTrackProgressByUpdateCount(boolean trackProgressByUpdateCount) {
073                    this.trackProgressByUpdateCount = trackProgressByUpdateCount;
074            }
075    
076            public long getAggregateSqlCount() {
077                    return aggregateSqlCount;
078            }
079    
080            public long getAggregateSqlSize() {
081                    return aggregateSqlSize;
082            }
083    }