You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/05/25 23:36:07 UTC

svn commit: r541784 - in /myfaces/orchestra/trunk: core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/ core/src/main/java/org/apache/myfaces/orchestra/conversation/...

Author: imario
Date: Fri May 25 14:36:06 2007
New Revision: 541784

URL: http://svn.apache.org/viewvc?view=rev&rev=541784
Log:
added a connection proxy to fix the problem where the ORM might not pass a db connection back to the pool if there was a lazy-init during the render response phase.
It depends on the environment if the user requires this "hack" or not.

Added:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/AbstractConnectionManagerListener.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerListener.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnection.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnectionFactory.java
    myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/LoggingConnectionManagerListener.java
Modified:
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/OrchestraServletFilter.java
    myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContextConversationInterceptor.java
    myfaces/orchestra/trunk/examples/pom.xml
    myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/AbstractConnectionManagerListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/AbstractConnectionManagerListener.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/AbstractConnectionManagerListener.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/AbstractConnectionManagerListener.java Fri May 25 14:36:06 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.connectionManager;
+
+import java.sql.Connection;
+
+/**
+ * @see ConnectionManagerListener  
+ */
+public abstract class AbstractConnectionManagerListener implements ConnectionManagerListener
+{
+	public void borrowConnection(Connection con)
+	{
+	}
+
+	public void releaseConnection(Connection con)
+	{
+	}
+}

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerDataSource.java Fri May 25 14:36:06 2007
@@ -0,0 +1,158 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.connectionManager;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * manage all borrowed connections and hand out {@link org.apache.myfaces.orchestra.connectionManager.DisconnectableConnection}s
+ * so that we can close them again after the HTTP request has been finished.
+ * <br />
+ * I'd consider this as a hack, but a required one if your JPA-implementation do not free the connection
+ * again after a lazy-init.
+ * 
+ * @see org.apache.myfaces.orchestra.connectionManager.DisconnectableConnection
+ */
+public class ConnectionManagerDataSource implements DataSource
+{
+	private DataSource dataSource;
+	private String jndiName;
+	private AbstractConnectionManagerListener[] listeners;
+	private static ThreadLocal borrowedConnections = new ThreadLocal()
+	{
+		protected Object initialValue()
+		{
+			return new HashSet();
+		}
+	};
+
+	public ConnectionManagerDataSource()
+	{
+	}
+
+	void onAfterBorrowConnection(Connection con)
+	{
+		((Set) borrowedConnections.get()).add(con);
+
+		for (int i = 0; i<listeners.length; i++)
+		{
+			listeners[i].borrowConnection(con);
+		}
+	}
+
+	public void onBeforeReleaseConnection(Connection con)
+	{
+		if (listeners != null)
+		{
+			for (int i = 0; i<listeners.length; i++)
+			{
+				listeners[i].releaseConnection(con);
+			}
+		}
+	}
+
+	void onAfterReleaseConnection(Connection con)
+	{
+		((Set) borrowedConnections.get()).remove(con);
+	}
+
+	public static void releaseAllBorrowedConnections()
+	{
+	 	Iterator iterBorrowedConnections = ((Set) borrowedConnections.get()).iterator();
+		while (iterBorrowedConnections.hasNext())
+		{
+			DisconnectableConnection connection = (DisconnectableConnection) iterBorrowedConnections.next();
+			connection.disconnect();
+		}
+	}
+
+	public void setListeners(AbstractConnectionManagerListener[] listeners)
+	{
+		this.listeners = listeners;
+	}
+
+	public void setDataSource(DataSource dataSource)
+	{
+		this.dataSource = dataSource;
+	}
+
+	public DataSource getDataSource()
+	{
+		if (dataSource != null)
+		{
+			return dataSource;
+		}
+
+		try
+		{
+			Context ctx = new InitialContext();
+			dataSource = (DataSource) ctx.lookup(jndiName);
+		}
+		catch (NamingException e)
+		{
+			throw (IllegalArgumentException) new IllegalArgumentException(jndiName).initCause(e);
+		}
+
+		return dataSource;
+	}
+
+	public void setJndiName(String jndiName)
+	{
+		this.jndiName = jndiName;
+	}
+
+	public Connection getConnection() throws SQLException
+	{
+		return DisconnectableConnectionFactory.create(this);
+	}
+
+	public Connection getConnection(String username, String password) throws SQLException
+	{
+		throw new UnsupportedOperationException();
+	}
+
+	public PrintWriter getLogWriter() throws SQLException
+	{
+		return getDataSource().getLogWriter();
+	}
+
+	public void setLogWriter(PrintWriter out) throws SQLException
+	{
+		getDataSource().setLogWriter(out);
+	}
+
+	public void setLoginTimeout(int seconds) throws SQLException
+	{
+		getDataSource().setLoginTimeout(seconds);
+	}
+
+	public int getLoginTimeout() throws SQLException
+	{
+		return getDataSource().getLoginTimeout();
+	}
+}

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerListener.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerListener.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/ConnectionManagerListener.java Fri May 25 14:36:06 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.connectionManager;
+
+import java.sql.Connection;
+
+/**
+ * Implement this class if you would like to add a listener to the ConnectionManager which e.g. allows
+ * you to do some database setup/shutdown procedures.<br />
+ * Its recommended to extend from the {@link AbstractConnectionManagerListener} class to be prepared
+ * for future interface enhancements. 
+ * 
+ * @see org.apache.myfaces.orchestra.connectionManager.AbstractConnectionManagerListener
+ */
+public interface ConnectionManagerListener
+{
+	public void borrowConnection(Connection con);
+	public void releaseConnection(Connection con);
+}

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnection.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnection.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnection.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnection.java Fri May 25 14:36:06 2007
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.connectionManager;
+
+import java.sql.Connection;
+
+/**
+ * A workaround to the lazy-init-in-view problem.<br />
+ *
+ * We hand out DisconnectableConnections to the JPA-implementation, now,
+ * if a lazy-init happens during the view rendering we are able to disconnect it again
+ * at the end of the request (using a servlet filter). Once the JPA-implementation would like to
+ * do something with the connection again, we simply request a new from the connection pool
+ */
+public interface DisconnectableConnection extends Connection
+{
+	public void disconnect();
+	public Connection getConnection();
+}

Added: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnectionFactory.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnectionFactory.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnectionFactory.java (added)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/connectionManager/DisconnectableConnectionFactory.java Fri May 25 14:36:06 2007
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.orchestra.connectionManager;
+
+import org.apache.commons.logging.LogFactory;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Proxy connections to being able to handle disconnection.
+ *
+ * @see org.apache.myfaces.orchestra.connectionManager.DisconnectableConnection
+ */
+public class DisconnectableConnectionFactory
+{
+	private DisconnectableConnectionFactory()
+	{
+	}
+
+	public static DisconnectableConnection create(final ConnectionManagerDataSource connectionManager)
+	{
+		return (DisconnectableConnection) Proxy.newProxyInstance(
+
+			DisconnectableConnection.class.getClassLoader(),
+
+			new Class[]
+				{
+					DisconnectableConnection.class
+				},
+
+			new InvocationHandler()
+			{
+				private Connection connection;
+
+				public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+				{
+					if ("equals".equals(method.getName()) || "hashCode".equals(method.getName())) // NON-NLS
+					{
+						// do not pass these methods to the connection as we dont want to change the
+						// identity of the connection proxy
+						return method.invoke(this, args);
+					}
+					else if ("close".equals(method.getName())) // NON-NLS
+					{
+						try
+						{
+							connectionManager.onBeforeReleaseConnection((Connection) proxy);
+							if (connection != null)
+							{
+								connection.close();
+							}
+							connection = null;
+						}
+						finally
+						{
+							connectionManager.onAfterReleaseConnection((Connection) proxy);
+						}
+						return null;
+					}
+					else if ("disconnect".equals(method.getName())) // NON-NLS
+					{
+						connectionManager.onBeforeReleaseConnection((Connection) proxy);
+						try
+						{
+							if (connection != null)
+							{
+								try
+								{
+									if (!connection.isClosed())
+									{
+										connection.close();
+									}
+								}
+								catch (SQLException e)
+								{
+									LogFactory.getLog(DisconnectableConnectionFactory.class).warn(e.getLocalizedMessage(), e);
+								}
+							}
+						}
+						finally
+						{
+							connectionManager.onAfterReleaseConnection((Connection) proxy);
+							connection = null;
+						}
+						return null;
+					}
+					else if ("getConnection".equals(method.getName())) // NON-NLS
+					{
+						return connection;
+					}
+
+					if (connection == null)
+					{
+						connection = connectionManager.getDataSource().getConnection();
+						connectionManager.onAfterBorrowConnection((Connection) proxy);
+					}
+
+					return method.invoke(connection, args);
+				}
+			});
+	}
+}

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/OrchestraServletFilter.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/OrchestraServletFilter.java?view=diff&rev=541784&r1=541783&r2=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/OrchestraServletFilter.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/jsf/filter/OrchestraServletFilter.java Fri May 25 14:36:06 2007
@@ -19,7 +19,7 @@
 
 package org.apache.myfaces.orchestra.conversation.jsf.filter;
 
-import org.apache.myfaces.orchestra.conversation.spring.PersistenceContextConversationInterceptor;
+import org.apache.myfaces.orchestra.connectionManager.ConnectionManagerDataSource;
 
 import javax.servlet.Filter;
 import javax.servlet.FilterChain;
@@ -59,7 +59,7 @@
 		{
 			try
 			{
-				unbindAllUsedPersistenceContexts();
+				cleanupPersistence();
 			}
 			finally
 			{
@@ -69,10 +69,14 @@
 		}
 	}
 
-	protected void unbindAllUsedPersistenceContexts()
+	protected void cleanupPersistence()
 	{
+		/*
 		// XXX: this cross link into the spring domain is not the best way .... figure out a better way
-		PersistenceContextConversationInterceptor.unbindAllUsedPersistenceContexts();
+		PersistenceContextConversationInterceptor.cleanupPersistence();
+		*/
+
+		ConnectionManagerDataSource.releaseAllBorrowedConnections();
 	}
 
 	public static HttpServletRequest getHttpServletRequest()

Modified: myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContextConversationInterceptor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContextConversationInterceptor.java?view=diff&rev=541784&r1=541783&r2=541784
==============================================================================
--- myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContextConversationInterceptor.java (original)
+++ myfaces/orchestra/trunk/core/src/main/java/org/apache/myfaces/orchestra/conversation/spring/PersistenceContextConversationInterceptor.java Fri May 25 14:36:06 2007
@@ -22,12 +22,6 @@
 import org.aopalliance.intercept.MethodInterceptor;
 import org.aopalliance.intercept.MethodInvocation;
 import org.apache.myfaces.orchestra.conversation.Conversation;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapter;
-import org.apache.myfaces.orchestra.frameworkAdapter.FrameworkAdapterInterface;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
 
 /**
  * <p/>
@@ -81,7 +75,7 @@
 
 		if (persistenceContext != null)
 		{
-			registerPersistenceContextUsage(persistenceContext);
+			// registerPersistenceContextUsage(persistenceContext);
 
 			persistenceContext.bind();
 		}
@@ -99,6 +93,7 @@
 		}
 	}
 
+	/*
 	protected void registerPersistenceContextUsage(PersistenceContext persistenceContext)
 	{
 		FrameworkAdapterInterface fai = FrameworkAdapter.getInstance();
@@ -114,7 +109,7 @@
 		}
 	}
 
-	public static void unbindAllUsedPersistenceContexts()
+	public static void cleanupPersistence()
 	{
 		FrameworkAdapterInterface fai = FrameworkAdapter.getInstance();
 		Set persistencesContexts = (Set) fai.getRequestAttribute(REQUEST_ATTRIBUTE);
@@ -130,4 +125,5 @@
 			persistenceContext.unbind();
 		}
 	}
+	*/
 }

Modified: myfaces/orchestra/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/pom.xml?view=diff&rev=541784&r1=541783&r2=541784
==============================================================================
--- myfaces/orchestra/trunk/examples/pom.xml (original)
+++ myfaces/orchestra/trunk/examples/pom.xml Fri May 25 14:36:06 2007
@@ -77,9 +77,9 @@
 			<version>2.0.2</version>
 		</dependency>
 		<dependency>
-				<groupId>javax.mail</groupId>
-				<artifactId>mail</artifactId>
-				<version>1.4</version>
+			<groupId>javax.mail</groupId>
+			<artifactId>mail</artifactId>
+			<version>1.4</version>
 		</dependency>
 		<dependency>
 			<groupId>javax.servlet</groupId>
@@ -94,9 +94,9 @@
 		</dependency>
 
 		<dependency>
-		  <groupId>javax.persistence</groupId>
-		  <artifactId>toplink-essentials</artifactId>
-		  <version>1.0</version>
+			<groupId>javax.persistence</groupId>
+			<artifactId>toplink-essentials</artifactId>
+			<version>1.0</version>
 		</dependency>
 
 		<dependency>
@@ -105,6 +105,12 @@
 			<version>10.2.2.0</version>
 		</dependency>
 
+		<dependency>
+			<groupId>commons-dbcp</groupId>
+			<artifactId>commons-dbcp</artifactId>
+			<version>1.2.2</version>
+		</dependency>
+
 		<!-- jetty -->
 		<dependency>
 			<groupId>javax.servlet</groupId>
@@ -159,13 +165,13 @@
 		</resources>
 
 		<plugins>
-                        <plugin>
-                                <artifactId>maven-compiler-plugin</artifactId>
-                                <configuration>
-                                        <source>1.5</source>
-                                        <target>1.5</target>
-                                </configuration>
-                        </plugin>
+			<plugin>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
 
 			<plugin>
 				<artifactId>maven-source-plugin</artifactId>
@@ -182,7 +188,7 @@
 			<plugin>
 				<groupId>org.mortbay.jetty</groupId>
 				<artifactId>maven-jetty-plugin</artifactId>
-				<version>6.1.1</version>				
+				<version>6.1.1</version>
 				<configuration>
 					<connectors>
 						<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
@@ -196,28 +202,27 @@
 		</plugins>
 	</build>
 
-        <reporting>
-                <plugins>
-
-           <plugin>
-                <artifactId>maven-pmd-plugin</artifactId>
-                <version>2.0</version>
-                <configuration>
-                    <rulesets>
-                        <ruleset>/rulesets/basic.xml</ruleset>
-                        <ruleset>/rulesets/unusedcode.xml</ruleset>
-                    </rulesets>
-                    <linkXref>true</linkXref>
-                    <minimumTokens>100</minimumTokens>
-                    <targetJdk>1.5</targetJdk>
-                </configuration>
-            </plugin>
+	<reporting>
+		<plugins>
 
+			<plugin>
+				<artifactId>maven-pmd-plugin</artifactId>
+				<version>2.0</version>
+				<configuration>
+					<rulesets>
+						<ruleset>/rulesets/basic.xml</ruleset>
+						<ruleset>/rulesets/unusedcode.xml</ruleset>
+					</rulesets>
+					<linkXref>true</linkXref>
+					<minimumTokens>100</minimumTokens>
+					<targetJdk>1.5</targetJdk>
+				</configuration>
+			</plugin>
 
-                </plugins>
 
-        </reporting>
+		</plugins>
 
+	</reporting>
 
 
 </project>

Added: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/LoggingConnectionManagerListener.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/LoggingConnectionManagerListener.java?view=auto&rev=541784
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/LoggingConnectionManagerListener.java (added)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/lib/LoggingConnectionManagerListener.java Fri May 25 14:36:06 2007
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.examples.lib;
+
+import org.apache.myfaces.orchestra.connectionManager.AbstractConnectionManagerListener;
+import org.apache.commons.logging.LogFactory;
+
+import java.sql.Connection;
+
+public class LoggingConnectionManagerListener extends AbstractConnectionManagerListener
+{
+	public void borrowConnection(Connection con)
+	{
+		LogFactory.getLog(LoggingConnectionManagerListener.class).info(">>>> borrowConnection:" + System.identityHashCode(con));
+	}
+
+	public void releaseConnection(Connection con)
+	{
+		LogFactory.getLog(LoggingConnectionManagerListener.class).info("<<<< releaseConnection:" + System.identityHashCode(con));
+	}
+}

Modified: myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml?view=diff&rev=541784&r1=541783&r2=541784
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml Fri May 25 14:36:06 2007
@@ -66,62 +66,91 @@
 	<!-- persistence -->
 	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>
 
-	<tx:annotation-driven />
+	<tx:annotation-driven/>
 
 	<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
 		<property name="entityManagerFactory" ref="entityManagerFactory"/>
 	</bean>
 
+
+	<bean id="dataSource" destroy-method="close" class="org.apache.commons.dbcp.BasicDataSource">
+		<property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
+		<property name="url" value="jdbc:derby:myfacesOrchestraDB/V1;create=true"/>
+		<property name="username" value="sa"/>
+		<property name="password" value="foobar"/>
+		<property name="initialSize" value="10"/>
+		<property name="maxIdle" value="10"/>
+		<property name="maxActive" value="20"/>
+		<property name="maxWait" value="10000"/>
+	</bean>
+
+	<bean id="managedDataSource" class="org.apache.myfaces.orchestra.connectionManager.ConnectionManagerDataSource">
+		<property name="dataSource" ref="dataSource"/>
+		<property name="listeners">
+			<bean class="org.apache.myfaces.examples.lib.LoggingConnectionManagerListener"/>
+		</property>
+	</bean>
+
 	<bean id="entityManagerFactory"
-		  class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
+		  class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
+		<property name="dataSource" ref="managedDataSource"/>
+		<property name="jpaDialect">
+			<bean class="org.springframework.orm.jpa.vendor.TopLinkJpaDialect"/>
+		</property>
+		<property name="jpaVendorAdapter">
+			<bean
+				class="org.springframework.orm.jpa.vendor.TopLinkJpaVendorAdapter">
+				<property name="showSql" value="false"/>
+				<property name="generateDdl" value="true"/>
+				<property name="databasePlatform" value="oracle.toplink.essentials.platform.database.DerbyPlatform"/>
+			</bean>
+		</property>
 		<property name="jpaProperties">
 			<props>
 				<prop key="toplink.logging.level">FINE</prop>
-				<prop key="toplink.jdbc.driver">org.apache.derby.jdbc.EmbeddedDriver</prop>
-				<prop key="toplink.jdbc.url">jdbc:derby:myfacesOrchestraDB/V1;create=true</prop>
-				<prop key="toplink.jdbc.user">sa</prop>
-				<prop key="toplink.jdbc.password">foobar</prop>
 				<prop key="toplink.target-database">oracle.toplink.essentials.platform.database.DerbyPlatform</prop>
 				<prop key="toplink.ddl-generation">create-tables</prop>
+				<prop key="toplink.cache.type.default">HardWeak</prop>
+				<prop key="toplink.cache.size.default">5000</prop>
+				<prop key="toplink.weaving">false</prop>
 			</props>
 		</property>
-		<property name="persistenceUnitName" value="default"/>
-	</bean>
-
-<!--
-	<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
-		<property name="sessionFactory" ref="sessionFactory" />
 	</bean>
 
-	 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
-		 <property name="dataSource" ref="dataSource"/>
-		 <property name="annotatedClasses">
-			 <list>
-				 <value>org.apache.myfaces.examples.configurator.model.po.Component</value>
-				 <value>org.apache.myfaces.examples.configurator.model.po.Piece</value>
-				 <value>org.apache.myfaces.examples.configurator.model.po.OrderHead</value>
-				 <value>org.apache.myfaces.examples.configurator.model.po.OrderItem</value>
-			 </list>
-		 </property>
-		 <property name="hibernateProperties">
-			 <props>
-				 <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
-				 <prop key="hibernate.show_sql">true</prop>
-				 <prop key="hibernate.generate_statistics">true</prop>
-				 <prop key="hibernate.hbm2ddl.auto">update</prop>
-				 <prop key="hibernate.jdbc.batch_size">0</prop>
-				 <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
-				 <prop key="hibernate.cache.use_second_level_cache">true</prop>
-				 <prop key="hibernate.cache.use_query_cache">true</prop>
-			 </props>
-		 </property>
-	 </bean>
- -->
+	<!--
+		<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
+			<property name="sessionFactory" ref="sessionFactory" />
+		</bean>
+
+		 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
+			 <property name="dataSource" ref="dataSource"/>
+			 <property name="annotatedClasses">
+				 <list>
+					 <value>org.apache.myfaces.examples.configurator.model.po.Component</value>
+					 <value>org.apache.myfaces.examples.configurator.model.po.Piece</value>
+					 <value>org.apache.myfaces.examples.configurator.model.po.OrderHead</value>
+					 <value>org.apache.myfaces.examples.configurator.model.po.OrderItem</value>
+				 </list>
+			 </property>
+			 <property name="hibernateProperties">
+				 <props>
+					 <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
+					 <prop key="hibernate.show_sql">true</prop>
+					 <prop key="hibernate.generate_statistics">true</prop>
+					 <prop key="hibernate.hbm2ddl.auto">update</prop>
+					 <prop key="hibernate.jdbc.batch_size">0</prop>
+					 <prop key="hibernate.cache.provider_class">org.hibernate.cache.HashtableCacheProvider</prop>
+					 <prop key="hibernate.cache.use_second_level_cache">true</prop>
+					 <prop key="hibernate.cache.use_query_cache">true</prop>
+				 </props>
+			 </property>
+		 </bean>
+	 -->
 
 	<!-- system stuff -->
 
 	<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
-	   <property name="host" value="smtp"/>
+		<property name="host" value="smtp"/>
 	</bean>
 
 	<!-- dao -->