geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xuhaih...@apache.org
Subject svn commit: r966115 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat: GeronimoStandardContext.java HostGBean.java TomcatManagerImpl.java
Date Wed, 21 Jul 2010 07:14:47 GMT
Author: xuhaihong
Date: Wed Jul 21 07:14:46 2010
New Revision: 966115

URL: http://svn.apache.org/viewvc?rev=966115&view=rev
Log:
Pass the initial web.xml to security builder while starting the web application

Modified:
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
    geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java?rev=966115&r1=966114&r2=966115&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/GeronimoStandardContext.java
Wed Jul 21 07:14:46 2010
@@ -17,6 +17,7 @@
 package org.apache.geronimo.tomcat;
 
 import java.beans.PropertyChangeListener;
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -40,7 +41,6 @@ import javax.servlet.Servlet;
 import javax.servlet.ServletContainerInitializer;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletException;
-
 import org.apache.catalina.Container;
 import org.apache.catalina.ContainerListener;
 import org.apache.catalina.Engine;
@@ -82,6 +82,8 @@ import org.apache.geronimo.webservices.P
 import org.apache.geronimo.webservices.WebServiceContainer;
 import org.apache.geronimo.webservices.WebServiceContainerInvoker;
 import org.apache.naming.resources.FileDirContext;
+import org.apache.openejb.jee.JaxbJavaee;
+import org.apache.openejb.jee.WebApp;
 import org.apache.tomcat.InstanceManager;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.ServiceRegistration;
@@ -307,11 +309,17 @@ public class GeronimoStandardContext ext
     private void addJACCSecurityLifecycleListener(TomcatWebAppContext tomcatWebAppContext)
throws DeploymentException {
         float schemaVersion = (Float) tomcatWebAppContext.getDeploymentAttribute(WebAttributeName.SCHEMA_VERSION.name());
         boolean metaComplete = (Boolean) tomcatWebAppContext.getDeploymentAttribute(WebAttributeName.META_COMPLETE.name());
-        addLifecycleListener(new JACCSecurityLifecycleListener(bundle,
-                null, 
-                schemaVersion >= 2.5f && !metaComplete,
-                tomcatWebAppContext.getApplicationPolicyConfigurationManager(),
-                tomcatWebAppContext.getSecurityHolder().getPolicyContextID()));
+        try {
+            WebApp webApp = tomcatWebAppContext.getDeploymentDescriptor() == null ? null
: (WebApp) JaxbJavaee.unmarshalJavaee(WebApp.class, new ByteArrayInputStream(tomcatWebAppContext
+                    .getDeploymentDescriptor().getBytes()));
+            addLifecycleListener(new JACCSecurityLifecycleListener(bundle, webApp, schemaVersion
>= 2.5f && !metaComplete, tomcatWebAppContext.getApplicationPolicyConfigurationManager(),
+                    tomcatWebAppContext.getSecurityHolder().getPolicyContextID()));
+        } catch (DeploymentException e) {
+            throw e;
+        } catch (Exception e) {
+            logger.error("fail to parse the web.xml file while starting the web application",
e);
+            throw new DeploymentException("fail to parse the web.xml file while starting
the web application", e);
+        }
     }
 
     private final Object instanceListenersLock = new Object();

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/HostGBean.java?rev=966115&r1=966114&r2=966115&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/HostGBean.java
Wed Jul 21 07:14:46 2010
@@ -40,44 +40,44 @@ import org.slf4j.LoggerFactory;
 public class HostGBean extends BaseGBean implements GBeanLifecycle, ObjectRetriever {
 
     private static final Logger log = LoggerFactory.getLogger(HostGBean.class);
-    
+
     public static final String J2EE_TYPE = "Host";
     private static final String WORKDIR = "workDir";
     private static final String NAME = "name";
-    
+
     private final Host host;
     private final EngineGBean engine;
-    
+
     public HostGBean(){
         host = null;
         engine = null;
     }
 
-    public HostGBean(String className, 
-            Map initParams, 
-            ArrayList aliases,
-            ObjectRetriever realmGBean,            
+    public HostGBean(String className,
+            Map initParams,
+            ArrayList<String> aliases,
+            ObjectRetriever realmGBean,
             ValveGBean tomcatValveChain,
             LifecycleListenerGBean listenerChain,
             CatalinaClusterGBean clusterGBean,
             ManagerGBean manager,
             EngineGBean engine) throws Exception {
         super(); // TODO: make it an attribute
-        
+
         //Validate
         if (className == null){
             className = "org.apache.catalina.core.StandardHost";
         }
-        
+
         if (initParams == null){
             throw new IllegalArgumentException("Must have a 'name' value in initParams.");
         }
-        
+
         //Be sure the name has been declared.
         if (!initParams.containsKey(NAME)){
             throw new IllegalArgumentException("Must have a 'name' value initParams.");
         }
-        
+
         //Be sure we have a default working directory
         if (!initParams.containsKey(WORKDIR)){
             initParams.put(WORKDIR, "work");
@@ -85,10 +85,10 @@ public class HostGBean extends BaseGBean
 
         //Create the Host object
         host = (Host)Class.forName(className).newInstance();
-        
+
         //Set the parameters
         setParameters(host, initParams);
-        
+
         //Add aliases, if any
         if (aliases != null){
             for (Iterator iter = aliases.iterator(); iter.hasNext();) {
@@ -96,13 +96,13 @@ public class HostGBean extends BaseGBean
                 host.addAlias(alias);
             }
         }
-        
+
         if (realmGBean != null)
             host.setRealm((Realm)realmGBean.getInternalObject());
 
         //Add the valve list
         if (host instanceof StandardHost){
-            
+
             if (tomcatValveChain != null){
                 ValveGBean valveGBean = tomcatValveChain;
                 while(valveGBean != null){
@@ -110,7 +110,7 @@ public class HostGBean extends BaseGBean
                     valveGBean = valveGBean.getNextValve();
                 }
             }
-            
+
             if (listenerChain != null){
                 LifecycleListenerGBean listenerGBean = listenerChain;
                 while(listenerGBean != null){
@@ -118,14 +118,14 @@ public class HostGBean extends BaseGBean
                     listenerGBean = listenerGBean.getNextListener();
                 }
             }
-            
+
        }
 
         //Add clustering
         if (clusterGBean != null){
             host.setCluster((Cluster)clusterGBean.getInternalObject());
         }
-        
+
         //Add manager
         if (manager != null)
             host.setManager((Manager)manager.getInternalObject());
@@ -169,11 +169,11 @@ public class HostGBean extends BaseGBean
         infoFactory.addReference("Manager", ManagerGBean.class, ManagerGBean.J2EE_TYPE);
         infoFactory.addReference("Engine", EngineGBean.class, GBeanInfoBuilder.DEFAULT_J2EE_TYPE);
         infoFactory.addOperation("getInternalObject");
-        infoFactory.setConstructor(new String[] { 
-                "className", 
-                "initParams", 
-                "aliases", 
-                "RealmGBean", 
+        infoFactory.setConstructor(new String[] {
+                "className",
+                "initParams",
+                "aliases",
+                "RealmGBean",
                 "TomcatValveChain",
                 "LifecycleListenerChain",
                 "CatalinaCluster",

Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java?rev=966115&r1=966114&r2=966115&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
(original)
+++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatManagerImpl.java
Wed Jul 21 07:14:46 2010
@@ -265,32 +265,31 @@ public class TomcatManagerImpl implement
         if(protocol == null) {
             return getConnectors();
         }
-        List result = new ArrayList();
+        List<TomcatWebConnector> result = new ArrayList<TomcatWebConnector>();
         ProxyManager proxyManager = kernel.getProxyManager();
         AbstractNameQuery query = new AbstractNameQuery(TomcatWebConnector.class.getName());
-        Set names = kernel.listGBeans(query);
-        for (Iterator it = names.iterator(); it.hasNext();) {
-            AbstractName name = (AbstractName) it.next();
+        Set<AbstractName> names = kernel.listGBeans(query);
+        for (AbstractName name : names) {
             try {
                 if (kernel.getAttribute(name, "protocol").equals(protocol)) {
-                    result.add(proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader()));
+                    result.add((TomcatWebConnector)proxyManager.createProxy(name, TomcatWebConnector.class.getClassLoader()));
                 }
             } catch (Exception e) {
                 log.error("Unable to check the protocol for a connector", e);
             }
         }
-        return (TomcatWebConnector[]) result.toArray(new TomcatWebConnector[names.size()]);
+        return result.toArray(new TomcatWebConnector[names.size()]);
     }
 
     public WebAccessLog getAccessLog(WebContainer container) {
         AbstractNameQuery query = new AbstractNameQuery(TomcatLogManager.class.getName());
-        Set names = kernel.listGBeans(query);
+        Set<AbstractName> names = kernel.listGBeans(query);
         if(names.size() == 0) {
             return null;
         } else if(names.size() > 1) {
             throw new IllegalStateException("Should not be more than one Tomcat access log
manager");
         }
-        return (WebAccessLog) kernel.getProxyManager().createProxy((AbstractName)names.iterator().next(),
TomcatLogManager.class.getClassLoader());
+        return (WebAccessLog) kernel.getProxyManager().createProxy(names.iterator().next(),
TomcatLogManager.class.getClassLoader());
     }
 
     public List<ConnectorType> getConnectorTypes() {



Mime
View raw message