geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r475941 - in /geronimo/server/trunk/modules: geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/ geronimo-jetty/src/main/java/org/apache/geronimo/jetty/ geronimo-jetty/src/main/java/org/apache/geronim...
Date Thu, 16 Nov 2006 22:03:28 GMT
Author: djencks
Date: Thu Nov 16 14:03:27 2006
New Revision: 475941

URL: http://svn.apache.org/viewvc?view=rev&rev=475941
Log:
GERONIMO-2491 Possible solution for Hibernate problem.  Use the same context for connection
tracking for all includes/dispatches in a servlet request.

Added:
    geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
  (with props)
Modified:
    geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java
    geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
    geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java

Added: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java?view=auto&rev=475941
==============================================================================
--- geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
(added)
+++ geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
Thu Nov 16 14:03:27 2006
@@ -0,0 +1,72 @@
+/*
+ * 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.geronimo.connector.outbound.connectiontracking;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class SharedConnectorInstanceContext implements ConnectorInstanceContext {
+
+    private Map connectionManagerMap = new HashMap();
+
+    private final Set unshareableResources;
+    private final Set applicationManagedSecurityResources;
+
+    private boolean hide = false;
+
+    public SharedConnectorInstanceContext(Set unshareableResources, Set applicationManagedSecurityResources,
boolean share) {
+        this.unshareableResources = unshareableResources;
+        this.applicationManagedSecurityResources = applicationManagedSecurityResources;
+        if (!share) {
+            connectionManagerMap = new HashMap();
+        }
+    }
+
+    public void share(SharedConnectorInstanceContext context) {
+        connectionManagerMap = context.connectionManagerMap;
+    }
+
+    public void hide() {
+        this.hide = true;
+    }
+
+    public Map getConnectionManagerMap() {
+        if (hide) {
+            return Collections.EMPTY_MAP;
+        }
+        return connectionManagerMap;
+    }
+
+    public Set getUnshareableResources() {
+        return unshareableResources;
+    }
+
+    public Set getApplicationManagedSecurityResources() {
+        return applicationManagedSecurityResources;
+    }
+}

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/modules/geronimo-connector/src/main/java/org/apache/geronimo/connector/outbound/connectiontracking/SharedConnectorInstanceContext.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java?view=diff&rev=475941&r1=475940&r2=475941
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/JettyWebAppContext.java
Thu Nov 16 14:03:27 2006
@@ -214,7 +214,7 @@
         Context enc = EnterpriseNamingContext.createEnterpriseNamingContext(componentContext,
userTransaction, kernel, webClassLoader);
 
         int index = 0;
-        BeforeAfter interceptor = new InstanceContextBeforeAfter(null, index++, unshareableResources,
applicationManagedSecurityResources, trackedConnectionAssociator);
+        BeforeAfter interceptor = new InstanceContextBeforeAfter(null, index++, index++,
unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator);
         interceptor = new ComponentContextBeforeAfter(interceptor, index++, enc);
         interceptor = new ThreadClassloaderBeforeAfter(interceptor, index++, index++, this.webClassLoader);
         interceptor = new WebApplicationContextBeforeAfter(interceptor, index++, this);

Modified: geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java?view=diff&rev=475941&r1=475940&r2=475941
==============================================================================
--- geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
(original)
+++ geronimo/server/trunk/modules/geronimo-jetty/src/main/java/org/apache/geronimo/jetty/interceptor/InstanceContextBeforeAfter.java
Thu Nov 16 14:03:27 2006
@@ -21,9 +21,8 @@
 
 import javax.resource.ResourceException;
 
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContextImpl;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
 import org.mortbay.http.HttpRequest;
 import org.mortbay.http.HttpResponse;
 
@@ -33,14 +32,16 @@
 public class InstanceContextBeforeAfter implements BeforeAfter {
     
     private final BeforeAfter next;
-    private final int index;
+    private final int oldIndex;
+    private final int newIndex;
     private final Set unshareableResources;
     private final Set applicationManagedSecurityResources;
     private final TrackedConnectionAssociator trackedConnectionAssociator;
 
-    public InstanceContextBeforeAfter(BeforeAfter next, int index, Set unshareableResources,
Set applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator)
{
+    public InstanceContextBeforeAfter(BeforeAfter next, int oldIndex, int newIndex, Set unshareableResources,
Set applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator)
{
         this.next = next;
-        this.index = index;
+        this.oldIndex = oldIndex;
+        this.newIndex = newIndex;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.trackedConnectionAssociator = trackedConnectionAssociator;
@@ -48,7 +49,13 @@
 
     public void before(Object[] context, HttpRequest httpRequest, HttpResponse httpResponse)
{
         try {
-            context[index] = trackedConnectionAssociator.enter(new ConnectorInstanceContextImpl(unshareableResources,
applicationManagedSecurityResources));
+            SharedConnectorInstanceContext newConnectorInstanceContext = new SharedConnectorInstanceContext(unshareableResources,
applicationManagedSecurityResources, false);
+            SharedConnectorInstanceContext oldContext = (SharedConnectorInstanceContext)
trackedConnectionAssociator.enter(newConnectorInstanceContext);
+            if (oldContext != null) {
+                newConnectorInstanceContext.share(oldContext);
+            }
+            context[oldIndex] = oldContext;
+            context[newIndex] = newConnectorInstanceContext;
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }
@@ -62,7 +69,12 @@
             next.after(context, httpRequest, httpResponse);
         }
         try {
-            trackedConnectionAssociator.exit((ConnectorInstanceContext) context[index]);
+            SharedConnectorInstanceContext oldConnectorInstanceContext = (SharedConnectorInstanceContext)
context[oldIndex];
+            SharedConnectorInstanceContext newConnectorInstanceContext = (SharedConnectorInstanceContext)
context[newIndex];
+            if (oldConnectorInstanceContext != null) {
+                newConnectorInstanceContext.hide();
+            }
+            trackedConnectionAssociator.exit(oldConnectorInstanceContext);
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }

Modified: geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?view=diff&rev=475941&r1=475940&r2=475941
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Thu Nov 16 14:03:27 2006
@@ -97,8 +97,9 @@
         }
 
         int index = 0;
-        BeforeAfter interceptor = new InstanceContextBeforeAfter(null, index++,
-                ctx.getUnshareableResources(),
+        BeforeAfter interceptor = new InstanceContextBeforeAfter(null,
+                index++,
+                index++, ctx.getUnshareableResources(),
                 ctx.getApplicationManagedSecurityResources(),
                 ctx.getTrackedConnectionAssociator());
 

Modified: geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java?view=diff&rev=475941&r1=475940&r2=475941
==============================================================================
--- geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java
(original)
+++ geronimo/server/trunk/modules/geronimo-tomcat/src/main/java/org/apache/geronimo/tomcat/interceptor/InstanceContextBeforeAfter.java
Thu Nov 16 14:03:27 2006
@@ -22,21 +22,22 @@
 import javax.servlet.ServletRequest;
 import javax.servlet.ServletResponse;
 
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContextImpl;
-import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
 import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
 
 public class InstanceContextBeforeAfter implements BeforeAfter{
 
     private final BeforeAfter next;
-    private final int index;
+    private final int oldIndex;
+    private final int newIndex;
     private final Set unshareableResources;
     private final Set applicationManagedSecurityResources;
     private final TrackedConnectionAssociator trackedConnectionAssociator;
 
-    public InstanceContextBeforeAfter(BeforeAfter next, int index, Set unshareableResources,
Set applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator)
{
+    public InstanceContextBeforeAfter(BeforeAfter next, int oldIndex, int newIndex, Set unshareableResources,
Set applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator)
{
         this.next = next;
-        this.index = index;
+        this.oldIndex = oldIndex;
+        this.newIndex = newIndex;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
         this.trackedConnectionAssociator = trackedConnectionAssociator;
@@ -44,7 +45,13 @@
 
     public void before(Object[] context, ServletRequest httpRequest, ServletResponse httpResponse)
{
         try {
-            context[index] = trackedConnectionAssociator.enter(new ConnectorInstanceContextImpl(unshareableResources,
applicationManagedSecurityResources));
+            SharedConnectorInstanceContext newConnectorInstanceContext = new SharedConnectorInstanceContext(unshareableResources,
applicationManagedSecurityResources, false);
+            SharedConnectorInstanceContext oldContext = (SharedConnectorInstanceContext)
trackedConnectionAssociator.enter(newConnectorInstanceContext);
+            if (oldContext != null) {
+                newConnectorInstanceContext.share(oldContext);
+            }
+            context[oldIndex] = oldContext;
+            context[newIndex] = newConnectorInstanceContext;
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }
@@ -58,7 +65,12 @@
             next.after(context, httpRequest, httpResponse);
         }
         try {
-            trackedConnectionAssociator.exit((ConnectorInstanceContext) context[index]);
+            SharedConnectorInstanceContext oldConnectorInstanceContext = (SharedConnectorInstanceContext)
context[oldIndex];
+            SharedConnectorInstanceContext newConnectorInstanceContext = (SharedConnectorInstanceContext)
context[newIndex];
+            if (oldConnectorInstanceContext != null) {
+                newConnectorInstanceContext.hide();
+            }
+            trackedConnectionAssociator.exit(oldConnectorInstanceContext);
         } catch (ResourceException e) {
             throw new RuntimeException(e);
         }



Mime
View raw message