You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2009/06/17 07:57:24 UTC
svn commit: r785478 [2/2] - in /geronimo/server/trunk/plugins/jetty7:
geronimo-jetty7-builder/src/main/java/org/apache/geronimo/jetty7/deployment/
geronimo-jetty7-builder/src/test/java/org/apache/geronimo/jetty7/deployment/
geronimo-jetty7-clustering-w...
Added: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java?rev=785478&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java (added)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java Wed Jun 17 05:57:23 2009
@@ -0,0 +1,153 @@
+/*
+ * 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.jetty7.handler;
+
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.transaction.UserTransaction;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.servlet.ServletException;
+import javax.resource.ResourceException;
+
+import org.apache.geronimo.connector.outbound.connectiontracking.TrackedConnectionAssociator;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.naming.java.RootContext;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.DispatcherType;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class IntegrationContext {
+
+ private final Context componentContext;
+ private final Set<String> unshareableResources;
+ private final Set<String> applicationManagedSecurityResources;
+ private final TrackedConnectionAssociator trackedConnectionAssociator;
+ private final UserTransaction userTransaction;
+
+ public IntegrationContext(Context componentContext, Set<String> unshareableResources, Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator, UserTransaction userTransaction) {
+ this.componentContext = componentContext;
+ this.unshareableResources = unshareableResources;
+ this.applicationManagedSecurityResources = applicationManagedSecurityResources;
+ this.trackedConnectionAssociator = trackedConnectionAssociator;
+ this.userTransaction = userTransaction;
+ }
+
+ public Context getComponentContext() {
+ return componentContext;
+ }
+
+ public Set<String> getUnshareableResources() {
+ return unshareableResources;
+ }
+
+ public Set<String> getApplicationManagedSecurityResources() {
+ return applicationManagedSecurityResources;
+ }
+
+ public TrackedConnectionAssociator getTrackedConnectionAssociator() {
+ return trackedConnectionAssociator;
+ }
+
+ public UserTransaction getUserTransaction() {
+ return userTransaction;
+ }
+
+ public SharedConnectorInstanceContext newConnectorInstanceContext(Request baseRequest) {
+ return new SharedConnectorInstanceContext(getUnshareableResources(),
+ getApplicationManagedSecurityResources(),
+ !isDispatch(baseRequest));
+ }
+
+ private boolean isDispatch(Request baseRequest) {
+ if (baseRequest == null) return true;
+ return DispatcherType.REQUEST.equals(baseRequest.getDispatcherType());
+ }
+
+ public ConnectorInstanceContext setConnectorInstance(Request baseRequest, SharedConnectorInstanceContext newContext) throws ServletException {
+ try {
+ SharedConnectorInstanceContext oldContext = (SharedConnectorInstanceContext) getTrackedConnectionAssociator().enter(newContext);
+ if (oldContext != null && !isDispatch(baseRequest)) {
+ newContext.share(oldContext);
+ }
+ return oldContext;
+ } catch (ResourceException e) {
+ throw new ServletException(e);
+ }
+ }
+
+ public void restoreConnectorContext(ConnectorInstanceContext oldConnectorContext, Request baseRequest, SharedConnectorInstanceContext newContext) throws ServletException {
+ try {
+ if (isDispatch(baseRequest)) {
+ getTrackedConnectionAssociator().exit(oldConnectorContext);
+ } else {
+ newContext.hide();
+ getTrackedConnectionAssociator().exit(oldConnectorContext);
+ }
+ } catch (ResourceException e) {
+ throw new ServletException(e);
+ }
+ }
+
+
+ public javax.naming.Context setContext() {
+ javax.naming.Context oldContext = RootContext.getComponentContext();
+ RootContext.setComponentContext(getComponentContext());
+ return oldContext;
+ }
+
+ public void restoreContext(javax.naming.Context context) {
+ RootContext.setComponentContext(context);
+ }
+
+ public boolean isTxActive() throws ServletException {
+ try {
+ return !(getUserTransaction().getStatus() == Status.STATUS_NO_TRANSACTION
+ || getUserTransaction().getStatus() == Status.STATUS_COMMITTED);
+ } catch (SystemException e) {
+ throw new ServletException("Could not determine transaction status", e);
+ }
+ }
+
+ private boolean isMarkedRollback() throws ServletException {
+ try {
+ return getUserTransaction().getStatus() == Status.STATUS_MARKED_ROLLBACK;
+ } catch (SystemException e) {
+ throw new ServletException("Could not determine transaction status", e);
+ }
+ }
+
+
+ public void completeTx(boolean txActive, Request baseRequest) throws ServletException {
+ if ((!txActive && isMarkedRollback()) || (isDispatch(baseRequest) && isTxActive())) {
+ try {
+ getUserTransaction().rollback();
+ } catch (SystemException e) {
+ throw new ServletException("Error rolling back transaction left open by user program", e);
+ }
+ }
+ }
+
+}
Propchange: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/IntegrationContext.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/JettySecurityHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/JettySecurityHandler.java?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/JettySecurityHandler.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/JettySecurityHandler.java Wed Jun 17 05:57:23 2009
@@ -129,7 +129,7 @@
}
protected boolean checkWebResourcePermissions(String pathInContext, Request request, Response response, Object constraintInfo, UserIdentity userIdentity) throws IOException {
- if (!(userIdentity instanceof GeronimoUserIdentity) && !(userIdentity instanceof GeronimoUserIdentityWrapper)){
+ if (!(userIdentity instanceof GeronimoUserIdentity)){
//we already checked against default_acc and got false
return false;
}
Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/TwistyWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/TwistyWebAppContext.java?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/TwistyWebAppContext.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/handler/TwistyWebAppContext.java Wed Jun 17 05:57:23 2009
@@ -25,16 +25,24 @@
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import javax.naming.Context;
+import javax.transaction.Status;
+import javax.transaction.SystemException;
+import javax.resource.ResourceException;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.DispatcherType;
import org.eclipse.jetty.server.handler.ErrorHandler;
import org.eclipse.jetty.security.SecurityHandler;
import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.server.session.SessionHandler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.util.component.LifeCycle;
+import org.apache.geronimo.naming.java.RootContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.ConnectorInstanceContext;
+import org.apache.geronimo.connector.outbound.connectiontracking.SharedConnectorInstanceContext;
/**
* @version $Rev$ $Date$
@@ -42,10 +50,13 @@
public class TwistyWebAppContext extends WebAppContext {
private Handler handler;
+ protected final IntegrationContext integrationContext;
- public TwistyWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler) {
+ public TwistyWebAppContext(SecurityHandler securityHandler, SessionHandler sessionHandler, ServletHandler servletHandler, ErrorHandler errorHandler, IntegrationContext integrationContext, ClassLoader classLoader) {
super(sessionHandler, securityHandler, servletHandler, errorHandler);
+ this.integrationContext = integrationContext;
+ setClassLoader(classLoader);
}
public void setTwistyHandler(Handler handler) {
@@ -57,10 +68,65 @@
}
@Override
- public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
- handler.handle(target, baseRequest, request, response);
+ protected void doStart() throws Exception {
+ javax.naming.Context context = integrationContext.setContext();
+ boolean txActive = integrationContext.isTxActive();
+ SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
+ ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
+ try {
+ try {
+ super.doStart();
+ } finally {
+ integrationContext.restoreConnectorContext(connectorContext, null, newContext);
+ }
+ } finally {
+ integrationContext.restoreContext(context);
+ integrationContext.completeTx(txActive, null);
+ }
+ }
+
+ @Override
+ protected void doStop() throws Exception {
+ javax.naming.Context context = integrationContext.setContext();
+ boolean txActive = integrationContext.isTxActive();
+ SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
+ ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null, newContext);
+ try {
+ try {
+ super.doStop();
+ } finally {
+ integrationContext.restoreConnectorContext(connectorContext, null, newContext);
+ }
+ } finally {
+ integrationContext.restoreContext(context);
+ integrationContext.completeTx(txActive, null);
+ }
+ }
+
+ @Override
+ public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+ javax.naming.Context context = integrationContext.setContext();
+ boolean txActive = integrationContext.isTxActive();
+ SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(baseRequest);
+ ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(baseRequest, newContext);
+ try {
+ try {
+ super.doScope(target, baseRequest, request, response);
+ } finally {
+ integrationContext.restoreConnectorContext(connectorContext, baseRequest, newContext);
+ }
+ } finally {
+ integrationContext.restoreContext(context);
+ integrationContext.completeTx(txActive, baseRequest);
+ }
}
+
+// @Override
+// public void doHandle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+// handler.handle(target, baseRequest, request, response);
+// }
+
private class TwistyHandler implements Handler {
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
@@ -117,4 +183,5 @@
public void removeLifeCycleListener(Listener listener) {
}
}
+
}
Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/security/JettyIdentityService.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/security/JettyIdentityService.java?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/security/JettyIdentityService.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/main/java/org/apache/geronimo/jetty7/security/JettyIdentityService.java Wed Jun 17 05:57:23 2009
@@ -20,21 +20,20 @@
package org.apache.geronimo.jetty7.security;
-import java.security.Principal;
import java.security.AccessControlContext;
+import java.security.Principal;
import java.util.Arrays;
import javax.security.auth.Subject;
-import org.eclipse.jetty.security.IdentityService;
-import org.eclipse.jetty.security.RunAsToken;
-import org.eclipse.jetty.server.UserIdentity;
-import org.apache.geronimo.jetty7.handler.GeronimoUserIdentity;
import org.apache.geronimo.jetty7.handler.GeronimoRunAsToken;
-import org.apache.geronimo.jetty7.handler.GeronimoUserIdentityWrapper;
-import org.apache.geronimo.security.ContextManager;
+import org.apache.geronimo.jetty7.handler.GeronimoUserIdentity;
import org.apache.geronimo.security.Callers;
+import org.apache.geronimo.security.ContextManager;
import org.apache.geronimo.security.jacc.RunAsSource;
+import org.eclipse.jetty.security.IdentityService;
+import org.eclipse.jetty.security.RunAsToken;
+import org.eclipse.jetty.server.UserIdentity;
/**
* @version $Rev$ $Date$
@@ -49,16 +48,14 @@
this.runAsSource = runAsSource;
}
- //Umm, what was this supposed to do?
public void associate(UserIdentity user) {
-// if (user instanceof GeronimoUserIdentityWrapper) {
-// return ((GeronimoUserIdentityWrapper) user).newWrapper(context);
-// } else {
-// return new GeronimoUserIdentityWrapper(user, context);
-// }
- }
-
- public void disassociate(GeronimoUserIdentityWrapper source) {
+ if (user == null) {
+ //exit
+ ContextManager.clearCallers();
+ } else {
+ //enter
+ ContextManager.setCallers(user.getSubject(), user.getSubject());
+ }
}
public Object setRunAs(UserIdentity userIdentity, RunAsToken token) {
@@ -74,7 +71,6 @@
public UserIdentity newUserIdentity(Subject subject, Principal userPrincipal, String[] roles) {
if (subject != null) {
AccessControlContext acc = ContextManager.registerSubjectShort(subject, userPrincipal, roles == null? null: Arrays.asList(roles));
- ContextManager.setCallers(subject, subject);
return new GeronimoUserIdentity(subject, userPrincipal, acc);
}
return new GeronimoUserIdentity(null, null, defaultAcc);
Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/AbstractWebModuleTest.java?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/AbstractWebModuleTest.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/AbstractWebModuleTest.java Wed Jun 17 05:57:23 2009
@@ -140,7 +140,7 @@
Collections.<String, Object>emptyMap(),
cl,
new URL(configurationBaseURL, uriString),
- null,
+ null, null,
null,
"context",
null,
@@ -156,7 +156,6 @@
sessionHandlerFactory,
preHandlerFactory,
policyContextId,
- securityRealmName,
securityHandlerFactory,
runAsSource,
null,
Modified: geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/GBeanInfoTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/GBeanInfoTest.java?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/GBeanInfoTest.java (original)
+++ geronimo/server/trunk/plugins/jetty7/geronimo-jetty7/src/test/java/org/apache/geronimo/jetty7/GBeanInfoTest.java Wed Jun 17 05:57:23 2009
@@ -19,6 +19,7 @@
package org.apache.geronimo.jetty7;
import junit.framework.TestCase;
+import org.apache.geronimo.gbean.annotation.AnnotationGBeanInfoFactory;
import org.apache.geronimo.system.serverinfo.BasicServerInfo;
import org.apache.geronimo.system.serverinfo.ServerInfo;
@@ -28,12 +29,12 @@
public class GBeanInfoTest extends TestCase {
public void testJettyPOJOWebServiceHolder() throws Exception {
- JettyPOJOWebServiceHolder.getGBeanInfo();
- new JettyPOJOWebServiceHolder();
+ new AnnotationGBeanInfoFactory().getGBeanInfo(JettyPOJOWebServiceHolder.class);
+// new JettyPOJOWebServiceHolder();
}
public void testJettyContainerImpl() throws Exception {
- JettyContainerImpl.getGBeanInfo();
+ new AnnotationGBeanInfoFactory().getGBeanInfo(JettyContainerImpl.class);
ServerInfo serverInfo = new BasicServerInfo(".");
new JettyContainerImpl(null, null, null, serverInfo);
}
Modified: geronimo/server/trunk/plugins/jetty7/jetty7/src/main/history/dependencies.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty7/jetty7/src/main/history/dependencies.xml?rev=785478&r1=785477&r2=785478&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty7/jetty7/src/main/history/dependencies.xml (original)
+++ geronimo/server/trunk/plugins/jetty7/jetty7/src/main/history/dependencies.xml Wed Jun 17 05:57:23 2009
@@ -86,9 +86,4 @@
<artifactId>jetty-io</artifactId>
<type>jar</type>
</dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jaspi_1.0_spec</artifactId>
- <type>jar</type>
- </dependency>
</plugin-artifact>