Author: eckardjf
Date: Thu Mar 22 17:08:31 2012 New Revision: 1303894 URL: http://svn.apache.org/viewvc?rev=1303894&view=rev Log: update jetty container to use the latest jetty-8 release, 8.1.2 Added: ofbiz/trunk/framework/jetty/lib/com.sun.el-2.2.0.v201108011116.jar ofbiz/trunk/framework/jetty/lib/javax.el-2.2.0.v201108011116.jar ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp-2.2.0.v201112011158.jar ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar ofbiz/trunk/framework/jetty/lib/jetty-ajp-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-continuation-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-http-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-io-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-security-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-server-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-servlet-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-util-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-webapp-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/jetty-xml-8.1.2.v20120308.jar ofbiz/trunk/framework/jetty/lib/org.apache.jasper.glassfish-2.2.2.v201112011158.jar ofbiz/trunk/framework/jetty/lib/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar ofbiz/trunk/framework/jetty/lib/org.eclipse.jdt.core-3.7.1.jar Removed: ofbiz/trunk/framework/jetty/lib/ant-1.8.2.jar ofbiz/trunk/framework/jetty/lib/jasper-compiler-5.5.15.jar ofbiz/trunk/framework/jetty/lib/jasper-compiler-jdt-5.5.15.jar ofbiz/trunk/framework/jetty/lib/jasper-runtime-5.5.15.jar ofbiz/trunk/framework/jetty/lib/jcl104-over-slf4j-1.3.1.jar ofbiz/trunk/framework/jetty/lib/jetty-6.1.11.jar ofbiz/trunk/framework/jetty/lib/jetty-ajp-6.1.11.jar ofbiz/trunk/framework/jetty/lib/jetty-sslengine-6.1.11.jar ofbiz/trunk/framework/jetty/lib/jetty-util-6.1.11.jar ofbiz/trunk/framework/jetty/lib/xmlParserAPIs-2.6.2.jar Modified: ofbiz/trunk/framework/base/config/jetty-containers.xml ofbiz/trunk/framework/jetty/src/org/ofbiz/jetty/container/JettyContainer.java Modified: ofbiz/trunk/framework/base/config/jetty-containers.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/jetty-containers.xml?rev=1303894&r1=1303893&r2=1303894&view=diff ============================================================================== --- ofbiz/trunk/framework/base/config/jetty-containers.xml (original) +++ ofbiz/trunk/framework/base/config/jetty-containers.xml Thu Mar 22 17:08:31 2012 @@ -19,21 +19,17 @@ under the License. --> <ofbiz-containers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-containers.xsd"> + xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-containers.xsd"> + <!-- load the ofbiz component container (always first) --> <container name="component-container" class="org.ofbiz.base.container.ComponentContainer"/> <!-- load the cached classloader container (always second) --> <container name="classloader-container" class="org.ofbiz.base.container.ClassLoaderContainer"/> - <!-- load JNDI/JOTM; this is no longer needed, leaving this in for now just in case someone wants to drop in JOTM from the specialized directory - <container name="jotm-container" class="org.ofbiz.jotm.container.JotmContainer"> - <property name="jndi-config" value="iiop.properties"/> - </container> - --> - <!-- load the naming (JNDI) server --> <container name="naming-container" class="org.ofbiz.base.container.NamingServiceContainer"> + <property name="host" value="0.0.0.0"/> <property name="port" value="1099"/> </container> @@ -52,105 +48,54 @@ under the License. <property name="ssl-client-auth" value="false"/> </container> - <!-- JavaMail Listener Container - Triggers MCA Rules --> - <!-- if delete-mail is set to true, will delete messages after fetching them. otherwise, will try to mark them as seen - mail.store.protocol supports both imap and pop3, but pop3 will not be able to mark messages as seen, so you would need to delete them - Sounds like mail.store.protocol value should be "imaps" for GMail inbound emails to work. - Not tested found here https://sourceforge.net/forum/message.php?msg_id=5879468 --> - <!-- To use the mail listerner just uncomment and go... - <container name="javamail-container" class="org.ofbiz.service.mail.JavaMailContainer"> - <property name="delegator-name" value="default"/> - <property name="dispatcher-name" value="JavaMailDispatcher"/> - <property name="run-as-user" value="system"/> - <property name="poll-delay" value="300000"/> - <property name="delete-mail" value="false"/> - <property name="maxSize" value="100000"/> - <property name="default-listener" value="store-listener"> - <property name="mail.store.protocol" value="imap"/> - <property name="mail.host" value="[host]"/> - <property name="mail.user" value="[user]"/> - <property name="mail.pass" value="[pass]"/> - <property name="mail.debug" value="false"/> - </property> - </container> - --> - - <!-- load Shark Workflow Engine --> - <!-- NOTE: before uncommenting this please see the instructions in the ofbiz/OPTIONAL_LIBRARIES file. - <container name="shark-container" class="org.ofbiz.shark.container.SharkContainer"> - <property name="engine-name" value="Shark"/> - <property name="delegator-name" value="default"/> - <property name="dispatcher-name" value="WFDispatcher"/> - <property name="admin-user" value="system"/> - <property name="admin-pass" value="ofbiz"/> - <property name="iiop-host" value="127.0.0.1"/> - <property name="iiop-port" value="2000"/> - </container> - --> - <!-- load jetty and all web applications --> <container name="jetty-container" class="org.ofbiz.jetty.container.JettyContainer"> - <property name="default-server"> + <property name="default-server" value="server"> <property name="send-server-version" value="false"/> - <property name="http-listener" value="connector"> + <!-- thread pool config --> + <property name="min-threads" value="5"/> + <property name="max-threads" value="100"/> + <property name="max-idle-time-ms" value="30000"/> + <property name="max-stop-time-ms" value="5000"/> + <!-- connectors --> + <!-- + <property name="http-connector" value="connector"> <property name="type" value="http"/> <property name="host" value="0.0.0.0"/> <property name="port" value="8080"/> - <property name="min-threads" value="5"/> - <property name="max-threads" value="100"/> - <property name="max-idle-time" value="30000"/> - <property name="low-threads" value="0"/> - <property name="low-resource-max-idle-time" value="5000"/> </property> - <property name="https-listener" value="connector"> + <property name="https-connector" value="connector"> <property name="type" value="https"/> <property name="host" value="0.0.0.0"/> <property name="port" value="8443"/> - <property name="min-threads" value="5"/> - <property name="max-threads" value="100"/> - <property name="max-idle-time" value="30000"/> - <property name="low-threads" value="0"/> - <property name="low-resource-max-idle-time" value="5000"/> <property name="keystore" value="framework/base/config/ofbizssl.jks"/> <property name="password" value="changeit"/> <property name="key-password" value="changeit"/> <property name="client-auth" value="false"/> </property> - <!-- - <property name="nio-http-listener" value="connector"> + --> + <property name="nio-http-connector" value="connector"> <property name="type" value="http"/> <property name="host" value="0.0.0.0"/> <property name="port" value="8080"/> - <property name="min-threads" value="5"/> - <property name="max-threads" value="100"/> - <property name="max-idle-time" value="30000"/> - <property name="low-threads" value="0"/> - <property name="low-resource-max-idle-time" value="5000"/> </property> - <property name="nio-https-listener" value="connector"> + <property name="nio-https-connector" value="connector"> <property name="type" value="https"/> <property name="host" value="0.0.0.0"/> <property name="port" value="8443"/> - <property name="min-threads" value="5"/> - <property name="max-threads" value="100"/> - <property name="max-idle-time" value="30000"/> - <property name="low-threads" value="0"/> - <property name="low-resource-max-idle-time" value="5000"/> <property name="keystore" value="framework/base/config/ofbizssl.jks"/> <property name="password" value="changeit"/> <property name="key-password" value="changeit"/> <property name="client-auth" value="false"/> </property> - <property name="ajp13-listener" value="connector"> + <!-- + <property name="ajp13-connector" value="connector"> <property name="type" value="ajp13"/> <property name="host" value="0.0.0.0"/> <property name="port" value="8009"/> - <property name="min-threads" value="5"/> - <property name="max-threads" value="100"/> - <property name="max-idle-time" value="30000"/> - <property name="buffer-size" value="8192"/> </property> --> + <!-- request logs --> <property name="request-log" value="request-log"> <property name="filename" value="runtime/logs/yyyy_mm_dd.request.log"/> <property name="append" value="true"/> @@ -161,10 +106,4 @@ under the License. </property> </container> - <!-- load BeanShell remote telnet server --> - <container name="beanshell-container" class="org.ofbiz.base.container.BeanShellContainer"> - <!-- the port below and port-1 will be opened by beanshell --> - <property name="telnet-port" value="9990"/> - <property name="app-name" value="OFBiz"/> - </container> </ofbiz-containers> Added: ofbiz/trunk/framework/jetty/lib/com.sun.el-2.2.0.v201108011116.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/com.sun.el-2.2.0.v201108011116.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/com.sun.el-2.2.0.v201108011116.jar (added) and ofbiz/trunk/framework/jetty/lib/com.sun.el-2.2.0.v201108011116.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/javax.el-2.2.0.v201108011116.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/javax.el-2.2.0.v201108011116.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/javax.el-2.2.0.v201108011116.jar (added) and ofbiz/trunk/framework/jetty/lib/javax.el-2.2.0.v201108011116.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp-2.2.0.v201112011158.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp-2.2.0.v201112011158.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp-2.2.0.v201112011158.jar (added) and ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp-2.2.0.v201112011158.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar (added) and ofbiz/trunk/framework/jetty/lib/javax.servlet.jsp.jstl-1.2.0.v201105211821.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-ajp-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-ajp-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-ajp-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-ajp-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-continuation-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-continuation-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-continuation-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-continuation-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-http-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-http-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-http-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-http-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-io-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-io-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-io-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-io-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-security-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-security-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-security-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-security-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-server-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-server-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-server-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-server-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-servlet-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-servlet-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-servlet-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-servlet-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-util-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-util-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-util-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-util-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-webapp-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-webapp-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-webapp-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-webapp-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/jetty-xml-8.1.2.v20120308.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/jetty-xml-8.1.2.v20120308.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/jetty-xml-8.1.2.v20120308.jar (added) and ofbiz/trunk/framework/jetty/lib/jetty-xml-8.1.2.v20120308.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/org.apache.jasper.glassfish-2.2.2.v201112011158.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/org.apache.jasper.glassfish-2.2.2.v201112011158.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/org.apache.jasper.glassfish-2.2.2.v201112011158.jar (added) and ofbiz/trunk/framework/jetty/lib/org.apache.jasper.glassfish-2.2.2.v201112011158.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar (added) and ofbiz/trunk/framework/jetty/lib/org.apache.taglibs.standard.glassfish-1.2.0.v201112081803.jar Thu Mar 22 17:08:31 2012 differ Added: ofbiz/trunk/framework/jetty/lib/org.eclipse.jdt.core-3.7.1.jar URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/lib/org.eclipse.jdt.core-3.7.1.jar?rev=1303894&view=auto ============================================================================== Files ofbiz/trunk/framework/jetty/lib/org.eclipse.jdt.core-3.7.1.jar (added) and ofbiz/trunk/framework/jetty/lib/org.eclipse.jdt.core-3.7.1.jar Thu Mar 22 17:08:31 2012 differ Modified: ofbiz/trunk/framework/jetty/src/org/ofbiz/jetty/container/JettyContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/jetty/src/org/ofbiz/jetty/container/JettyContainer.java?rev=1303894&r1=1303893&r2=1303894&view=diff ============================================================================== --- ofbiz/trunk/framework/jetty/src/org/ofbiz/jetty/container/JettyContainer.java (original) +++ ofbiz/trunk/framework/jetty/src/org/ofbiz/jetty/container/JettyContainer.java Thu Mar 22 17:08:31 2012 @@ -18,24 +18,10 @@ *******************************************************************************/ package org.ofbiz.jetty.container; -import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.mortbay.jetty.AbstractConnector; -import org.mortbay.jetty.NCSARequestLog; -import org.mortbay.jetty.Server; -import org.mortbay.jetty.ajp.Ajp13SocketConnector; -import org.mortbay.jetty.bio.SocketConnector; -import org.mortbay.jetty.handler.RequestLogHandler; -import org.mortbay.jetty.nio.SelectChannelConnector; -import org.mortbay.jetty.security.SslSelectChannelConnector; -import org.mortbay.jetty.security.SslSocketConnector; -import org.mortbay.jetty.servlet.HashSessionManager; -import org.mortbay.jetty.servlet.SessionHandler; -import org.mortbay.jetty.webapp.WebAppContext; -import org.mortbay.thread.BoundedThreadPool; import org.ofbiz.base.component.ComponentConfig; import org.ofbiz.base.container.Container; import org.ofbiz.base.container.ContainerConfig; @@ -44,363 +30,322 @@ import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.SSLUtil; import org.ofbiz.base.util.UtilValidate; +import org.eclipse.jetty.ajp.Ajp13SocketConnector; +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.NCSARequestLog; +import org.eclipse.jetty.server.Server; +import org.eclipse.jetty.server.bio.SocketConnector; +import org.eclipse.jetty.server.handler.HandlerCollection; +import org.eclipse.jetty.server.handler.RequestLogHandler; +import org.eclipse.jetty.server.nio.SelectChannelConnector; +import org.eclipse.jetty.server.session.HashSessionManager; +import org.eclipse.jetty.server.session.SessionHandler; +import org.eclipse.jetty.server.ssl.SslConnector; +import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; +import org.eclipse.jetty.server.ssl.SslSocketConnector; +import org.eclipse.jetty.util.ssl.SslContextFactory; +import org.eclipse.jetty.util.thread.QueuedThreadPool; +import org.eclipse.jetty.util.thread.ThreadPool; +import org.eclipse.jetty.webapp.WebAppContext; + /** - * JettyContainer - Container implementation for Jetty 6 - * + * JettyContainer - Container implementation for Jetty */ public class JettyContainer implements Container { public static final String module = JettyContainer.class.getName(); - protected String configFile = null; private Map<String, Server> servers = new HashMap<String, Server>(); /** - * @see org.ofbiz.base.container.Container#init(java.lang.String[],java.lang.String) + * @see org.ofbiz.base.container.Container#init(java.lang.String[], java.lang.String) */ - public void init(String[] args, String configFile) { - this.configFile = configFile; - } - - private void initJetty() throws ContainerException { + public void init(String[] args, String configFile) throws ContainerException { // configure JSSE properties SSLUtil.loadJsseProperties(); - // get the container - ContainerConfig.Container jc = ContainerConfig.getContainer("jetty-container", configFile); + // get the jetty container config + ContainerConfig.Container jettyContainerConfig = ContainerConfig.getContainer("jetty-container", configFile); // create the servers - for (ContainerConfig.Container.Property property : jc.properties.values()) { - servers.put(property.name, createServer(property)); + for (ContainerConfig.Container.Property serverConfig : jettyContainerConfig.getPropertiesWithValue("server")) { + servers.put(serverConfig.name, createServer(serverConfig)); } - // load the applications - Collection<ComponentConfig> componentConfigs = ComponentConfig.getAllComponents(); - if (componentConfigs != null) { + // create the webapp contexts + for (ComponentConfig componentConfig : ComponentConfig.getAllComponents()) { - for (Object componentConfig : componentConfigs) { + for (ComponentConfig.WebappInfo webappInfo : componentConfig.getWebappInfos()) { - ComponentConfig component = (ComponentConfig) componentConfig; + Server server = servers.get(webappInfo.server); + if (server == null) { - for (ComponentConfig.WebappInfo webappInfo : component.getWebappInfos()) { + Debug.logError("Server with name [" + webappInfo.server + "] not found; not mounting [" + webappInfo.name + "]", module); - List<String> virtualHosts = webappInfo.getVirtualHosts(); - Map<String, String> initParameters = webappInfo.getInitParameters(); + } else { - Server server = servers.get(webappInfo.server); + // set the root location (make sure we set the paths correctly) + String location = componentConfig.getRootLocation() + webappInfo.location; + location = location.replace('\\', '/'); + if (location.endsWith("/")) { + location = location.substring(0, location.lastIndexOf("/")); + } - if (server == null) { - Debug.logWarning("Server with name [" + webappInfo.server + "] not found; not mounting [" + webappInfo.name + "]", module); - } else { - - // set the root location (make sure we set the paths correctly) - String location = component.getRootLocation() + webappInfo.location; - location = location.replace('\\', '/'); - if (location.endsWith("/")) { - location = location.substring(0, location.lastIndexOf("/")); - } + String mountPoint = webappInfo.mountPoint; + if (mountPoint.endsWith("/*")) { + mountPoint = mountPoint.substring(0, mountPoint.lastIndexOf("/")); + } - // load the application - String mountPoint = webappInfo.mountPoint; - if (mountPoint.endsWith("/*")) { - mountPoint = mountPoint.substring(0, mountPoint.lastIndexOf("/")); - } + WebAppContext context = new WebAppContext(location, mountPoint); + context.setAttribute("_serverId", webappInfo.server); + context.setLogUrlOnStart(true); + + // set the session manager + HashSessionManager sm = new HashSessionManager(); + context.setSessionHandler(new SessionHandler(sm)); - WebAppContext context = new WebAppContext(location, mountPoint); - context.setAttribute("_serverId", webappInfo.server); - context.setLogUrlOnStart(true); - - // set the session manager - HashSessionManager sm = new HashSessionManager(); - context.setSessionHandler(new SessionHandler(sm)); - - // set the virtual hosts - if (UtilValidate.isNotEmpty(virtualHosts)) { - context.setVirtualHosts(virtualHosts.toArray(new String[virtualHosts.size()])); - } + // set the virtual hosts + List<String> virtualHosts = webappInfo.getVirtualHosts(); + if (UtilValidate.isNotEmpty(virtualHosts)) { + context.setVirtualHosts(virtualHosts.toArray(new String[virtualHosts.size()])); + } - // set the init parameters - if (UtilValidate.isNotEmpty(initParameters)) { - context.setInitParams(initParameters); + // set the init parameters + Map<String, String> initParameters = webappInfo.getInitParameters(); + if (UtilValidate.isNotEmpty(initParameters)) { + for (Map.Entry<String, String> e : initParameters.entrySet()) { + context.setInitParameter(e.getKey(), e.getValue()); } - - server.addHandler(context); } + + ((HandlerCollection) server.getHandler()).addHandler(context); } } } } - private Server createServer(ContainerConfig.Container.Property serverConfig) throws ContainerException { + private Server createServer(ContainerConfig.Container.Property serverConfig) { Server server = new Server(); + server.setHandler(new HandlerCollection()); - // configure the connectors / loggers - for (ContainerConfig.Container.Property props : serverConfig.properties.values()) { - - if ("send-server-version".equals(props.name)) { - if ("false".equalsIgnoreCase(props.value)) { - server.setSendServerVersion(false); - } - } else if ("connector".equals(props.value)) { - - if ("http".equals(props.getProperty("type").value)) { - - AbstractConnector connector = new SocketConnector(); - setConnectorOptions(connector, props); - server.addConnector(connector); - - } else if ("https".equals(props.getProperty("type").value)) { - - SslSocketConnector connector = new SslSocketConnector(); - setConnectorOptions(connector, props); - - if (props.getProperty("keystore") != null) { - connector.setKeystore(props.getProperty("keystore").value); - } - if (props.getProperty("password") != null) { - connector.setPassword(props.getProperty("password").value); - } - if (props.getProperty("key-password") != null) { - connector.setKeyPassword(props.getProperty("key-password").value); - } - if (props.getProperty("client-auth") != null) { - if ("need".equals(props.getProperty("client-auth").value)) { - connector.setNeedClientAuth(true); - } else if ("want".equals(props.getProperty("client-auth").value)) { - connector.setWantClientAuth(true); - } - } - - server.addConnector(connector); - - } else if ("nio-http".equals(props.getProperty("type").value)) { - - AbstractConnector connector = new SelectChannelConnector(); - setConnectorOptions(connector, props); - server.addConnector(connector); - - } else if ("nio-https".equals(props.getProperty("type").value)) { - - SslSelectChannelConnector connector = new SslSelectChannelConnector(); - setConnectorOptions(connector, props); - - if (props.getProperty("keystore") != null) { - connector.setKeystore(props.getProperty("keystore").value); - } - if (props.getProperty("password") != null) { - connector.setPassword(props.getProperty("password").value); - } - if (props.getProperty("key-password") != null) { - connector.setKeyPassword(props.getProperty("key-password").value); - } - if (props.getProperty("need-client-auth") != null) { - boolean needClientAuth = "true".equalsIgnoreCase(props.getProperty("need-client-auth").value); - connector.setNeedClientAuth(needClientAuth); - } - - server.addConnector(connector); - - } else if ("ajp13".equals(props.getProperty("type").value)) { + // send server version? + if (UtilValidate.isNotEmpty(serverConfig.getProperty("send-server-version"))) { + String sendServerVersionPropertyValue = serverConfig.getProperty("send-server-version").value; + try { + server.setSendServerVersion(Boolean.parseBoolean(sendServerVersionPropertyValue)); + } catch (NumberFormatException e) { + Debug.logError(e, "invalid value for send-server-version: " + sendServerVersionPropertyValue, module); + } + } - AbstractConnector connector = new Ajp13SocketConnector(); - setConnectorOptions(connector, props); - server.addConnector(connector); - } + // thread pool + server.setThreadPool(createThreadPool(serverConfig)); - } else if ("request-log".equals(props.value)) { + // connectors + for (ContainerConfig.Container.Property connectorConfig : serverConfig.getPropertiesWithValue("connector")) { - RequestLogHandler requestLogHandler = new RequestLogHandler(); + Connector connector = null; - NCSARequestLog requestLog = new NCSARequestLog(); + String connectorType = connectorConfig.getProperty("type").value; - if (props.getProperty("filename") != null) { - requestLog.setFilename(props.getProperty("filename").value); - } + if ("http".equals(connectorType)) { + connector = new SocketConnector(); + } else if ("https".equals(connectorType)) { + connector = new SslSocketConnector(); + } else if ("nio-http".equals(connectorType)) { + connector = new SelectChannelConnector(); + } else if ("nio-https".equals(connectorType)) { + connector = new SslSelectChannelConnector(); + } else if ("ajp13".equals(connectorType)) { + connector = new Ajp13SocketConnector(); + } - if (props.getProperty("append") != null) { - requestLog.setAppend("true".equalsIgnoreCase(props.getProperty("append").value)); - } + if (connector != null) { + setConnectorOptions(connector, connectorConfig); + server.addConnector(connector); + } + } - if (props.getProperty("extended") != null) { - requestLog.setExtended("true".equalsIgnoreCase(props.getProperty("extended").value)); - } + // request logs + for (ContainerConfig.Container.Property props : serverConfig.getPropertiesWithValue("request-log")) { - if (props.getProperty("timezone") != null) { - requestLog.setLogTimeZone(props.getProperty("timezone").value); - } + NCSARequestLog requestLog = new NCSARequestLog(); - if (props.getProperty("date-format") != null) { - requestLog.setLogDateFormat(props.getProperty("date-format").value); + if (UtilValidate.isNotEmpty(props.getProperty("filename"))) { + requestLog.setFilename(props.getProperty("filename").value); + } + if (UtilValidate.isNotEmpty(props.getProperty("append"))) { + requestLog.setAppend("true".equalsIgnoreCase(props.getProperty("append").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("extended"))) { + requestLog.setExtended("true".equalsIgnoreCase(props.getProperty("extended").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("log-dispatch"))) { + requestLog.setLogDispatch("true".equalsIgnoreCase(props.getProperty("log-dispatch").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("log-latency"))) { + requestLog.setLogLatency("true".equalsIgnoreCase(props.getProperty("log-latency").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("log-server"))) { + requestLog.setLogServer("true".equalsIgnoreCase(props.getProperty("log-server").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("prefer-proxied-for-address"))) { + requestLog.setPreferProxiedForAddress("true".equalsIgnoreCase(props.getProperty("prefer-proxied-for-address").value)); + } + if (UtilValidate.isNotEmpty(props.getProperty("timezone"))) { + requestLog.setLogTimeZone(props.getProperty("timezone").value); + } + if (UtilValidate.isNotEmpty(props.getProperty("date-format"))) { + requestLog.setLogDateFormat(props.getProperty("date-format").value); + } + if (UtilValidate.isNotEmpty(props.getProperty("retain-days"))) { + String retainDaysPropertyValue = props.getProperty("retain-days").value; + try { + requestLog.setRetainDays(Integer.parseInt(retainDaysPropertyValue)); + } catch (NumberFormatException e) { + Debug.logError(e, "invalid value for retain-days: " + retainDaysPropertyValue, module); } + } - if (props.getProperty("retain-days") != null) { - int days = 90; - try { - days = Integer.parseInt(props.getProperty("retain-days").value); - } catch (NumberFormatException e) { - days = 90; - } - requestLog.setRetainDays(days); - } + RequestLogHandler requestLogHandler = new RequestLogHandler(); + requestLogHandler.setRequestLog(requestLog); - requestLogHandler.setRequestLog(requestLog); - server.addHandler(requestLogHandler); - } + ((HandlerCollection) server.getHandler()).addHandler(requestLogHandler); } return server; } - private void setConnectorOptions(AbstractConnector connector, ContainerConfig.Container.Property props) throws ContainerException { + private ThreadPool createThreadPool(ContainerConfig.Container.Property serverConfig) { - String systemHost = null; - if ("default".equals(props.getProperty("type").value)) { - systemHost = System.getProperty(props.name + ".host"); - } - if (props.getProperty("host") != null && systemHost == null) { - connector.setHost(props.getProperty("host").value); - } else { - String host = "0.0.0.0"; - if (systemHost != null) { - host = systemHost; - } - connector.setHost(host); - } + QueuedThreadPool threadPool = new QueuedThreadPool(); - String systemPort = null; - if ("default".equals(props.getProperty("type").value)) { - systemPort = System.getProperty(props.name + ".port"); - } - if (props.getProperty("port") != null && systemPort == null) { - int value = 8080; + if (UtilValidate.isNotEmpty(serverConfig.getProperty("min-threads"))) { + String minThreadsPropertyValue = serverConfig.getProperty("min-threads").value; try { - value = Integer.parseInt(props.getProperty("port").value); + threadPool.setMinThreads(Integer.parseInt(minThreadsPropertyValue)); } catch (NumberFormatException e) { - value = 8080; - } - if (value == 0) value = 8080; - - connector.setPort(value); - } else { - int port = 8080; - if (systemPort != null) { - try { - port = Integer.parseInt(systemPort); - } catch (NumberFormatException e) { - port = 8080; - } + Debug.logError(e, "invalid value for min-threads: " + minThreadsPropertyValue, module); } - connector.setPort(port); } - - if (props.getProperty("buffer-size") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(serverConfig.getProperty("max-threads"))) { + String maxThreadsPropertyValue = serverConfig.getProperty("max-threads").value; try { - value = Integer.parseInt(props.getProperty("buffer-size").value); + threadPool.setMaxThreads(Integer.parseInt(maxThreadsPropertyValue)); } catch (NumberFormatException e) { - value = 0; - } - if (value > 0) { - connector.setResponseBufferSize(value); + Debug.logError(e, "invalid value for max-threads: " + maxThreadsPropertyValue, module); } } - - if (props.getProperty("linger-time") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(serverConfig.getProperty("max-idle-time-ms"))) { + String maxIdleTimeMsPropertyValue = serverConfig.getProperty("max-idle-time-ms").value; try { - value = Integer.parseInt(props.getProperty("linger-time").value); + threadPool.setMaxIdleTimeMs(Integer.parseInt(maxIdleTimeMsPropertyValue)); } catch (NumberFormatException e) { - value = 0; - } - if (value > 0) { - connector.setSoLingerTime(value); + Debug.logError(e, "invalid value for max-idle-time-ms: " + maxIdleTimeMsPropertyValue, module); } } - - if (props.getProperty("low-resource-max-idle-time") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(serverConfig.getProperty("max-stop-time-ms"))) { + String maxStopTimeMsPropertyValue = serverConfig.getProperty("max-stop-time-ms").value; try { - value = Integer.parseInt(props.getProperty("low-resource-max-idle-time").value); + threadPool.setMaxStopTimeMs(Integer.parseInt(maxStopTimeMsPropertyValue)); } catch (NumberFormatException e) { - value = 0; - } - if (value > 0) { - connector.setLowResourceMaxIdleTime(value); + Debug.logError(e, "invalid value for max-stop-time-ms: " + maxStopTimeMsPropertyValue, module); } } + return threadPool; + } - BoundedThreadPool threadPool = new BoundedThreadPool(); + private void setConnectorOptions(Connector connector, ContainerConfig.Container.Property connectorConfig) { - if (props.getProperty("min-threads") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("host"))) { + connector.setHost(connectorConfig.getProperty("host").value); + } + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("port"))) { + String portPropertyValue = connectorConfig.getProperty("port").value; try { - value = Integer.parseInt(props.getProperty("min-threads").value); + connector.setPort(Integer.parseInt(portPropertyValue)); } catch (NumberFormatException e) { - value = 0; - } - if (value > 0) { - threadPool.setMinThreads(value); + Debug.logError(e, "invalid value for port: " + portPropertyValue, module); } } - - if (props.getProperty("max-threads") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("request-buffer-size"))) { + String requestBufferSizePropertyValue = connectorConfig.getProperty("request-buffer-size").value; try { - value = Integer.parseInt(props.getProperty("max-threads").value); + connector.setRequestBufferSize(Integer.parseInt(requestBufferSizePropertyValue)); } catch (NumberFormatException e) { - value = 0; - } - if (value > 0) { - threadPool.setMaxThreads(value); + Debug.logError(e, "invalid value for request-buffer-size: " + requestBufferSizePropertyValue, module); } } - - if (props.getProperty("max-idle-time") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("request-header-size"))) { + String requestHeaderSizePropertyValue = connectorConfig.getProperty("request-header-size").value; try { - value = Integer.parseInt(props.getProperty("max-idle-time").value); + connector.setRequestHeaderSize(Integer.parseInt(requestHeaderSizePropertyValue)); } catch (NumberFormatException e) { - value = 0; + Debug.logError(e, "invalid value for request-header-size: " + requestHeaderSizePropertyValue, module); } - if (value > 0) { - threadPool.setMaxIdleTimeMs(value); + } + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("response-buffer-size"))) { + String responseBufferSizePropertyValue = connectorConfig.getProperty("response-buffer-size").value; + try { + connector.setResponseBufferSize(Integer.parseInt(responseBufferSizePropertyValue)); + } catch (NumberFormatException e) { + Debug.logError(e, "invalid value for response-buffer-size: " + responseBufferSizePropertyValue, module); } } - - if (props.getProperty("low-threads") != null) { - int value = 0; + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("response-header-size"))) { + String responseHeaderSizePropertyValue = connectorConfig.getProperty("response-header-size").value; try { - value = Integer.parseInt(props.getProperty("low-threads").value); + connector.setResponseHeaderSize(Integer.parseInt(responseHeaderSizePropertyValue)); } catch (NumberFormatException e) { - value = 0; + Debug.logError(e, "invalid value for response-header-size: " + responseHeaderSizePropertyValue, module); } - if (value > 0) { - threadPool.setLowThreads(value); + } + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("low-resource-max-idle-time"))) { + String lowResourceMaxIdleTimePropertyValue = connectorConfig.getProperty("low-resource-max-idle-time").value; + try { + connector.setLowResourceMaxIdleTime(Integer.parseInt(lowResourceMaxIdleTimePropertyValue)); + } catch (NumberFormatException e) { + Debug.logError(e, "invalid value for low-resource-max-idle-time: " + lowResourceMaxIdleTimePropertyValue, module); } } - connector.setThreadPool(threadPool); + // SSL options + if (connector instanceof SslConnector) { + + SslContextFactory cf = ((SslConnector) connector).getSslContextFactory(); + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("keystore"))) { + cf.setKeyStorePath(connectorConfig.getProperty("keystore").value); + } + if (connectorConfig.getProperty("password") != null) { + cf.setKeyStorePassword(connectorConfig.getProperty("password").value); + } + if (connectorConfig.getProperty("key-password") != null) { + cf.setKeyManagerPassword(connectorConfig.getProperty("key-password").value); + } + if (UtilValidate.isNotEmpty(connectorConfig.getProperty("client-auth"))) { + if ("need".equals(connectorConfig.getProperty("client-auth").value)) { + cf.setNeedClientAuth(true); + } else if ("want".equals(connectorConfig.getProperty("client-auth").value)) { + cf.setWantClientAuth(true); + } + } + } } /** * @see org.ofbiz.base.container.Container#start() */ public boolean start() throws ContainerException { - // start the server(s) - this.initJetty(); - if (servers != null) { - for (Server server : servers.values()) { - try { - server.start(); - } catch (Exception e) { - Debug.logError(e, "Jetty Server Exception", module); - throw new ContainerException(e); - } + for (Server server : servers.values()) { + try { + server.start(); + } catch (Exception e) { + throw new ContainerException(e); } } return true; @@ -410,14 +355,13 @@ public class JettyContainer implements C * @see org.ofbiz.base.container.Container#stop() */ public void stop() throws ContainerException { - if (servers != null) { - for (Server server : servers.values()) { - try { - server.stop(); - } catch (Exception e) { - Debug.logWarning(e, module); - } + for (Server server : servers.values()) { + try { + server.stop(); + } catch (Exception e) { + throw new ContainerException(e); } } } + } |
Free forum by Nabble | Edit this page |