geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r1029726 - in /geronimo/server/trunk/plugins/jetty8: geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/ geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/ geronimo-jetty8/src/main/java/org/apache/geronimo/je...
Date Mon, 01 Nov 2010 16:08:04 GMT
Author: djencks
Date: Mon Nov  1 16:08:04 2010
New Revision: 1029726

URL: http://svn.apache.org/viewvc?rev=1029726&view=rev
Log:
GERONIMO-5050 use single owb lifecycle and context in jetty, fix a couple small problems

Modified:
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
    geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java?rev=1029726&r1=1029725&r2=1029726&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8-builder/src/main/java/org/apache/geronimo/jetty8/deployment/JettyModuleBuilder.java
Mon Nov  1 16:08:04 2010
@@ -25,6 +25,7 @@ import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
+import java.util.LinkedHashSet;
 import java.util.Map;
 import java.util.jar.JarFile;
 
@@ -72,6 +73,7 @@ import org.apache.geronimo.kernel.util.J
 import org.apache.geronimo.naming.deployment.ENCConfigBuilder;
 import org.apache.geronimo.naming.deployment.GBeanResourceEnvironmentBuilder;
 import org.apache.geronimo.naming.deployment.ResourceEnvironmentSetter;
+import org.apache.geronimo.openwebbeans.SharedOwbContext;
 import org.apache.geronimo.schema.ElementConverter;
 import org.apache.geronimo.schema.NamespaceElementConverter;
 import org.apache.geronimo.schema.SchemaConversionUtils;
@@ -524,6 +526,14 @@ public class JettyModuleBuilder extends 
                 webModuleData.setAttribute("compactPath", Boolean.TRUE);
             }
 
+            LinkedHashSet<Module<?, ?>> submodules = module.getModules();
+            for (Module<?, ?> subModule: submodules) {
+                if (subModule.getSharedContext().get(SharedOwbContext.class) != null) {
+                    GBeanData data = (GBeanData) subModule.getSharedContext().get(SharedOwbContext.class);
+                    AbstractName name = data.getAbstractName();
+                    webModuleData.setReferencePattern("SharedOwbContext", name);
+                }
+            }
             //Save Deployment Attributes
             Map<String, Object> deploymentAttributes = new HashMap<String, Object>();
             deploymentAttributes.put(WebAttributeName.META_COMPLETE.name(), webApp.isMetadataComplete());
@@ -598,7 +608,6 @@ public class JettyModuleBuilder extends 
         JettyAuthenticationType authType = jettyWebApp.getAuthentication();
         if (loginConfigInfo != null || authType != null || jettyWebApp.isSetSecurityRealmName())
{
             AbstractName factoryName = moduleContext.getNaming().createChildName(module.getModuleName(),
"securityHandlerFactory", GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
-            webModuleData.setReferencePattern("SecurityHandlerFactory", factoryName);
 
 
             if (authType != null) {
@@ -609,40 +618,46 @@ public class JettyModuleBuilder extends 
                 configureConfigurationFactory(jettyWebApp, null, securityFactoryData);
                 moduleContext.addGBean(securityFactoryData);
                 configureLocalJaspicProvider(new JettyAuthenticationWrapper(authType), contextPath,
module, securityFactoryData);
+                webModuleData.setReferencePattern("SecurityHandlerFactory", factoryName);
                 //otherwise rely on pre-configured jaspi
             } else {
-                GBeanData securityFactoryData = new GBeanData(factoryName, JettySecurityHandlerFactory.class);
-                configureConfigurationFactory(jettyWebApp, loginConfigInfo, securityFactoryData);
-                BuiltInAuthMethod auth = BuiltInAuthMethod.NONE;
-                if (loginConfigInfo != null) {
-                    if (loginConfigInfo.authMethod != null) {
-                        String authMethod = loginConfigInfo.authMethod.trim();
-                        auth = BuiltInAuthMethod.getValueOf(authMethod);
-
-                        if (auth == BuiltInAuthMethod.BASIC) {
-                            securityFactoryData.setAttribute("realmName", loginConfigInfo.realmName);
-                        } else if (auth == BuiltInAuthMethod.DIGEST) {
-                            securityFactoryData.setAttribute("realmName", loginConfigInfo.realmName);
-                        } else if (auth == BuiltInAuthMethod.FORM) {
-                            if (loginConfigInfo.formLoginPage != null) {
-                                securityFactoryData.setAttribute("loginPage", loginConfigInfo.formLoginPage);
-                                securityFactoryData.setAttribute("errorPage", loginConfigInfo.formErrorPage);
+                if ((loginConfigInfo != null && loginConfigInfo.realmName != null)
|| jettyWebApp.isSetSecurityRealmName()) {
+                    GBeanData securityFactoryData = new GBeanData(factoryName, JettySecurityHandlerFactory.class);
+                    configureConfigurationFactory(jettyWebApp, loginConfigInfo, securityFactoryData);
+                    BuiltInAuthMethod auth = BuiltInAuthMethod.NONE;
+                    if (loginConfigInfo != null) {
+                        if (loginConfigInfo.authMethod != null) {
+                            String authMethod = loginConfigInfo.authMethod.trim();
+                            auth = BuiltInAuthMethod.getValueOf(authMethod);
+
+                            if (auth == BuiltInAuthMethod.BASIC) {
+                                securityFactoryData.setAttribute("realmName", loginConfigInfo.realmName);
+                            } else if (auth == BuiltInAuthMethod.DIGEST) {
+                                securityFactoryData.setAttribute("realmName", loginConfigInfo.realmName);
+                            } else if (auth == BuiltInAuthMethod.FORM) {
+                                if (loginConfigInfo.formLoginPage != null) {
+                                    securityFactoryData.setAttribute("loginPage", loginConfigInfo.formLoginPage);
+                                    securityFactoryData.setAttribute("errorPage", loginConfigInfo.formErrorPage);
+                                }
+                            } else if (auth == BuiltInAuthMethod.CLIENTCERT) {
+                                //nothing to do
+                            } else {
+                                throw new DeploymentException("unrecognized auth method,
use jaspi to configure: " + authMethod);
                             }
-                        } else if (auth == BuiltInAuthMethod.CLIENTCERT) {
-                            //nothing to do
+
                         } else {
-                            throw new DeploymentException("unrecognized auth method, use
jaspi to configure: " + authMethod);
+                            throw new DeploymentException("No auth method configured and
no jaspi configured");
+                        }
+                        if (loginConfigInfo.realmName != null) {
+                            webModuleData.setAttribute("realmName", loginConfigInfo.realmName);
                         }
-
-                    } else {
-                        throw new DeploymentException("No auth method configured and no jaspi
configured");
-                    }
-                    if (loginConfigInfo.realmName != null) {
-                        webModuleData.setAttribute("realmName", loginConfigInfo.realmName);
                     }
+                    securityFactoryData.setAttribute("authMethod", auth);
+                    moduleContext.addGBean(securityFactoryData);
+                    webModuleData.setReferencePattern("SecurityHandlerFactory", factoryName);
+                } else {
+                    log.warn("partial security info but no realm to authenticate against");
                 }
-                securityFactoryData.setAttribute("authMethod", auth);
-                moduleContext.addGBean(securityFactoryData);
             }
         }
     }
@@ -692,7 +707,6 @@ public class JettyModuleBuilder extends 
         if (jettyWebApp.isSetSecurityRealmName()) {
             securityRealmName = jettyWebApp.getSecurityRealmName().trim();
         } else {
-            if (loginConfigInfo == null ||loginConfigInfo.realmName == null) return;
             securityRealmName = loginConfigInfo.realmName;
         }
         AbstractNameQuery configurationFactoryName = new AbstractNameQuery(null, Collections.singletonMap("name",
securityRealmName), ConfigurationFactory.class.getName());

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java?rev=1029726&r1=1029725&r2=1029726&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/WebAppContextWrapper.java
Mon Nov  1 16:08:04 2010
@@ -54,6 +54,7 @@ import org.apache.geronimo.management.J2
 import org.apache.geronimo.management.geronimo.WebContainer;
 import org.apache.geronimo.management.geronimo.WebModule;
 import org.apache.geronimo.openwebbeans.OpenWebBeansWebInitializer;
+import org.apache.geronimo.openwebbeans.SharedOwbContext;
 import org.apache.geronimo.security.jacc.ApplicationPolicyConfigurationManager;
 import org.apache.geronimo.security.jacc.RunAsSource;
 import org.apache.geronimo.transaction.GeronimoUserTransaction;
@@ -132,6 +133,7 @@ public class WebAppContextWrapper implem
                                 @ParamReference(name = "J2EEApplication") J2EEApplication
application,
                                 @ParamReference(name = "ContextSource") ContextSource contextSource,
                                 @ParamReference(name = "TransactionManager") TransactionManager
transactionManager,
+                                @ParamReference(name = "SharedOwbContext") SharedOwbContext
sharedOwbContext,
 
                                 @ParamAttribute(name = "deploymentAttributes") Map<String,
Object> deploymentAttributes
     ) throws Exception {
@@ -206,7 +208,9 @@ public class WebAppContextWrapper implem
                 }
             }
         }
-        IntegrationContext integrationContext = new IntegrationContext(componentContext,
unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction,
bundle, holder, servletContainerInitializerMap);
+        Map<String, Object> owbContext = sharedOwbContext == null? new HashMap<String,
Object>(): sharedOwbContext.getOWBContext();
+
+        IntegrationContext integrationContext = new IntegrationContext(componentContext,
unshareableResources, applicationManagedSecurityResources, trackedConnectionAssociator, userTransaction,
bundle, holder, servletContainerInitializerMap, owbContext);
         webAppContext = new GeronimoWebAppContext(securityHandler, sessionHandler, servletHandler,
null, integrationContext, classLoader, modulePath, webAppInfo, policyContextID, applicationPolicyConfigurationManager);
         webAppContext.setContextPath(contextPath);
         //See Jetty-386.  Setting this to true can expose secured content.
@@ -296,8 +300,10 @@ public class WebAppContextWrapper implem
         }
         //supply web.xml to jasper
         webAppContext.setAttribute(JASPER_WEB_XML_NAME, originalSpecDD);
-        new OpenWebBeansWebInitializer(integrationContext.getOWBContext(), webAppContext.getServletContext());
-
+        if (sharedOwbContext == null) {
+            //we have to initialize the owb context
+            new OpenWebBeansWebInitializer(integrationContext.getOWBContext(), webAppContext.getServletContext());
+        }
     }
 
 

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java?rev=1029726&r1=1029725&r2=1029726&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/GeronimoWebAppContext.java
Mon Nov  1 16:08:04 2010
@@ -136,6 +136,7 @@ public class GeronimoWebAppContext exten
         boolean txActive = integrationContext.isTxActive();
         SharedConnectorInstanceContext newContext = integrationContext.newConnectorInstanceContext(null);
         ConnectorInstanceContext connectorContext = integrationContext.setConnectorInstance(null,
newContext);
+        Map<String, Object> oldOwbContext = integrationContext.contextEntered();
         try {
             setRestrictListeners(false);
             try {
@@ -181,6 +182,7 @@ public class GeronimoWebAppContext exten
                 integrationContext.restoreConnectorContext(connectorContext, null, newContext);
             }
         } finally {
+            integrationContext.contextExited(oldOwbContext);
             integrationContext.restoreContext(context);
             integrationContext.completeTx(txActive, null);
         }

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java?rev=1029726&r1=1029725&r2=1029726&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/main/java/org/apache/geronimo/jetty8/handler/IntegrationContext.java
Mon Nov  1 16:08:04 2010
@@ -55,9 +55,9 @@ public class IntegrationContext {
     private final Bundle bundle;
     private final Holder holder;
     private final Map<ServletContainerInitializer, Set<Class<?>>> servletContainerInitializerMap;
-    private final Map<String, Object> owbContext = new HashMap<String, Object>();
+    private final Map<String, Object> owbContext;
 
-    public IntegrationContext(Context componentContext, Set<String> unshareableResources,
Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator,
UserTransaction userTransaction, Bundle bundle, Holder holder, Map<ServletContainerInitializer,
Set<Class<?>>> servletContainerInitializerMap) {
+    public IntegrationContext(Context componentContext, Set<String> unshareableResources,
Set<String> applicationManagedSecurityResources, TrackedConnectionAssociator trackedConnectionAssociator,
UserTransaction userTransaction, Bundle bundle, Holder holder, Map<ServletContainerInitializer,
Set<Class<?>>> servletContainerInitializerMap, Map<String, Object> owbContext)
{
         this.componentContext = componentContext;
         this.unshareableResources = unshareableResources;
         this.applicationManagedSecurityResources = applicationManagedSecurityResources;
@@ -66,6 +66,7 @@ public class IntegrationContext {
         this.bundle = bundle;
         this.holder = holder;
         this.servletContainerInitializerMap = servletContainerInitializerMap == null? Collections.<ServletContainerInitializer,
Set<Class<?>>>emptyMap(): servletContainerInitializerMap;
+        this.owbContext = owbContext;
     }
 
     public Context getComponentContext() {

Modified: geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java?rev=1029726&r1=1029725&r2=1029726&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
(original)
+++ geronimo/server/trunk/plugins/jetty8/geronimo-jetty8/src/test/java/org/apache/geronimo/jetty8/AbstractWebModuleTest.java
Mon Nov  1 16:08:04 2010
@@ -179,6 +179,7 @@ public class AbstractWebModuleTest exten
                 null,
                 contextSource,
                 transactionManager,
+                null,
                 deploymentAttributes
         );
         app.doStart();



Mime
View raw message