You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(81) |
Nov
|
Dec
|
---|
From: <me...@us...> - 2002-10-05 17:53:07
|
Update of /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/util In directory usw-pr-cvs1:/tmp/cvs-serv27594/src/tests/java/org/objectstyle/cayenne/util Modified Files: AllTests.java RequestDequeueTst.java Added Files: RequestQueueTst.java Log Message: added test suite for multithreaded RequestQueue --- NEW FILE: RequestQueueTst.java --- /* ==================================================================== * * The ObjectStyle Group Software License, Version 1.0 * * Copyright (c) 2002 The ObjectStyle Group * and individual authors of the software. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * ObjectStyle Group (http://objectstyle.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "ObjectStyle Group" and "Cayenne" * must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact an...@ob.... * * 5. Products derived from this software may not be called "ObjectStyle" * nor may "ObjectStyle" appear in their names without prior written * permission of the ObjectStyle Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the ObjectStyle Group. For more * information on the ObjectStyle Group, please see * <http://objectstyle.org/>. * */ package org.objectstyle.cayenne.util; import org.apache.log4j.Logger; import org.objectstyle.cayenne.CayenneTestCase; /** * @author Andrei Adamchik */ public class RequestQueueTst extends CayenneTestCase { static Logger logObj = Logger.getLogger(RequestQueueTst.class.getName()); /** * Constructor for RequestQueueTst. * @param arg0 */ public RequestQueueTst(String arg0) { super(arg0); } public void testDequeueSuccess() throws Exception { // create non-expiring queue QueueTestThread testCase1 = new QueueTestThread("thread-1", new RequestQueue(5, Integer.MAX_VALUE)); QueueTestThread testCase2 = new QueueTestThread("thread-2", testCase1.getQueue()); try { synchronized (testCase1.getLock()) { testCase1.start(); testCase1.getLock().wait(1000); synchronized (testCase2.getLock()) { testCase2.start(); testCase2.getLock().wait(1000); } assertEquals(2, testCase1.getQueue().getSize()); // test dequeue Object dequeueObj = new Object(); assertTrue(testCase1.getQueue().dequeueFirst(dequeueObj)); RequestDequeue result = testCase1.getResult(); assertNotNull(result); assertTrue(result.isDequeueSuccess()); assertSame(dequeueObj, result.getDequeueEventObject()); // second thread should still be waiting assertNull(testCase2.getResult()); assertEquals(1, testCase1.getQueue().getSize()); } } finally { testCase1.die(); testCase2.die(); } } public void testQueueFull() throws Exception { // create non-expiring queue QueueTestThread testCase1 = new QueueTestThread("thread-3", new RequestQueue(1, Integer.MAX_VALUE)); QueueTestThread testCase2 = new QueueTestThread("thread-4", testCase1.getQueue()); try { testCase1.start(); // thread must exit immediately synchronized (testCase2.getLock()) { testCase2.start(); // will release the lock for a short period of time // to allow thread to run testCase2.getLock().wait(1000); } // second thread must have finished with "QUEUE_FULL" status RequestDequeue result = testCase2.getResult(); assertNotNull(result); assertTrue(result.isQueueFull()); // first thread should still be waiting assertNull(testCase1.getResult()); } finally { testCase1.die(); testCase2.die(); } } public void testWaitTimedOut() throws Exception { // create quickly expiring queue QueueTestThread testCase1 = new QueueTestThread("thread-5", new RequestQueue(1, 100)); try { synchronized (testCase1.getLock()) { testCase1.start(); // will release the lock for a short period of time // to allow thread to run testCase1.getLock().wait(1000); // thread must have finished with "WAIT_TIMED_OUT" status RequestDequeue result = testCase1.getResult(); assertNotNull(result); assertTrue(result.isTimedOut()); assertEquals(0, testCase1.getQueue().getSize()); } } finally { testCase1.die(); } } public void testThreadDied() throws Exception { // create non-expiring queue QueueTestThread testCase1 = new QueueTestThread("thread-6", new RequestQueue(1, Integer.MAX_VALUE)); try { // thread must exit immediately synchronized (testCase1.getLock()) { testCase1.start(); // will release the lock for a short period of time // to allow thread to run testCase1.getLock().wait(1000); // still waiting assertNull(testCase1.getResult()); // assert that dead threads are removed from the queue assertEquals(1, testCase1.getQueue().getSize()); testCase1.die(); testCase1.getLock().wait(1000); assertEquals(0, testCase1.getQueue().getSize()); RequestDequeue result = testCase1.getResult(); assertNotNull(result); assertTrue(result.isInterrupted()); } } finally { testCase1.die(); } } /** A class that tests the queue in a separate thread. */ class QueueTestThread extends Thread { protected RequestQueue queue; protected RequestDequeue result; protected Object lock = new Object(); QueueTestThread(String name, RequestQueue queue) { super(name); this.queue = queue; } /** * @see java.lang.Runnable#run() */ public void run() { // This is a stumbling block for threads to avoid // premature startup before caller is ready. // Caller would start threads while maintaining a lock // on this object, and after all threads are started, caller // would wait on the lock, until any of the finished threads // would call "notify" synchronized (lock) { logObj.debug("Thread started: " + this.getName()); } result = queue.queueThread(); synchronized (lock) { lock.notifyAll(); } logObj.debug("Thread finished: " + this.getName()); } public void die() { // this make sure that thread is not waiting forever // in the queue if (this.isAlive()) { this.interrupt(); } } /** * Returns the queue. * @return RequestQueue */ public RequestQueue getQueue() { return queue; } /** * Returns the result. * @return RequestDequeue */ public RequestDequeue getResult() { return result; } /** * Returns the lock. * @return Object */ public Object getLock() { return lock; } } } Index: AllTests.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/util/AllTests.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- AllTests.java 5 Oct 2002 16:30:10 -0000 1.3 +++ AllTests.java 5 Oct 2002 17:53:04 -0000 1.4 @@ -66,6 +66,7 @@ suite.addTestSuite(ResourceLocatorTst.class); suite.addTestSuite(CayenneMapTst.class); suite.addTestSuite(RequestDequeueTst.class); + suite.addTestSuite(RequestQueueTst.class); return suite; } } Index: RequestDequeueTst.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/util/RequestDequeueTst.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RequestDequeueTst.java 5 Oct 2002 16:30:10 -0000 1.1 +++ RequestDequeueTst.java 5 Oct 2002 17:53:04 -0000 1.2 @@ -91,8 +91,14 @@ public void testTimedOut() throws Exception { RequestDequeue dequeue = new RequestDequeue(); - dequeue.setDequeueEventCode(RequestDequeue.WAIT_TIMED_OUT); + dequeue.setDequeueEventCode(RequestDequeue.TIMED_OUT); assertTrue(dequeue.isTimedOut()); + } + + public void testInterrupted() throws Exception { + RequestDequeue dequeue = new RequestDequeue(); + dequeue.setDequeueEventCode(RequestDequeue.INTERRUPTED); + assertTrue(dequeue.isInterrupted()); } public void testDequeueEventObject() throws Exception { |
From: <me...@us...> - 2002-10-05 17:53:07
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util In directory usw-pr-cvs1:/tmp/cvs-serv27594/src/cayenne/java/org/objectstyle/cayenne/util Modified Files: RequestDequeue.java RequestQueue.java Log Message: added test suite for multithreaded RequestQueue Index: RequestDequeue.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util/RequestDequeue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RequestDequeue.java 4 Oct 2002 06:10:45 -0000 1.1 +++ RequestDequeue.java 5 Oct 2002 17:53:04 -0000 1.2 @@ -64,7 +64,8 @@ public class RequestDequeue { public static final int DEQUEUE_SUCCESS = 1; public static final int QUEUE_FULL = 2; - public static final int WAIT_TIMED_OUT = 3; + public static final int TIMED_OUT = 3; + public static final int INTERRUPTED = 4; protected Object dequeueEventObject; protected int dequeueEventCode; @@ -110,6 +111,24 @@ } public boolean isTimedOut() { - return WAIT_TIMED_OUT == dequeueEventCode; + return TIMED_OUT == dequeueEventCode; + } + + public boolean isInterrupted() { + return INTERRUPTED == dequeueEventCode; + } + + public String toString() { + StringBuffer buf = new StringBuffer(); + buf.append('[').append(getClass().getName()).append(": "); + if (isDequeueSuccess()) { + buf.append("success"); + } else if (isQueueFull()) { + buf.append("queue full"); + } else if (isTimedOut()) { + buf.append("timeout or interrupted"); + } + buf.append(']'); + return buf.toString(); } } Index: RequestQueue.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util/RequestQueue.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- RequestQueue.java 5 Oct 2002 16:30:10 -0000 1.2 +++ RequestQueue.java 5 Oct 2002 17:53:04 -0000 1.3 @@ -81,8 +81,9 @@ /** * Constructor for RequestQueue. * - * @param maxSize - maximum allowed number of - * threads in the queue. + * @param maxSize - maximum allowed number of threads in the queue. + * @param timeout - timeout in milliseconds that determines maximum possible + * wait time in the queue. */ public RequestQueue(int maxSize, int timeout) { this.maxSize = maxSize; @@ -90,6 +91,12 @@ this.queue = Collections.synchronizedList(new ArrayList()); } + public int getSize() { + synchronized (queue) { + return queue.size(); + } + } + /** * Queues current thread. This will block * the caller till the thread is dequeued as a result @@ -114,19 +121,22 @@ // wait synchronized (result) { + boolean interrupted = false; try { // release lock and wait result.wait(timeout); - } catch (InterruptedException e) {} + } catch (InterruptedException e) { + interrupted = true; + } // wait is over, remove itself from the queue - if (result.getDequeueEventCode() != RequestDequeue.DEQUEUE_SUCCESS) { - // timeout + // timeout or interrupted synchronized (queue) { queue.remove(result); - result.setDequeueEventCode(RequestDequeue.WAIT_TIMED_OUT); + int code = (interrupted) ? RequestDequeue.INTERRUPTED : RequestDequeue.TIMED_OUT; + result.setDequeueEventCode(code); } } @@ -148,9 +158,8 @@ first.notifyAll(); } return true; - } - else { - return false; + } else { + return false; } } } |
From: <me...@us...> - 2002-10-05 16:30:16
|
Update of /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/util In directory usw-pr-cvs1:/tmp/cvs-serv4769/src/tests/java/org/objectstyle/cayenne/util Modified Files: AllTests.java Added Files: RequestDequeueTst.java Log Message: created unit tests for RequestDequeue --- NEW FILE: RequestDequeueTst.java --- /* ==================================================================== * * The ObjectStyle Group Software License, Version 1.0 * * Copyright (c) 2002 The ObjectStyle Group * and individual authors of the software. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * ObjectStyle Group (http://objectstyle.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "ObjectStyle Group" and "Cayenne" * must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact an...@ob.... * * 5. Products derived from this software may not be called "ObjectStyle" * nor may "ObjectStyle" appear in their names without prior written * permission of the ObjectStyle Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the ObjectStyle Group. For more * information on the ObjectStyle Group, please see * <http://objectstyle.org/>. * */ package org.objectstyle.cayenne.util; import org.objectstyle.cayenne.CayenneTestCase; /** * @author Andrei Adamchik */ public class RequestDequeueTst extends CayenneTestCase { /** * Constructor for RequestDequeueTst. * * @param arg0 */ public RequestDequeueTst(String arg0) { super(arg0); } public void testDequeueEventCode() throws Exception { RequestDequeue dequeue = new RequestDequeue(); dequeue.setDequeueEventCode(RequestDequeue.QUEUE_FULL); assertEquals(RequestDequeue.QUEUE_FULL, dequeue.getDequeueEventCode()); } public void testDequeueSuccess() throws Exception { RequestDequeue dequeue = new RequestDequeue(); dequeue.setDequeueEventCode(RequestDequeue.DEQUEUE_SUCCESS); assertTrue(dequeue.isDequeueSuccess()); } public void testQueueFull() throws Exception { RequestDequeue dequeue = new RequestDequeue(); dequeue.setDequeueEventCode(RequestDequeue.QUEUE_FULL); assertTrue(dequeue.isQueueFull()); } public void testTimedOut() throws Exception { RequestDequeue dequeue = new RequestDequeue(); dequeue.setDequeueEventCode(RequestDequeue.WAIT_TIMED_OUT); assertTrue(dequeue.isTimedOut()); } public void testDequeueEventObject() throws Exception { RequestDequeue dequeue = new RequestDequeue(); Object obj = new Object(); dequeue.setDequeueEventObject(obj); assertSame(obj, dequeue.getDequeueEventObject()); } } Index: AllTests.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/util/AllTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- AllTests.java 10 Sep 2002 19:49:18 -0000 1.2 +++ AllTests.java 5 Oct 2002 16:30:10 -0000 1.3 @@ -65,6 +65,7 @@ suite.addTestSuite(NameConverterTst.class); suite.addTestSuite(ResourceLocatorTst.class); suite.addTestSuite(CayenneMapTst.class); + suite.addTestSuite(RequestDequeueTst.class); return suite; } } |
From: <me...@us...> - 2002-10-05 16:30:15
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util In directory usw-pr-cvs1:/tmp/cvs-serv4769/src/cayenne/java/org/objectstyle/cayenne/util Modified Files: RequestQueue.java Log Message: created unit tests for RequestDequeue Index: RequestQueue.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util/RequestQueue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- RequestQueue.java 4 Oct 2002 06:10:46 -0000 1.1 +++ RequestQueue.java 5 Oct 2002 16:30:10 -0000 1.2 @@ -67,7 +67,7 @@ * <ul> * <li>Thread is already #1 in the queue and an awaited event occurrs</li> * <li>Thread timeout interval expired</li> - * </li> + * </ul> * * In both cases thread will be removed from the queue. * |
From: <me...@us...> - 2002-10-04 06:10:49
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn In directory usw-pr-cvs1:/tmp/cvs-serv14437/src/cayenne/java/org/objectstyle/cayenne/conn Modified Files: PoolManager.java Log Message: fixed connection pool multithreading problems - implemented request queue with timeouts Index: PoolManager.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/PoolManager.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- PoolManager.java 4 Oct 2002 04:37:58 -0000 1.3 +++ PoolManager.java 4 Oct 2002 06:10:45 -0000 1.4 @@ -71,10 +71,13 @@ import javax.sql.PooledConnection; import org.apache.log4j.Logger; +import org.objectstyle.cayenne.util.RequestDequeue; +import org.objectstyle.cayenne.util.RequestQueue; /** * PoolManager is a pooling DataSource impementation. - * It wraps a non-pooling datasource. + * Internally to obtain connections PoolManager uses either a JDBC driver + * or another pooling datasource. * * <p>TODO: create a low priority thread that will do pool maintenance.</p> * @@ -83,6 +86,21 @@ public class PoolManager implements DataSource, ConnectionEventListener { static Logger logObj = Logger.getLogger(PoolManager.class.getName()); + /** + * Defines a maximum number of threads that could wait in the + * connection queue at any given moment. In the future this + * parameter should be made configurable. + */ + public static final int MAX_QUEUE_SIZE = 25; + + /** + * Defines a maximum time in milliseconds that a connection + * request could wait in the connection queue. After this period + * expires, an exception will be thrown in the calling method. + * In the future this parameter should be made configurable. + */ + public static final int MAX_QUEUE_WAIT = 30000; + protected ConnectionPoolDataSource poolDataSource; protected int minConnections; protected int maxConnections; @@ -93,9 +111,12 @@ protected List unusedPool; protected List usedPool; + protected RequestQueue threadQueue; - /** Creates new PoolManager using org.objectstyle.cayenne.conn.PoolDataSource - * for an underlying ConnectionPoolDataSource. */ + /** + * Creates new PoolManager using org.objectstyle.cayenne.conn.PoolDataSource + * for an underlying ConnectionPoolDataSource. + */ public PoolManager( String jdbcDriver, String dataSourceUrl, @@ -163,6 +184,7 @@ this.poolDataSource = poolDataSource; // init pool + threadQueue = new RequestQueue(MAX_QUEUE_SIZE, MAX_QUEUE_WAIT); usedPool = Collections.synchronizedList(new ArrayList(maxConnections)); unusedPool = Collections.synchronizedList(new ArrayList(maxConnections)); growPool(minConnections, userName, password); @@ -202,32 +224,27 @@ } } - /** Increase connection pool by the specified number of connections.. - * Throw SQLException if no more connections are allowed, or if - * an error happens when creating a new connection. + /** + * Increases connection pool by the specified number of connections. + * + * @return the actual number of created connections. + * @throws SQLException if an error happens when creating a new connection. */ - protected synchronized void growPool( + protected synchronized int growPool( int addConnections, String userName, String password) throws SQLException { - if (unusedPool.size() + usedPool.size() + addConnections > maxConnections) { - StringBuffer msg = new StringBuffer(); - msg - .append("An attempt to open more connections ") - .append("than pool is allowed to handle.") - .append("\n\tCurrent size: " + (unusedPool.size() + usedPool.size())) - .append("\n\tTrying to open: " + addConnections) - .append("\n\tMax allowed: " + maxConnections); - throw new SQLException(msg.toString()); - } - - for (int i = 0; i < addConnections; i++) { + int i = 0; + int startPoolSize = getPoolSize(); + for (; i < addConnections && startPoolSize + i < maxConnections; i++) { PooledConnection newConnection = newPooledConnection(userName, password); newConnection.addConnectionEventListener(this); unusedPool.add(newConnection); } + + return i; } protected synchronized void shrinkPool(int closeConnections) throws SQLException { @@ -286,11 +303,18 @@ return userName; } + /** + * Returns current number of connections. + */ + public synchronized int getPoolSize() { + return usedPool.size() + unusedPool.size(); + } + /** * Returns the number of connections obtained via this DataSource * that are currently in use by the DataSource clients. */ - public int getCurrentlyInUse() { + public synchronized int getCurrentlyInUse() { return usedPool.size(); } @@ -299,7 +323,7 @@ * pool that are currently not used by any clients and are * available immediately via <code>getConnection</code> method. */ - public int getCurrentlyUnused() { + public synchronized int getCurrentlyUnused() { return unusedPool.size(); } @@ -309,7 +333,7 @@ * * <p><code>ds.getConnection(ds.getUserName(), ds.getPassword())</code></p> */ - public synchronized Connection getConnection() throws SQLException { + public Connection getConnection() throws SQLException { return getConnection(userName, password); } @@ -317,18 +341,24 @@ public Connection getConnection(String userName, String password) throws SQLException { - // security check - int totalCon = usedPool.size() + unusedPool.size(); - if (totalCon > maxConnections) { - shrinkPool(totalCon - maxConnections); - } - // increase pool if needed // if further increase is not possible // (say we exceed the maximum number of connections) // this will throw an SQL exception... if (unusedPool.size() == 0) { - growPool(1, userName, password); + int size = growPool(1, userName, password); + + // can't grow anymore, put on hold + if (size == 0) { + RequestDequeue result = threadQueue.queueThread(); + if (result.isDequeueSuccess()) { + return ((PooledConnection) result.getDequeueEventObject()).getConnection(); + } else if (result.isQueueFull()) { + throw new SQLException("Can't obtain connection. Too many requests waiting in the queue."); + } else { + throw new SQLException("Can't obtain connection. Request timed out."); + } + } } int lastObjectInd = unusedPool.size() - 1; @@ -353,7 +383,9 @@ poolDataSource.setLogWriter(out); } - /** Returns closed connection to the pool. */ + /** + * Returns closed connection to the pool. + */ public synchronized void connectionClosed(ConnectionEvent event) { // return connection to the pool PooledConnection closedConn = (PooledConnection) event.getSource(); @@ -362,8 +394,13 @@ // managed by this pool... int usedInd = usedPool.indexOf(closedConn); if (usedInd >= 0) { - usedPool.remove(usedInd); - unusedPool.add(closedConn); + + // check connection request queue and assign connection to the + // first requestor in line + if (!threadQueue.dequeueFirst(closedConn)) { + usedPool.remove(usedInd); + unusedPool.add(closedConn); + } } // else .... // other possibility is that this is a bad connection, so just ignore its closing event, @@ -387,8 +424,7 @@ int usedInd = usedPool.indexOf(errorSrc); if (usedInd >= 0) { usedPool.remove(usedInd); - } - else { + } else { int unusedInd = unusedPool.indexOf(errorSrc); if (unusedInd >= 0) unusedPool.remove(unusedInd); |
From: <me...@us...> - 2002-10-04 06:10:49
|
Update of /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle In directory usw-pr-cvs1:/tmp/cvs-serv14437/src/tests/java/org/objectstyle Modified Files: TestMain.java Log Message: fixed connection pool multithreading problems - implemented request queue with timeouts Index: TestMain.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/TestMain.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- TestMain.java 8 Sep 2002 23:02:00 -0000 1.1 +++ TestMain.java 4 Oct 2002 06:10:46 -0000 1.2 @@ -207,7 +207,7 @@ new PoolManager( poolDS, 1, - 2, + 1, dsi.getUserName(), dsi.getPassword()); |
From: <me...@us...> - 2002-10-04 06:10:48
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/util In directory usw-pr-cvs1:/tmp/cvs-serv14437/src/cayenne/java/org/objectstyle/cayenne/util Added Files: RequestDequeue.java RequestQueue.java Log Message: fixed connection pool multithreading problems - implemented request queue with timeouts --- NEW FILE: RequestDequeue.java --- /* ==================================================================== * * The ObjectStyle Group Software License, Version 1.0 * * Copyright (c) 2002 The ObjectStyle Group * and individual authors of the software. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * ObjectStyle Group (http://objectstyle.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "ObjectStyle Group" and "Cayenne" * must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact an...@ob.... * * 5. Products derived from this software may not be called "ObjectStyle" * nor may "ObjectStyle" appear in their names without prior written * permission of the ObjectStyle Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the ObjectStyle Group. For more * information on the ObjectStyle Group, please see * <http://objectstyle.org/>. * */ package org.objectstyle.cayenne.util; /** * RequestDequeue encapsulates the result of a thread wait in the * RequestQueue. * * @author Andrei Adamchik */ public class RequestDequeue { public static final int DEQUEUE_SUCCESS = 1; public static final int QUEUE_FULL = 2; public static final int WAIT_TIMED_OUT = 3; protected Object dequeueEventObject; protected int dequeueEventCode; /** * Returns the dequeueEventCode. * @return int */ public int getDequeueEventCode() { return dequeueEventCode; } /** * Returns the dequeueEventObject. * @return Object */ public Object getDequeueEventObject() { return dequeueEventObject; } /** * Sets the dequeueEventCode. * @param dequeueEventCode The dequeueEventCode to set */ public void setDequeueEventCode(int dequeueEventCode) { this.dequeueEventCode = dequeueEventCode; } /** * Sets the dequeueEventObject. * @param dequeueEventObject The dequeueEventObject to set */ public void setDequeueEventObject(Object dequeueEventObject) { this.dequeueEventObject = dequeueEventObject; } public boolean isDequeueSuccess() { return DEQUEUE_SUCCESS == dequeueEventCode; } public boolean isQueueFull() { return QUEUE_FULL == dequeueEventCode; } public boolean isTimedOut() { return WAIT_TIMED_OUT == dequeueEventCode; } } --- NEW FILE: RequestQueue.java --- /* ==================================================================== * * The ObjectStyle Group Software License, Version 1.0 * * Copyright (c) 2002 The ObjectStyle Group * and individual authors of the software. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: * "This product includes software developed by the * ObjectStyle Group (http://objectstyle.org/)." * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "ObjectStyle Group" and "Cayenne" * must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact an...@ob.... * * 5. Products derived from this software may not be called "ObjectStyle" * nor may "ObjectStyle" appear in their names without prior written * permission of the ObjectStyle Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE OBJECTSTYLE GROUP OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the ObjectStyle Group. For more * information on the ObjectStyle Group, please see * <http://objectstyle.org/>. * */ package org.objectstyle.cayenne.util; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * RequestQueue implements a FIFO queue for threads waiting for a * particular event, resource, etc. Each thread will wait * in the queue until either of the following events happen: * * <ul> * <li>Thread is already #1 in the queue and an awaited event occurrs</li> * <li>Thread timeout interval expired</li> * </li> * * In both cases thread will be removed from the queue. * * @author Andrei Adamchik */ public class RequestQueue { protected List queue; protected int maxSize; protected int timeout; /** * Constructor for RequestQueue. * * @param maxSize - maximum allowed number of * threads in the queue. */ public RequestQueue(int maxSize, int timeout) { this.maxSize = maxSize; this.timeout = timeout; this.queue = Collections.synchronizedList(new ArrayList()); } /** * Queues current thread. This will block * the caller till the thread is dequeued as a result * of another thread calling <code>dequeueFirst</code> * or as a result of a timeout. * * @return an object that represents an event or resource that * caused */ public RequestDequeue queueThread() { RequestDequeue result = new RequestDequeue(); // queue up request synchronized (queue) { if (maxSize > 0 && queue.size() >= maxSize) { result.setDequeueEventCode(RequestDequeue.QUEUE_FULL); return result; } queue.add(result); } // wait synchronized (result) { try { // release lock and wait result.wait(timeout); } catch (InterruptedException e) {} // wait is over, remove itself from the queue if (result.getDequeueEventCode() != RequestDequeue.DEQUEUE_SUCCESS) { // timeout synchronized (queue) { queue.remove(result); result.setDequeueEventCode(RequestDequeue.WAIT_TIMED_OUT); } } return result; } } /** * Releases the first thread in the queue. */ public boolean dequeueFirst(Object dequeuedObj) { synchronized (queue) { if (queue.size() > 0) { RequestDequeue first = (RequestDequeue) queue.get(0); synchronized (first) { queue.remove(0); first.setDequeueEventObject(dequeuedObj); first.setDequeueEventCode(RequestDequeue.DEQUEUE_SUCCESS); first.notifyAll(); } return true; } else { return false; } } } } |
From: <me...@us...> - 2002-10-04 04:38:03
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn In directory usw-pr-cvs1:/tmp/cvs-serv28149/src/cayenne/java/org/objectstyle/cayenne/conn Modified Files: PoolManager.java Log Message: synchronized connection pool access Index: PoolManager.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/PoolManager.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- PoolManager.java 4 Oct 2002 04:23:51 -0000 1.2 +++ PoolManager.java 4 Oct 2002 04:37:58 -0000 1.3 @@ -60,6 +60,8 @@ import java.sql.Connection; import java.sql.SQLException; import java.util.ArrayList; +import java.util.Collections; +import java.util.List; import java.util.ListIterator; import javax.sql.ConnectionEvent; @@ -79,329 +81,321 @@ * @author Andrei Adamchik */ public class PoolManager implements DataSource, ConnectionEventListener { - static Logger logObj = Logger.getLogger(PoolManager.class.getName()); + static Logger logObj = Logger.getLogger(PoolManager.class.getName()); - protected ConnectionPoolDataSource poolDataSource; - protected int minConnections; - protected int maxConnections; - protected String dataSourceUrl; - protected String jdbcDriver; - protected String password; - protected String userName; + protected ConnectionPoolDataSource poolDataSource; + protected int minConnections; + protected int maxConnections; + protected String dataSourceUrl; + protected String jdbcDriver; + protected String password; + protected String userName; - private ArrayList unusedPool; - private ArrayList usedPool; + protected List unusedPool; + protected List usedPool; - /** Creates new PoolManager using org.objectstyle.cayenne.conn.PoolDataSource - * for an underlying ConnectionPoolDataSource. */ - public PoolManager( - String jdbcDriver, - String dataSourceUrl, - int minCons, - int maxCons, - String userName, - String password) - throws SQLException { + /** Creates new PoolManager using org.objectstyle.cayenne.conn.PoolDataSource + * for an underlying ConnectionPoolDataSource. */ + public PoolManager( + String jdbcDriver, + String dataSourceUrl, + int minCons, + int maxCons, + String userName, + String password) + throws SQLException { - this.jdbcDriver = jdbcDriver; - this.dataSourceUrl = dataSourceUrl; - PoolDataSource poolDS = new PoolDataSource(jdbcDriver, dataSourceUrl); - init(poolDS, minCons, maxCons, userName, password); - } + this.jdbcDriver = jdbcDriver; + this.dataSourceUrl = dataSourceUrl; + PoolDataSource poolDS = new PoolDataSource(jdbcDriver, dataSourceUrl); + init(poolDS, minCons, maxCons, userName, password); + } - /** Creates new PoolManager with the specified policy for - * connection pooling and a ConnectionPoolDataSource object. - * - * @param poolDataSource data source for pooled connections - * @param minCons Non-negative integer that specifies a minimum number of open connections - * to keep in the pool at all times - * @param maxCons Non-negative integer that specifies maximum number of simultaneuosly open connections - * - * @throws SQLException if pool manager can not be created. - */ - public PoolManager( - ConnectionPoolDataSource poolDataSource, - int minCons, - int maxCons, - String userName, - String password) - throws SQLException { - init(poolDataSource, minCons, maxCons, userName, password); - } + /** Creates new PoolManager with the specified policy for + * connection pooling and a ConnectionPoolDataSource object. + * + * @param poolDataSource data source for pooled connections + * @param minCons Non-negative integer that specifies a minimum number of open connections + * to keep in the pool at all times + * @param maxCons Non-negative integer that specifies maximum number of simultaneuosly open connections + * + * @throws SQLException if pool manager can not be created. + */ + public PoolManager( + ConnectionPoolDataSource poolDataSource, + int minCons, + int maxCons, + String userName, + String password) + throws SQLException { + init(poolDataSource, minCons, maxCons, userName, password); + } - /** Initializes pool. Normally called from constructor. */ - private void init( - ConnectionPoolDataSource poolDataSource, - int minCons, - int maxCons, - String userName, - String password) - throws SQLException { + /** Initializes pool. Normally called from constructor. */ + protected void init( + ConnectionPoolDataSource poolDataSource, + int minCons, + int maxCons, + String userName, + String password) + throws SQLException { - // do sanity checks... - if (maxConnections < 0) { - throw new SQLException( - "Maximum number of connections can not be negative (" - + maxCons - + ")."); - } + // do sanity checks... + if (maxConnections < 0) { + throw new SQLException( + "Maximum number of connections can not be negative (" + maxCons + ")."); + } - if (minConnections < 0) { - throw new SQLException( - "Minimum number of connections can not be negative (" - + minCons - + ")."); - } + if (minConnections < 0) { + throw new SQLException( + "Minimum number of connections can not be negative (" + minCons + ")."); + } - if (minConnections > maxConnections) { - throw new SQLException("Minimum number of connections can not be bigger then maximum."); - } + if (minConnections > maxConnections) { + throw new SQLException("Minimum number of connections can not be bigger then maximum."); + } - // init properties - this.userName = userName; - this.password = password; - this.minConnections = minCons; - this.maxConnections = maxCons; - this.poolDataSource = poolDataSource; + // init properties + this.userName = userName; + this.password = password; + this.minConnections = minCons; + this.maxConnections = maxCons; + this.poolDataSource = poolDataSource; - // init pool - usedPool = new ArrayList(maxConnections); - unusedPool = new ArrayList(maxConnections); - growPool(minConnections, userName, password); - } + // init pool + usedPool = Collections.synchronizedList(new ArrayList(maxConnections)); + unusedPool = Collections.synchronizedList(new ArrayList(maxConnections)); + growPool(minConnections, userName, password); + } - /** Creates and returns new PooledConnection object. */ - private PooledConnection newPooledConnection( - String userName, - String password) - throws SQLException { - if (userName != null) - return poolDataSource.getPooledConnection(userName, password); - else - return poolDataSource.getPooledConnection(); - } + /** Creates and returns new PooledConnection object. */ + protected PooledConnection newPooledConnection(String userName, String password) + throws SQLException { + return (userName != null) + ? poolDataSource.getPooledConnection(userName, password) + : poolDataSource.getPooledConnection(); + } - /** Closes all existing connections, removes them from the pool. */ - public void dispose() throws SQLException { - // clean connections from the pool - ListIterator unusedIterator = unusedPool.listIterator(); - while (unusedIterator.hasNext()) { - PooledConnection con = (PooledConnection) unusedIterator.next(); - // close connection - con.close(); - // remove connection from the list - unusedIterator.remove(); - } + /** Closes all existing connections, removes them from the pool. */ + public synchronized void dispose() throws SQLException { - // clean used connections - ListIterator usedIterator = usedPool.listIterator(); - while (usedIterator.hasNext()) { - PooledConnection con = (PooledConnection) usedIterator.next(); - // stop listening for connection events - con.removeConnectionEventListener(this); - // close connection - con.close(); - // remove connection from the list - usedIterator.remove(); - } - } + // clean connections from the pool + ListIterator unusedIterator = unusedPool.listIterator(); + while (unusedIterator.hasNext()) { + PooledConnection con = (PooledConnection) unusedIterator.next(); + // close connection + con.close(); + // remove connection from the list + unusedIterator.remove(); + } - /** Increase connection pool by the specified number of connections.. - * Throw SQLException if no more connections are allowed, or if - * an error happens when creating a new connection. - */ - private void growPool(int addConnections, String userName, String password) - throws SQLException { - if (unusedPool.size() + usedPool.size() + addConnections - > maxConnections) { - StringBuffer msg = new StringBuffer(); - msg - .append("An attempt to open more connections ") - .append("than pool is allowed to handle.") - .append( - "\n\tCurrent size: " - + (unusedPool.size() + usedPool.size())) - .append("\n\tTrying to open: " + addConnections) - .append("\n\tMax allowed: " + maxConnections); - throw new SQLException(msg.toString()); - } + // clean used connections + ListIterator usedIterator = usedPool.listIterator(); + while (usedIterator.hasNext()) { + PooledConnection con = (PooledConnection) usedIterator.next(); + // stop listening for connection events + con.removeConnectionEventListener(this); + // close connection + con.close(); + // remove connection from the list + usedIterator.remove(); + } + } - for (int i = 0; i < addConnections; i++) { - PooledConnection newConnection = - newPooledConnection(userName, password); - newConnection.addConnectionEventListener(this); - unusedPool.add(newConnection); - } - } + /** Increase connection pool by the specified number of connections.. + * Throw SQLException if no more connections are allowed, or if + * an error happens when creating a new connection. + */ + protected synchronized void growPool( + int addConnections, + String userName, + String password) + throws SQLException { - private void shrinkPool(int closeConnections) throws SQLException { - int close = - unusedPool.size() < closeConnections - ? unusedPool.size() - : closeConnections; - int lastInd = unusedPool.size() - close; + if (unusedPool.size() + usedPool.size() + addConnections > maxConnections) { + StringBuffer msg = new StringBuffer(); + msg + .append("An attempt to open more connections ") + .append("than pool is allowed to handle.") + .append("\n\tCurrent size: " + (unusedPool.size() + usedPool.size())) + .append("\n\tTrying to open: " + addConnections) + .append("\n\tMax allowed: " + maxConnections); + throw new SQLException(msg.toString()); + } - for (int i = unusedPool.size() - 1; i >= lastInd; i--) { - PooledConnection con = (PooledConnection) unusedPool.remove(i); - con.close(); - } - } + for (int i = 0; i < addConnections; i++) { + PooledConnection newConnection = newPooledConnection(userName, password); + newConnection.addConnectionEventListener(this); + unusedPool.add(newConnection); + } + } - /** - * Returns maximum number of connections this pool can keep. - * This parameter when configured allows to limit the number of simultaneously - * open connections. - */ - public int getMaxConnections() { - return maxConnections; - } + protected synchronized void shrinkPool(int closeConnections) throws SQLException { + int close = + unusedPool.size() < closeConnections ? unusedPool.size() : closeConnections; + int lastInd = unusedPool.size() - close; - public void setMaxConnections(int maxConnections) { - this.maxConnections = maxConnections; - } + for (int i = unusedPool.size() - 1; i >= lastInd; i--) { + PooledConnection con = (PooledConnection) unusedPool.remove(i); + con.close(); + } + } - /** Returns the absolute minimum number of connections allowed - * in this pool at any moment in time. */ - public int getMinConnections() { - return minConnections; - } + /** + * Returns maximum number of connections this pool can keep. + * This parameter when configured allows to limit the number of simultaneously + * open connections. + */ + public int getMaxConnections() { + return maxConnections; + } - public void setMinConnections(int minConnections) { - this.minConnections = minConnections; - } + public void setMaxConnections(int maxConnections) { + this.maxConnections = maxConnections; + } - /** Returns a database URL used to initialize this pool. - * Will return null if the pool was initialized with ConnectionPoolDataSource. */ - public String getDataSourceUrl() { - return dataSourceUrl; - } + /** Returns the absolute minimum number of connections allowed + * in this pool at any moment in time. */ + public int getMinConnections() { + return minConnections; + } - /** Returns a name of a JDBC driver used to initialize this pool. - * Will return null if the pool was initialized with ConnectionPoolDataSource. */ - public String getJdbcDriver() { - return jdbcDriver; - } + public void setMinConnections(int minConnections) { + this.minConnections = minConnections; + } - /** Returns a data source password used to initialize this pool. */ - public String getPassword() { - return password; - } + /** Returns a database URL used to initialize this pool. + * Will return null if the pool was initialized with ConnectionPoolDataSource. */ + public String getDataSourceUrl() { + return dataSourceUrl; + } - /** Returns a data source user name used to initialize this pool. */ - public String getUserName() { - return userName; - } + /** Returns a name of a JDBC driver used to initialize this pool. + * Will return null if the pool was initialized with ConnectionPoolDataSource. */ + public String getJdbcDriver() { + return jdbcDriver; + } - /** - * Returns the number of connections obtained via this DataSource - * that are currently in use by the DataSource clients. - */ - public int getCurrentlyInUse() { - return usedPool.size(); - } + /** Returns a data source password used to initialize this pool. */ + public String getPassword() { + return password; + } - /** - * Returns the number of connections maintained in the - * pool that are currently not used by any clients and are - * available immediately via <code>getConnection</code> method. - */ - public int getCurrentlyUnused() { - return unusedPool.size(); - } + /** Returns a data source user name used to initialize this pool. */ + public String getUserName() { + return userName; + } - /** - * Returns connection from the pool using internal values of user name - * and password. Eqivalent to calling: - * - * <p><code>ds.getConnection(ds.getUserName(), ds.getPassword())</code></p> - */ - public synchronized Connection getConnection() throws SQLException { - return getConnection(userName, password); - } + /** + * Returns the number of connections obtained via this DataSource + * that are currently in use by the DataSource clients. + */ + public int getCurrentlyInUse() { + return usedPool.size(); + } - /** Returns connection from the pool. */ - public Connection getConnection(String userName, String password) - throws SQLException { + /** + * Returns the number of connections maintained in the + * pool that are currently not used by any clients and are + * available immediately via <code>getConnection</code> method. + */ + public int getCurrentlyUnused() { + return unusedPool.size(); + } - // security check - int totalCon = usedPool.size() + unusedPool.size(); - if (totalCon > maxConnections) { - shrinkPool(totalCon - maxConnections); - } + /** + * Returns connection from the pool using internal values of user name + * and password. Eqivalent to calling: + * + * <p><code>ds.getConnection(ds.getUserName(), ds.getPassword())</code></p> + */ + public synchronized Connection getConnection() throws SQLException { + return getConnection(userName, password); + } - // increase pool if needed - // if further increase is not possible - // (say we exceed the maximum number of connections) - // this will throw an SQL exception... - if (unusedPool.size() == 0) { - growPool(1, userName, password); - } + /** Returns connection from the pool. */ + public Connection getConnection(String userName, String password) + throws SQLException { - int lastObjectInd = unusedPool.size() - 1; - PooledConnection pooledConn = - (PooledConnection) unusedPool.remove(lastObjectInd); - usedPool.add(pooledConn); - return pooledConn.getConnection(); - } + // security check + int totalCon = usedPool.size() + unusedPool.size(); + if (totalCon > maxConnections) { + shrinkPool(totalCon - maxConnections); + } - public int getLoginTimeout() throws java.sql.SQLException { - return poolDataSource.getLoginTimeout(); - } + // increase pool if needed + // if further increase is not possible + // (say we exceed the maximum number of connections) + // this will throw an SQL exception... + if (unusedPool.size() == 0) { + growPool(1, userName, password); + } - public void setLoginTimeout(int seconds) throws java.sql.SQLException { - poolDataSource.setLoginTimeout(seconds); - } + int lastObjectInd = unusedPool.size() - 1; + PooledConnection pooledConn = (PooledConnection) unusedPool.remove(lastObjectInd); + usedPool.add(pooledConn); + return pooledConn.getConnection(); + } - public PrintWriter getLogWriter() throws java.sql.SQLException { - return poolDataSource.getLogWriter(); - } + public int getLoginTimeout() throws java.sql.SQLException { + return poolDataSource.getLoginTimeout(); + } - public void setLogWriter(PrintWriter out) throws java.sql.SQLException { - poolDataSource.setLogWriter(out); - } + public void setLoginTimeout(int seconds) throws java.sql.SQLException { + poolDataSource.setLoginTimeout(seconds); + } - /** Returns closed connection to the pool. */ - public synchronized void connectionClosed(ConnectionEvent event) { - // return connection to the pool - PooledConnection closedConn = (PooledConnection) event.getSource(); + public PrintWriter getLogWriter() throws java.sql.SQLException { + return poolDataSource.getLogWriter(); + } - // remove this connection from the list of connections - // managed by this pool... - int usedInd = usedPool.indexOf(closedConn); - if (usedInd >= 0) { - usedPool.remove(usedInd); - unusedPool.add(closedConn); - } - // else .... - // other possibility is that this is a bad connection, so just ignore its closing event, - // since it was unregistered in "connectionErrorOccurred" - } + public void setLogWriter(PrintWriter out) throws java.sql.SQLException { + poolDataSource.setLogWriter(out); + } - /** - * Removes connection with an error from the pool. This method - * is called by PoolManager connections on connection errors - * to notify PoolManager that connection is in invalid state. - */ - public synchronized void connectionErrorOccurred(ConnectionEvent event) { - // later on we should analize the error to see if this - // is fatal... right now just kill this PooledConnection + /** Returns closed connection to the pool. */ + public synchronized void connectionClosed(ConnectionEvent event) { + // return connection to the pool + PooledConnection closedConn = (PooledConnection) event.getSource(); - PooledConnection errorSrc = (PooledConnection) event.getSource(); + // remove this connection from the list of connections + // managed by this pool... + int usedInd = usedPool.indexOf(closedConn); + if (usedInd >= 0) { + usedPool.remove(usedInd); + unusedPool.add(closedConn); + } + // else .... + // other possibility is that this is a bad connection, so just ignore its closing event, + // since it was unregistered in "connectionErrorOccurred" + } - // remove this connection from the list of connections - // managed by this pool... + /** + * Removes connection with an error from the pool. This method + * is called by PoolManager connections on connection errors + * to notify PoolManager that connection is in invalid state. + */ + public synchronized void connectionErrorOccurred(ConnectionEvent event) { + // later on we should analize the error to see if this + // is fatal... right now just kill this PooledConnection - int usedInd = usedPool.indexOf(errorSrc); - if (usedInd >= 0) - usedPool.remove(usedInd); - else { - int unusedInd = unusedPool.indexOf(errorSrc); - if (unusedInd >= 0) - unusedPool.remove(unusedInd); - } + PooledConnection errorSrc = (PooledConnection) event.getSource(); - // do not close connection, - // let the code that catches the exception handle it - // .... - } + // remove this connection from the list of connections + // managed by this pool... + + int usedInd = usedPool.indexOf(errorSrc); + if (usedInd >= 0) { + usedPool.remove(usedInd); + } + else { + int unusedInd = unusedPool.indexOf(errorSrc); + if (unusedInd >= 0) + unusedPool.remove(unusedInd); + } + + // do not close connection, + // let the code that catches the exception handle it + // .... + } } |
From: <me...@us...> - 2002-10-04 04:38:03
|
Update of /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/conn In directory usw-pr-cvs1:/tmp/cvs-serv28149/src/tests/java/org/objectstyle/cayenne/conn Modified Files: PoolManagerTst.java Log Message: synchronized connection pool access Index: PoolManagerTst.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tests/java/org/objectstyle/cayenne/conn/PoolManagerTst.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PoolManagerTst.java 8 Sep 2002 23:02:01 -0000 1.1 +++ PoolManagerTst.java 4 Oct 2002 04:37:58 -0000 1.2 @@ -65,9 +65,9 @@ public PoolManagerTst(String name) { super(name); - } - - public void testDataSourceUrl() throws java.lang.Exception { + } + + public void testDataSourceUrl() throws Exception { String driverName = org.objectstyle.TestMain.getFreshConnInfo().getJdbcDriver(); String url = org.objectstyle.TestMain.getFreshConnInfo().getDataSourceUrl(); @@ -76,27 +76,27 @@ assertEquals(driverName, pm.getJdbcDriver()); } - public void testPassword() throws java.lang.Exception { + public void testPassword() throws Exception { PoolManager pm = new PoolManager(null, 0, 3, "", "b"); assertEquals("b", pm.getPassword()); } - public void testUserName() throws java.lang.Exception { + public void testUserName() throws Exception { PoolManager pm = new PoolManager(null, 0, 3, "a", ""); assertEquals("a", pm.getUserName()); } - public void testMinConnections() throws java.lang.Exception { + public void testMinConnections() throws Exception { PoolManager pm = new PoolManager(null, 0, 3, "", ""); assertEquals(0, pm.getMinConnections()); } - public void testMaxConnections() throws java.lang.Exception { + public void testMaxConnections() throws Exception { PoolManager pm = new PoolManager(null, 0, 3, "", ""); assertEquals(3, pm.getMaxConnections()); } - public void testPooling() throws java.lang.Exception { + public void testPooling() throws Exception { DataSourceInfo dsi = TestMain.getFreshConnInfo(); PoolManager pm = new PoolManager( |
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn In directory usw-pr-cvs1:/tmp/cvs-serv25586/src/cayenne/java/org/objectstyle/cayenne/conn Modified Files: ConnectionWrapper.java DriverDataSource.java PoolDataSource.java PoolManager.java PooledConnectionImpl.java Log Message: refactoring - cleaning import statements, fixing API docs Index: ConnectionWrapper.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/ConnectionWrapper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ConnectionWrapper.java 8 Sep 2002 22:46:47 -0000 1.1 +++ ConnectionWrapper.java 4 Oct 2002 04:23:51 -0000 1.2 @@ -55,20 +55,25 @@ * */ -import java.sql.*; +import java.sql.CallableStatement; +import java.sql.Connection; +import java.sql.DatabaseMetaData; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.sql.SQLWarning; +import java.sql.Savepoint; +import java.sql.Statement; import java.util.Map; /** - * <p>Cayenne specific java.sql.Connection implementation that allowes to pool - * JDBC connections when a driver used does not support pooled connections. + * <p>ConnectionWrapper is a <code>java.sql.Connection</code> implementation that + * allows to pool JDBC connections when a driver used does not support pooled connections. * This implementation will wrap existing connection object obtained elsewhere, * delegating all the calls to it, except for "close" method that is * implemented to return connection to the pool and "isClosed" method that * returns true if connection was returned to the pool or closed by the pool.</p> - * - * <p>Because of the overhead involved when calling connection methods, this class - * should only be used when a corresponding driver does not support connection - * pooling at all.</p> + * + * @author Andrei Adamchik */ public class ConnectionWrapper implements Connection { private Connection connectionObj; Index: DriverDataSource.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/DriverDataSource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- DriverDataSource.java 8 Sep 2002 22:46:47 -0000 1.1 +++ DriverDataSource.java 4 Oct 2002 04:23:51 -0000 1.2 @@ -56,15 +56,17 @@ */ import java.io.PrintWriter; -import java.sql.*; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.SQLException; import javax.sql.DataSource; /** - * Class that wrapps "old-style" JDBC access via Drivers - * to "new-style" access via DataSource. Also provides things like - * connection pooling, etc... - * + * DriverDataSource is a simple DataSource implementation + * on top of a JDBC driver. + * + * @author Andrei Adamchik */ public class DriverDataSource implements DataSource { private int loginTimeout; Index: PoolDataSource.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/PoolDataSource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PoolDataSource.java 8 Sep 2002 22:46:47 -0000 1.1 +++ PoolDataSource.java 4 Oct 2002 04:23:51 -0000 1.2 @@ -57,17 +57,22 @@ import java.io.PrintWriter; import java.sql.SQLException; -import org.apache.log4j.Logger; -import javax.sql.*; +import javax.sql.ConnectionPoolDataSource; +import javax.sql.DataSource; +import javax.sql.PooledConnection; + +import org.apache.log4j.Logger; /** - * <p>This class allows to generate pooled connections.</p> - * - * <p>It is implemented as a wrapper around a non-pooled data source object. Delegates all method - * calls except for "getPooledConnection" to the underlying datasource... - * </p> + * <p>PoolDataSource allows to generate pooled connections.</p> * + * <p>It is implemented as a wrapper around a non-pooled data source object. + * Delegates all method calls except for "getPooledConnection" to the underlying + * datasource. + * </p> + * + * @author Andrei Adamchik */ public class PoolDataSource implements ConnectionPoolDataSource { static Logger logObj = Logger.getLogger(PoolDataSource.class.getName()); Index: PoolManager.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/PoolManager.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PoolManager.java 8 Sep 2002 22:46:47 -0000 1.1 +++ PoolManager.java 4 Oct 2002 04:23:51 -0000 1.2 @@ -61,15 +61,18 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.ListIterator; -import org.apache.log4j.Logger; -import javax.sql.*; +import javax.sql.ConnectionEvent; +import javax.sql.ConnectionEventListener; +import javax.sql.ConnectionPoolDataSource; +import javax.sql.DataSource; +import javax.sql.PooledConnection; + +import org.apache.log4j.Logger; /** - * PoolManager is a DataSource impementation that hides connection pooling logic - * from the users, acting as a normal DataSource. Application servers may provide - * their own DataSources that handle pooling. In such cases Cayenne should - * use app server specific implementation instead of PoolManager. + * PoolManager is a pooling DataSource impementation. + * It wraps a non-pooling datasource. * * <p>TODO: create a low priority thread that will do pool maintenance.</p> * Index: PooledConnectionImpl.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/conn/PooledConnectionImpl.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- PooledConnectionImpl.java 8 Sep 2002 22:46:47 -0000 1.1 +++ PooledConnectionImpl.java 4 Oct 2002 04:23:51 -0000 1.2 @@ -59,14 +59,20 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Iterator; -import org.apache.log4j.Logger; -import javax.sql.*; +import javax.sql.ConnectionEvent; +import javax.sql.ConnectionEventListener; +import javax.sql.PooledConnection; + +import org.apache.log4j.Logger; /** - * Cayenne implementation of the pooling wrapper for the database connection - * as per J2EE spec. Most of the modern JDBC drivers should have its - * own implementation that should be used instead of this class... + * PooledConnectionImpl is an implementation of a pooling wrapper + * for the database connection as per JDBC3 spec. Most of the modern + * JDBC drivers should have its own implementation that may be + * used instead of this class. + * + * @author Andrei Adamchik */ public class PooledConnectionImpl implements PooledConnection { static Logger logObj = Logger.getLogger(PooledConnectionImpl.class.getName()); |
From: <me...@us...> - 2002-10-04 04:12:18
|
Update of /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/gui/action In directory usw-pr-cvs1:/tmp/cvs-serv23223/src/cayenne/java/org/objectstyle/cayenne/gui/action Modified Files: NewProjectAction.java Log Message: bug fix for 608127 Index: NewProjectAction.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/cayenne/java/org/objectstyle/cayenne/gui/action/NewProjectAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- NewProjectAction.java 8 Sep 2002 22:46:47 -0000 1.1 +++ NewProjectAction.java 4 Oct 2002 04:12:10 -0000 1.2 @@ -74,90 +74,98 @@ * @author Andrei Adamchik */ public class NewProjectAction extends ProjectAction { - static Logger logObj = - Logger.getLogger(NewProjectAction.class.getName()); - - public static final String ACTION_NAME = "New Project"; + static Logger logObj = Logger.getLogger(NewProjectAction.class.getName()); - public NewProjectAction() { - super(ACTION_NAME); - } + public static final String ACTION_NAME = "New Project"; - public String getIconName() { - return "icon-new.gif"; - } + public NewProjectAction() { + super(ACTION_NAME); + } - public KeyStroke getAcceleratorKey() { - return KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK); - } + public String getIconName() { + return "icon-new.gif"; + } - /** - * @see org.objectstyle.cayenne.gui.action.CayenneAction#performAction(ActionEvent) - */ - public void performAction(ActionEvent e) { - newProject(); - } + public KeyStroke getAcceleratorKey() { + return KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK); + } - protected void newProject() { - Preferences pref = Preferences.getPreferences(); - String startDir = (String) pref.getProperty(Preferences.LAST_DIR); - try { - boolean finished = false; - File file = null; - File projectFile = null; + /** + * @see org.objectstyle.cayenne.gui.action.CayenneAction#performAction(ActionEvent) + */ + public void performAction(ActionEvent e) { + newProject(); + } - while (!finished) { - fileChooser.setAcceptAllFileFilterUsed(false); - fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - fileChooser.setDialogTitle("Choose project location"); - if (startDir != null) { - File init_dir_file = new File(startDir); - if (init_dir_file.exists()) - fileChooser.setCurrentDirectory(init_dir_file); - } - int ret_code = fileChooser.showSaveDialog(Editor.getFrame()); - if (ret_code != JFileChooser.APPROVE_OPTION) - return; - file = fileChooser.getSelectedFile(); - if (!file.exists()) - file.createNewFile(); - projectFile = new File(file, ProjectFileFilter.PROJ_FILE_NAME); - if (projectFile.exists()) { - int ret = - JOptionPane.showConfirmDialog( - Editor.getFrame(), - "There is already " - + "project in this folder. Overwrite?"); - if (ret == JOptionPane.YES_OPTION) { - finished = true; - } else if (ret == JOptionPane.CANCEL_OPTION) { - return; - } - } else { - finished = true; - } - } + protected void newProject() { + Preferences pref = Preferences.getPreferences(); + String startDir = (String) pref.getProperty(Preferences.LAST_DIR); + try { + boolean finished = false; + File file = null; + File projectFile = null; - // Save and close (if needed) currently open project. - if (getMediator() != null && !closeProject()) { - return; - } + while (!finished) { + fileChooser.setAcceptAllFileFilterUsed(false); + fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); + fileChooser.setDialogTitle("Choose project location"); + if (startDir != null) { + File startDirFile = new File(startDir); + if (startDirFile.exists()) { + fileChooser.setCurrentDirectory(startDirFile); + } + } - // Save dir path to the preferences - pref.setProperty(Preferences.LAST_DIR, file.getAbsolutePath()); - try { - GuiConfiguration.initSharedConfig(projectFile, false); - } catch (ConfigException e) { - logObj.warn(e); - } - - setMediator(Mediator.getMediator(GuiConfiguration.getGuiConfig())); - Editor.getFrame().projectOpened(); - - // Set title to contain proj file path - Editor.getFrame().setProjectTitle(projectFile.getAbsolutePath()); - } catch (Exception e) { - logObj.warn("Error loading project file.", e); - } - } + int retCode = fileChooser.showSaveDialog(Editor.getFrame()); + if(retCode == JFileChooser.CANCEL_OPTION) { + return; + } + + file = fileChooser.getSelectedFile(); + if (!file.exists()) { + file.mkdirs(); + } else if (!file.isDirectory()) { + JOptionPane.showMessageDialog( + Editor.getFrame(), + "Can't create directory " + file); + return; + } + projectFile = new File(file, ProjectFileFilter.PROJ_FILE_NAME); + if (projectFile.exists()) { + int ret = + JOptionPane.showConfirmDialog( + Editor.getFrame(), + "There is already " + "project in this folder. Overwrite?"); + if (ret == JOptionPane.YES_OPTION) { + finished = true; + } else if (ret == JOptionPane.CANCEL_OPTION) { + return; + } + } else { + finished = true; + } + } + + // Save and close (if needed) currently open project. + if (getMediator() != null && !closeProject()) { + return; + } + + // Save dir path to the preferences + pref.setProperty(Preferences.LAST_DIR, file.getAbsolutePath()); + try { + GuiConfiguration.initSharedConfig(projectFile, false); + } catch (ConfigException e) { + logObj.warn(e); + } + + setMediator(Mediator.getMediator(GuiConfiguration.getGuiConfig())); + Editor.getFrame().projectOpened(); + + // Set title to contain proj file path + Editor.getFrame().setProjectTitle(projectFile.getAbsolutePath()); + } catch (Exception e) { + logObj.warn("Error loading project file.", e); + } + } } |
From: <me...@us...> - 2002-10-03 04:24:08
|
Update of /cvsroot/cayenne/cayenne/xdocs/userguide In directory usw-pr-cvs1:/tmp/cvs-serv16874/xdocs/userguide Modified Files: intro.xml Log Message: minor user guide corrections Index: intro.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/intro.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- intro.xml 3 May 2002 13:55:27 -0000 1.6 +++ intro.xml 3 Oct 2002 04:24:05 -0000 1.7 @@ -22,10 +22,10 @@ "transparent" does not mean that you can't do what you used to do with SQL. You still can. Also Cayenne includes GUI tool to automate and streamline most mapping tasks. Cayenne allows tying multiple database - into what looks to the application like a single data source. Cayenne - allows issuing a direct SQL query, calling stored procedures, setting - the automatic primary key generation, caching policy, integrating - with EJB-s, and other things. Some of the ideas used in Cayenne + into what looks to an application like a single data source. Cayenne + allows issuing direct SQL queries, supports + automatic primary key generation, various caching policies, integration + with web containers, and other things. Some of the ideas used in Cayenne have been inspired by the persistence mechanism of NeXT' (and now Apple's) WebObjects application server. </p> |
From: <me...@us...> - 2002-10-03 04:24:08
|
Update of /cvsroot/cayenne/cayenne/xdocs In directory usw-pr-cvs1:/tmp/cvs-serv16874/xdocs Modified Files: todo.xml Log Message: minor user guide corrections Index: todo.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/todo.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- todo.xml 7 Sep 2002 21:52:52 -0000 1.4 +++ todo.xml 3 Oct 2002 04:24:05 -0000 1.5 @@ -14,7 +14,7 @@ If you are willing to help, you can do it in many different ways (in no particular order): <ul> - <li>By contributing code for one or more tasks listed below.</li> + <li>By contributing code.</li> <li>By contributing documentation.</li> <li>By testing Cayenne and reporting bugs.</li> <li>By using Cayenne and reporting bugs.</li> @@ -34,10 +34,6 @@ <a href="http://jakarta.apache.org/site/source.html">Jakarta Apache</a> site. You can use all these hints as related to Cayenne. </p> - - <p>For the latest list of tasks that Cayenne team is working on visit our - <a href="http://sourceforge.net/pm/?group_id=48132">task tracker</a>. - </p> </section> </body> </document> |
From: <me...@us...> - 2002-10-03 04:24:08
|
Update of /cvsroot/cayenne/cayenne/doc/release-notes In directory usw-pr-cvs1:/tmp/cvs-serv16874/doc/release-notes Modified Files: RELEASE-NOTES-1.0b1-dev.txt Log Message: minor user guide corrections Index: RELEASE-NOTES-1.0b1-dev.txt =================================================================== RCS file: /cvsroot/cayenne/cayenne/doc/release-notes/RELEASE-NOTES-1.0b1-dev.txt,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- RELEASE-NOTES-1.0b1-dev.txt 18 Sep 2002 04:55:56 -0000 1.4 +++ RELEASE-NOTES-1.0b1-dev.txt 3 Oct 2002 04:24:05 -0000 1.5 @@ -17,4 +17,6 @@ 4. Made DataContext serializable -5. Added "paged" queries support \ No newline at end of file +5. Added "paged" queries support + +6. Cleaned up tutorials, fixed tutorial bugs and inconsistencies. \ No newline at end of file |
From: <me...@us...> - 2002-10-03 04:14:42
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF In directory usw-pr-cvs1:/tmp/cvs-serv15171/src/tutorials/cayenne-web-app/WEB-INF Modified Files: struts-config.xml web.xml Log Message: fixed web tutorial Index: struts-config.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/struts-config.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- struts-config.xml 1 Oct 2002 05:12:27 -0000 1.1 +++ struts-config.xml 3 Oct 2002 04:14:39 -0000 1.2 @@ -1,71 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd"> -<!-- - - This is a blank Struts configuration file based on the example application, - - with commented examples of some items. - - - - NOTE: If you have a generator tool to create the corresponding Java classes - - for you, you could include the details in the "form-bean" declarations. - - Otherwise, you would only define the "form-bean" element itself, with the - - corresponding "name" and "type" attributes, as shown here. - ---><struts-config> - - - - - - <!-- ========== Data Source Configuration =============================== --> - -<!-- - - <data-sources> - - <data-source - - autoCommit="false" - - description="Example Data Source Configuration" - - driverClass="org.postgresql.Driver" - - maxCount="4" - - minCount="2" - - password="mypassword" - - url="jdbc:postgresql://localhost/mydatabase" - - user="myusername" - - /> - - </data-sources> - ---> - - - +<struts-config> <!-- ========== Form Bean Definitions =================================== --> <form-beans> - <form-bean name="artistForm" type="formbean.ArtistForm" /> <form-bean name="paintingForm" type="formbean.PaintingForm" /> - <form-bean name="galleryForm" type="formbean.GalleryForm" /> - + <form-bean name="galleryForm" type="formbean.GalleryForm" /> </form-beans> <!-- ========== Global Forward Definitions ============================== --> - <global-forwards> </global-forwards> @@ -117,104 +61,10 @@ <action path="/removePaintingFromGallery" type="action.RemovePaintingFromGalleryAction"> <forward name="success" path="/browseGalleries.do" /> </action> - - - <!-- Example logon action - - <action path="/logon" - - type="org.apache.struts.example.LogonAction" - - name="logonForm" - - scope="request" - - input="/logon.jsp"> - - </action> - - --> - - - - <!-- Example logoff action - - <action path="/logoff" - - type="org.apache.struts.example.LogoffAction"> - - <forward name="success" path="/index.jsp"/> - - </action> - - --> - - - - - - <!-- The standard administrative actions available with Struts --> - - <!-- These would be either omitted or protected by security --> - - <!-- in a real application deployment --> - -<!-- <action path="/admin/addFormBean" type="org.apache.struts.actions.AddFormBeanAction" /> - - <action path="/admin/addForward" type="org.apache.struts.actions.AddForwardAction" /> - - <action path="/admin/addMapping" type="org.apache.struts.actions.AddMappingAction" /> - - <action path="/admin/reload" type="org.apache.struts.actions.ReloadAction" /> - - <action path="/admin/removeFormBean" type="org.apache.struts.actions.RemoveFormBeanAction" /> - - <action path="/admin/removeForward" type="org.apache.struts.actions.RemoveForwardAction" /> - - <action path="/admin/removeMapping" type="org.apache.struts.actions.RemoveMappingAction" /> --> - - - </action-mappings> - - - <!-- ========== Message Resources Definitions =========================== --> - - - <message-resources parameter="ApplicationResources" key="org.apache.struts.action.MESSAGE" /> - - - - <!-- ========== Plug Ins Configuration ================================== --> - - - - <!-- - - Add multiple validator resource files by setting the pathname property. - - Default pluggable validator definitions are contained in validator-rules.xml. - - Add any validation rules for forms in validator.xml. - - --> - - <!-- - - <plug-in className="org.apache.struts.validator.ValidatorPlugIn"> - - <set-property property="pathname" value="/WEB-INF/validator-rules.xml"/> - - <set-property property="pathname" value="/WEB-INF/validator.xml"/> - - </plug-in> - - --> - - </struts-config> Index: web.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/web.xml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- web.xml 1 Oct 2002 05:12:27 -0000 1.1 +++ web.xml 3 Oct 2002 04:14:39 -0000 1.2 @@ -1,8 +1,6 @@ <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE web-app - PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/j2ee/dtds/web-app_2_3.dtd"> @@ -10,7 +8,7 @@ <!-- Configure ServletConfiguration to listen for container events. --> <listener> - <listener-class>test.CustomConfiguration</listener-class> + <listener-class>webtest.CustomConfiguration</listener-class> </listener> @@ -39,74 +37,41 @@ <!-- Standard Action Servlet Mapping --> - <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <!-- The Usual Welcome File List --> - <welcome-file-list> - <welcome-file>index.jsp</welcome-file> - </welcome-file-list> - <!-- Example Application Tag Library Descriptor - - <taglib> - - <taglib-uri>/WEB-INF/app.tld</taglib-uri> - - <taglib-location>/WEB-INF/app.tld</taglib-location> - - </taglib> - - --> - - <!-- Struts Tag Library Descriptors --> <taglib> - <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri> - <taglib-location>/WEB-INF/struts-bean.tld</taglib-location> - </taglib> - - <taglib> - <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri> - <taglib-location>/WEB-INF/struts-html.tld</taglib-location> - </taglib> - <taglib> - <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri> - <taglib-location>/WEB-INF/struts-logic.tld</taglib-location> - </taglib> <taglib> - <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri> - <taglib-location>/WEB-INF/struts-nested.tld</taglib-location> - </taglib> - </web-app> |
From: <me...@us...> - 2002-10-03 04:14:42
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app/java/test In directory usw-pr-cvs1:/tmp/cvs-serv15171/src/tutorials/cayenne-cmd-app/java/test Modified Files: Main.java Log Message: fixed web tutorial Index: Main.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app/java/test/Main.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Main.java 3 Oct 2002 03:41:14 -0000 1.2 +++ Main.java 3 Oct 2002 04:14:39 -0000 1.3 @@ -62,9 +62,9 @@ likePattern); SelectQuery query = new SelectQuery("Gallery", qual); - // using log level of INFO to make sure that query + // using log level of WARN to make sure that query // execution is logged to STDOUT - query.setLoggingLevel(Level.INFO); + query.setLoggingLevel(Level.WARN); List galleries = ctxt.performQuery(query); if (galleries.size() == 1) { @@ -96,7 +96,7 @@ dali.addToPaintingArray(paint); // commit to the database - // using log level of ERROR to show the query execution - ctxt.commitChanges(Level.INFO); + // using log level of WARN to show the query execution + ctxt.commitChanges(Level.WARN); } } |
From: <me...@us...> - 2002-10-03 04:14:42
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app In directory usw-pr-cvs1:/tmp/cvs-serv15171/src/tutorials/cayenne-cmd-app Modified Files: tutorialdb.sql Log Message: fixed web tutorial Index: tutorialdb.sql =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app/tutorialdb.sql,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- tutorialdb.sql 1 Oct 2002 05:12:26 -0000 1.1 +++ tutorialdb.sql 3 Oct 2002 04:14:39 -0000 1.2 @@ -1,5 +1,5 @@ CREATE TABLE ARTIST ( - DATE_OF_BIRTH TIME NULL, + DATE_OF_BIRTH DATE NULL, ARTIST_ID INT NOT NULL, ARTIST_NAME CHAR(255) NOT NULL, PRIMARY KEY (ARTIST_ID) |
From: <me...@us...> - 2002-10-03 04:14:42
|
Update of /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart In directory usw-pr-cvs1:/tmp/cvs-serv15171/xdocs/userguide/quickstart Modified Files: comline.xml webapp.xml Log Message: fixed web tutorial Index: comline.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart/comline.xml,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- comline.xml 3 Oct 2002 03:41:14 -0000 1.19 +++ comline.xml 3 Oct 2002 04:14:39 -0000 1.20 @@ -143,33 +143,21 @@ would match the word "metro"), the following output will be printed: </p> <source> ---- will run 1 query. -SELECT t0.GALLERY_NAME, t0.GALLERY_ID FROM GALLERY t0 WHERE UPPER(t0.GALLERY_NAME) LIKE UPPER(?) -[params: '%metro%'] - prepared in 20 ms. -=== returned 1 row. - took 10 ms. +WARN QueryLogger: --- will run 1 query. +WARN QueryLogger: SELECT t0.GALLERY_NAME, t0.GALLERY_ID FROM GALLERY t0 WHERE UPPER(t0.GALLERY_NAME +) LIKE UPPER(?) [params: '%metro%'] - prepared in 20 ms. +WARN QueryLogger: === returned 1 row. - took 0 ms. Found gallery 'The Metropolitan Museum of Art'. ---- will run 2 queries. -SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'ARTIST' -=== returned 1 row. - took 0 ms. -UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'ARTIST' -=== updated 1 row. -+++ transaction committed. ---- will run 2 queries. -SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'PAINTING' -=== returned 1 row. - took 0 ms. -UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'PAINTING' -=== updated 1 row. -+++ transaction committed. ---- will run 2 queries. -INSERT INTO ARTIST (ARTIST_ID, DATE_OF_BIRTH, ARTIST_NAME) VALUES (?, ?, ?) -[params: 280, NULL, 'Salvador Dali'] -=== updated 1 row. -INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, ESTIMATED_PRICE, PAINTING_TITLE) VALUES (?, ?, ?, ?) -[params: 280, 280, NULL, 'Sleep'] -=== updated 1 row. -+++ transaction committed. +WARN QueryLogger: --- will run 2 queries. +WARN QueryLogger: INSERT INTO ARTIST (ARTIST_ID, DATE_OF_BIRTH, ARTIST_NAME) VALUES (?, ?, ?) +[params: 320, NULL, 'Salvador Dali'] +WARN QueryLogger: === updated 1 row. +WARN QueryLogger: INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, ESTIMATED_PRICE, PAINTING_TITLE) +VALUES (?, ?, ?, ?) [params: 320, 320, NULL, 'Sleep'] +WARN QueryLogger: === updated 1 row. +WARN QueryLogger: +++ transaction committed. </source> </subsection> </subsection> Index: webapp.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart/webapp.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- webapp.xml 2 Oct 2002 04:54:21 -0000 1.12 +++ webapp.xml 3 Oct 2002 04:14:39 -0000 1.13 @@ -42,10 +42,9 @@ All references to Tomcat below should apply in some form to other web containers as well.</p> - <p>- Create a new folder named <code>cayenne-web-app</code> - anywhere in the filesystem. This directory is referred to as - "project directory" further in this chapter. For a sample project - layout look at the tutorial source distributed with Cayenne.</p> + <p>- Use tutorial source directory distributed with Cayenne at + <code>$CAYENNE_HOME/src/tutorials/cayenne-web-app</code> + as a project directory.</p> <p>- Copy <code>cayenne.jar</code> to the <code>WEB-INF/lib</code> subdirectory of the tutorial project directory.</p> @@ -115,7 +114,7 @@ <li><a href="../../tutorials/cayenne-web-app/WEB-INF/driverinfo.xml">driverinfo.xml</a></li> </ul> - Open <code>cayenne.xml</code> + Save these files under WEB-INF subdirectory of the tutorial project folder. Open <code>cayenne.xml</code> file in CayenneModeler and make the following changes: <ul> <li>if the database used is NOT MySQL, <code>cayenne.xml</code> @@ -160,11 +159,12 @@ </p> </subsection> <subsection name="3.2.6 Compile and Deploy the Application" anchor="6"> - <p>Compile the source code lime ypou would normally compile a webapplications. + <p>Compile the source code like you would normally compile a webapplication. The example is given for javac from the command line (assuming that JAVA_HOME variable - points to the JSDK 1.4 installation). - On Windows (substitute <code>[servlet.jar]</code> with the path to the actiual JAR file, - for instance tomcat/common/lib/servlet.jar):</p> + points to the JDK 1.3 or 1.4 installation). Substitute <code>[servlet.jar]</code> + with the path to the actiual JAR file, + for instance tomcat/common/lib/servlet.jar + On Windows:</p> <source> cayenne-web-app> cd WEB-INF\classes cayenne-web-app\WEB-INF\classes> set CLASSPATH=%CLASSPATH%;[servlet.jar] |
From: <me...@us...> - 2002-10-03 03:41:17
|
Update of /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart In directory usw-pr-cvs1:/tmp/cvs-serv7502/xdocs/userguide/quickstart Modified Files: comline.xml Log Message: straightened Cayenne cmd tutorial Index: comline.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart/comline.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- comline.xml 2 Oct 2002 04:54:21 -0000 1.18 +++ comline.xml 3 Oct 2002 03:41:14 -0000 1.19 @@ -143,21 +143,33 @@ would match the word "metro"), the following output will be printed: </p> <source> -SEVERE access.QueryLogger 0: --- will run 1 query. -SEVERE access.QueryLogger 40: SELECT t0.GALLERY_NAME, t0.GALLERY_ID FROM GALLERY t0 -WHERE UPPER(t0.GALLERY_NAME) LIKE UPPER(?) [params: '%metro%'] -SEVERE access.QueryLogger 140: === returned 1 row. +--- will run 1 query. +SELECT t0.GALLERY_NAME, t0.GALLERY_ID FROM GALLERY t0 WHERE UPPER(t0.GALLERY_NAME) LIKE UPPER(?) +[params: '%metro%'] - prepared in 20 ms. +=== returned 1 row. - took 10 ms. Found gallery 'The Metropolitan Museum of Art'. -SEVERE access.QueryLogger 210: --- will run 2 queries. -SEVERE access.QueryLogger 220: INSERT INTO ARTIST (ARTIST_ID, DATE_OF_BIRTH, ARTIST_NAME) -VALUES (?, ?, ?) [params: 41, NULL, 'Salvador Dali'] -SEVERE access.QueryLogger 220: === updated 1 row. -SEVERE access.QueryLogger 230: INSERT INTO PAINTING (PAINTING_ID, PAINTING_TITLE, -ESTIMATED_PRICE, ARTIST_ID) VALUES (?, ?, ?, ?) [params: 41, 'Sleep', NULL, 41] -SEVERE access.QueryLogger 240: === updated 1 row. -SEVERE access.QueryLogger 250: +++ transaction committed. +--- will run 2 queries. +SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'ARTIST' +=== returned 1 row. - took 0 ms. +UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'ARTIST' +=== updated 1 row. ++++ transaction committed. +--- will run 2 queries. +SELECT NEXT_ID FROM AUTO_PK_SUPPORT WHERE TABLE_NAME = 'PAINTING' +=== returned 1 row. - took 0 ms. +UPDATE AUTO_PK_SUPPORT SET NEXT_ID = NEXT_ID + 20 WHERE TABLE_NAME = 'PAINTING' +=== updated 1 row. ++++ transaction committed. +--- will run 2 queries. +INSERT INTO ARTIST (ARTIST_ID, DATE_OF_BIRTH, ARTIST_NAME) VALUES (?, ?, ?) +[params: 280, NULL, 'Salvador Dali'] +=== updated 1 row. +INSERT INTO PAINTING (PAINTING_ID, ARTIST_ID, ESTIMATED_PRICE, PAINTING_TITLE) VALUES (?, ?, ?, ?) +[params: 280, 280, NULL, 'Sleep'] +=== updated 1 row. ++++ transaction committed. </source> </subsection> </subsection> |
From: <me...@us...> - 2002-10-03 03:41:17
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app/java/test In directory usw-pr-cvs1:/tmp/cvs-serv7502/src/tutorials/cayenne-cmd-app/java/test Modified Files: Main.java Log Message: straightened Cayenne cmd tutorial Index: Main.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-cmd-app/java/test/Main.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Main.java 1 Oct 2002 05:12:26 -0000 1.1 +++ Main.java 3 Oct 2002 03:41:14 -0000 1.2 @@ -62,9 +62,9 @@ likePattern); SelectQuery query = new SelectQuery("Gallery", qual); - // using log level of ERROR to make sure that query + // using log level of INFO to make sure that query // execution is logged to STDOUT - query.setLoggingLevel(Level.ERROR); + query.setLoggingLevel(Level.INFO); List galleries = ctxt.performQuery(query); if (galleries.size() == 1) { @@ -97,6 +97,6 @@ // commit to the database // using log level of ERROR to show the query execution - ctxt.commitChanges(Level.ERROR); + ctxt.commitChanges(Level.INFO); } } |
From: <me...@us...> - 2002-10-03 03:41:16
|
Update of /cvsroot/cayenne/cayenne In directory usw-pr-cvs1:/tmp/cvs-serv7502 Modified Files: build-tutorials.xml Log Message: straightened Cayenne cmd tutorial Index: build-tutorials.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/build-tutorials.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- build-tutorials.xml 2 Oct 2002 03:50:00 -0000 1.2 +++ build-tutorials.xml 3 Oct 2002 03:41:13 -0000 1.3 @@ -16,6 +16,12 @@ <target name="dist-src"> <ant antfile="src/tutorials/cayenne-cmd-app/build.xml" target="dist-src"/> <ant antfile="src/tutorials/cayenne-web-app/build.xml" target="dist-src"/> + + <mkdir dir="${dist}/doc/tutorials"/> + + <copy todir="${dist}/doc/tutorials"> + <fileset dir="${dist}/src/tutorials"/> + </copy> </target> <target name="release-site" depends="nositedir,dist-src"> @@ -26,13 +32,7 @@ </copy> </target> - <target name="doc" depends="dist-src"> - <mkdir dir="${dist}/doc/tutorials"/> - - <copy todir="${dist}/doc/tutorials"> - <fileset dir="${dist}/src/tutorials"/> - </copy> - </target> + <target name="doc" depends="dist-src"/> <!-- Simply calls compile task. Exists in the project --> |
From: <me...@us...> - 2002-10-03 03:40:53
|
Update of /cvsroot/cayenne/cayenne In directory usw-pr-cvs1:/tmp/cvs-serv7349 Modified Files: build.xml Log Message: made "clean-java" eclipse friendly - now it will NOT delete classes generated by Eclipse, only the ones relevant to ANt Index: build.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/build.xml,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- build.xml 2 Oct 2002 03:50:00 -0000 1.41 +++ build.xml 3 Oct 2002 03:40:50 -0000 1.42 @@ -117,7 +117,12 @@ </target> <target name="clean-java"> - <delete dir="${build}"/> + <delete includeEmptyDirs="true"> + <!-- Eclipse-friendly - preserve "classes" --> + <fileset dir="${build}"> + <exclude name="classes/**"/> + </fileset> + </delete> </target> <!-- ========================================== --> |
From: <me...@us...> - 2002-10-02 05:04:57
|
Update of /cvsroot/cayenne/cayenne In directory usw-pr-cvs1:/tmp/cvs-serv30306 Modified Files: build-doc.xml Log Message: fixed site building - now old site directory is not deleted and an incremental build is done Index: build-doc.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/build-doc.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- build-doc.xml 2 Oct 2002 03:50:00 -0000 1.8 +++ build-doc.xml 2 Oct 2002 05:04:54 -0000 1.9 @@ -17,7 +17,6 @@ <!-- Deploys Cayenne web site in a local directory --> <!-- ============================================= --> <target name="release-site" depends="nositedir,prepare,doc,api"> - <delete dir="${site.dir}/cayenne"/> <mkdir dir="${site.dir}/cayenne"/> <!-- copy all but HTML --> |
From: <me...@us...> - 2002-10-02 04:54:24
|
Update of /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart In directory usw-pr-cvs1:/tmp/cvs-serv27428/xdocs/userguide/quickstart Modified Files: comline.xml webapp.xml Log Message: fixing web tutorial docs page regenerated tutorial DO classes Index: comline.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart/comline.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- comline.xml 2 Oct 2002 04:42:31 -0000 1.17 +++ comline.xml 2 Oct 2002 04:54:21 -0000 1.18 @@ -45,7 +45,7 @@ anywhere in the filesystem. This directory is referred to as "project directory" further in this chapter. Note that when you are finished going through all the steps below, project directory - will become a mirror of this tutorial source folder distributed + will become similar to this tutorial source folder distributed with Cayenne.</p> </subsection> Index: webapp.xml =================================================================== RCS file: /cvsroot/cayenne/cayenne/xdocs/userguide/quickstart/webapp.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- webapp.xml 22 Jul 2002 17:02:04 -0000 1.11 +++ webapp.xml 2 Oct 2002 04:54:21 -0000 1.12 @@ -14,11 +14,9 @@ <p>This section shows how to write and a deploy a web application using Cayenne.</p> - <ul> - <li><strong><a href= - "http://objectstyle.org/cayenne/tutorial/cayenne-web-app.tar.gz">Download - full tutorial source</a></strong></li> - </ul> + <panel name="Note:"> + Full tutorial source code is included in Cayenne distribution in "src/tutorials" folder. + </panel> <p>Tutorial steps:</p> @@ -37,17 +35,17 @@ </p> <p>- Install a web container. This tutorial was tested with <a href= - "http://jakarta.apache.org/tomcat/index.html">Tomcat</a> version 4.0.3. + "http://jakarta.apache.org/tomcat/index.html">Tomcat</a> version 4.1.10. It should work with any other container that is compliant with Servlet 2.3 - specification (older containers should also work, but you will not be able - to use some of ServletConfiguration features discussed below). All - references to Tomcat below should apply in some form to other web containers + specification (older containers will also work, but you will not be able + to use some of ServletConfiguration features discussed below). + All references to Tomcat below should apply in some form to other web containers as well.</p> - <p>- Unpack downloaded tutorial file (<code>cayenne-cmd-app.tar.gz</code>) - anywhere in the filesystem. A new directory named <code>cayenne-web-app</code> - will be created. This directory is referred to as "project directory" further in - this tutorial.</p> + <p>- Create a new folder named <code>cayenne-web-app</code> + anywhere in the filesystem. This directory is referred to as + "project directory" further in this chapter. For a sample project + layout look at the tutorial source distributed with Cayenne.</p> <p>- Copy <code>cayenne.jar</code> to the <code>WEB-INF/lib</code> subdirectory of the tutorial project directory.</p> @@ -99,7 +97,7 @@ </subsection> <subsection name="3.2.2 Prepare Tutorial Database" anchor="2"> - <p>Run <a href="../../tutorial/cayenne-web-app/tutorialdb.sql"><code>tutorialdb.sql</code></a> + <p>Run <a href="../../tutorials/cayenne-web-app/tutorialdb.sql"><code>tutorialdb.sql</code></a> script located in the project directory to create test tables. This script is tested on MySQL, but it should be easy to port to any other RDBMS. Also note that if you already tried "Command Line Application" tutorial in @@ -112,9 +110,9 @@ <p>Configuration files included in this tutorial are: <ul> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/cayenne.xml">cayenne.xml</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/datamap.xml">datamap.xml</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/driverinfo.xml">driverinfo.xml</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/cayenne.xml">cayenne.xml</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/datamap.xml">datamap.xml</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/driverinfo.xml">driverinfo.xml</a></li> </ul> Open <code>cayenne.xml</code> @@ -152,12 +150,12 @@ project directory: <ul> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/_Artist.java">_Artist.java</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/Artist.java">Artist.java</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/_Painting.java">_Painting.java</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/Painting.java">Painting.java</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/_Gallery.java">_Gallery.java</a></li> - <li><a href="../../tutorial/cayenne-web-app/WEB-INF/classes/test/Gallery.java">Gallery.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Artist.java">_Artist.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/Artist.java">Artist.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Painting.java">_Painting.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/Painting.java">Painting.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Gallery.java">_Gallery.java</a></li> + <li><a href="../../tutorials/cayenne-web-app/WEB-INF/classes/webtest/Gallery.java">Gallery.java</a></li> </ul> </p> </subsection> @@ -171,14 +169,14 @@ cayenne-web-app> cd WEB-INF\classes cayenne-web-app\WEB-INF\classes> set CLASSPATH=%CLASSPATH%;[servlet.jar] cayenne-web-app\WEB-INF\classes> set CLASSPATH=%CLASSPATH%;..\lib\struts.jar;..\lib\cayenne.jar -cayenne-web-app\WEB-INF\classes> %JAVA_HOME%\bin\javac test\*.java formbean\*.java action\*.java +cayenne-web-app\WEB-INF\classes> %JAVA_HOME%\bin\javac webtest\*.java formbean\*.java action\*.java </source> <p>On UNIX:</p> <source> cayenne-web-app# cd WEB-INF/classes cayenne-web-app# export CLASSPATH=$CLASSPATH:[servlet.jar]:../lib/struts.jar:../lib/cayenne.jar -cayenne-web-app# $JAVA_HOME/bin/javac test/*.java formbean/*.java action/*.java +cayenne-web-app# $JAVA_HOME/bin/javac webtest/*.java formbean/*.java action/*.java </source> <p>To deploy, simply copy <code>cayenne-web-app</code> directory to Tomcat |
From: <me...@us...> - 2002-10-02 04:54:24
|
Update of /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/classes/webtest In directory usw-pr-cvs1:/tmp/cvs-serv27428/src/tutorials/cayenne-web-app/WEB-INF/classes/webtest Modified Files: _Artist.java _Gallery.java _Painting.java Log Message: fixing web tutorial docs page regenerated tutorial DO classes Index: _Artist.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Artist.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- _Artist.java 1 Oct 2002 05:12:27 -0000 1.1 +++ _Artist.java 2 Oct 2002 04:54:21 -0000 1.2 @@ -1,8 +1,7 @@ package webtest; import java.util.List; - -import org.objectstyle.cayenne.CayenneDataObject; +import org.objectstyle.cayenne.*; /** Class _Artist was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, @@ -11,29 +10,31 @@ */ public class _Artist extends CayenneDataObject { - public void setDateOfBirth(java.sql.Date dateOfBirth) { - writeProperty("dateOfBirth", dateOfBirth); + public void setArtistName(String artistName) { + writeProperty("artistName", artistName); } - public java.sql.Date getDateOfBirth() { - return (java.sql.Date)readProperty("dateOfBirth"); + public String getArtistName() { + return (String)readProperty("artistName"); } - public void setArtistName(java.lang.String artistName) { - writeProperty("artistName", artistName); + public void setDateOfBirth(java.sql.Date dateOfBirth) { + writeProperty("dateOfBirth", dateOfBirth); } - public java.lang.String getArtistName() { - return (String)readProperty("artistName"); + public java.sql.Date getDateOfBirth() { + return (java.sql.Date)readProperty("dateOfBirth"); } - public void addToPaintingArray(webtest.Painting obj) { + public void addToPaintingArray(Painting obj) { addToManyTarget("paintingArray", obj, true); } - public void removeFromPaintingArray(webtest.Painting obj) { + public void removeFromPaintingArray(Painting obj) { removeToManyTarget("paintingArray", obj, true); } public List getPaintingArray() { return (List)readProperty("paintingArray"); } + + } Index: _Gallery.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Gallery.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- _Gallery.java 1 Oct 2002 05:12:27 -0000 1.1 +++ _Gallery.java 2 Oct 2002 04:54:21 -0000 1.2 @@ -1,8 +1,7 @@ package webtest; import java.util.List; - -import org.objectstyle.cayenne.CayenneDataObject; +import org.objectstyle.cayenne.*; /** Class _Gallery was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, @@ -14,18 +13,20 @@ public void setGalleryName(String galleryName) { writeProperty("galleryName", galleryName); } - public java.lang.String getGalleryName() { + public String getGalleryName() { return (String)readProperty("galleryName"); } - public void addToPaintingArray(webtest.Painting obj) { + public void addToPaintingArray(Painting obj) { addToManyTarget("paintingArray", obj, true); } - public void removeFromPaintingArray(webtest.Painting obj) { + public void removeFromPaintingArray(Painting obj) { removeToManyTarget("paintingArray", obj, true); } public List getPaintingArray() { return (List)readProperty("paintingArray"); } + + } Index: _Painting.java =================================================================== RCS file: /cvsroot/cayenne/cayenne/src/tutorials/cayenne-web-app/WEB-INF/classes/webtest/_Painting.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- _Painting.java 1 Oct 2002 05:12:27 -0000 1.1 +++ _Painting.java 2 Oct 2002 04:54:21 -0000 1.2 @@ -1,6 +1,7 @@ package webtest; -import org.objectstyle.cayenne.CayenneDataObject; +import java.util.List; +import org.objectstyle.cayenne.*; /** Class _Painting was generated by Cayenne. * It is probably a good idea to avoid changing this class manually, @@ -20,26 +21,26 @@ public void setPaintingTitle(String paintingTitle) { writeProperty("paintingTitle", paintingTitle); } - public java.lang.String getPaintingTitle() { + public String getPaintingTitle() { return (String)readProperty("paintingTitle"); } - public void setToGallery(webtest.Gallery toGallery) { - setToOneTarget("toGallery", toGallery, true); + public void setToArtist(Artist toArtist) { + setToOneTarget("toArtist", toArtist, true); } - public webtest.Gallery getToGallery() { - return (webtest.Gallery)readProperty("toGallery"); + public Artist getToArtist() { + return (Artist)readProperty("toArtist"); } - public void setToArtist(webtest.Artist toArtist) { - setToOneTarget("toArtist", toArtist, true); + public void setToGallery(Gallery toGallery) { + setToOneTarget("toGallery", toGallery, true); } - public webtest.Artist getToArtist() { - return (webtest.Artist)readProperty("toArtist"); + public Gallery getToGallery() { + return (Gallery)readProperty("toGallery"); } |