[Mulgara-svn] r1525 - in trunk: conf src/jar/server/java/org/mulgara/server
alexhall at mulgara.org
alexhall at mulgara.org
Wed Feb 18 20:50:48 UTC 2009
Author: alexhall
Date: 2009-02-18 12:50:47 -0800 (Wed, 18 Feb 2009)
New Revision: 1525
Modified:
trunk/conf/mulgara-embedded.xsd
trunk/src/jar/server/java/org/mulgara/server/HttpServices.java
Log:
Use a common XSD type to represent the public and private Jetty connectors in mulgara-config. This elminates the need for a private utility class in HttpServices to wrap the different connector types.
Modified: trunk/conf/mulgara-embedded.xsd
===================================================================
--- trunk/conf/mulgara-embedded.xsd 2009-02-18 20:16:57 UTC (rev 1524)
+++ trunk/conf/mulgara-embedded.xsd 2009-02-18 20:50:47 UTC (rev 1525)
@@ -18,32 +18,19 @@
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="Connector">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="Disabled" type="xs:boolean" minOccurs="0"/>
- <xs:element ref="Host" minOccurs="0"/>
- <xs:element ref="Port"/>
- <xs:element ref="Acceptors" minOccurs="0"/>
- <xs:element ref="MaxThreads" minOccurs="0"/>
- <xs:element ref="MaxIdleTimeMs" minOccurs="0"/>
- <xs:element ref="LowResourceMaxIdleTimeMs" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="PublicConnector">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="Disabled" type="xs:boolean" minOccurs="0"/>
- <xs:element ref="Host" minOccurs="0"/>
- <xs:element ref="Port"/>
- <xs:element ref="Acceptors" minOccurs="0"/>
- <xs:element ref="MaxThreads" minOccurs="0"/>
- <xs:element ref="MaxIdleTimeMs" minOccurs="0"/>
- <xs:element ref="LowResourceMaxIdleTimeMs" minOccurs="0"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
+ <xs:element name="Connector" type="JettyConnector"/>
+ <xs:element name="PublicConnector" type="JettyConnector"/>
+ <xs:complexType name="JettyConnector">
+ <xs:sequence>
+ <xs:element name="Disabled" type="xs:boolean" minOccurs="0" />
+ <xs:element ref="Host" minOccurs="0" />
+ <xs:element ref="Port" />
+ <xs:element ref="Acceptors" minOccurs="0" />
+ <xs:element ref="MaxThreads" minOccurs="0" />
+ <xs:element ref="MaxIdleTimeMs" minOccurs="0" />
+ <xs:element ref="LowResourceMaxIdleTimeMs" minOccurs="0" />
+ </xs:sequence>
+ </xs:complexType>
<xs:element name="LowResourceMaxIdleTimeMs" type="xs:int"/>
<xs:element name="MaxIdleTimeMs" type="xs:int"/>
<xs:element name="Acceptors" type="xs:int"/>
Modified: trunk/src/jar/server/java/org/mulgara/server/HttpServices.java
===================================================================
--- trunk/src/jar/server/java/org/mulgara/server/HttpServices.java 2009-02-18 20:16:57 UTC (rev 1524)
+++ trunk/src/jar/server/java/org/mulgara/server/HttpServices.java 2009-02-18 20:50:47 UTC (rev 1525)
@@ -41,9 +41,8 @@
import org.mortbay.jetty.webapp.WebAppContext;
import org.mortbay.thread.QueuedThreadPool;
import org.mortbay.util.MultiException;
-import org.mulgara.config.Connector;
+import org.mulgara.config.JettyConnector;
import org.mulgara.config.MulgaraConfig;
-import org.mulgara.config.PublicConnector;
import org.mulgara.util.MortbayLogger;
import org.mulgara.util.Reflect;
import org.mulgara.util.TempDir;
@@ -187,8 +186,8 @@
MortbayLogger.setEnabled(true);
// create and register a new HTTP server
- Server privateServer = buildAndConfigure(new JettyConnector(config.getJetty().getConnector()), ServerInfo.getHttpPort());
- Server publicServer = buildAndConfigure(new JettyConnector(config.getJetty().getPublicConnector()), ServerInfo.getPublicHttpPort());
+ Server privateServer = buildAndConfigure(config.getJetty().getConnector(), ServerInfo.getHttpPort());
+ Server publicServer = buildAndConfigure(config.getJetty().getPublicConnector(), ServerInfo.getPublicHttpPort());
// Accumulator for all the services
@@ -239,8 +238,8 @@
* @throws UnknownHostException The configured host name is invalid.
*/
Server buildAndConfigure(JettyConnector cfg, int port) throws UnknownHostException {
- Server s;
- if (cfg.isProvided()) {
+ Server s = null;
+ if (cfg != null) {
s = new Server();
addConnector(s, cfg);
} else {
@@ -460,120 +459,4 @@
}
- /**
- * A common class for representing the identical configuration found in the
- * separate Connector and PublicConnector classes.
- */
- private class JettyConnector {
- boolean provided = false;
- Boolean disabled = null;
- String host = null;
- Integer port = null;
- Integer acceptors = null;
- Integer maxThreads = null;
- Integer maxIdleTimeMs = null;
- Integer lowResourceMaxIdleTimeMs = null;
-
- /**
- * Creates a config from a Connector object.
- * @param c The Connector to build the config from.
- */
- public JettyConnector(Connector c) {
- if (c == null) return;
- provided = true;
- if (c.hasDisabled()) disabled = c.isDisabled();
- host = c.getHost();
- if (c.hasPort()) port = c.getPort();
- if (c.hasAcceptors()) acceptors = c.getAcceptors();
- if (c.hasMaxThreads()) maxThreads = c.getMaxThreads();
- if (c.hasMaxIdleTimeMs()) maxIdleTimeMs = c.getMaxIdleTimeMs();
- if (c.hasLowResourceMaxIdleTimeMs()) lowResourceMaxIdleTimeMs = c.getLowResourceMaxIdleTimeMs();
- }
-
- /**
- * Creates a config from a PublicConnector object.
- * @param c The PublicConnector to build the config from.
- */
- public JettyConnector(PublicConnector c) {
- if (c == null) return;
- provided = true;
- if (c.hasDisabled()) disabled = c.isDisabled();
- host = c.getHost();
- if (c.hasPort()) port = c.getPort();
- if (c.hasAcceptors()) acceptors = c.getAcceptors();
- if (c.hasMaxThreads()) maxThreads = c.getMaxThreads();
- if (c.hasMaxIdleTimeMs()) maxIdleTimeMs = c.getMaxIdleTimeMs();
- if (c.hasLowResourceMaxIdleTimeMs()) lowResourceMaxIdleTimeMs = c.getLowResourceMaxIdleTimeMs();
- }
-
- /** @return if this config was provided. */
- public boolean isProvided() {
- return provided;
- }
-
- /** @return if this config is disabled or not. */
- public boolean isDisabled() {
- return disabled;
- }
-
- /** @return the host name */
- public String getHost() {
- return host;
- }
-
- /** @return the port to use */
- public int getPort() {
- return port;
- }
-
- /** @return the number of acceptors to use */
- public int getAcceptors() {
- return acceptors;
- }
-
- /** @return the maximum number of threads for the thread pool. */
- public int getMaxThreads() {
- return maxThreads;
- }
-
- /** @return the maxIdleTimeMs */
- public int getMaxIdleTimeMs() {
- return maxIdleTimeMs;
- }
-
- /** @return the lowResourceMaxIdleTimeMs */
- public int getLowResourceMaxIdleTimeMs() {
- return lowResourceMaxIdleTimeMs;
- }
-
- /** @return <code>true</code> if the Disabled value was provided. */
- public boolean hasDisabled() {
- return disabled != null;
- }
-
- /** @return <code>true</code> if the Port value was provided. */
- public boolean hasPort() {
- return port != null;
- }
-
- /** @return <code>true</code> if the Accepted value was provided. */
- public boolean hasAcceptors() {
- return acceptors != null;
- }
-
- /** @return <code>true</code> if the MaxThreads value was provided. */
- public boolean hasMaxThreads() {
- return maxThreads != null;
- }
-
- /** @return <code>true</code> if the MaxIdelTimeMs value was provided. */
- public boolean hasMaxIdleTimeMs() {
- return maxIdleTimeMs != null;
- }
-
- /** @return <code>true</code> if the LogResourceMaxIdeTimeMs value was provided. */
- public boolean hasLowResourceMaxIdleTimeMs() {
- return lowResourceMaxIdleTimeMs != null;
- }
- }
}
More information about the Mulgara-svn
mailing list