activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1234346 - in /activemq/activemq-apollo/trunk: ./ apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-distro/src/main/descriptors/ apollo-distro/src/main/release/examples/java-embedded-broker/ apollo-distro/src/main/relea...
Date Sat, 21 Jan 2012 15:29:16 GMT
Author: chirino
Date: Sat Jan 21 15:29:16 2012
New Revision: 1234346

URL: http://svn.apache.org/viewvc?rev=1234346&view=rev
Log:
APLO-135 - Add example to the distro that shows how you can boot up an embedded broker in
a Java app.

Added:
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/pom.xml
      - copied, changed from r1234345, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/readme.md
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/EmbeddedBroker.java
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/log4j.properties
Modified:
    activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
    activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/unix-bin.xml
    activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/windows-bin.xml
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml
    activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/readme.md
    activemq/activemq-apollo/trunk/pom.xml

Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
Sat Jan 21 15:29:16 2012
@@ -35,6 +35,8 @@ import javax.management.ObjectName
 import org.fusesource.hawtdispatch.TaskTracker._
 import java.util.concurrent.TimeUnit
 import security.SecuredResource.BrokerKind
+import reflect.BeanProperty
+
 /**
  * <p>
  * The BrokerFactory creates Broker objects from a URI.
@@ -217,9 +219,12 @@ class Broker() extends BaseService with 
 
   import Broker._
 
+  @BeanProperty
   var tmp: File = _
 
+  @BeanProperty
   var config: BrokerDTO = new BrokerDTO
+
   config.virtual_hosts.add({
     val rc = new VirtualHostDTO
     rc.id = "default"

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/unix-bin.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/unix-bin.xml?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/unix-bin.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/unix-bin.xml Sat Jan
21 15:29:16 2012
@@ -22,15 +22,19 @@
   </formats>
 
   <fileSets>
+
     <!-- Copy over everything that needs to get unix line endings -->
     <fileSet>
       <directory>src/main/release</directory>
       <outputDirectory>/</outputDirectory>
       <excludes>
-        <exclude>bin/**</exclude>
+        <exclude>bin/**</exclude> <!-- Exclude windows bits. -->
+        <exclude>**/pom.xml</exclude> <!-- Needs filtering -->
       </excludes>
       <lineEnding>unix</lineEnding>
     </fileSet>
+    
+    <!-- Copy the unix scripts .. chmod 755 and exclude the windows bits-->
     <fileSet>
       <directory>src/main/release/bin</directory>
       <outputDirectory>/bin</outputDirectory>
@@ -41,32 +45,16 @@
         <exclude>*.cmd</exclude>
       </excludes>
     </fileSet>
-
+    
+    <!-- filtered files --> 
     <fileSet>
-      <directory>..</directory>
+      <directory>src/main/release</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>*.txt</include>
-      </includes>
-      <lineEnding>unix</lineEnding>
-    </fileSet>
-
-    <!-- copy the examples -->
-    <fileSet>
-      <directory>../samples</directory>
-      <outputDirectory>/samples</outputDirectory>
-      <includes>
-        <include>pom.xml</include>
         <include>**/pom.xml</include>
-        <include>**/run</include>
-        <include>*/src/**</include>
       </includes>
-      <excludes>
-        <exclude>target</exclude>
-        <exclude>**/target</exclude>
-        <exclude>**/target/**</exclude>
-      </excludes>
       <lineEnding>unix</lineEnding>
+      <filtered>true</filtered>
     </fileSet>
 
   </fileSets>

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/windows-bin.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/windows-bin.xml?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/windows-bin.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/windows-bin.xml Sat
Jan 21 15:29:16 2012
@@ -27,10 +27,13 @@
       <directory>src/main/release</directory>
       <outputDirectory>/</outputDirectory>
       <excludes>
-        <exclude>bin/**</exclude>
+        <exclude>bin/**</exclude> <!-- Exclude unix bits. -->
+        <exclude>**/pom.xml</exclude> <!-- Needs filtering -->
       </excludes>
       <lineEnding>dos</lineEnding>
     </fileSet>
+    
+    <!-- Copy the windows scripts .. exclude the unix bits-->
     <fileSet>
       <directory>src/main/release/bin</directory>
       <outputDirectory>/bin</outputDirectory>
@@ -41,32 +44,15 @@
       </includes>
     </fileSet>
 
+    <!-- filtered files --> 
     <fileSet>
-      <directory>..</directory>
+      <directory>src/main/release</directory>
       <outputDirectory>/</outputDirectory>
       <includes>
-        <include>*.txt</include>
-      </includes>
-      <lineEnding>dos</lineEnding>
-    </fileSet>
-
-    <!-- copy the examples -->
-
-    <fileSet>
-      <directory>../samples</directory>
-      <outputDirectory>/samples</outputDirectory>
-      <includes>
-        <include>pom.xml</include>
         <include>**/pom.xml</include>
-        <include>**/run</include>
-        <include>*/src/**</include>
       </includes>
-      <excludes>
-        <exclude>target</exclude>
-        <exclude>**/target</exclude>
-        <exclude>**/target/**</exclude>
-      </excludes>
-      <lineEnding>dos</lineEnding>
+      <lineEnding>unix</lineEnding>
+      <filtered>true</filtered>
     </fileSet>
 
   </fileSets>

Copied: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/pom.xml
(from r1234345, activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/pom.xml?p2=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/pom.xml&p1=activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml&r1=1234345&r2=1234346&rev=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/pom.xml
Sat Jan 21 15:29:16 2012
@@ -20,30 +20,38 @@
   <modelVersion>4.0.0</modelVersion>
   
   <groupId>example</groupId>
-  <artifactId>example</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <artifactId>example-embedded-broker</artifactId>
+  <version>0.1-SNAPSHOT</version>
   
-  <name>${project.artifactId}</name>
-  <description>Apollo Java Examples</description>
+  <name>example-embedded-broker</name>
+  <description>Apollo Java Embedded Broker Example</description>
 
-  <repositories>
-    <repository>
-      <id>Fusesource Snapshots</id>
-      <url>http://repo.fusesource.com/nexus/content/repositories/snapshots</url>
-    </repository>
-  </repositories>
-  
   <dependencies>
     
     <dependency>
-      <groupId>org.apache.geronimo.specs</groupId>
-      <artifactId>geronimo-jms_1.1_spec</artifactId>
-      <version>1.1</version>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-broker</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-stomp</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-leveldb</artifactId>
+      <version>${project.version}</version>
     </dependency>
     <dependency>
-      <groupId>org.fusesource.stompjms</groupId>
-      <artifactId>stompjms-client</artifactId>
-      <version>1.7</version>
+      <groupId>org.apache.activemq</groupId>
+      <artifactId>apollo-web</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <version>${slf4j-version}</version>
     </dependency>
 
   </dependencies>
@@ -55,24 +63,10 @@
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.1</version>
         <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
+          <source>1.6</source>
+          <target>1.6</target>
         </configuration>
       </plugin>
-
-      <!-- include all the dependencies into the jar so it's easier to execute the example
-->
-      <plugin>
-        <groupId>org.fusesource.mvnplugins</groupId>
-        <artifactId>maven-uberize-plugin</artifactId>
-        <version>1.14</version>
-        <executions>
-          <execution>
-            <phase>package</phase>
-            <goals><goal>uberize</goal></goals>
-          </execution>
-        </executions>
-      </plugin>
-      
     </plugins>
   </build>
   

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/readme.md?rev=1234346&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/readme.md
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/readme.md
Sat Jan 21 15:29:16 2012
@@ -0,0 +1,21 @@
+## Overview
+
+This is an example of how you can embed Apollo inside your Java application.
+
+## Prereqs
+
+- Install a Java SDK
+- Install [Maven](http://maven.apache.org/download.html) 
+
+## Building
+
+Run:
+
+    mvn install
+
+## Running the Example
+
+In a terminal window run:
+
+    java -cp '../../lib/*':target/classes example.EmbeddedBroker
+

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/EmbeddedBroker.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/EmbeddedBroker.java?rev=1234346&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/EmbeddedBroker.java
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/java/example/EmbeddedBroker.java
Sat Jan 21 15:29:16 2012
@@ -0,0 +1,122 @@
+/**
+ * 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 example;
+
+import org.apache.activemq.apollo.broker.Broker;
+import org.apache.activemq.apollo.broker.store.leveldb.dto.*;
+import org.apache.activemq.apollo.dto.*;
+
+import java.io.File;
+
+/**
+ * Example of how to setup an embedded broker.
+ */
+public class EmbeddedBroker {
+
+    public static void main(String[] args) throws Exception {
+
+        //
+        // Creating and initially configuring the broker.
+        Broker broker = new Broker();
+        broker.setTmp(new File("./tmp"));
+        broker.setConfig(createConfig());
+
+        //
+        // The broker starts asynchronously. The runnable is invoked once
+        // the broker if fully started.
+        System.out.println("Starting the broker.");
+        broker.start(new Runnable(){
+            public void run() {
+                System.out.println("The broker has now started.");
+                System.out.println("Press enter to change the broker port...");
+            }
+        });
+
+        System.in.read();
+        System.out.println("Updating the broker configuration.");
+        
+        //
+        // The configuration update also occurs asnyc.
+        broker.update(createUpdate(), new Runnable() {
+            public void run() {
+                System.out.println("The configuration has been applied.");
+                System.out.println("Press enter to stop the broker...");
+            }
+        });
+
+        System.in.read();
+        System.out.println("Stopping the broker.");
+        
+        //
+        // The broker stops asynchronously. The runnable is invoked once
+        // the broker if fully stopped.
+        broker.stop(new Runnable(){
+            public void run() {
+                System.out.println("The broker has now stopped.");
+            }
+        });
+        
+    }
+
+    /**
+     * Builds a simple configuration model with just plain Java.  Corresponds 1 to 1 with
+     * the XML configuration model.  See the Apollo user guide for more details.
+     * @return
+     */
+    private static BrokerDTO createConfig() {
+        BrokerDTO broker = new BrokerDTO();
+
+        // Brokers support multiple virtual hosts.
+        VirtualHostDTO host = new VirtualHostDTO();
+        host.id = "localhost";
+        host.host_names.add("localhost");
+        host.host_names.add("127.0.0.1");
+
+        // The message store is configured on the virtual host.
+        LevelDBStoreDTO store = new LevelDBStoreDTO();
+        store.directory = new File("./data");
+        host.store = store;
+
+        broker.virtual_hosts.add(host);
+
+        //
+        // Control which ports and protocols the broker binds and accepts
+        AcceptingConnectorDTO connector = new AcceptingConnectorDTO();
+        connector.id = "tcp";
+        connector.bind = "tcp://0.0.0.0:61613";
+        broker.connectors.add(connector);
+
+        //
+        // Fires up the web admin console on HTTP.
+        WebAdminDTO webadmin = new WebAdminDTO();
+        webadmin.bind = "http://0.0.0.0:8080";
+        broker.web_admins.add(webadmin);
+
+        return broker;
+    }
+
+    private static BrokerDTO createUpdate() {
+        BrokerDTO broker = createConfig();
+
+        // Lets change the port.
+        AcceptingConnectorDTO connector = (AcceptingConnectorDTO) broker.connectors.get(0);
+        connector.bind = "tcp://0.0.0.0:61614";
+
+        return broker;
+    }
+
+}

Added: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/log4j.properties?rev=1234346&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/log4j.properties
(added)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java-embedded-broker/src/main/resources/log4j.properties
Sat Jan 21 15:29:16 2012
@@ -0,0 +1,37 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# Setup the default logging levels
+#
+log4j.rootLogger=ERROR
+log4j.logger.org.apache.activemq.apollo=INFO, console
+
+#
+# Uncomment one of the following to enable debug logging
+#
+# log4j.logger.org.apache.activemq.apollo.broker=DEBUG
+# log4j.logger.org.apache.activemq.apollo.broker.store=DEBUG
+# log4j.logger.org.apache.activemq.apollo.stomp=DEBUG
+# log4j.logger.org.apache.activemq.apollo.web=DEBUG
+# log4j.logger.org.apache.activemq.apollo.cli=DEBUG
+
+# Console Settings
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p | %m%n
+log4j.appender.console.threshold=INFO

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/pom.xml Sat
Jan 21 15:29:16 2012
@@ -21,9 +21,9 @@
   
   <groupId>example</groupId>
   <artifactId>example</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <version>0.1-SNAPSHOT</version>
   
-  <name>${project.artifactId}</name>
+  <name>example</name>
   <description>Apollo Java Examples</description>
 
   <repositories>
@@ -43,7 +43,7 @@
     <dependency>
       <groupId>org.fusesource.stompjms</groupId>
       <artifactId>stompjms-client</artifactId>
-      <version>1.7</version>
+      <version>${stompjms-version}</version>
     </dependency>
 
   </dependencies>
@@ -55,8 +55,8 @@
         <artifactId>maven-compiler-plugin</artifactId>
         <version>2.1</version>
         <configuration>
-          <source>1.5</source>
-          <target>1.5</target>
+          <source>1.6</source>
+          <target>1.6</target>
         </configuration>
       </plugin>
 

Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/readme.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/readme.md?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/readme.md
(original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/release/examples/java/readme.md
Sat Jan 21 15:29:16 2012
@@ -1,18 +1,19 @@
-Prereqs
-=======
+## Overview
+
+This is an example of how use the Java JMS api with Apollo.
+
+## Prereqs
 
 - Install Java SDK
 - Install [Maven](http://maven.apache.org/download.html) 
 
-Building
-========
+## Building
 
 Run:
 
     mvn install
 
-Running the Examples
-====================
+## Running the Examples
 
 In one terminal window run:
 

Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1234346&r1=1234345&r2=1234346&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Sat Jan 21 15:29:16 2012
@@ -98,6 +98,7 @@
 
     <hawtdispatch-version>1.7</hawtdispatch-version>
     <hawtbuf-version>1.8</hawtbuf-version>
+    <stompjms-version>1.7</stompjms-version>
     
     <jdbm-version>2.0.1</jdbm-version>
     <bdb-version>4.1.10</bdb-version>



Mime
View raw message