Author: rgodfrey
Date: Fri Jun 15 14:47:48 2012
New Revision: 1350644

URL: http://svn.apache.org/viewvc?rev=1350644&view=rev
Log:
QPID-3999 : Applying patch from Alex Rudyy to generate war file

Added:
    qpid/branches/java-config-and-management/qpid/java/broker-web/   (with 
props)
    qpid/branches/java-config-and-management/qpid/java/broker-web/build.xml
    qpid/branches/java-config-and-management/qpid/java/broker-web/src/
    qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/
    qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/BrokerOptionsBuilder.java
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/InitParametersOptionsBuilder.java
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/QpidServletContextListener.java
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/config.xml
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/virtualhosts.xml
    
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/web.xml
Modified:
    
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
    
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
    
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
    qpid/branches/java-config-and-management/qpid/java/build.deps
    qpid/branches/java-config-and-management/qpid/java/build.xml

Propchange: qpid/branches/java-config-and-management/qpid/java/broker-web/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jun 15 14:47:48 2012
@@ -0,0 +1 @@
+release

Added: qpid/branches/java-config-and-management/qpid/java/broker-web/build.xml
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/build.xml?rev=1350644&view=auto
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/broker-web/build.xml 
(added)
+++ qpid/branches/java-config-and-management/qpid/java/broker-web/build.xml Fri 
Jun 15 14:47:48 2012
@@ -0,0 +1,107 @@
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you 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.
+ -->
+<project name="broker-web" xmlns:ivy="antlib:org.apache.ivy.ant" 
default="build">
+
+    <condition property="bdbstore" value="bdbstore" else="">
+        <contains string="${modules.opt}" substring="bdbstore"/>
+    </condition>
+
+    <import file="../common.xml"/>
+    <findSubProjects name="broker-plugins" dir="../broker-plugins"/>
+    <property name="module.depends" value="common management/common 
amqp-1-0-common broker ${bdbstore} ${broker-plugins}" />
+    <property name="module.test.depends" value="test client common/test 
broker/test management/common systests" />
+    <property name="module.genpom" value="true"/>
+
+    <import file="../module.xml"/>
+
+    <scriptdef name="string-replace" language="javascript">
+         <attribute name="string" />
+         <attribute name="token" />
+         <attribute name="value" />
+         <attribute name="property" />
+         <![CDATA[
+           var string = attributes.get("string");
+           var token = attributes.get("token");
+           var value = attributes.get("value");
+           project.setProperty(attributes.get("property"), 
string.replace(token, value));
+         ]]>
+      </scriptdef>
+
+    <!-- war is built as part of build task and stored in module release 
folder -->
+    <target name="postbuild" description="Create war" >
+
+        <property name="war.dir" value="../build/war"/>
+        <mkdir dir="${war.dir}/WEB-INF/lib"/>
+
+        <!-- copy third-party dependencies into WEB-INF/lib -->
+        <copy todir="${war.dir}/WEB-INF/lib" flatten="true">
+            <fileset dir="${project.root}" includes="${module.depends.libs}"
+                excludes="**/jetty-* **/*servlet*"/>
+        </copy>
+
+        <!-- copy qpid dependencies into WEB-INF/lib -->
+        <foreach property="dependency" list="${module.depends}">
+            <string-replace string="qpid-${dependency}" token="/" value="-" 
property="dependency.path"/>
+            <copy todir="${war.dir}/WEB-INF/lib">
+              <fileset dir="${project.root}/build/lib" 
includes="**/${dependency.path}*.jar"
+                  excludes="*-tests-*.jar *-sources.jar *.osgi.jar"/>
+            </copy>
+        </foreach>
+
+        <!-- copy management jar into WEB-INF/lib in order to use servlets 
from it-->
+        <copy todir="${war.dir}/WEB-INF/lib">
+          <fileset dir="${project.root}/build/lib/plugins" 
includes="qpid-broker-plugins-management*.jar"/>
+        </copy>
+
+        <mkdir dir="${war.dir}/WEB-INF/etc"/>
+        <mkdir dir="${war.dir}/WEB-INF/work/log"/>
+
+        <!-- copy default broker configuration into /WEB-INF/etc-->
+        <copy todir="${war.dir}/WEB-INF/etc">
+            <fileset dir="${project.root}/broker/etc" excludes="config.xml 
virtualhosts.xml"/>
+        </copy>
+
+        <copy todir="${war.dir}/WEB-INF/etc">
+            <fileset dir="src/main/resources/WEB-INF/etc/"/>
+        </copy>
+
+        <!-- copy management.html into index.html -->
+        <copy tofile="${war.dir}/index.html"
+            
file="../broker-plugins/management/src/main/java/resources/management.html"/>
+
+        <!-- extract dojo -->
+        <unwar src="${project.root}/${dojo}" dest="${war.dir}/dojo">
+          <patternset>
+              <exclude name="META-INF/**"/>
+              <exclude name="WEB-INF/**"/>
+              <exclude name="**/*.uncompressed.js"/>
+          </patternset>
+        </unwar>
+
+        <!-- build war -->
+        <war destfile="release/qpid.war" 
webxml="src/main/resources/WEB-INF/web.xml">
+          <lib file="${module.jar}"/>
+          <fileset dir="../broker-plugins/management/src/main/java/resources"/>
+          <fileset dir="${war.dir}"/>
+        </war>
+
+        <copy file="release/qpid.war" 
tofile="release/qpid-${project.version}.war"/>
+    </target>
+
+</project>

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/BrokerOptionsBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/BrokerOptionsBuilder.java?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/BrokerOptionsBuilder.java
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/BrokerOptionsBuilder.java
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,36 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.qpid.web.listener;
+
+import javax.servlet.ServletContext;
+
+import org.apache.qpid.server.BrokerOptions;
+
+/**
+ * Defines operations to build {@link BrokerOptions} from {@link 
ServletContext}.
+ */
+public interface BrokerOptionsBuilder
+{
+    /**
+     * Builds {@link BrokerOptions} from {@link ServletContext}.
+     */
+    BrokerOptions buildBrokerOptions(ServletContext context);
+}

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/InitParametersOptionsBuilder.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/InitParametersOptionsBuilder.java?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/InitParametersOptionsBuilder.java
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/InitParametersOptionsBuilder.java
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,314 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.qpid.web.listener;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import javax.servlet.ServletContext;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.TransformerFactoryConfigurationError;
+
+import org.apache.qpid.server.BrokerOptions;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+/**
+ * Builder to build {@link BrokerOptions} from initialization parameters of 
servlet context.
+ * <p>
+ * The following init parameters are supported:
+ * <ul>
+ * <li>home, QPID_HOME setting
+ * <li>work, QPID_WORK setting
+ * <li>config, path to Qpid configuration file
+ * <li>logconfig, path to Qpid log configuration file
+ * <li>port, Qpid AMQP port
+ * <li>sslport, SSL port for AMQP
+ * <li>jmxregistryport, RMI port
+ * <li>jmxconnectorport, JMX connector port
+ * <li>bind, bind address
+ * <li>logwatch, log watch frequency
+ * </ul>
+ * <p>
+ * If parameters are not set then default configuration in WEB-INF/etc is used
+ * to start the broker
+ * <p>
+ * Examples of init configuration for web.xml
+ * <code>
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;config&lt;/param-name&gt;
+ *  &lt;param-value&gt;/home/user/qpid/etc/config.xml&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ *
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;work&lt;/param-name&gt;
+ *  &lt;param-value&gt;/home/user/qpid/work&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ *
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;home&lt;/param-name&gt;
+ *  &lt;param-value&gt;/home/user/qpid&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ *
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;port&lt;/param-name&gt;
+ *  &lt;param-value&gt;5671&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;jmxregistryport&lt;/param-name&gt;
+ *  &lt;param-value&gt;8998&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ * &lt;context-param&gt;
+ *  &lt;param-name&gt;jmxconnectorport&lt;/param-name&gt;
+ *  &lt;param-value&gt;9098&lt;/param-value&gt;
+ * &lt;/context-param&gt;
+ * </code>
+ */
+public class InitParametersOptionsBuilder implements BrokerOptionsBuilder
+{
+    private static final String INIT_PARAM_HOME_FOLDER = "home";
+
+    private static final String INIT_PARAM_WORK_FOLDER = "work";
+
+    private static final String INIT_PARAM_CONFIG_FILE = "config";
+
+    private static final String INIT_PARAM_LOG_CONFIG_FILE = "logconfig";
+
+    private static final String INIT_PARAM_PORT = "port";
+
+    private static final String INIT_PARAM_SSL_PORT = "sslport";
+
+    private static final String INIT_PARAM_JMX_PORT_REGISTRY_SERVER = 
"jmxregistryport";
+
+    private static final String INIT_PARAM_JMX_PORT_CONNECTOR_SERVER = 
"jmxconnectorport";
+
+    private static final String INIT_PARAM_BIND = "bind";
+
+    private static final String INIT_PARAM_LOG_WATCH = "logwatch";
+
+    @Override
+    public BrokerOptions buildBrokerOptions(ServletContext context)
+    {
+        BrokerOptions options = new BrokerOptions();
+
+        String homeFolder = context.getInitParameter(INIT_PARAM_HOME_FOLDER);
+        if (homeFolder == null)
+        {
+            homeFolder = context.getRealPath("/WEB-INF");
+        }
+        options.setQpidHome(homeFolder);
+
+        String workFolder = context.getInitParameter(INIT_PARAM_WORK_FOLDER);
+        if (workFolder == null)
+        {
+            workFolder = context.getRealPath("/WEB-INF/work");
+        }
+        options.setQpidWork(workFolder);
+
+        String configFile = context.getInitParameter(INIT_PARAM_CONFIG_FILE);
+        if (configFile == null)
+        {
+            configFile = context.getRealPath("/WEB-INF/" + 
BrokerOptions.DEFAULT_CONFIG_FILE);
+        }
+        options.setConfigFile(configFile);
+
+        String logConfig = 
context.getInitParameter(INIT_PARAM_LOG_CONFIG_FILE);
+        if (logConfig == null)
+        {
+            logConfig = createLogConfigurationFromTemplate(context);
+        }
+        options.setLogConfigFile(logConfig);
+
+        String port = context.getInitParameter(INIT_PARAM_PORT);
+        if (port != null)
+        {
+            int p = 0;
+            try
+            {
+                p = Integer.parseInt(port);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot parse broker port. Please 
specify correct value for a port!");
+            }
+            options.addPort(p);
+        }
+        String sslport = context.getInitParameter(INIT_PARAM_SSL_PORT);
+        if (sslport != null)
+        {
+            int p = 0;
+            try
+            {
+                p = Integer.parseInt(sslport);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot parse broker ssl port. 
Please specify correct value for ssl port!");
+            }
+            options.addSSLPort(p);
+        }
+        String jmxRegistryPort = 
context.getInitParameter(INIT_PARAM_JMX_PORT_REGISTRY_SERVER);
+        if (jmxRegistryPort != null)
+        {
+            int p = 0;
+            try
+            {
+                p = Integer.parseInt(jmxRegistryPort);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot parse broker RMI port. 
Please specify correct value for RMI port!");
+            }
+            options.setJmxPortRegistryServer(p);
+        }
+        String jmxConnectorPort = 
context.getInitParameter(INIT_PARAM_JMX_PORT_CONNECTOR_SERVER);
+        if (jmxConnectorPort != null)
+        {
+            int p = 0;
+            try
+            {
+                p = Integer.parseInt(jmxConnectorPort);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot parse broker JMX connector 
port."
+                        + " Please specify correct value for JMX connector 
port!");
+            }
+            options.setJmxPortConnectorServer(p);
+        }
+        String logwatch = context.getInitParameter(INIT_PARAM_LOG_WATCH);
+        if (logwatch != null)
+        {
+            int logWatchFrequency = 0;
+            try
+            {
+                logWatchFrequency = Integer.parseInt(logwatch);
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot parse broker log watch 
frequency."
+                        + " Please specify correct value for log watch 
frequency!");
+            }
+            options.setLogWatchFrequency(logWatchFrequency);
+        }
+        String bind = context.getInitParameter(INIT_PARAM_BIND);
+        if (bind != null)
+        {
+            options.setBind(bind);
+        }
+        return options;
+    }
+
+
+    /**
+     * Opens /WEB-INF/etc/log4j.xml, changes the location of the log file to
+     * "/WEB-INF/work/log/qpid.log" and stores log configuration in
+     * "/WEB-INF/work/log4j.xml"
+     */
+    private String createLogConfigurationFromTemplate(ServletContext context)
+    {
+        String webInfPath = context.getRealPath("/WEB-INF");
+        String template = webInfPath + "/" + 
BrokerOptions.DEFAULT_LOG_CONFIG_FILE;
+        String targetLogConfig = webInfPath + "/work/log4j.xml";
+        String logFile = webInfPath + 
"/work/log/${logprefix}qpid${logsuffix}.log";
+        transformLog(template, targetLogConfig, logFile);
+        return targetLogConfig;
+    }
+
+    private void transformLog(String template, String targetLogConfig, String 
logFile)
+            throws TransformerFactoryConfigurationError
+    {
+        Document document = null;
+        try
+        {
+            DocumentBuilderFactory documentBuilderFactory = 
DocumentBuilderFactory.newInstance();
+            
documentBuilderFactory.setAttribute("http://xml.org/sax/features/namespaces";, 
true);
+            
documentBuilderFactory.setAttribute("http://xml.org/sax/features/validation";, 
false);
+            
documentBuilderFactory.setAttribute("http://apache.org/xml/features/nonvalidating/load-dtd-grammar";,
 false);
+            
documentBuilderFactory.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-dtd";,
 false);
+            documentBuilderFactory.setNamespaceAware(true);
+            documentBuilderFactory.setIgnoringElementContentWhitespace(false);
+            documentBuilderFactory.setIgnoringComments(false);
+            documentBuilderFactory.setValidating(false);
+
+            DocumentBuilder builder = 
documentBuilderFactory.newDocumentBuilder();
+            document = builder.parse(new File(template));
+            NodeList parameters = 
document.getDocumentElement().getElementsByTagName("param");
+            for (int i = 0, l = parameters.getLength(); i < l; i++)
+            {
+                Node node = parameters.item(i);
+                if (node instanceof Element)
+                {
+                    Element element = (Element) node;
+                    String nameAttribute = element.getAttribute("name");
+                    if (nameAttribute != null && 
nameAttribute.equalsIgnoreCase("file"))
+                    {
+
+                        element.setAttribute("value", logFile);
+                    }
+                }
+            }
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Cannot open log4j configuration at " + 
template, e);
+        }
+        FileWriter fileWriter = null;
+        try
+        {
+            fileWriter = new FileWriter(targetLogConfig);
+            DOMImplementationLS ls = (DOMImplementationLS) 
DOMImplementationRegistry.newInstance()
+                    .getDOMImplementation("LS");
+            LSOutput lsout = ls.createLSOutput();
+            lsout.setCharacterStream(fileWriter);
+            lsout.setEncoding(document.getXmlEncoding());
+            LSSerializer serializer = ls.createLSSerializer();
+            serializer.write(document, lsout);
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Cannot save log4j configuration at " + 
targetLogConfig, e);
+        }
+        finally
+        {
+            if (fileWriter != null)
+            {
+                try
+                {
+                    fileWriter.close();
+                }
+                catch (IOException e)
+                {
+                    // ignore this
+                }
+            }
+        }
+
+    }
+}

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/QpidServletContextListener.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/QpidServletContextListener.java?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/QpidServletContextListener.java
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/java/org/apache/qpid/web/listener/QpidServletContextListener.java
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,162 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.qpid.web.listener;
+
+import java.util.Enumeration;
+import java.util.Properties;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+import org.apache.commons.configuration.interpol.ConfigurationInterpolator;
+import org.apache.commons.lang.text.StrLookup;
+import org.apache.qpid.server.Broker;
+import org.apache.qpid.server.BrokerOptions;
+
+/**
+ * An implementation of {@link ServletContextListener} allowing to start Qpid
+ * broker in web container.
+ * <p>
+ * The listener instantiate {@link BrokerOptionsBuilder} specified in
+ * initialization parameter "broker-options-builder" and uses this builder to
+ * create {@link BrokerOptions} instance to start broker.
+ */
+public class QpidServletContextListener implements ServletContextListener
+{
+    private static final String INIT_PARAM_BROKER_OPTIONS_BUILDER = 
"broker-options-builder";
+
+    private Broker _broker;
+
+    @Override
+    public void contextDestroyed(ServletContextEvent event)
+    {
+        if (_broker != null)
+        {
+            _broker.shutdown();
+        }
+    }
+
+    @Override
+    public void contextInitialized(ServletContextEvent event)
+    {
+        ServletContext context = event.getServletContext();
+        BrokerOptions options = createBrokerOptions(context);
+        setConfigurationVariables(options, context);
+        startBroker(options);
+    }
+
+    /**
+     * Starts broker with given {@link BrokerOptions}.
+     */
+    private void startBroker(BrokerOptions options)
+    {
+        _broker = new Broker();
+        try
+        {
+            _broker.startup(options);
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException("Broker cannot be started", e);
+        }
+    }
+
+    /**
+     * Sets resolver for QPID_HOME and QPID_WORK configuration variables and 
all
+     * context initialization parameters, so, they can be used in default
+     * configuration files.
+     */
+    private void setConfigurationVariables(BrokerOptions options, 
ServletContext context)
+    {
+        Properties properties = new Properties();
+        @SuppressWarnings("unchecked")
+        Enumeration<String> parameterNames = context.getInitParameterNames();
+        while (parameterNames.hasMoreElements())
+        {
+            String name = parameterNames.nextElement();
+            properties.put(name, context.getInitParameter(name));
+        }
+        properties.put(BrokerOptions.QPID_HOME, options.getQpidHome());
+        properties.put(BrokerOptions.QPID_WORK, options.getQpidWork());
+        PropertiesLookup lookup = new PropertiesLookup(properties);
+        ConfigurationInterpolator.registerGlobalLookup("web", lookup);
+    }
+
+    /**
+     * Creates {@link BrokerOptions} using initialization parameters of servlet
+     * context.
+     */
+    private BrokerOptions createBrokerOptions(final ServletContext context)
+    {
+        BrokerOptionsBuilder builder = null;
+        String builderClassName = 
context.getInitParameter(INIT_PARAM_BROKER_OPTIONS_BUILDER);
+        if (builderClassName != null)
+        {
+            Class<?> builderClass = null;
+            try
+            {
+                builderClass = Class.forName(builderClassName);
+            }
+            catch (ClassNotFoundException e)
+            {
+                throw new RuntimeException("Invalid options builder class " + 
builderClassName + " is specified", e);
+            }
+            try
+            {
+                builder = (BrokerOptionsBuilder) builderClass.newInstance();
+            }
+            catch (Exception e)
+            {
+                throw new RuntimeException("Cannot instantiate options 
builder", e);
+            }
+        }
+        else
+        {
+            builder = new InitParametersOptionsBuilder();
+        }
+        return builder.buildBrokerOptions(context);
+    }
+
+    /**
+     * A variable resolver to resolve variables set in given {@link 
Properties}.
+     * <p>
+     * It is used to resolve "QPID_HOME" and "QPID_WORK" and servlet context
+     * init parameters.
+     */
+    private static class PropertiesLookup extends StrLookup
+    {
+        private Properties _properties;
+
+        private PropertiesLookup(Properties properties)
+        {
+            _properties = properties;
+        }
+
+        @Override
+        public String lookup(String varName)
+        {
+            return _properties.getProperty(varName);
+        }
+
+    }
+
+}

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/config.xml
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/config.xml?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/config.xml
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/config.xml
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you 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.
+ -
+ -->
+<broker>
+    <prefix>${web:QPID_HOME}</prefix>
+    <work>${web:QPID_WORK}</work>
+    <conf>${prefix}/etc</conf>
+
+    <plugin-directory>${web:QPID_HOME}/lib/plugins</plugin-directory>
+    <cache-directory>${web:QPID_WORK}/cache</cache-directory>
+
+    <connector>
+        <!-- To enable SSL edit the keystorePath and keystorePassword
+            and set enabled to true.
+             To disable Non-SSL port set sslOnly to true -->
+        <ssl>
+            <enabled>false</enabled>
+            <port>5671</port>
+            <sslOnly>false</sslOnly>
+            <keyStorePath>/path/to/keystore.ks</keyStorePath>
+            <keyStorePassword>keystorepass</keyStorePassword>
+        </ssl>
+        <port>5672</port>
+        <socketReceiveBuffer>262144</socketReceiveBuffer>
+        <socketSendBuffer>262144</socketSendBuffer>
+    </connector>
+    <management>
+        <enabled>false</enabled>
+        <platform-mbeanserver>false</platform-mbeanserver>
+        <http>
+            <enabled>false</enabled>
+        </http>
+        <jmxport>
+            <registryServer>8999</registryServer>
+            <!--
+             If unspecified, connectorServer defaults to 100 + registryServer 
port.
+            <connectorServer>9099</connectionServer>
+            -->
+        </jmxport>
+        <ssl>
+            <enabled>false</enabled>
+            <!-- Update below path to your keystore location. -->
+            <keyStorePath>${conf}/qpid.keystore</keyStorePath>
+            <keyStorePassword>password</keyStorePassword>
+        </ssl>
+    </management>
+    <advanced>
+        <framesize>65535</framesize>
+        <locale>en_US</locale>
+    </advanced>
+
+    <security>
+        <pd-auth-manager>
+            <principal-database>
+                
<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
+                <attributes>
+                    <attribute>
+                        <name>passwordFile</name>
+                        <value>${conf}/passwd</value>
+                    </attribute>
+                </attributes>
+            </principal-database>
+        </pd-auth-manager>
+
+        <!-- By default, all authenticated users have permissions to perform 
all actions -->
+
+        <!-- ACL Example
+             This example illustrates securing the both Management (JMX) and 
Messaging.
+        <acl>${conf}/broker_example.acl</acl>
+        -->
+
+        <msg-auth>false</msg-auth>
+    </security>
+
+    <virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
+
+    <heartbeat>
+        <delay>0</delay>
+        <timeoutFactor>2.0</timeoutFactor>
+    </heartbeat>
+    <queue>
+        <auto_register>true</auto_register>
+    </queue>
+
+    <status-updates>ON</status-updates>
+
+</broker>
+
+

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/virtualhosts.xml
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/virtualhosts.xml?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/virtualhosts.xml
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/etc/virtualhosts.xml
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,162 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ -
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you 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.
+ -
+ -->
+<virtualhosts>
+    <default>test</default>
+    <virtualhost>
+        <name>localhost</name>
+        <localhost>
+            <store>
+                
<class>org.apache.qpid.server.store.derby.DerbyMessageStore</class>
+                
<environment-path>${web:QPID_WORK}/derbystore</environment-path>
+            </store>
+
+            <housekeeping>
+                <threadCount>2</threadCount>
+                <checkPeriod>20000</checkPeriod>
+            </housekeeping>
+
+            <exchanges>
+                <exchange>
+                    <type>direct</type>
+                    <name>test.direct</name>
+                    <durable>true</durable>
+                </exchange>
+                <exchange>
+                    <type>topic</type>
+                    <name>test.topic</name>
+                </exchange>
+            </exchanges>
+            <queues>
+                <exchange>amq.direct</exchange>
+                <maximumQueueDepth>4235264</maximumQueueDepth>
+                <!-- 4Mb -->
+                <maximumMessageSize>2117632</maximumMessageSize>
+                <!-- 2Mb -->
+                <maximumMessageAge>600000</maximumMessageAge>
+                <!-- 10 mins -->
+                <maximumMessageCount>50</maximumMessageCount>
+                <!-- 50 messages -->
+
+                <queue>
+                    <name>queue</name>
+                </queue>
+                <queue>
+                    <name>ping</name>
+                </queue>
+                <queue>
+                    <name>test-queue</name>
+                    <test-queue>
+                        <exchange>test.direct</exchange>
+                        <durable>true</durable>
+                    </test-queue>
+                </queue>
+                <queue>
+                    <name>test-ping</name>
+                    <test-ping>
+                        <exchange>test.direct</exchange>
+                    </test-ping>
+                </queue>
+
+            </queues>
+        </localhost>
+    </virtualhost>
+
+
+    <virtualhost>
+        <name>development</name>
+        <development>
+            <store>
+                
<class>org.apache.qpid.server.store.derby.DerbyMessageStore</class>
+                
<environment-path>${web:QPID_WORK}/derbystore</environment-path>
+            </store>
+
+            <queues>
+                <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+                <maximumMessageCount>50</maximumMessageCount>
+                <queue>
+                    <name>queue</name>
+                    <queue>
+                        <exchange>amq.direct</exchange>
+                        <maximumQueueDepth>4235264</maximumQueueDepth>
+                        <!-- 4Mb -->
+                        <maximumMessageSize>2117632</maximumMessageSize>
+                        <!-- 2Mb -->
+                        <maximumMessageAge>600000</maximumMessageAge>
+                        <!-- 10 mins -->
+                    </queue>
+                </queue>
+                <queue>
+                    <name>ping</name>
+                    <ping>
+                        <exchange>amq.direct</exchange>
+                        <maximumQueueDepth>4235264</maximumQueueDepth>
+                        <!-- 4Mb -->
+                        <maximumMessageSize>2117632</maximumMessageSize>
+                        <!-- 2Mb -->
+                        <maximumMessageAge>600000</maximumMessageAge>
+                        <!-- 10 mins -->
+                    </ping>
+                </queue>
+            </queues>
+        </development>
+    </virtualhost>
+    <virtualhost>
+        <name>test</name>
+        <test>
+            <store>
+                
<class>org.apache.qpid.server.store.derby.DerbyMessageStore</class>
+                
<environment-path>${web:QPID_WORK}/derbystore</environment-path>
+            </store>
+
+            <queues>
+                <minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
+                <maximumMessageCount>50</maximumMessageCount>
+                <queue>
+                    <name>queue</name>
+                    <queue>
+                        <exchange>amq.direct</exchange>
+                        <maximumQueueDepth>4235264</maximumQueueDepth>
+                        <!-- 4Mb -->
+                        <maximumMessageSize>2117632</maximumMessageSize>
+                        <!-- 2Mb -->
+                        <maximumMessageAge>600000</maximumMessageAge>
+                        <!-- 10 mins -->
+                    </queue>
+                </queue>
+                <queue>
+                    <name>ping</name>
+                    <ping>
+                        <exchange>amq.direct</exchange>
+                        <maximumQueueDepth>4235264</maximumQueueDepth>
+                        <!-- 4Mb -->
+                        <maximumMessageSize>2117632</maximumMessageSize>
+                        <!-- 2Mb -->
+                        <maximumMessageAge>600000</maximumMessageAge>
+                        <!-- 10 mins -->
+                    </ping>
+                </queue>
+            </queues>
+        </test>
+    </virtualhost>
+</virtualhosts>
+
+

Added: 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/web.xml
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/web.xml?rev=1350644&view=auto
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/web.xml
 (added)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker-web/src/main/resources/WEB-INF/web.xml
 Fri Jun 15 14:47:48 2012
@@ -0,0 +1,230 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ - Licensed to the Apache Software Foundation (ASF) under one
+ - or more contributor license agreements.  See the NOTICE file
+ - distributed with this work for additional information
+ - regarding copyright ownership.  The ASF licenses this file
+ - to you 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.
+ -->
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee";
+xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd";>
+
+  <session-config><!--  10 minutes -->
+   <session-timeout>10</session-timeout>
+  </session-config>
+
+  <servlet>
+    <display-name>VhostsServlet</display-name>
+    <servlet-name>VhostsServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.api.VhostsServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>ExchangesServlet</display-name>
+    <servlet-name>ExchangesServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.api.ExchangesServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>BrokerRestServlet</display-name>
+    <servlet-name>BrokerRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>VirtualHostRestServlet</display-name>
+    <servlet-name>VirtualHostRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>ExchangeRestServlet</display-name>
+    <servlet-name>ExchangeRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost,Exchange</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>QueueRestServlet</display-name>
+    <servlet-name>QueueRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost,Queue</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>ConnectionRestServlet</display-name>
+    <servlet-name>ConnectionRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost,Connection</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>BindingRestServlet</display-name>
+    <servlet-name>BindingRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost,Exchange,Queue,Binding</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>PortRestServlet</display-name>
+    <servlet-name>PortRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>Port</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>SessionRestServlet</display-name>
+    <servlet-name>SessionRestServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.RestServlet</servlet-class>
+    <init-param>
+     <param-name>hierarchy</param-name>
+     <param-value>VirtualHost,Connection,Session</param-value>
+   </init-param>
+  </servlet>
+
+  <servlet>
+    <display-name>StructureServlet</display-name>
+    <servlet-name>StructureServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.StructureServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>MessageServlet</display-name>
+    <servlet-name>MessageServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.MessageServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>MessageContentServlet</display-name>
+    <servlet-name>MessageContentServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.MessageContentServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>LogRecordsServlet</display-name>
+    <servlet-name>LogRecordsServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.LogRecordsServlet</servlet-class>
+  </servlet>
+
+  <servlet>
+    <display-name>SaslServlet</display-name>
+    <servlet-name>SaslServlet</servlet-name>
+    
<servlet-class>org.apache.qpid.server.management.plugin.servlet.rest.SaslServlet</servlet-class>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>VhostsServlet</servlet-name>
+    <url-pattern>/api/vhosts/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ExchangesServlet</servlet-name>
+    <url-pattern>/api/exchanges/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>BrokerRestServlet</servlet-name>
+    <url-pattern>/rest/broker/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>VirtualHostRestServlet</servlet-name>
+    <url-pattern>/rest/virtualhost/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ExchangeRestServlet</servlet-name>
+    <url-pattern>/rest/exchange/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>QueueRestServlet</servlet-name>
+    <url-pattern>/rest/queue/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>ConnectionRestServlet</servlet-name>
+    <url-pattern>/rest/connection/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>BindingRestServlet</servlet-name>
+    <url-pattern>/rest/binding/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>PortRestServlet</servlet-name>
+    <url-pattern>/rest/port/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>SessionRestServlet</servlet-name>
+    <url-pattern>/rest/session/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>StructureServlet</servlet-name>
+    <url-pattern>/rest/structure</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>MessageServlet</servlet-name>
+    <url-pattern>/rest/message/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>MessageContentServlet</servlet-name>
+    <url-pattern>/rest/message-content/*</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>LogRecordsServlet</servlet-name>
+    <url-pattern>/rest/logrecords</url-pattern>
+  </servlet-mapping>
+
+  <servlet-mapping>
+    <servlet-name>SaslServlet</servlet-name>
+    <url-pattern>/rest/sasl</url-pattern>
+  </servlet-mapping>
+
+  <listener>
+    
<listener-class>org.apache.qpid.web.listener.QpidServletContextListener</listener-class>
+  </listener>
+
+  <welcome-file-list>
+    <welcome-file>index.html</welcome-file>
+    <welcome-file>management.html</welcome-file>
+  </welcome-file-list>
+
+</web-app>

Modified: 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java?rev=1350644&r1=1350643&r2=1350644&view=diff
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
 (original)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
 Fri Jun 15 14:47:48 2012
@@ -111,6 +111,14 @@ public class Broker
 
         ConfigurationFileApplicationRegistry config = new 
ConfigurationFileApplicationRegistry(configFile, options.getBundleContext());
         ServerConfiguration serverConfig = config.getConfiguration();
+        if (options.getQpidWork() != null)
+        {
+            serverConfig.setQpidWork(options.getQpidWork());
+        }
+        if (options.getQpidHome() != null)
+        {
+            serverConfig.setQpidHome(options.getQpidHome());
+        }
         updateManagementPorts(serverConfig, 
options.getJmxPortRegistryServer(), options.getJmxPortConnectorServer());
 
         ApplicationRegistry.initialise(config);

Modified: 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java?rev=1350644&r1=1350643&r2=1350644&view=diff
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
 (original)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/BrokerOptions.java
 Fri Jun 15 14:47:48 2012
@@ -33,6 +33,7 @@ public class BrokerOptions
     public static final String DEFAULT_CONFIG_FILE = "etc/config.xml";
     public static final String DEFAULT_LOG_CONFIG_FILE = "etc/log4j.xml";
     public static final String QPID_HOME = "QPID_HOME";
+    public static final String QPID_WORK = "QPID_WORK";
 
     private final Set<Integer> _ports = new HashSet<Integer>();
     private final Set<Integer> _sslPorts = new HashSet<Integer>();
@@ -47,6 +48,8 @@ public class BrokerOptions
     private BundleContext _bundleContext;
 
     private Integer _logWatchFrequency = 0;
+    private String _qpidWorkFolder;
+    private String _qpidHomeFolder;
 
     public void addPort(final int port)
     {
@@ -109,7 +112,7 @@ public class BrokerOptions
     }
     public String getQpidHome()
     {
-        return System.getProperty(QPID_HOME);
+        return _qpidHomeFolder == null? System.getProperty(QPID_HOME): 
_qpidHomeFolder;
     }
 
     public Set<Integer> getExcludedPorts(final ProtocolExclusion 
excludeProtocol)
@@ -179,4 +182,19 @@ public class BrokerOptions
         Set<Integer> ports = _inclusionMap.get(includeProtocol);
         ports.add(port);
     }
+
+    public String getQpidWork()
+    {
+        return _qpidWorkFolder;
+    }
+
+    public void setQpidWork(String qpidWorkFolder)
+    {
+        _qpidWorkFolder = qpidWorkFolder;
+    }
+
+    public void setQpidHome(String qpidHomeFolder)
+    {
+        _qpidHomeFolder = qpidHomeFolder;
+    }
 }
\ No newline at end of file

Modified: 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java?rev=1350644&r1=1350643&r2=1350644&view=diff
==============================================================================
--- 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
 (original)
+++ 
qpid/branches/java-config-and-management/qpid/java/broker/src/main/java/org/apache/qpid/server/configuration/ServerConfiguration.java
 Fri Jun 15 14:47:48 2012
@@ -76,6 +76,8 @@ public class ServerConfiguration extends
 
     private File _configFile;
     private File _vhostsFile;
+    private String _qpidWork;
+    private String _qpidHome;
 
     // Map of environment variables to config items
     private static final Map<String, String> envVarMap = new HashMap<String, 
String>();
@@ -504,12 +506,26 @@ public class ServerConfiguration extends
 
     public String getQpidWork()
     {
-        return System.getProperty(QPID_WORK, 
System.getProperty("java.io.tmpdir"));
+        if ( _qpidWork == null )
+        {
+            return System.getProperty(QPID_WORK, 
System.getProperty("java.io.tmpdir"));
+        }
+        else
+        {
+            return _qpidWork;
+        }
     }
 
     public String getQpidHome()
     {
-        return System.getProperty(QPID_HOME);
+        if ( _qpidHome == null )
+        {
+            return System.getProperty(QPID_HOME);
+        }
+        else
+        {
+            return _qpidHome;
+        }
     }
 
     public void setJMXPortRegistryServer(int registryServerPort)
@@ -980,4 +996,14 @@ public class ServerConfiguration extends
 
         return reply == null ? null : AmqpProtocolVersion.valueOf(reply);
     }
+
+    public void setQpidWork(String path)
+    {
+        _qpidWork = path;
+    }
+
+    public void setQpidHome(String path)
+    {
+        _qpidHome = path;
+    }
 }

Modified: qpid/branches/java-config-and-management/qpid/java/build.deps
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/build.deps?rev=1350644&r1=1350643&r2=1350644&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/build.deps (original)
+++ qpid/branches/java-config-and-management/qpid/java/build.deps Fri Jun 15 
14:47:48 2012
@@ -178,6 +178,9 @@ csvjdbc.jar=lib/csvjdbc/csvjdbc-1.0.8.ja
 perftests-visualisation-jfc.libs=${jfreechart.jar} ${jcommon.jar} 
${csvjdbc.jar}
 perftests-visualisation-jfc.test.libs=${test.libs}
 
+#optional qpid-web module deps
+broker-web.libs=${servlet-api}
+
 # Libraries used only within the build
 bnd=lib/required/bnd-0.0.384.jar
 jython=lib/required/jython-standalone-2.5.2.jar

Modified: qpid/branches/java-config-and-management/qpid/java/build.xml
URL: 
http://svn.apache.org/viewvc/qpid/branches/java-config-and-management/qpid/java/build.xml?rev=1350644&r1=1350643&r2=1350644&view=diff
==============================================================================
--- qpid/branches/java-config-and-management/qpid/java/build.xml (original)
+++ qpid/branches/java-config-and-management/qpid/java/build.xml Fri Jun 15 
14:47:48 2012
@@ -27,7 +27,7 @@
   <findSubProjects name="management" dir="management" 
excludes="common,example"/>
 
   <property name="optional" value="false"/>
-  <property name="modules.opt.default" value="bdbstore bdbstore/jmx 
perftests/visualisation-jfc"/>
+  <property name="modules.opt.default" value="bdbstore bdbstore/jmx 
perftests/visualisation-jfc broker-web"/>
   <condition property="modules.opt" value="" else="${modules.opt.default}">
     <isfalse value="${optional}"/>
   </condition>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to