Return-Path:
Delivered-To: apmail-tomcat-dev-archive@www.apache.org
Received: (qmail 36039 invoked from network); 5 Dec 2008 15:58:25 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2)
by minotaur.apache.org with SMTP; 5 Dec 2008 15:58:25 -0000
Received: (qmail 71072 invoked by uid 500); 5 Dec 2008 15:58:25 -0000
Delivered-To: apmail-tomcat-dev-archive@tomcat.apache.org
Received: (qmail 71018 invoked by uid 500); 5 Dec 2008 15:58:25 -0000
Mailing-List: contact dev-help@tomcat.apache.org; run by ezmlm
Precedence: bulk
List-Help:
List-Unsubscribe:
List-Post:
List-Id:
Reply-To: "Tomcat Developers List"
Delivered-To: mailing list dev@tomcat.apache.org
Received: (qmail 70995 invoked by uid 99); 5 Dec 2008 15:58:25 -0000
Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 07:58:25 -0800
X-ASF-Spam-Status: No, hits=-2000.0 required=10.0
tests=ALL_TRUSTED
X-Spam-Check-By: apache.org
Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4)
by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Dec 2008 15:57:01 +0000
Received: by eris.apache.org (Postfix, from userid 65534)
id 71F5023889C1; Fri, 5 Dec 2008 07:57:49 -0800 (PST)
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r723775 [4/5] - in /tomcat/trunk: java/org/apache/juli/
modules/bayeux/ modules/bayeux/java/org/apache/cometd/bayeux/
modules/bayeux/java/org/apache/tomcat/bayeux/
modules/bayeux/java/org/apache/tomcat/bayeux/request/
modules/bayeux/test/or...
Date: Fri, 05 Dec 2008 15:57:46 -0000
To: dev@tomcat.apache.org
From: markt@apache.org
X-Mailer: svnmailer-1.0.8
Message-Id: <20081205155749.71F5023889C1@eris.apache.org>
X-Virus-Checked: Checked by ClamAV on apache.org
Modified: tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/BayeuxStockTicker.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/BayeuxStockTicker.java?rev=723775&r1=723774&r2=723775&view=diff
==============================================================================
--- tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/BayeuxStockTicker.java (original)
+++ tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/BayeuxStockTicker.java Fri Dec 5 07:57:43 2008
@@ -1,215 +1,215 @@
-package org.apache.cometd.bayeux.samples;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletContextAttributeListener;
-import javax.servlet.ServletContextAttributeEvent;
-import org.apache.cometd.bayeux.Bayeux;
-
-import java.text.DecimalFormat;
-import java.util.List;
-import java.util.Random;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.cometd.bayeux.Client;
-import org.apache.cometd.bayeux.Listener;
-import org.apache.cometd.bayeux.Message;
-import org.apache.cometd.bayeux.Channel;
-
-public class BayeuxStockTicker implements ServletContextListener,
- ServletContextAttributeListener, Listener {
-
- static AtomicInteger counter = new AtomicInteger(0);
- protected int id;
- protected Bayeux b;
- protected Client c;
- protected boolean alive = true;
- protected boolean initialized = false;
- protected TickerThread tt = new TickerThread();
-
- public BayeuxStockTicker() {
- id = counter.incrementAndGet();
- System.out.println("new listener created with id:" + id);
- }
-
- public void contextDestroyed(ServletContextEvent servletContextEvent) {
- alive = false;
- tt.run = false;
- tt.interrupt();
- }
-
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- }
-
- public void attributeAdded(ServletContextAttributeEvent scae) {
- if (scae.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) {
- if (initialized) return;
- initialized = true;
- System.out.println("Starting stock ticker server client!");
- b = (Bayeux) scae.getValue();
- c = b.newClient("stock-ticker-", this);
- tt.start();
- }
- }
-
- public void attributeRemoved(ServletContextAttributeEvent scae) {
- if (scae.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) {
- initialized = false;
- b = (Bayeux) scae.getValue();
- List chs = b.getChannels();
- for (Channel ch : chs) {
- ch.unsubscribe(c);
- }
- }
- }
-
- public void attributeReplaced(
- ServletContextAttributeEvent servletContextAttributeEvent) {
- }
-
- public void removed(boolean timeout) {
- System.out.println("Client removed.");
- }
-
- public void deliver(Message[] msgs) {
- for (int i = 0; msgs != null && i < msgs.length; i++) {
- Message msg = msgs[i];
- System.out.println("[stock ticker server client ]received message:" + msg);
- }
- }
-
- public class TickerThread extends Thread {
- public boolean run = true;
-
- public TickerThread() {
- setName("Ticker Thread");
- }
-
- public void run() {
- try {
-
- Stock[] stocks = new Stock[] {
- new Stock("GOOG", 435.43),
- new Stock("YHOO", 27.88),
- new Stock("SPRG", 1015.55), };
- for (Stock s : stocks) {
- Channel ch = b.getChannel("/stock/"+s.getSymbol(), true);
- ch.subscribe(c);
-
- }
- Random r = new Random(System.currentTimeMillis());
- while (run) {
- for (int j = 0; j < 1; j++) {
- int i = r.nextInt() % 3;
- if (i < 0)
- i = i * (-1);
- Stock stock = stocks[i];
- double change = r.nextDouble();
- boolean plus = r.nextBoolean();
- if (plus) {
- stock.setValue(stock.getValue() + change);
- } else {
- stock.setValue(stock.getValue() - change);
- }
- Channel ch = b.getChannel("/stock/"+stock.getSymbol(), true);
- Message m = b.newMessage(c);
- m.put("stock", stock.toString());
- m.put("symbol", stock.getSymbol());
- m.put("price", stock.getValueAsString());
- m.put("change", stock.getLastChangeAsString());
- ch.publish(m);
- System.out.println("Stock: "+stock.getSymbol()+" Price: "+stock.getValueAsString()+" Change: "+stock.getLastChangeAsString());
- }
- Thread.sleep(850);
- }
- } catch (InterruptedException ix) {
-
- } catch (Exception x) {
- x.printStackTrace();
- }
- }
- }
-
- public static class Stock {
- protected static DecimalFormat df = new DecimalFormat("0.00");
- protected String symbol = "";
- protected double value = 0.0d;
- protected double lastchange = 0.0d;
- protected int cnt = 0;
-
- public Stock(String symbol, double initvalue) {
- this.symbol = symbol;
- this.value = initvalue;
- }
-
- public void setCnt(int c) {
- this.cnt = c;
- }
-
- public int getCnt() {
- return cnt;
- }
-
- public String getSymbol() {
- return symbol;
- }
-
- public double getValue() {
- return value;
- }
-
- public void setValue(double value) {
- double old = this.value;
- this.value = value;
- this.lastchange = value - old;
- }
-
- public String getValueAsString() {
- return df.format(value);
- }
-
- public double getLastChange() {
- return this.lastchange;
- }
-
- public void setLastChange(double lastchange) {
- this.lastchange = lastchange;
- }
-
- public String getLastChangeAsString() {
- return df.format(lastchange);
- }
-
- public int hashCode() {
- return symbol.hashCode();
- }
-
- public boolean equals(Object other) {
- if (other instanceof Stock) {
- return this.symbol.equals(((Stock) other).symbol);
- } else {
- return false;
- }
- }
-
- public String toString(){
- StringBuffer buf = new StringBuffer("STOCK#");
- buf.append(getSymbol());
- buf.append("#");
- buf.append(getValueAsString());
- buf.append("#");
- buf.append(getLastChangeAsString());
- buf.append("#");
- buf.append(String.valueOf(getCnt()));
- return buf.toString();
-
- }
-
- public Object clone() {
- Stock s = new Stock(this.getSymbol(), this.getValue());
- s.setLastChange(this.getLastChange());
- s.setCnt(this.cnt);
- return s;
- }
- }
-
+package org.apache.cometd.bayeux.samples;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextAttributeListener;
+import javax.servlet.ServletContextAttributeEvent;
+import org.apache.cometd.bayeux.Bayeux;
+
+import java.text.DecimalFormat;
+import java.util.List;
+import java.util.Random;
+import java.util.concurrent.atomic.AtomicInteger;
+import org.apache.cometd.bayeux.Client;
+import org.apache.cometd.bayeux.Listener;
+import org.apache.cometd.bayeux.Message;
+import org.apache.cometd.bayeux.Channel;
+
+public class BayeuxStockTicker implements ServletContextListener,
+ ServletContextAttributeListener, Listener {
+
+ static AtomicInteger counter = new AtomicInteger(0);
+ protected int id;
+ protected Bayeux b;
+ protected Client c;
+ protected boolean alive = true;
+ protected boolean initialized = false;
+ protected TickerThread tt = new TickerThread();
+
+ public BayeuxStockTicker() {
+ id = counter.incrementAndGet();
+ System.out.println("new listener created with id:" + id);
+ }
+
+ public void contextDestroyed(ServletContextEvent servletContextEvent) {
+ alive = false;
+ tt.run = false;
+ tt.interrupt();
+ }
+
+ public void contextInitialized(ServletContextEvent servletContextEvent) {
+ }
+
+ public void attributeAdded(ServletContextAttributeEvent scae) {
+ if (scae.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) {
+ if (initialized) return;
+ initialized = true;
+ System.out.println("Starting stock ticker server client!");
+ b = (Bayeux) scae.getValue();
+ c = b.newClient("stock-ticker-", this);
+ tt.start();
+ }
+ }
+
+ public void attributeRemoved(ServletContextAttributeEvent scae) {
+ if (scae.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) {
+ initialized = false;
+ b = (Bayeux) scae.getValue();
+ List chs = b.getChannels();
+ for (Channel ch : chs) {
+ ch.unsubscribe(c);
+ }
+ }
+ }
+
+ public void attributeReplaced(
+ ServletContextAttributeEvent servletContextAttributeEvent) {
+ }
+
+ public void removed(boolean timeout) {
+ System.out.println("Client removed.");
+ }
+
+ public void deliver(Message[] msgs) {
+ for (int i = 0; msgs != null && i < msgs.length; i++) {
+ Message msg = msgs[i];
+ System.out.println("[stock ticker server client ]received message:" + msg);
+ }
+ }
+
+ public class TickerThread extends Thread {
+ public boolean run = true;
+
+ public TickerThread() {
+ setName("Ticker Thread");
+ }
+
+ public void run() {
+ try {
+
+ Stock[] stocks = new Stock[] {
+ new Stock("GOOG", 435.43),
+ new Stock("YHOO", 27.88),
+ new Stock("SPRG", 1015.55), };
+ for (Stock s : stocks) {
+ Channel ch = b.getChannel("/stock/"+s.getSymbol(), true);
+ ch.subscribe(c);
+
+ }
+ Random r = new Random(System.currentTimeMillis());
+ while (run) {
+ for (int j = 0; j < 1; j++) {
+ int i = r.nextInt() % 3;
+ if (i < 0)
+ i = i * (-1);
+ Stock stock = stocks[i];
+ double change = r.nextDouble();
+ boolean plus = r.nextBoolean();
+ if (plus) {
+ stock.setValue(stock.getValue() + change);
+ } else {
+ stock.setValue(stock.getValue() - change);
+ }
+ Channel ch = b.getChannel("/stock/"+stock.getSymbol(), true);
+ Message m = b.newMessage(c);
+ m.put("stock", stock.toString());
+ m.put("symbol", stock.getSymbol());
+ m.put("price", stock.getValueAsString());
+ m.put("change", stock.getLastChangeAsString());
+ ch.publish(m);
+ System.out.println("Stock: "+stock.getSymbol()+" Price: "+stock.getValueAsString()+" Change: "+stock.getLastChangeAsString());
+ }
+ Thread.sleep(850);
+ }
+ } catch (InterruptedException ix) {
+
+ } catch (Exception x) {
+ x.printStackTrace();
+ }
+ }
+ }
+
+ public static class Stock {
+ protected static DecimalFormat df = new DecimalFormat("0.00");
+ protected String symbol = "";
+ protected double value = 0.0d;
+ protected double lastchange = 0.0d;
+ protected int cnt = 0;
+
+ public Stock(String symbol, double initvalue) {
+ this.symbol = symbol;
+ this.value = initvalue;
+ }
+
+ public void setCnt(int c) {
+ this.cnt = c;
+ }
+
+ public int getCnt() {
+ return cnt;
+ }
+
+ public String getSymbol() {
+ return symbol;
+ }
+
+ public double getValue() {
+ return value;
+ }
+
+ public void setValue(double value) {
+ double old = this.value;
+ this.value = value;
+ this.lastchange = value - old;
+ }
+
+ public String getValueAsString() {
+ return df.format(value);
+ }
+
+ public double getLastChange() {
+ return this.lastchange;
+ }
+
+ public void setLastChange(double lastchange) {
+ this.lastchange = lastchange;
+ }
+
+ public String getLastChangeAsString() {
+ return df.format(lastchange);
+ }
+
+ public int hashCode() {
+ return symbol.hashCode();
+ }
+
+ public boolean equals(Object other) {
+ if (other instanceof Stock) {
+ return this.symbol.equals(((Stock) other).symbol);
+ } else {
+ return false;
+ }
+ }
+
+ public String toString(){
+ StringBuffer buf = new StringBuffer("STOCK#");
+ buf.append(getSymbol());
+ buf.append("#");
+ buf.append(getValueAsString());
+ buf.append("#");
+ buf.append(getLastChangeAsString());
+ buf.append("#");
+ buf.append(String.valueOf(getCnt()));
+ return buf.toString();
+
+ }
+
+ public Object clone() {
+ Stock s = new Stock(this.getSymbol(), this.getValue());
+ s.setLastChange(this.getLastChange());
+ s.setCnt(this.cnt);
+ return s;
+ }
+ }
+
}
\ No newline at end of file
Propchange: tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/BayeuxStockTicker.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/EchoChatClient.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/EchoChatClient.java?rev=723775&r1=723774&r2=723775&view=diff
==============================================================================
--- tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/EchoChatClient.java (original)
+++ tomcat/trunk/modules/bayeux/test/org/apache/cometd/bayeux/samples/EchoChatClient.java Fri Dec 5 07:57:43 2008
@@ -1,101 +1,101 @@
-package org.apache.cometd.bayeux.samples;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import javax.servlet.ServletContextAttributeListener;
-import javax.servlet.ServletContextAttributeEvent;
-import org.apache.cometd.bayeux.Bayeux;
-import java.util.concurrent.atomic.AtomicInteger;
-import org.apache.cometd.bayeux.Client;
-import org.apache.cometd.bayeux.Listener;
-import org.apache.cometd.bayeux.Message;
-import org.apache.cometd.bayeux.Channel;
-
-public class EchoChatClient implements ServletContextListener, ServletContextAttributeListener, Listener {
-
- static AtomicInteger counter = new AtomicInteger(0);
- protected int id;
- protected Bayeux b;
- protected Client c;
- protected boolean alive = true;
- protected TimestampThread tt = new TimestampThread();
-
- public EchoChatClient() {
- id = counter.incrementAndGet();
- System.out.println("new listener created with id:"+id);
- }
-
- public void contextDestroyed(ServletContextEvent servletContextEvent) {
- alive = false;
- tt.interrupt();
- }
-
- public void contextInitialized(ServletContextEvent servletContextEvent) {
- }
-
- public void attributeAdded(ServletContextAttributeEvent scae) {
- if (scae.getName().equals(Bayeux.DOJOX_COMETD_BAYEUX)) {
- System.out.println("Starting echo chat client!");
- b = (Bayeux)scae.getValue();
- c = b.newClient("echochat-",this);
- Channel ch = b.getChannel("/chat/demo",true);
- ch.subscribe(c);
- tt.start();
- }
- }
-
- public void attributeRemoved(ServletContextAttributeEvent servletContextAttributeEvent) {
- }
-
- public void attributeReplaced(ServletContextAttributeEvent servletContextAttributeEvent) {
- }
-
- public void removed(boolean timeout) {
- System.out.println("Client removed.");
- }
-
- public void deliver(Message[] msgs) {
- for (int i=0; msgs!=null && i
-
- Cometd Test WebApp
-
-
- cometd
- org.apache.tomcat.bayeux.BayeuxServlet
-
- timeout
- 120000000
-
-
- reconnectInterval
- 250
-
- 1
-
-
-
- cometd
- /cometd/*
-
-
-
- org.apache.cometd.bayeux.samples.EchoChatClient
-
-
- org.apache.cometd.bayeux.samples.BayeuxStockTicker
-
-
-
-
-
+
+
+ Cometd Test WebApp
+
+
+ cometd
+ org.apache.tomcat.bayeux.BayeuxServlet
+
+ timeout
+ 120000000
+
+
+ reconnectInterval
+ 250
+
+ 1
+
+
+
+ cometd
+ /cometd/*
+
+
+
+ org.apache.cometd.bayeux.samples.EchoChatClient
+
+
+ org.apache.cometd.bayeux.samples.BayeuxStockTicker
+
+
+
+
+
Propchange: tomcat/trunk/modules/bayeux/webapps/cometd/WEB-INF/web.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/modules/bayeux/webapps/cometd/examples/simplechat/ticker.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/bayeux/webapps/cometd/examples/simplechat/ticker.html?rev=723775&r1=723774&r2=723775&view=diff
==============================================================================
--- tomcat/trunk/modules/bayeux/webapps/cometd/examples/simplechat/ticker.html (original)
+++ tomcat/trunk/modules/bayeux/webapps/cometd/examples/simplechat/ticker.html Fri Dec 5 07:57:43 2008
@@ -1,128 +1,128 @@
-
-
-
-
-Bayeux Stock Ticker
-
-
-
-
-
-
-Bayeux Stock Ticker
-
-
-
-
-
+
+
+
+
+Bayeux Stock Ticker
+
+
+
+
+
+
+Bayeux Stock Ticker
+
+
+
+
+
\ No newline at end of file
Propchange: tomcat/trunk/modules/bayeux/webapps/cometd/examples/simplechat/ticker.html
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/modules/bayeux/webapps/cometd/index.html
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/bayeux/webapps/cometd/index.html?rev=723775&r1=723774&r2=723775&view=diff
==============================================================================
--- tomcat/trunk/modules/bayeux/webapps/cometd/index.html (original)
+++ tomcat/trunk/modules/bayeux/webapps/cometd/index.html Fri Dec 5 07:57:43 2008
@@ -1,7 +1,7 @@
-
-Cometd demo
-
-
-Try the Simple Chat Demo.
-Try the Stock Ticker Demo.
-
+
+Cometd demo
+
+
+Try the Simple Chat Demo.
+Try the Stock Ticker Demo.
+
Propchange: tomcat/trunk/modules/bayeux/webapps/cometd/index.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/doc/changelog.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/AbstractCreateStatementInterceptor.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java?rev=723775&r1=723774&r2=723775&view=diff
==============================================================================
--- tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java (original)
+++ tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/ConnectionState.java Fri Dec 5 07:57:43 2008
@@ -1,135 +1,135 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.tomcat.jdbc.pool.interceptor;
-
-import java.lang.reflect.Method;
-import java.sql.SQLException;
-
-import org.apache.juli.logging.Log;
-import org.apache.juli.logging.LogFactory;
-import org.apache.tomcat.jdbc.pool.ConnectionPool;
-import org.apache.tomcat.jdbc.pool.DataSourceFactory;
-import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
-import org.apache.tomcat.jdbc.pool.PoolProperties;
-import org.apache.tomcat.jdbc.pool.PooledConnection;
-
-/**
- * Interceptor that keep track of connection state to avoid roundtrips to the database
- * @author fhanik
- *
- */
-
-public class ConnectionState extends JdbcInterceptor {
- protected static Log log = LogFactory.getLog(ConnectionState.class);
-
- protected final String[] readState = {"getAutoCommit","getTransactionIsolation","isReadOnly","getCatalog"};
- protected final String[] writeState = {"setAutoCommit","setTransactionIsolation","setReadOnly","setCatalog"};
-
- protected Boolean autoCommit = null;
- protected Integer transactionIsolation = null;
- protected Boolean readOnly = null;
- protected String catalog = null;
-
-
- public void reset(ConnectionPool parent, PooledConnection con) {
- PoolProperties poolProperties = parent.getPoolProperties();
- if (poolProperties.getDefaultReadOnly()!=null) {
- try {
- if (readOnly==null || readOnly.booleanValue()!=poolProperties.getDefaultReadOnly().booleanValue()) {
- con.getConnection().setReadOnly(poolProperties.getDefaultReadOnly().booleanValue());
- readOnly = poolProperties.getDefaultReadOnly();
- }
- }catch (SQLException x) {
- readOnly = null;
- log.error("Unable to reset readonly state to connection.",x);
- }
- }
- if (poolProperties.getDefaultAutoCommit()!=null) {
- try {
- if (autoCommit==null || autoCommit.booleanValue()!=poolProperties.getDefaultAutoCommit().booleanValue()) {
- con.getConnection().setAutoCommit(poolProperties.getDefaultAutoCommit().booleanValue());
- autoCommit = poolProperties.getDefaultAutoCommit();
- }
- }catch (SQLException x) {
- autoCommit = null;
- log.error("Unable to reset autocommit state to connection.",x);
- }
- }
- if (poolProperties.getDefaultCatalog()!=null) {
- try {
- if (catalog==null || (!catalog.equals(poolProperties.getDefaultCatalog()))) {
- con.getConnection().setCatalog(poolProperties.getDefaultCatalog());
- catalog = poolProperties.getDefaultCatalog();
- }
- }catch (SQLException x) {
- catalog = null;
- log.error("Unable to reset default catalog state to connection.",x);
- }
- }
- if (poolProperties.getDefaultTransactionIsolation()!=DataSourceFactory.UNKNOWN_TRANSACTIONISOLATION) {
- try {
- if (transactionIsolation==null || transactionIsolation.intValue()!=poolProperties.getDefaultTransactionIsolation()) {
- con.getConnection().setTransactionIsolation(poolProperties.getDefaultTransactionIsolation());
- transactionIsolation = poolProperties.getDefaultTransactionIsolation();
- }
- }catch (SQLException x) {
- transactionIsolation = null;
- log.error("Unable to reset transaction isolation state to connection.",x);
- }
- }
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String name = method.getName();
- boolean read = false;
- int index = -1;
- for (int i=0; (!read) && i> perPoolStats =
- new IdentityHashMap>();
-
- protected HashMap queries = null;
-
- protected long threshold = 100; //don't report queries less than this
- protected int maxQueries= 1000; //don't store more than this amount of queries
-
-
-
- public SlowQueryReport() {
- super();
- }
-
- public long getThreshold() {
- return threshold;
- }
-
- public void setThreshold(long threshold) {
- this.threshold = threshold;
- }
-
- @Override
- public void closeInvoked() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public Object createStatement(Object proxy, Method method, Object[] args, Object statement) {
- // TODO Auto-generated method stub
- String sql = null;
- if (method.getName().startsWith("prepare")) {
- sql = (args.length>0 && (args[0] instanceof String))?(String)args[0]:null;
- }
- return new StatementProxy(statement,sql);
- }
-
- protected boolean process(final String[] names, Method method, boolean process) {
- for (int i=0; (!process) && ithreshold) {
- String sql = null;//TODO
- QueryStats qs = SlowQueryReport.this.queries.get(sql);
- if (qs == null) {
- qs = new QueryStats(sql);
- SlowQueryReport.this.queries.put((String)sql,qs);
- }
- qs.add(delta);
- return qs;
- }
- if (close) {
- closed=true;
- delegate = null;
- }
- return result;
- }
- }
-
- public void reset(ConnectionPool parent, PooledConnection con) {
- if (queries==null && SlowQueryReport.perPoolStats.get(parent)==null) {
- queries = new LinkedHashMap() {
- @Override
- protected boolean removeEldestEntry(Entry eldest) {
- return size()>maxQueries;
- }
-
- };
- }
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomcat.jdbc.pool.interceptor;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
+import java.sql.SQLException;
+import java.util.HashMap;
+import java.util.IdentityHashMap;
+import java.util.LinkedHashMap;
+import java.util.Map.Entry;
+
+import org.apache.tomcat.jdbc.pool.ConnectionPool;
+import org.apache.tomcat.jdbc.pool.JdbcInterceptor;
+import org.apache.tomcat.jdbc.pool.PooledConnection;
+
+/**
+ * @author Filip Hanik
+ * @version 1.0
+ */
+public class SlowQueryReport extends AbstractCreateStatementInterceptor {
+ protected final String[] statements = {"createStatement","prepareStatement","prepareCall"};
+ protected final String[] executes = {"execute","executeQuery","executeUpdate","executeBatch"};
+
+ protected static IdentityHashMap> perPoolStats =
+ new IdentityHashMap>();
+
+ protected HashMap queries = null;
+
+ protected long threshold = 100; //don't report queries less than this
+ protected int maxQueries= 1000; //don't store more than this amount of queries
+
+
+
+ public SlowQueryReport() {
+ super();
+ }
+
+ public long getThreshold() {
+ return threshold;
+ }
+
+ public void setThreshold(long threshold) {
+ this.threshold = threshold;
+ }
+
+ @Override
+ public void closeInvoked() {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object createStatement(Object proxy, Method method, Object[] args, Object statement) {
+ // TODO Auto-generated method stub
+ String sql = null;
+ if (method.getName().startsWith("prepare")) {
+ sql = (args.length>0 && (args[0] instanceof String))?(String)args[0]:null;
+ }
+ return new StatementProxy(statement,sql);
+ }
+
+ protected boolean process(final String[] names, Method method, boolean process) {
+ for (int i=0; (!process) && ithreshold) {
+ String sql = null;//TODO
+ QueryStats qs = SlowQueryReport.this.queries.get(sql);
+ if (qs == null) {
+ qs = new QueryStats(sql);
+ SlowQueryReport.this.queries.put((String)sql,qs);
+ }
+ qs.add(delta);
+ return qs;
+ }
+ if (close) {
+ closed=true;
+ delegate = null;
+ }
+ return result;
+ }
+ }
+
+ public void reset(ConnectionPool parent, PooledConnection con) {
+ if (queries==null && SlowQueryReport.perPoolStats.get(parent)==null) {
+ queries = new LinkedHashMap() {
+ @Override
+ protected boolean removeEldestEntry(Entry eldest) {
+ return size()>maxQueries;
+ }
+
+ };
+ }
+ }
+}
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/SlowQueryReport.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/java/org/apache/tomcat/jdbc/pool/interceptor/StatementFinalizer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/BorrowWaitTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/SimplePOJOExample.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/StatementFinalizerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TestConnectionState.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: tomcat/trunk/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/TwoDataSources.java
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org