Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 49239 invoked from network); 2 May 2010 16:54:00 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 2 May 2010 16:54:00 -0000 Received: (qmail 61598 invoked by uid 500); 2 May 2010 16:54:00 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 61557 invoked by uid 500); 2 May 2010 16:54:00 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 61550 invoked by uid 99); 2 May 2010 16:54:00 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 May 2010 16:54:00 +0000 X-ASF-Spam-Status: No, hits=-1692.7 required=10.0 tests=ALL_TRUSTED,AWL X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 May 2010 16:53:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3AC03238897A; Sun, 2 May 2010 16:53:09 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r940258 - in /geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat: GeronimoStandardContext.java TomcatExecutorWrapper.java TomcatServerGBean.java core/GeronimoApplicationContext.java Date: Sun, 02 May 2010 16:53:09 -0000 To: scm@geronimo.apache.org From: xuhaihong@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100502165309.3AC03238897A@eris.apache.org> Author: xuhaihong Date: Sun May 2 16:53:08 2010 New Revision: 940258 URL: http://svn.apache.org/viewvc?rev=940258&view=rev Log: Update Tomcat integration codes due to recent changes in Tomcat 7 trunk 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/TomcatExecutorWrapper.java geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.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=940258&r1=940257&r2=940258&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 Sun May 2 16:53:08 2010 @@ -397,9 +397,9 @@ public class GeronimoStandardContext ext } } - public void init() throws Exception { + protected void initInternal() throws LifecycleException { String docBase = getDocBase(); - super.init(); + super.initInternal(); setDocBase(docBase); } Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatExecutorWrapper.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatExecutorWrapper.java?rev=940258&r1=940257&r2=940258&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatExecutorWrapper.java (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatExecutorWrapper.java Sun May 2 16:53:08 2010 @@ -61,4 +61,12 @@ public class TomcatExecutorWrapper exten executor.execute(runnable); // FIXME Figure out how to implement it } + + @Override + protected void destroyInternal() throws LifecycleException { + } + + @Override + protected void initInternal() throws LifecycleException { + } } Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java?rev=940258&r1=940257&r2=940258&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/TomcatServerGBean.java Sun May 2 16:53:08 2010 @@ -17,7 +17,6 @@ * under the License. */ - package org.apache.geronimo.tomcat; import java.io.File; @@ -41,7 +40,6 @@ import javax.xml.stream.XMLStreamExcepti import javax.xml.stream.XMLStreamReader; import org.apache.catalina.Executor; -import org.apache.catalina.Lifecycle; import org.apache.catalina.LifecycleListener; import org.apache.catalina.Server; import org.apache.catalina.Service; @@ -63,15 +61,20 @@ import org.xml.sax.SAXException; /** * @version $Rev$ $Date$ */ - @GBean public class TomcatServerGBean implements GBeanLifecycle { + public static final XMLInputFactory XMLINPUT_FACTORY = XMLInputFactory.newInstance(); + public static final JAXBContext SERVER_CONTEXT; + private static final String DEFAULT_CATALINA_HOME = "var/catalina"; - public static final Map ConnectorName=new HashMap(); - public static final List LifecycleListeners=new ArrayList(); - public static final Map executors=new HashMap(); + + public static final Map ConnectorName = new HashMap(); + + public static final List LifecycleListeners = new ArrayList(); + + public static final Map executors = new HashMap(); static { try { SERVER_CONTEXT = JAXBContext.newInstance(ServerType.class); @@ -82,33 +85,34 @@ public class TomcatServerGBean implement //server.xml as a string private final String serverConfig; + private final ClassLoader classLoader; + private final ServerInfo serverInfo; + private final Server server; + private TomcatServerConfigManager tomcatServerConfigManager; public TomcatServerGBean(@ParamAttribute(name = "serverConfig") String serverConfig, - @ParamAttribute(name = "serverConfigLocation") String serverConfigLocation, - @ParamAttribute(name = "catalinaHome") String catalinaHome, - @ParamReference(name = "ServerInfo") ServerInfo serverInfo, - @ParamReference(name = "AttributeManager", namingType = "AttributeStore") PluginAttributeStore attributeStore, - @ParamReference(name = "MBeanServerReference") MBeanServerReference mbeanServerReference, - @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader, - @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel) throws Exception { + @ParamAttribute(name = "serverConfigLocation") String serverConfigLocation, + @ParamAttribute(name = "catalinaHome") String catalinaHome, + @ParamReference(name = "ServerInfo") ServerInfo serverInfo, + @ParamReference(name = "AttributeManager", namingType = "AttributeStore") PluginAttributeStore attributeStore, + @ParamReference(name = "MBeanServerReference") MBeanServerReference mbeanServerReference, + @ParamSpecial(type = SpecialAttributeType.classLoader) ClassLoader classLoader, + @ParamSpecial(type = SpecialAttributeType.kernel) Kernel kernel) throws Exception { this.serverConfig = serverConfig; this.serverInfo = serverInfo; this.classLoader = classLoader; - if (mbeanServerReference != null) { Registry.getRegistry(null, null).setMBeanServer(mbeanServerReference.getMBeanServer()); } - - if (catalinaHome == null){ + if (catalinaHome == null) { catalinaHome = DEFAULT_CATALINA_HOME; } System.setProperty("catalina.home", serverInfo.resolveServerPath(catalinaHome)); System.setProperty("catalina.base", serverInfo.resolveServerPath(catalinaHome)); - if (serverConfig == null) { File serverConfigFile = serverInfo.resolveServer(serverConfigLocation); this.tomcatServerConfigManager = new TomcatServerConfigManager(serverConfigFile); @@ -121,12 +125,10 @@ public class TomcatServerGBean implement } serverConfig = b.toString(); } - if (attributeStore != null) { serverConfig = attributeStore.substitute(serverConfig); } Reader in = new StringReader(serverConfig); - try { ServerType serverType = loadServerType(in); server = serverType.build(classLoader, kernel); @@ -147,15 +149,16 @@ public class TomcatServerGBean implement ClassLoader cl = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); - server.initialize(); - ((Lifecycle) server).start(); + server.init(); + server.start(); } finally { Thread.currentThread().setContextClassLoader(cl); } } public void doStop() throws Exception { - ((Lifecycle)server).stop(); + server.stop(); + server.destroy(); } public void doFail() { @@ -170,18 +173,17 @@ public class TomcatServerGBean implement Service service; if (serviceName == null) { Service[] services = server.findServices(); - if (services == null || services.length == 0) throw new IllegalStateException("No services in server"); - - if (services.length > 1) throw new IllegalStateException("More than one service in server. Provide name of desired server" + Arrays.asList(services)); + if (services == null || services.length == 0) + throw new IllegalStateException("No services in server"); + if (services.length > 1) + throw new IllegalStateException("More than one service in server. Provide name of desired server" + Arrays.asList(services)); service = services[0]; - } else { service = server.findService(serviceName); } return service; } - public TomcatServerConfigManager getTomcatServerConfigManager() { return tomcatServerConfigManager; } Modified: geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.java?rev=940258&r1=940257&r2=940258&view=diff ============================================================================== --- geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.java (original) +++ geronimo/server/trunk/plugins/tomcat/geronimo-tomcat7/src/main/java/org/apache/geronimo/tomcat/core/GeronimoApplicationContext.java Sun May 2 16:53:08 2010 @@ -20,6 +20,7 @@ package org.apache.geronimo.tomcat.core; import javax.servlet.Servlet; import javax.servlet.ServletRegistration.Dynamic; +import org.apache.catalina.LifecycleState; import org.apache.catalina.Wrapper; import org.apache.catalina.core.ApplicationContext; import org.apache.geronimo.tomcat.GeronimoStandardContext; @@ -59,7 +60,7 @@ public class GeronimoApplicationContext @Override public void declareRoles(String... roles) { - if(context.isInitialized()) { + if (!context.getState().equals(LifecycleState.STARTING_PREP)) { throw new IllegalStateException("declareRoles is not allowed to invoke after the ServletContext is initialized"); } specSecurityBuilder.declareRoles(roles);