You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by xu...@apache.org on 2010/05/02 18:53:09 UTC
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
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<Connector,String> ConnectorName=new HashMap<Connector,String>();
- public static final List<LifecycleListener> LifecycleListeners=new ArrayList<LifecycleListener>();
- public static final Map<String,Executor> executors=new HashMap<String,Executor>();
+
+ public static final Map<Connector, String> ConnectorName = new HashMap<Connector, String>();
+
+ public static final List<LifecycleListener> LifecycleListeners = new ArrayList<LifecycleListener>();
+
+ public static final Map<String, Executor> executors = new HashMap<String, Executor>();
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);