activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r910238 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/broker/ activemq-core/src/main/java/org/apache/activemq/store/journal/ activemq-core/src/main/java/org/apache/activemq/store/memory/ activemq-core/src/main/java/o...
Date Mon, 15 Feb 2010 15:34:59 GMT
Author: gtully
Date: Mon Feb 15 15:34:58 2010
New Revision: 910238

URL: http://svn.apache.org/viewvc?rev=910238&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2599 - tidy up exmple config to make it compliant with the schema - added simpe schema validation test and extended the broker start test, mvn test in assembly will now validate all the configs. added destroyApplicationContextOnStop to ensure jetty and other additions to the context are cleaned up when broker stops, allows mulitple brokers to rerun in the same jvm

Added:
    activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java   (with props)
    activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java   (with props)
Removed:
    activemq/trunk/assembly/src/sample-conf/quickMem-example.xml
    activemq/trunk/assembly/src/sample-conf/rapid-example.xml
    activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigTest.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java
    activemq/trunk/assembly/pom.xml
    activemq/trunk/assembly/src/release/conf/activemq.xml
    activemq/trunk/assembly/src/release/conf/camel.xml
    activemq/trunk/assembly/src/sample-conf/activemq-command.xml
    activemq/trunk/assembly/src/sample-conf/activemq-demo.xml
    activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker1.xml
    activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker2.xml
    activemq/trunk/assembly/src/sample-conf/activemq-jdbc.xml
    activemq/trunk/assembly/src/sample-conf/activemq-security.xml
    activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker1.xml
    activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker2.xml
    activemq/trunk/assembly/src/sample-conf/activemq-stomp.xml
    activemq/trunk/assembly/src/sample-conf/journaledMem-example.xml
    activemq/trunk/assembly/src/sample-conf/kaha-example.xml
    activemq/trunk/assembly/src/sample-conf/memory-example.xml
    activemq/trunk/assembly/src/sample-conf/quickJdbc-example.xml

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java Mon Feb 15 15:34:58 2010
@@ -598,7 +598,7 @@
         stopper.throwFirstException();
     }
     
-        public boolean checkQueueSize(String queueName) {
+    public boolean checkQueueSize(String queueName) {
         long count = 0;
         long queueSize = 0;
         Map<ActiveMQDestination, Destination> destinationMap = regionBroker.getDestinationMap();

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/journal/JournalPersistenceAdapter.java Mon Feb 15 15:34:58 2010
@@ -88,8 +88,8 @@
     protected static final Scheduler scheduler = Scheduler.getInstance();
     private static final Log LOG = LogFactory.getLog(JournalPersistenceAdapter.class);
 
-    private final Journal journal;
-    private final PersistenceAdapter longTermPersistence;
+    private Journal journal;
+    private PersistenceAdapter longTermPersistence;
 
     private final WireFormat wireFormat = new OpenWireFormat();
 
@@ -114,20 +114,27 @@
 
     private final Runnable periodicCheckpointTask = createPeriodicCheckpointTask();
 
+    private TaskRunnerFactory taskRunnerFactory;
+
     public JournalPersistenceAdapter(Journal journal, PersistenceAdapter longTermPersistence, TaskRunnerFactory taskRunnerFactory) throws IOException {
+        setJournal(journal);
+        setTaskRunnerFactory(taskRunnerFactory);
+        setPersistenceAdapter(longTermPersistence);
+    }
+
+    public void setTaskRunnerFactory(TaskRunnerFactory taskRunnerFactory) {
+        this.taskRunnerFactory = taskRunnerFactory;
+    }
 
+    public void setJournal(Journal journal) {
         this.journal = journal;
         journal.setJournalEventListener(this);
-
-        checkpointTask = taskRunnerFactory.createTaskRunner(new Task() {
-            public boolean iterate() {
-                return doCheckpoint();
-            }
-        }, "ActiveMQ Journal Checkpoint Worker");
-
+    }
+    
+    public void setPersistenceAdapter(PersistenceAdapter longTermPersistence) {
         this.longTermPersistence = longTermPersistence;
     }
-
+    
     final Runnable createPeriodicCheckpointTask() {
         return new Runnable() {
             public void run() {
@@ -229,6 +236,12 @@
             return;
         }
 
+        checkpointTask = taskRunnerFactory.createTaskRunner(new Task() {
+            public boolean iterate() {
+                return doCheckpoint();
+            }
+        }, "ActiveMQ Journal Checkpoint Worker");
+
         checkpointExecutor = new ThreadPoolExecutor(maxCheckpointWorkers, maxCheckpointWorkers, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() {
             public Thread newThread(Runnable runable) {
                 Thread t = new Thread(runable, "Journal checkpoint worker");

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/store/memory/MemoryPersistenceAdapter.java Mon Feb 15 15:34:58 2010
@@ -195,4 +195,10 @@
     public long size(){
         return 0;
     }
+    
+    public void setCreateTransactionStore(boolean create) throws IOException {
+        if (create) {
+            createTransactionStore();
+        }
+    }
 }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/xbean/XBeanBrokerService.java Mon Feb 15 15:34:58 2010
@@ -20,14 +20,13 @@
 
 import javax.annotation.PostConstruct;
 import javax.annotation.PreDestroy;
+
 import org.apache.activemq.broker.BrokerService;
 import org.apache.activemq.usage.SystemUsage;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.osgi.framework.BundleException;
 import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.DisposableBean;
-import org.springframework.beans.factory.InitializingBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.context.ConfigurableApplicationContext;
@@ -53,7 +52,24 @@
     private boolean start = true;
     private ApplicationContext applicationContext = null;
     private boolean destroyApplicationContextOnShutdown = false;
+    private boolean destroyApplicationContextOnStop = false;
+
+    Runnable stopContextRunnable = new Runnable() {
+        public void run() {
+            if (applicationContext instanceof ConfigurableApplicationContext) {
+                ((ConfigurableApplicationContext) applicationContext).close();
+            }
+            if (applicationContext instanceof OsgiBundleXmlApplicationContext){
+                try {
+                    ((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
+                } catch (BundleException e) {
+                    LOG.info("Error stopping OSGi bundle " + e, e);
+                }
+            }
 
+        }
+    };
+    
     public XBeanBrokerService() {
     }
 
@@ -69,21 +85,7 @@
             start();
         }
         if (destroyApplicationContextOnShutdown) {
-            addShutdownHook(new Runnable() {
-                public void run() {
-                    if (applicationContext instanceof ConfigurableApplicationContext) {
-	                    ((ConfigurableApplicationContext) applicationContext).close();
-                    }
-                    if (applicationContext instanceof OsgiBundleXmlApplicationContext){
-                        try {
-                            ((OsgiBundleXmlApplicationContext)applicationContext).getBundle().stop();
-                        } catch (BundleException e) {
-                            LOG.info("Error stopping OSGi bundle " + e, e);
-                        }
-                    }
-
-                }
-            });
+            addShutdownHook(stopContextRunnable);
         }
     }
 
@@ -107,9 +109,15 @@
         stop();
     }
 
-    public boolean isStart() {
-        return start;
-    }
+    
+   @Override
+   public void stop() throws Exception {      
+       if (destroyApplicationContextOnStop) {
+           stopContextRunnable.run();
+       }
+       super.stop();
+   }
+    
 
     /**
      * Sets whether or not the broker is started along with the ApplicationContext it is defined within.
@@ -121,12 +129,20 @@
     }
 
     /**
-     * Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
+     * Sets whether the broker should shutdown the ApplicationContext when the broker jvm is shutdown.
      * The broker can be stopped because the underlying JDBC store is unavailable for example.
      */
     public void setDestroyApplicationContextOnShutdown(boolean destroy) {
         this.destroyApplicationContextOnShutdown = destroy;
     }
+    
+    /**
+     * Sets whether the broker should shutdown the ApplicationContext when the broker is stopped.
+     * The broker can be stopped because the underlying JDBC store is unavailable for example.
+     */
+    public void setDestroyApplicationContextOnStop(boolean destroy) {
+        this.destroyApplicationContextOnStop = destroy;
+    }
 
 	public void setApplicationContext(ApplicationContext applicationContext)
 			throws BeansException {

Modified: activemq/trunk/assembly/pom.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/pom.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/pom.xml (original)
+++ activemq/trunk/assembly/pom.xml Mon Feb 15 15:34:58 2010
@@ -322,6 +322,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi.core</artifactId>
+      <scope>test</scope>
+    </dependency>
     
     <!-- dependencies specific to this module -->
     <dependency>
@@ -367,9 +372,18 @@
       </plugin>
       <plugin>
         <artifactId>maven-surefire-plugin</artifactId>
-        <configuration>
-          <forkMode>pertest</forkMode>
-        </configuration>
+        <executions>
+          <execution>
+            <id>validate-config</id>
+            <phase>test</phase>
+            <goals>
+             <goal>test</goal>
+            </goals>
+            <configuration>
+             <forkMode>pertest</forkMode>
+            </configuration>
+          </execution>
+        </executions>
       </plugin>
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
@@ -414,6 +428,30 @@
           <url>broker:(tcp://localhost:61616)?useJmx=false</url>
         </configuration>
       </plugin -->
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-conf</id>
+            <phase>process-test-resources</phase>
+            <goals>
+              <goal>copy-resources</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>target/conf</outputDirectory>
+              <resources> 
+                <resource>
+                  <directory>src/release/conf</directory>
+                </resource>
+                <resource>
+                  <directory>src/sample-conf</directory>
+                </resource>
+              </resources> 
+            </configuration>            
+          </execution>
+        </executions>
+      </plugin>
     </plugins>
   </build>
 

Modified: activemq/trunk/assembly/src/release/conf/activemq.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/release/conf/activemq.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/release/conf/activemq.xml (original)
+++ activemq/trunk/assembly/src/release/conf/activemq.xml Mon Feb 15 15:34:58 2010
@@ -31,31 +31,8 @@
     <!-- 
         The <broker> element is used to configure the ActiveMQ broker. 
     -->
-    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data">
-        
-        <!-- 
-            The managementContext is used to configure how ActiveMQ is exposed in 
-            JMX. By default, ActiveMQ uses the MBean server that is started by 
-            the JVM. For more information, see: 
-            
-            http://activemq.apache.org/jmx.html 
-        -->
-        <managementContext>
-            <managementContext createConnector="false"/>
-        </managementContext>
-
-        <!-- 
-            Configure message persistence for the broker. The default persistence
-            mechanism is the KahaDB store (identified by the kahaDB tag). 
-            For more information, see: 
-            
-            http://activemq.apache.org/persistence.html 
-        -->
-        <persistenceAdapter>
-            <kahaDB directory="${activemq.base}/data/kahadb"/>
-        </persistenceAdapter>
-        
-        
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data" destroyApplicationContextOnStop="true">
+ 
         <!--
 			For better performances use VM cursor and small memory limit.
 			For more information, see:
@@ -90,7 +67,31 @@
             </policyMap>
         </destinationPolicy> 
  
-         <!--
+        
+        <!-- 
+            The managementContext is used to configure how ActiveMQ is exposed in 
+            JMX. By default, ActiveMQ uses the MBean server that is started by 
+            the JVM. For more information, see: 
+            
+            http://activemq.apache.org/jmx.html 
+        -->
+        <managementContext>
+            <managementContext createConnector="false"/>
+        </managementContext>
+
+        <!-- 
+            Configure message persistence for the broker. The default persistence
+            mechanism is the KahaDB store (identified by the kahaDB tag). 
+            For more information, see: 
+            
+            http://activemq.apache.org/persistence.html 
+        -->
+        <persistenceAdapter>
+            <kahaDB directory="${activemq.base}/data/kahadb"/>
+        </persistenceAdapter>
+        
+        
+          <!--
             The systemUsage controls the maximum amount of space the broker will 
             use before slowing down producers. For more information, see:
             

Modified: activemq/trunk/assembly/src/release/conf/camel.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/release/conf/camel.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/release/conf/camel.xml (original)
+++ activemq/trunk/assembly/src/release/conf/camel.xml Mon Feb 15 15:34:58 2010
@@ -26,13 +26,16 @@
     e.g. <import resource="camel.xml"/>
 -->
 <beans
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+   xmlns="http://www.springframework.org/schema/beans"  
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+  
+  	<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
 
         <!-- You can use a <packages> element for each root package to search for Java routes -->
         <packageScan>
-           <packages>org.foo.bar</packages>
+           <package>org.foo.bar</package>
         </packageScan>
 
         <!-- You can use Spring XML syntax to define the routes here using the <route> element -->

Modified: activemq/trunk/assembly/src/sample-conf/activemq-command.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-command.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-command.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-command.xml Mon Feb 15 15:34:58 2010
@@ -25,7 +25,16 @@
     
     e.g. $ bin/activemq xbean:conf/activemq-command.xml
  -->
-<beans>
+ <beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+  
+     <!-- Allows us to use system properties as variables in this configuration file -->
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+ 
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="command-broker" dataDirectory="${activemq.base}/data">
         <managementContext>
             <managementContext createConnector="true"/>
@@ -34,6 +43,7 @@
         <transportConnectors>
             <!-- Create a XMPP transport for XMPP clients. -->
             <transportConnector name="xmpp" uri="xmpp://localhost:61222"/>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
         </transportConnectors>
     </broker>
     

Modified: activemq/trunk/assembly/src/sample-conf/activemq-demo.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-demo.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-demo.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-demo.xml Mon Feb 15 15:34:58 2010
@@ -23,11 +23,10 @@
  -->
 <beans
   xmlns="http://www.springframework.org/schema/beans"
-  xmlns:amq="http://activemq.apache.org/schema/core"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd   
-  http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
 
     <!-- 
         Allows us to use system properties as variables in this configuration 
@@ -48,7 +47,7 @@
           - Change the brokerName attribute to something unique  
     -->
 
-    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="amq-broker" useJmx="true">
+    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="amq-broker" useJmx="true" destroyApplicationContextOnStop="true">
 
         <!-- 
             Examples of destination-specific policies using destination 
@@ -139,9 +138,9 @@
             Configure the following if you wish to use journaled JDBC for message 
             persistence. 
         
-        <persistenceAdapter>
+        <persistenceFactory>
             <journaledJDBC dataDirectory="${activemq.base}/data" dataSource="#postgres-ds"/>
-        </persistenceAdapter>
+        </persistenceFactory>
         -->
 
         <!-- 
@@ -214,35 +213,18 @@
       
        http://activemq.apache.org/enterprise-integration-patterns.html
     -->
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-
-        <!-- You can use a <package> element for each root package to search for Java routes -->
-        <package>org.foo.bar</package>
+    <import resource="camel.xml"/>
 
-        <!-- You can use Spring XML syntax to define the routes here using the <route> element -->
-        <route>
-            <from uri="activemq:example.A"/>
-            <to uri="activemq:example.B"/>
-        </route>
-    </camelContext>
 
-    <!--
-       Lets configure some Camel endpoints
-    
-       http://activemq.apache.org/camel/components.html
+    <!-- 
+        An embedded servlet engine for serving up the Admin console and other demos. 
+        For more information, see: 
+        
+          http://activemq.apache.org/web-console.html
     -->
-
-    <!-- configure the camel activemq component to use the current broker -->
-    <bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
-        <property name="connectionFactory">
-          <bean class="org.apache.activemq.ActiveMQConnectionFactory">
-            <property name="brokerURL" value="vm://localhost?create=false&amp;waitForStart=10000" />
-            <property name="userName" value="${activemq.username}"/>
-            <property name="password" value="${activemq.password}"/>
-          </bean>
-        </property>
-    </bean>
-
+    <import resource="jetty.xml"/>
+    
+    
     <!-- 
         Uncomment to create a command agent to respond to message based admin 
         commands on the ActiveMQ.Agent topic. For more information, see: 
@@ -254,24 +236,6 @@
 
 
     <!-- 
-        An embedded servlet engine for serving up the Admin console and other demos. 
-        For more information, see: 
-        
-          http://activemq.apache.org/web-console.html
-    -->
-    <jetty xmlns="http://mortbay.com/schemas/jetty/1.0">
-        <connectors>
-            <nioConnector port="8161"/>
-        </connectors>
-
-        <handlers>
-            <webAppContext contextPath="/admin" resourceBase="${activemq.base}/webapps/admin" logUrlOnStart="true"/>
-            <webAppContext contextPath="/demo" resourceBase="${activemq.base}/webapps/demo" logUrlOnStart="true"/>
-            <webAppContext contextPath="/fileserver" resourceBase="${activemq.base}/webapps/fileserver" logUrlOnStart="true"/>
-        </handlers>
-    </jetty>
-
-    <!-- 
         This xbean configuration file supports all the standard Spring XML 
         configuration options such as the following bean definitions. 
     -->

Modified: activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker1.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker1.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker1.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker1.xml Mon Feb 15 15:34:58 2010
@@ -41,32 +41,6 @@
 
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="dynamic-broker1" dataDirectory="${activemq.base}/data">
 
-        <!-- First let's configure connectors -->
-
-        <!--
-            Configure network connector to use multicast protocol
-            For more information, see
-            
-            http://activemq.apache.org/multicast-transport-reference.html
-        -->
-	    <networkConnectors>
-	      <networkConnector uri="multicast://default"
-	        dynamicOnly="true" 
-	        networkTTL="3" 
-	        prefetchSize="1" 
-	        decreaseNetworkConsumerPriority="true" />
-	    </networkConnectors>
-	    
-	    <!-- 
-            The transport connectors ActiveMQ will listen to
-            Configure discovery URI to use multicast protocol
-        -->
-        <transportConnectors>
-            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" discoveryUri="multicast://default" />
-        </transportConnectors>
-        
-        <!-- Now configure the rest of the desired broker behavior -->
-
         <!-- Destination specific policies using destination names or wildcards -->
         <destinationPolicy>
             <policyMap>
@@ -87,6 +61,20 @@
             <managementContext createConnector="true"/>
         </managementContext>
 
+        <!--
+            Configure network connector to use multicast protocol
+            For more information, see
+            
+            http://activemq.apache.org/multicast-transport-reference.html
+        -->
+	    <networkConnectors>
+	      <networkConnector uri="multicast://default"
+	        dynamicOnly="true" 
+	        networkTTL="3" 
+	        prefetchSize="1" 
+	        decreaseNetworkConsumerPriority="true" />
+	    </networkConnectors>
+	    
         <persistenceAdapter>
             <kahaDB directory="${activemq.base}/data/dynamic-broker1/kahadb"/>
         </persistenceAdapter>
@@ -106,6 +94,15 @@
             </systemUsage>
         </systemUsage>
 
+	    <!-- 
+            The transport connectors ActiveMQ will listen to
+            Configure discovery URI to use multicast protocol
+        -->
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616" discoveryUri="multicast://default" />
+        </transportConnectors>
+        
+
     </broker>
 
 </beans>

Modified: activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker2.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker2.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker2.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-dynamic-network-broker2.xml Mon Feb 15 15:34:58 2010
@@ -42,32 +42,6 @@
 
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="dynamic-broker2" dataDirectory="${activemq.base}/data">
 
-        <!-- First let's configure connectors -->
-
-        <!--
-            Configure network connector to use multicast protocol
-            For more information, see
-            
-            http://activemq.apache.org/multicast-transport-reference.html
-        -->
-        <networkConnectors>
-          <networkConnector uri="multicast://default"
-            dynamicOnly="true" 
-            networkTTL="3" 
-            prefetchSize="1" 
-            decreaseNetworkConsumerPriority="true" />
-        </networkConnectors>
-        
-        <!-- 
-            The transport connectors ActiveMQ will listen to
-            Configure discovery URI to use multicast protocol
-        -->
-        <transportConnectors>
-            <transportConnector name="openwire" uri="tcp://0.0.0.0:61618" discoveryUri="multicast://default" />
-        </transportConnectors>
-
-        <!-- Now configure the rest of the desired broker behavior -->
-
         <!-- Destination specific policies using destination names or wildcards -->
         <destinationPolicy>
             <policyMap>
@@ -87,6 +61,21 @@
         <managementContext>
             <managementContext createConnector="true" connectorPort="1100"/>
         </managementContext>
+
+        <!--
+            Configure network connector to use multicast protocol
+            For more information, see
+            
+            http://activemq.apache.org/multicast-transport-reference.html
+        -->
+        <networkConnectors>
+          <networkConnector uri="multicast://default"
+            dynamicOnly="true" 
+            networkTTL="3" 
+            prefetchSize="1" 
+            decreaseNetworkConsumerPriority="true" />
+        </networkConnectors>
+        
 	
 	    <persistenceAdapter>
 	        <kahaDB directory="${activemq.base}/data/dynamic-broker2/kahadb" />
@@ -107,6 +96,14 @@
 	        </systemUsage>
 	    </systemUsage>
 
+        <!-- 
+            The transport connectors ActiveMQ will listen to
+            Configure discovery URI to use multicast protocol
+        -->
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61618" discoveryUri="multicast://default" />
+        </transportConnectors>
+
     </broker>
 
 </beans>

Modified: activemq/trunk/assembly/src/sample-conf/activemq-jdbc.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-jdbc.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-jdbc.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-jdbc.xml Mon Feb 15 15:34:58 2010
@@ -28,7 +28,11 @@
     
     e.g. $ bin/activemq xbean:conf/activemq-jdbc.xml
  -->
-<beans>
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
   
   <broker useJmx="false" brokerName="jdbcBroker" xmlns="http://activemq.apache.org/schema/core">
     <persistenceAdapter>

Modified: activemq/trunk/assembly/src/sample-conf/activemq-security.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-security.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-security.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-security.xml Mon Feb 15 15:34:58 2010
@@ -38,7 +38,7 @@
       </property>      
   </bean>
 
-  <broker useJmx="true" persistent="false" xmlns="http://activemq.apache.org/schema/core">
+  <broker useJmx="true" persistent="false" xmlns="http://activemq.apache.org/schema/core" destroyApplicationContextOnStop="true">
 
     <plugins>
         <!-- Configure authentication; Username, passwords and groups -->

Modified: activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker1.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker1.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker1.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker1.xml Mon Feb 15 15:34:58 2010
@@ -43,23 +43,6 @@
 
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker1" dataDirectory="${activemq.base}/data">
 
-        <!-- First let's configure connectors -->
-
-        <!-- 
-            The store and forward broker networks ActiveMQ will listen to.
-            We'll leave it empty as duplex network will be configured by another broker
-            Take a look at activemq-static_network-broker2.xml for example
-        -->
-        <networkConnectors>
-        </networkConnectors>
-        
-        <!-- The transport connectors ActiveMQ will listen to -->
-        <transportConnectors>
-            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
-        </transportConnectors>
-        
-        <!-- Now configure the rest of the desired broker behavior -->
-
         <!-- Destination specific policies using destination names or wildcards -->
         <destinationPolicy>
             <policyMap>
@@ -80,6 +63,14 @@
             <managementContext createConnector="true"/>
         </managementContext>
 
+        <!-- 
+            The store and forward broker networks ActiveMQ will listen to.
+            We'll leave it empty as duplex network will be configured by another broker
+            Take a look at activemq-static_network-broker2.xml for example
+        -->
+        <networkConnectors>
+        </networkConnectors>
+        
         <persistenceAdapter>
             <kahaDB directory="${activemq.base}/data/static-broker1/kahadb" />
         </persistenceAdapter>
@@ -99,6 +90,11 @@
             </systemUsage>
         </systemUsage>
 
+        <!-- The transport connectors ActiveMQ will listen to -->
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
+        </transportConnectors>
+        
     </broker>
 
 </beans>

Modified: activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker2.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker2.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker2.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-static-network-broker2.xml Mon Feb 15 15:34:58 2010
@@ -43,23 +43,6 @@
 
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker1" dataDirectory="${activemq.base}/data">
 
-        <!-- First let's configure connectors -->
-        
-        <!-- 
-            The store and forward broker networks ActiveMQ will listen to
-            Create a duplex connector to the first broker 
-        -->
-        <networkConnectors>
-            <networkConnector uri="static:(tcp://localhost:61616)" duplex="true"/>
-        </networkConnectors>
-        
-        <!-- The transport connectors ActiveMQ will listen to -->
-        <transportConnectors>
-            <transportConnector name="openwire" uri="tcp://0.0.0.0:61618"/>
-        </transportConnectors>
-        
-        <!-- Now configure the rest of the desired broker behavior -->
-
         <!-- Destination specific policies using destination names or wildcards -->
         <destinationPolicy>
             <policyMap>
@@ -80,6 +63,14 @@
             <managementContext createConnector="true" connectorPort="1100"/>
         </managementContext>
 
+        <!-- 
+            The store and forward broker networks ActiveMQ will listen to
+            Create a duplex connector to the first broker 
+        -->
+        <networkConnectors>
+            <networkConnector uri="static:(tcp://localhost:61616)" duplex="true"/>
+        </networkConnectors>
+        
         <persistenceAdapter>
             <kahaDB directory="${activemq.base}/data/static-broker2/kahadb" />
         </persistenceAdapter>
@@ -99,6 +90,11 @@
             </systemUsage>
         </systemUsage>
 
+        <!-- The transport connectors ActiveMQ will listen to -->
+        <transportConnectors>
+            <transportConnector name="openwire" uri="tcp://0.0.0.0:61618"/>
+        </transportConnectors>
+        
     </broker>
 
 </beans>

Modified: activemq/trunk/assembly/src/sample-conf/activemq-stomp.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/activemq-stomp.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/activemq-stomp.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/activemq-stomp.xml Mon Feb 15 15:34:58 2010
@@ -45,30 +45,7 @@
         The <broker> element is used to configure the ActiveMQ broker. 
     -->
     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.base}/data">
-        
-        <!-- 
-            The managementContext is used to configure how ActiveMQ is exposed in 
-            JMX. By default, ActiveMQ uses the MBean server that is started by 
-            the JVM. For more information, see: 
-            
-            http://activemq.apache.org/jmx.html 
-        -->
-        <managementContext>
-            <managementContext createConnector="false"/>
-        </managementContext>
-
-        <!-- 
-            Configure message persistence for the broker. The default persistence
-            mechanism is the KahaDB store (identified by the kahaDB tag). 
-            For more information, see: 
-            
-            http://activemq.apache.org/persistence.html 
-        -->
-        <persistenceAdapter>
-            <kahaDB directory="${activemq.base}/data/kahadb"/>
-        </persistenceAdapter>
-        
-        
+             
         <!--
             For better performances use VM cursor and small memory limit.
             For more information, see:
@@ -101,7 +78,31 @@
                 </policyEntry>
               </policyEntries>
             </policyMap>
-        </destinationPolicy> 
+        </destinationPolicy>
+        
+           
+        <!-- 
+            The managementContext is used to configure how ActiveMQ is exposed in 
+            JMX. By default, ActiveMQ uses the MBean server that is started by 
+            the JVM. For more information, see: 
+            
+            http://activemq.apache.org/jmx.html 
+        -->
+        <managementContext>
+            <managementContext createConnector="false"/>
+        </managementContext>
+
+        <!-- 
+            Configure message persistence for the broker. The default persistence
+            mechanism is the KahaDB store (identified by the kahaDB tag). 
+            For more information, see: 
+            
+            http://activemq.apache.org/persistence.html 
+        -->
+        <persistenceAdapter>
+            <kahaDB directory="${activemq.base}/data/kahadb"/>
+        </persistenceAdapter>
+         
           
         <!-- 
             The transport connectors expose ActiveMQ over a given protocol to

Modified: activemq/trunk/assembly/src/sample-conf/journaledMem-example.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/journaledMem-example.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/journaledMem-example.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/journaledMem-example.xml Mon Feb 15 15:34:58 2010
@@ -16,29 +16,35 @@
     limitations under the License.
 -->
 
-<beans xmlns:amq="http://activemq.apache.org/schema/core">
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
 
     <amq:broker brokerName="journaledMemBroker" start="false" persistent="false" useShutdownHook="false" deleteAllMessagesOnStartup="true" advisorySupport="false">
 
-        <amq:transportConnectors>
-            <amq:transportConnector uri="tcp://localhost:61616"/>
-        </amq:transportConnectors>
-
         <amq:persistenceAdapter>
             <amq:journalPersistenceAdapter>
-                <constructor-arg index="0">
+                <amq:journal>
                     <ref bean="myJournalImpl"/>
-                </constructor-arg>
+                </amq:journal>
 
-                <constructor-arg index="1">
-                    <amq:memoryPersistenceAdapter init-method="createTransactionStore"/>
-                </constructor-arg>
+                <amq:persistenceAdapter>
+                    <amq:memoryPersistenceAdapter createTransactionStore="true"/>
+                </amq:persistenceAdapter>
 
-                <constructor-arg index="2">
+                <amq:taskRunnerFactory>
                     <bean id="myTaskRunnerFactory" class="org.apache.activemq.thread.TaskRunnerFactory"/>
-                </constructor-arg>
+                </amq:taskRunnerFactory>
             </amq:journalPersistenceAdapter>
         </amq:persistenceAdapter>
+
+        <amq:transportConnectors>
+            <amq:transportConnector uri="tcp://localhost:61616"/>
+        </amq:transportConnectors>
+
     </amq:broker>
 
     <!-- The journal implementation that will be used -->

Modified: activemq/trunk/assembly/src/sample-conf/kaha-example.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/kaha-example.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/kaha-example.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/kaha-example.xml Mon Feb 15 15:34:58 2010
@@ -15,17 +15,25 @@
     limitations under the License.
 -->
 <!-- START SNIPPET: xbean -->
-<beans>
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+  
   <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
 
   <broker brokerName="broker" persistent="false" useJmx="false" xmlns="http://activemq.apache.org/schema/core">
+
+    <persistenceAdapter>
+      <kahaPersistenceAdapter directory = "${activemq.home}/activemq-data"/>
+    </persistenceAdapter>
+
      <transportConnectors>
       <transportConnector uri="tcp://localhost:61616"/>
     </transportConnectors>
 
-    <persistenceAdapter>
-      <kahaPersistenceAdapter dir = "${activemq.home}/activemq-data"/>
-    </persistenceAdapter>
   </broker>
 
 </beans>

Modified: activemq/trunk/assembly/src/sample-conf/memory-example.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/memory-example.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/memory-example.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/memory-example.xml Mon Feb 15 15:34:58 2010
@@ -15,8 +15,13 @@
     limitations under the License.
 -->
 <!-- START SNIPPET: xbean -->
-<beans>
-  
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:amq="http://activemq.apache.org/schema/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+    
   <broker useJmx="false" brokerName="memoryBroker" xmlns="http://activemq.apache.org/schema/core">
     <persistenceAdapter>
        <memoryPersistenceAdapter/>

Modified: activemq/trunk/assembly/src/sample-conf/quickJdbc-example.xml
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/sample-conf/quickJdbc-example.xml?rev=910238&r1=910237&r2=910238&view=diff
==============================================================================
--- activemq/trunk/assembly/src/sample-conf/quickJdbc-example.xml (original)
+++ activemq/trunk/assembly/src/sample-conf/quickJdbc-example.xml Mon Feb 15 15:34:58 2010
@@ -15,10 +15,14 @@
     limitations under the License.
 -->
 <!-- START SNIPPET: xbean -->
-<beans>
-  
+<beans
+  xmlns="http://www.springframework.org/schema/beans"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
+    
   <broker useJmx="false" brokerName="quickJdbcBroker" xmlns="http://activemq.apache.org/schema/core">
-    <persistenceAdapter>
+    <persistenceFactory>
        <journaledJDBC journalLogFiles="4" 
                       journalLogFileSize="32768" 
 		      useJournal="true" 
@@ -26,7 +30,7 @@
 		      dataSource="#derby-ds" 
 		      dataDirectory="target/quickJdbc-data"/>
 		      
-    </persistenceAdapter>
+    </persistenceFactory>
   
     <transportConnectors>
        <transportConnector name="default" uri="tcp://localhost:61616"/>

Added: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java?rev=910238&view=auto
==============================================================================
--- activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java (added)
+++ activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java Mon Feb 15 15:34:58 2010
@@ -0,0 +1,108 @@
+/**
+ * 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.activemq.config;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileInputStream;
+import java.net.URI;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Connection;
+import javax.jms.JMSException;
+
+import junit.framework.TestCase;
+import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.broker.BrokerFactory;
+import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.TransportConnection;
+import org.apache.activemq.broker.TransportConnector;
+import org.apache.activemq.transport.stomp.StompConnection;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class BrokerXmlConfigStartTest extends TestCase {
+
+    private static final Log LOG = LogFactory.getLog(BrokerXmlConfigStartTest.class);
+    Properties secProps;
+    public void testStartBrokerUsingXmlConfig() throws Exception {
+        doTestStartBrokerUsingXmlConfig("xbean:src/release/conf/activemq.xml");
+    }
+
+    public void testStartBrokerUsingSampleConfig() throws Exception {
+        // resource:copy-resource brings all config files into target/conf
+        File sampleConfDir = new File("target/conf");
+        
+        for (File xmlFile : sampleConfDir.listFiles(new FileFilter() {
+            public boolean accept(File pathname) {
+                return pathname.isFile() &&
+                pathname.getName().startsWith("activemq-") &&
+                pathname.getName().endsWith("xml");
+            }})) {
+            
+            doTestStartBrokerUsingXmlConfig("xbean:" + sampleConfDir.getAbsolutePath() + "/" + xmlFile.getName());
+        }
+    }
+
+    public void doTestStartBrokerUsingXmlConfig(String configUrl) throws Exception {
+
+        BrokerService broker = null;
+        LOG.info("Broker config: " + configUrl);
+        System.err.println("Broker config: " + configUrl);
+        broker = BrokerFactory.createBroker(configUrl);
+        // alive, now try connect to connect
+        try {
+            for (TransportConnector transport : broker.getTransportConnectors()) {
+                final URI UriToConnectTo = transport.getConnectUri();
+                 
+                if (UriToConnectTo.getScheme().startsWith("stomp")) {
+                    LOG.info("validating alive with connection to: " + UriToConnectTo);
+                    StompConnection connection = new StompConnection();
+                    connection.open(UriToConnectTo.getHost(), UriToConnectTo.getPort());
+                    connection.close();
+                    break;
+                } else if (UriToConnectTo.getScheme().startsWith("tcp")) {
+                    LOG.info("validating alive with connection to: " + UriToConnectTo);
+                    ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(UriToConnectTo);
+                    Connection connection = connectionFactory.createConnection(secProps.getProperty("activemq.username"),
+                            secProps.getProperty("activemq.password"));
+                    connection.start();
+                    connection.close();
+                    break;
+                } else {
+                    LOG.info("not validating connection to: " + UriToConnectTo);
+                }
+            }
+        } finally {
+            if (broker != null) {
+                broker.stop();
+                broker = null;
+            }
+        }
+    }
+
+    public void setUp() throws Exception {
+        System.setProperty("activemq.base", "target");
+        secProps = new Properties();
+        secProps.load(new FileInputStream(new File("target/conf/credentials.properties")));
+    }
+    
+    public void tearDown() throws Exception {
+        TimeUnit.SECONDS.sleep(1);
+    }
+}

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/BrokerXmlConfigStartTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java?rev=910238&view=auto
==============================================================================
--- activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java (added)
+++ activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java Mon Feb 15 15:34:58 2010
@@ -0,0 +1,112 @@
+/**
+ * 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.activemq.config;
+
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.junit.Test;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+
+public class ValidateXMLConfigTest {
+    private static final String SCHEMA_LANGUAGE_ATTRIBUTE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage";
+    private static final String XSD_SCHEMA_LANGUAGE = "http://www.w3.org/2001/XMLSchema";
+
+    
+    @Test
+    public void validateDefaultConfig() throws Exception {
+        validateXML("src/release/conf/activemq.xml");
+    }
+    
+    @Test
+    public void validateExampleConfig() throws Exception {
+        // resource:copy-resource brings all config files into target/conf
+        File sampleConfDir = new File("target/conf");
+        
+        for (File xmlFile : sampleConfDir.listFiles(new FileFilter() {
+            public boolean accept(File pathname) {
+                return pathname.isFile() && pathname.getName().endsWith("xml");
+            }})) {
+            
+            validateXML(xmlFile);
+        }
+    }
+    
+    private void validateXML(String fileName) throws Exception {
+        File xmlFile = new File(fileName);
+        validateXML(xmlFile);
+    }
+        
+    private void validateXML(File file) throws Exception {
+        getDocumentBuilder(file.getAbsolutePath()).parse(file);
+    }
+    
+    private DocumentBuilder getDocumentBuilder(final String fileName) throws Exception {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setValidating(true);
+        factory.setNamespaceAware(true);       
+        factory.setAttribute(SCHEMA_LANGUAGE_ATTRIBUTE, XSD_SCHEMA_LANGUAGE);
+        
+        DocumentBuilder builder = factory.newDocumentBuilder();
+       
+        builder.setEntityResolver(new EntityResolver() {
+
+            public InputSource resolveEntity(String publicId, String systemId)
+                    throws SAXException, IOException {
+                System.err.println("resolve: " + publicId + ", sys: " +  systemId);
+                InputSource source = null;
+                if (systemId.endsWith("activemq-core.xsd")) {
+                   InputStream stream = this.getClass().getClassLoader().getResourceAsStream("activemq.xsd");
+                   source = new InputSource(stream);
+                   source.setPublicId(publicId);
+                   source.setSystemId(systemId);
+                }
+                return source;       
+            }
+        });
+        
+        builder.setErrorHandler(new ErrorHandler() {
+            public void error(SAXParseException exception) throws SAXException {
+                fail(fileName + ", " + exception.toString());
+            }
+            public void fatalError(SAXParseException exception)
+                    throws SAXException {
+                fail(fileName + ", " + exception.toString());
+            }
+            public void warning(SAXParseException exception)
+                    throws SAXException {
+                fail(fileName + ", " + exception.toString());
+            }
+        });
+        
+        return builder;
+    }
+    
+    
+}

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java
------------------------------------------------------------------------------
    svn:executable = *

Propchange: activemq/trunk/assembly/src/test/java/org/apache/activemq/config/ValidateXMLConfigTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



Mime
View raw message