You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jl...@apache.org on 2004/12/18 01:07:32 UTC
svn commit: r122687 - in geronimo/trunk/modules: assembly/src/plan tomcat/src/java/org/apache/geronimo/tomcat tomcat/src/java/org/apache/geronimo/tomcat/connector tomcat/src/plan tomcat/src/test/org/apache/geronimo/tomcat
Author: jlaskowski
Date: Fri Dec 17 16:07:30 2004
New Revision: 122687
URL: http://svn.apache.org/viewcvs?view=rev&rev=122687
Log:
Apache Tomcat's HTTP/1.1 Connector GBean
Added:
geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/connector/
geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/connector/HTTPConnector.java (contents, props changed)
Modified:
geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml
geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml
geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml
geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml?view=diff&rev=122687&p1=geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml&r1=122686&p2=geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml&r2=122687
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml (original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-deployer-plan.xml Fri Dec 17 16:07:30 2004
@@ -188,6 +188,9 @@
<uri>tomcat/jars/naming-resources-${tomcat_version}.jar</uri>
</dependency>
<dependency>
+ <uri>tomcat/jars/tomcat-coyote-${tomcat_version}.jar</uri>
+ </dependency>
+ <dependency>
<uri>tomcat/jars/tomcat-util-${tomcat_version}.jar</uri>
</dependency>
<gbean name="geronimo.deployer:role=ModuleBuilder,type=Web,config=org/apache/geronimo/J2EEDeployer" class="org.apache.geronimo.tomcat.deployment.TomcatModuleBuilder">
Modified: geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml?view=diff&rev=122687&p1=geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml&r1=122686&p2=geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml&r2=122687
==============================================================================
--- geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml (original)
+++ geronimo/trunk/modules/assembly/src/plan/j2ee-server-tomcat-plan.xml Fri Dec 17 16:07:30 2004
@@ -93,9 +93,12 @@
<gbean name="geronimo.server:type=WebContainer,container=Tomcat" class="org.apache.geronimo.tomcat.TomcatContainer">
<attribute name="catalinaHome">var/catalina</attribute>
- <attribute name="port">8090</attribute>
<attribute name="endorsedDirs">lib</attribute>
<reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
+ </gbean>
+ <gbean name="geronimo.server:type=WebConnector,container=Tomcat,port=8090" class="org.apache.geronimo.tomcat.connector.HTTPConnector">
+ <attribute name="port" type="int">8090</attribute>
+ <reference name="TomcatContainer">geronimo.server:type=WebContainer,container=Tomcat</reference>
</gbean>
</configuration>
Modified: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java?view=diff&rev=122687&p1=geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java&r1=122686&p2=geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java&r2=122687
==============================================================================
--- geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java (original)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/TomcatContainer.java Fri Dec 17 16:07:30 2004
@@ -16,8 +16,6 @@
*/
package org.apache.geronimo.tomcat;
-import java.io.File;
-
import org.apache.catalina.Context;
import org.apache.catalina.Engine;
import org.apache.catalina.Host;
@@ -49,13 +47,6 @@
private static final String DEFAULT_CATALINA_HOME = "var/catalina";
/**
- * The default port the HTTP connector listens to
- *
- * TODO: Move it to another GBean, e.g. HTTPConnector
- */
- private static final int DEFAULT_HTTP_CONNECTOR_PORT = 8090;
-
- /**
* Work directory
*/
private static final String WORK_DIR = "work";
@@ -76,13 +67,6 @@
private Engine engine;
/**
- * Tomcat Connector that will process requests
- *
- * TODO: Make it a GBean
- */
- private Connector connector;
-
- /**
* Tomcat default Context
*
* TODO: Make it a gbean
@@ -90,13 +74,6 @@
private Context defaultContext;
/**
- * The port Tomcat's HTTP Connector listens to
- *
- * TODO: Make it a part of the Listener GBean
- */
- private int port;
-
- /**
* The java.endorsed.dirs directories
*/
private String endorsedDirs = System.getProperty("java.endorsed.dirs");
@@ -109,16 +86,13 @@
// Required as it's referenced by deployed webapps
public TomcatContainer() {
setCatalinaHome(DEFAULT_CATALINA_HOME);
- setPort(DEFAULT_HTTP_CONNECTOR_PORT);
}
/**
- * GBean constructor (invoked dynamically when the gbean is declared in a
- * plan)
+ * GBean constructor (invoked dynamically when the gbean is declared in a plan)
*/
- public TomcatContainer(String catalinaHome, int port, ServerInfo serverInfo) {
+ public TomcatContainer(String catalinaHome, ServerInfo serverInfo) {
setCatalinaHome(catalinaHome);
- setPort(port);
this.serverInfo = serverInfo;
}
@@ -132,8 +106,7 @@
/**
* Instantiate and start up Tomcat's Embedded class
*
- * See org.apache.catalina.startup.Embedded for details (TODO: provide the
- * link to the javadoc)
+ * See org.apache.catalina.startup.Embedded for details (TODO: provide the link to the javadoc)
*/
public void doStart() throws Exception {
log.debug("doStart()");
@@ -151,9 +124,8 @@
// Assemble FileLogger as a gbean
/*
- * FileLogger fileLog = new FileLogger(); fileLog.setDirectory(".");
- * fileLog.setPrefix("vsjMbedTC5"); fileLog.setSuffix(".log");
- * fileLog.setTimestamp(true);
+ * FileLogger fileLog = new FileLogger(); fileLog.setDirectory("."); fileLog.setPrefix("vsjMbedTC5");
+ * fileLog.setSuffix(".log"); fileLog.setTimestamp(true);
*/
// 2. Set the relevant properties of this object itself. In particular,
@@ -198,21 +170,6 @@
// Engines for this object.
embedded.addEngine(engine);
- // 7. Call createConnector() to create at least one TCP/IP connector,
- // and then call its property setters as desired.
-
- // It doesn't work - there's no HTTP connector created
- // connector = embedded.createConnector((String) null, 8080, "http");
-
- // Create an HTTP/1.1 connector manually
- connector = new Connector("HTTP/1.1");
- connector.setPort(this.getPort());
-
- // 8. Call addConnector() to attach this Connector to the set of defined
- // Connectors for this object. The added Connector will use the most
- // recently added Engine to process its received requests.
- embedded.addConnector(connector);
-
// 9. Call start() to initiate normal operations of all the attached
// components.
embedded.start();
@@ -230,8 +187,7 @@
*
* It simply delegates the call to Tomcat's Embedded and Host classes
*
- * @param ctx
- * the context to be added
+ * @param ctx the context to be added
*
* @see org.apache.catalina.startup.Embedded
* @see org.apache.catalina.Host
@@ -262,14 +218,6 @@
System.setProperty("catalina.home", catalinaHome);
}
- public int getPort() {
- return port;
- }
-
- public void setPort(int port) {
- this.port = port;
- }
-
public String getEndorsedDirs() {
return endorsedDirs;
}
@@ -278,21 +226,31 @@
this.endorsedDirs = endorsedDirs;
}
+ public void addConnector(Connector connector) {
+ embedded.addConnector(connector);
+ }
+
+ public void removeConnector(Connector connector) {
+ embedded.removeConnector(connector);
+ }
+
public static final GBeanInfo GBEAN_INFO;
static {
GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Tomcat Web Container", TomcatContainer.class);
- infoFactory.setConstructor(new String[] { "catalinaHome", "port", "ServerInfo" });
+ infoFactory.setConstructor(new String[] { "catalinaHome", "ServerInfo" });
infoFactory.addAttribute("catalinaHome", String.class, true);
- infoFactory.addAttribute("port", int.class, true);
infoFactory.addAttribute("endorsedDirs", String.class, true);
infoFactory.addReference("ServerInfo", ServerInfo.class);
infoFactory.addOperation("addContext", new Class[] { TomcatContext.class });
infoFactory.addOperation("removeContext", new Class[] { TomcatContext.class });
+
+ infoFactory.addOperation("addConnector", new Class[] { Connector.class });
+ infoFactory.addOperation("removeConnector", new Class[] { Connector.class });
GBEAN_INFO = infoFactory.getBeanInfo();
}
Added: geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/connector/HTTPConnector.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/connector/HTTPConnector.java?view=auto&rev=122687
==============================================================================
--- (empty file)
+++ geronimo/trunk/modules/tomcat/src/java/org/apache/geronimo/tomcat/connector/HTTPConnector.java Fri Dec 17 16:07:30 2004
@@ -0,0 +1,66 @@
+/**
+ *
+ * Copyright 2003-2004 The Apache Software Foundation
+ *
+ * Licensed 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.tomcat.connector;
+
+import org.apache.catalina.LifecycleException;
+import org.apache.catalina.connector.Connector;
+import org.apache.geronimo.gbean.GBeanInfo;
+import org.apache.geronimo.gbean.GBeanInfoBuilder;
+import org.apache.geronimo.gbean.GBeanLifecycle;
+import org.apache.geronimo.tomcat.TomcatContainer;
+
+/**
+ * Apache Tomcat HTTP 1.1 connector
+ *
+ * @version $Rev: 56022 $ $Date: 2004-10-30 07:16:18 +0200 (Sat, 30 Oct 2004) $
+ */
+public class HTTPConnector extends Connector implements GBeanLifecycle {
+ private final TomcatContainer container;
+
+ public HTTPConnector(TomcatContainer container) throws Exception {
+ super("HTTP/1.1"); // TODO: make it an attribute
+ this.container = container;
+ }
+
+ public void doStart() throws LifecycleException {
+ container.addConnector(this);
+ start();
+ }
+
+ public void doStop() {
+ container.removeConnector(this);
+ }
+
+ public void doFail() {
+ doStop();
+ }
+
+ public static final GBeanInfo GBEAN_INFO;
+
+ static {
+ GBeanInfoBuilder infoFactory = new GBeanInfoBuilder("Tomcat HTTP Connector", HTTPConnector.class);
+ infoFactory.addAttribute("port", int.class, true);
+ infoFactory.addReference("TomcatContainer", TomcatContainer.class);
+ infoFactory.setConstructor(new String[] { "TomcatContainer" });
+ GBEAN_INFO = infoFactory.getBeanInfo();
+ }
+
+ public static GBeanInfo getGBeanInfo() {
+ return GBEAN_INFO;
+ }
+}
Modified: geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml?view=diff&rev=122687&p1=geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml&r1=122686&p2=geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml&r2=122687
==============================================================================
--- geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml (original)
+++ geronimo/trunk/modules/tomcat/src/plan/tomcat-plan.xml Fri Dec 17 16:07:30 2004
@@ -84,16 +84,16 @@
<dependency>
<uri>mx4j/jars/mx4j-2.0.1.jar</uri>
</dependency>
- <!-- Required to deploy ROOT webapp -->
- <dependency>
- <uri>xerces/jars/xercesImpl-2.6.0.jar</uri>
- </dependency>
<gbean name="geronimo.server:type=WebContainer,container=Tomcat" class="org.apache.geronimo.tomcat.TomcatContainer">
<attribute name="catalinaHome">var/catalina</attribute>
<attribute name="port">8090</attribute>
<attribute name="endorsedDirs">lib</attribute>
<reference name="ServerInfo">geronimo.system:role=ServerInfo</reference>
+ </gbean>
+ <gbean name="geronimo.server:type=WebConnector,container=Tomcat,port=8090" class="org.apache.geronimo.tomcat.connector.HTTPConnector">
+ <attribute name="port" type="int">8090</attribute>
+ <reference name="TomcatContainer">geronimo.server:type=WebContainer,container=Tomcat</reference>
</gbean>
</configuration>
Modified: geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java
Url: http://svn.apache.org/viewcvs/geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java?view=diff&rev=122687&p1=geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java&r1=122686&p2=geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java&r2=122687
==============================================================================
--- geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java (original)
+++ geronimo/trunk/modules/tomcat/src/test/org/apache/geronimo/tomcat/AbstractWebModuleTest.java Fri Dec 17 16:07:30 2004
@@ -40,6 +40,7 @@
import org.apache.geronimo.security.jaas.LoginModuleGBean;
import org.apache.geronimo.security.realm.GenericSecurityRealm;
import org.apache.geronimo.system.serverinfo.ServerInfo;
+import org.apache.geronimo.tomcat.connector.HTTPConnector;
import org.apache.geronimo.transaction.context.TransactionContextManager;
import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
@@ -153,17 +154,13 @@
protected void setUpSecurity() throws Exception {
securityServiceName = new ObjectName("geronimo.security:type=SecurityService");
securityServiceGBean = new GBeanData(securityServiceName, SecurityServiceImpl.GBEAN_INFO);
- securityServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName(
- "geronimo.security:type=SecurityRealm,*")));
- securityServiceGBean.setReferencePatterns("Mappers", Collections.singleton(new ObjectName(
- "geronimo.security:type=SecurityRealm,*")));
- securityServiceGBean.setAttribute("policyConfigurationFactory",
- "org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory");
+ securityServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
+ securityServiceGBean.setReferencePatterns("Mappers", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
+ securityServiceGBean.setAttribute("policyConfigurationFactory", "org.apache.geronimo.security.jacc.GeronimoPolicyConfigurationFactory");
loginServiceName = new ObjectName("geronimo.security:type=JaasLoginService");
loginServiceGBean = new GBeanData(loginServiceName, JaasLoginService.GBEAN_INFO);
- loginServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName(
- "geronimo.security:type=SecurityRealm,*")));
+ loginServiceGBean.setReferencePatterns("Realms", Collections.singleton(new ObjectName("geronimo.security:type=SecurityRealm,*")));
// loginServiceGBean.setAttribute("reclaimPeriod", new Long(1000 *
// 1000));
loginServiceGBean.setAttribute("algorithm", "HmacSHA1");
@@ -171,8 +168,7 @@
propertiesLMName = new ObjectName("geronimo.security:type=LoginModule,name=demo-properties-login");
propertiesLMGBean = new GBeanData(propertiesLMName, LoginModuleGBean.GBEAN_INFO);
- propertiesLMGBean.setAttribute("loginModuleClass",
- "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
+ propertiesLMGBean.setAttribute("loginModuleClass", "org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule");
propertiesLMGBean.setAttribute("serverSide", Boolean.TRUE);
Properties options = new Properties();
options.setProperty("usersURI", "src/test-resources/data/users.properties");
@@ -189,8 +185,7 @@
propertiesRealmGBean.setAttribute("loginModuleConfiguration", config);
// propertiesRealmGBean.setAttribute("autoMapPrincipalClasses",
// "org.apache.geronimo.security.realm.providers.PropertiesFileGroupPrincipal");
- propertiesRealmGBean.setAttribute("defaultPrincipal",
- "metro=org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
+ propertiesRealmGBean.setAttribute("defaultPrincipal", "metro=org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
start(securityServiceGBean);
start(loginServiceGBean);
@@ -222,15 +217,12 @@
protected void setUp() throws Exception {
cl = this.getClass().getClassLoader();
- containerName = NameFactory.getWebComponentName(null, null, null, null, "tomcatContainer", "WebResource",
- moduleContext);
- webModuleName = NameFactory.getWebComponentName(null, null, null, null, NameFactory.WEB_MODULE, "WebResource",
- moduleContext);
-
- tmName = NameFactory
- .getComponentName(null, null, "TransactionManager", NameFactory.JTA_RESOURCE, moduleContext);
- tcmName = NameFactory.getComponentName(null, null, "TransactionContextManager", NameFactory.JTA_RESOURCE,
- moduleContext);
+ containerName = NameFactory.getWebComponentName(null, null, null, null, "tomcatContainer", "WebResource", moduleContext);
+ connectorName = NameFactory.getWebComponentName(null, null, null, null, "tomcatConnector", "WebResource", moduleContext);
+ webModuleName = NameFactory.getWebComponentName(null, null, null, null, NameFactory.WEB_MODULE, "WebResource", moduleContext);
+
+ tmName = NameFactory.getComponentName(null, null, "TransactionManager", NameFactory.JTA_RESOURCE, moduleContext);
+ tcmName = NameFactory.getComponentName(null, null, "TransactionContextManager", NameFactory.JTA_RESOURCE, moduleContext);
ctcName = new ObjectName("geronimo.test:role=ConnectionTrackingCoordinator");
kernel = new Kernel("test.kernel");
@@ -245,11 +237,15 @@
// Need to override the constructor for unit tests
container = new GBeanData(containerName, TomcatContainer.GBEAN_INFO);
container.setAttribute("catalinaHome", "target/var/catalina");
- container.setAttribute("port", new Integer(8080));
container.setAttribute("endorsedDirs", "target/endorsed");
container.setReferencePattern("ServerInfo", serverInfoName);
+ connector = new GBeanData(connectorName, HTTPConnector.GBEAN_INFO);
+ connector.setAttribute("port", new Integer(8080));
+ connector.setReferencePattern("TomcatContainer", containerName);
+
start(container);
+ start(connector);
tm = new GBeanData(tmName, TransactionManagerImpl.GBEAN_INFO);
Set patterns = new HashSet();