You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2010/12/10 06:30:34 UTC

svn commit: r1044209 [2/2] - in /activemq/activemq-apollo/trunk: ./ apollo-broker/ apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/security/ apollo-cli/ apollo-cli/src/main/...

Copied: activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/WebAdminDTO.java (from r1043831, activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AuthorizerDTO.java)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/WebAdminDTO.java?p2=activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/WebAdminDTO.java&p1=activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AuthorizerDTO.java&r1=1043831&r2=1044209&rev=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/AuthorizerDTO.java (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/main/java/org/apache/activemq/apollo/dto/WebAdminDTO.java Fri Dec 10 05:30:31 2010
@@ -16,21 +16,32 @@
  */
 package org.apache.activemq.apollo.dto;
 
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.annotate.JsonTypeInfo;
-
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
-import javax.xml.bind.annotation.XmlSeeAlso;
-import javax.xml.bind.annotation.XmlType;
-import java.io.File;
+import javax.xml.bind.annotation.XmlElement;
+import java.util.HashSet;
+import java.util.Set;
 
 /**
+ * <p>
+ * </p>
+ *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@XmlType(name = "authorizer-type")
-//@XmlSeeAlso({xxx.class})
-@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
-public abstract class AuthorizerDTO {
+@XmlAccessorType(XmlAccessType.FIELD)
+public class WebAdminDTO {
+
+    @XmlAttribute
+    public Boolean enabled;
+
+    @XmlAttribute
+    public String host;
+
+    @XmlAttribute
+    public Integer port;
 
+    @XmlAttribute
+    public String prefix;
 
 }

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/test/java/org/apache/activemq/apollo/dto/XmlCodecTest.java Fri Dec 10 05:30:31 2010
@@ -41,6 +41,11 @@ public class XmlCodecTest {
         assertEquals("vh-local", dto.virtual_hosts.get(0).id);
         assertEquals("localhost", dto.virtual_hosts.get(0).host_names.get(0));
         assertEquals("example.com", dto.virtual_hosts.get(0).host_names.get(1));
+
+        assertNotNull(dto.acl);
+        assertTrue(dto.acl.admins.contains(new PrincipalDTO("hiram")));
+        assertTrue(dto.acl.admins.contains(new PrincipalDTO("james")));
+        assertTrue(dto.acl.admins.contains(new PrincipalDTO("admins", "org.apache.activemq.jaas.GroupPrincipal")));
     }
 
 

Modified: activemq/activemq-apollo/trunk/apollo-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-dto/src/test/resources/org/apache/activemq/apollo/dto/simple.xml Fri Dec 10 05:30:31 2010
@@ -16,9 +16,16 @@
     limitations under the License.
 -->
 <broker basedir="./activemq-data/default" rev="0" enabled="true" id="default" xmlns="http://activemq.apache.org/schema/activemq/apollo">
-    <virtual-host enabled="true" id="vh-local">
-        <host-name>localhost</host-name>
-        <host-name>example.com</host-name>
-    </virtual-host>
-    <connector bind="tcp://0.0.0.0:61616" enabled="true" id="port-61616"/>
+
+  <acl>
+    <admin name="hiram"/>
+    <admin name="james"/>
+    <admin name="admins" kind="org.apache.activemq.jaas.GroupPrincipal"/>
+  </acl>
+
+  <virtual-host enabled="true" id="vh-local">
+    <host-name>localhost</host-name>
+    <host-name>example.com</host-name>
+  </virtual-host>
+  <connector bind="tcp://0.0.0.0:61616" enabled="true" id="port-61616"/>
 </broker>

Modified: activemq/activemq-apollo/trunk/apollo-web/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/pom.xml?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-web/pom.xml Fri Dec 10 05:30:31 2010
@@ -80,14 +80,8 @@
     </dependency>
 
     <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty</artifactId>
-      <version>${jetty-version}</version>
-      <optional>true</optional>
-    </dependency>
-    <dependency>
-      <groupId>org.mortbay.jetty</groupId>
-      <artifactId>jetty-util</artifactId>
+      <groupId>org.eclipse.jetty.aggregate</groupId>
+      <artifactId>jetty-all-server</artifactId>
       <version>${jetty-version}</version>
       <optional>true</optional>
     </dependency>
@@ -121,6 +115,12 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>commons-codec</groupId>
+      <artifactId>commons-codec</artifactId>
+      <version>1.4</version>
+      <optional>true</optional>
+    </dependency>
 
     <dependency>
       <groupId>junit</groupId>

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloListener.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloListener.scala?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloListener.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ApolloListener.scala Fri Dec 10 05:30:31 2010
@@ -38,22 +38,16 @@ class ApolloListener extends ServletCont
       if( ConfigStore() == null ) {
         configStore = createConfigStore
         ConfigStore() = configStore
-        configStore.dispatchQueue {
-          configStore.listBrokers.foreach { id=>
-            configStore.getBroker(id, true).foreach{ config=>
+        val config = configStore.load(true)
 
-              println("Config store contained broker: "+config.id);
-              // Only start the broker up if it's enabled..
-              if( config.enabled.getOrElse(true) ) {
-
-                println("starting broker: "+config.id);
-                val broker = new Broker()
-                broker.config = config
-                BrokerRegistry.add(config.id, broker)
-                broker.start()
-              }
-            }
-          }
+        println("Config store contained broker: "+config.id);
+        // Only start the broker up if it's enabled..
+        if( config.enabled.getOrElse(true) ) {
+          println("starting broker: "+config.id);
+          val broker = new Broker()
+          broker.config = config
+          BrokerRegistry.add(config.id, broker)
+          broker.start()
         }
       }
     } catch {
@@ -63,18 +57,13 @@ class ApolloListener extends ServletCont
   }
 
   def contextDestroyed(sce: ServletContextEvent) = {
-    val tracker = new LoggingTracker("webapp shutdown")
     if( configStore!=null ) {
-      configStore.dispatchQueue {
-        configStore.listBrokers.foreach { id=>
-          val broker = BrokerRegistry.remove(id);
-          if( broker!=null ) {
-            tracker.stop(broker)
-          }
-        }
+      val id = configStore.load(false).id
+      val broker = BrokerRegistry.remove(id);
+      if( broker!=null ) {
+        ServiceControl.stop(broker, "broker")
       }
-      tracker.stop(configStore)
-      tracker.await
+      configStore.stop
       configStore = null
     }
   }
@@ -82,9 +71,7 @@ class ApolloListener extends ServletCont
   def createConfigStore():ConfigStore = {
     val store = new FileConfigStore
     store.file = new File("apollo.xml")
-    LoggingTracker("config store startup") { tracker=>
-      store.start(tracker.task())
-    }
+    store.start
     store
   }
 

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/ConfigurationResource.scala Fri Dec 10 05:30:31 2010
@@ -33,13 +33,12 @@ import org.apache.activemq.apollo.broker
 case class ConfigurationResource(parent:BrokerResource) extends Resource(parent) {
 
   lazy val config = {
-    ConfigStore.sync{ store=>
-      if( store.can_write ) {
-        store.getBroker(parent.id, false)
-      } else {
-        None
-      }
-    } .getOrElse(result(NOT_FOUND))
+    val store = ConfigStore()
+    if( store.can_write ) {
+      store.load(false)
+    } else {
+      None
+    }.getOrElse(result(NOT_FOUND))
   }
 
 
@@ -65,25 +64,12 @@ case class ConfigurationResource(parent:
 
   @PUT @Path("{rev}")
   def put(@PathParam("rev") rev:Int, config:BrokerDTO) = {
-    config.id = parent.id;
     config.rev = rev
-    ConfigStore.sync { store=>
-      if( store.can_write ) {
-        store.putBroker(config)
-      } else {
-        false
-      }
-    } || result(NOT_FOUND)
-  }
-
-  @DELETE @Path("{rev}")
-  def delete(@PathParam("rev") rev:Int) = {
-    ConfigStore.sync { store=>
-      if( store.can_write ) {
-        store.removeBroker(parent.id, rev)
-      } else {
-        false
-      }
+    val store = ConfigStore()
+    if( store.can_write ) {
+      store.store(config)
+    } else {
+      false
     } || result(NOT_FOUND)
   }
 

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala Fri Dec 10 05:30:31 2010
@@ -137,76 +137,31 @@ class ViewHelper {
 }
 
 /**
- * Index resource
+ * Manages a collection of broker resources.
  */
 @Path("/")
 @Produces(Array("application/json", "application/xml","text/xml", "text/html;qs=5"))
-class IndexResource() extends Resource {
+class BrokerResource extends Resource {
 
-  @GET
-  def get = {
-    val cs = ConfigStore()
-    val brokers = cs.dispatchQueue.sync {
-      cs.listBrokers
-    }
-    if( brokers.size==1 ) {
-      result(path("brokers/"+brokers.head+"/runtime"))
-    } else {
-      result(path("brokers"))
-    }
-  }
-
-  @Path("brokers{x:/?}")
-  def brokers = new RootResource(this)
-
-}
-
-
-/**
- * Manages a collection of broker resources.
- */
-class RootResource(parent:Resource) extends Resource(parent) {
-
-  @GET
-  def brokers = {
-    val rc = new StringIdListDTO
-    val cs = ConfigStore()
-    cs.dispatchQueue.sync {
-      cs.listBrokers.foreach { x=>
-        rc.items.add( new StringIdLabeledDTO(x,x) )
-      }
-    }
-    rc
-  }
-
-  @Path("{id}")
-  def broker(@PathParam("id") id : String): BrokerResource = {
-    new BrokerResource(this, id)
-  }
-}
-
-/**
- * Resource that identifies a managed broker.
- */
-case class BrokerResource(parent:Resource, @BeanProperty id: String) extends Resource(parent) {
+  val cs = ConfigStore()
+  val config = cs.load(false)
+  def id = config.id
 
   @GET
   def get = {
-    val cs = ConfigStore()
     val rc = new BrokerSummaryDTO
     rc.id = id
     rc.manageable = BrokerRegistry.get(id)!=null
-    rc.configurable = cs.dispatchQueue.sync{
-      cs.can_write && cs.getBroker(id,false).isDefined
-    }
+    rc.configurable = cs.can_write
     rc
   }
 
   @Path("config")
-  def config = ConfigurationResource(this)
+  def config_resource = ConfigurationResource(this)
 
   @Path("runtime")
   def runtime = RuntimeResource(this)
-
 }
 
+
+

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerSummaryDTO.jade
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerSummaryDTO.jade?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerSummaryDTO.jade (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/webapp/WEB-INF/org/apache/activemq/apollo/dto/BrokerSummaryDTO.jade Fri Dec 10 05:30:31 2010
@@ -13,10 +13,17 @@
 -# See the License for the specific language governing permissions and
 -# limitations under the License.
 
+- import it._
 - val helper = new org.apache.activemq.apollo.web.resources.ViewHelper
 - import helper._
 
-.breadcumbs
-  a(href={strip_resolve(".")}) Back
+h1 Broker: #{id}
+
+- if (manageable)
+  p
+    a(href={path("runtime")}) manage
+
+- if (configurable)
+  p
+    a(href={path("config")}) configuration
 
-.clear
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-web/src/test/scala/org/apache/activemq/apollo/web/FileConfigStoreTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/test/scala/org/apache/activemq/apollo/web/FileConfigStoreTest.scala?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/test/scala/org/apache/activemq/apollo/web/FileConfigStoreTest.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/test/scala/org/apache/activemq/apollo/web/FileConfigStoreTest.scala Fri Dec 10 05:30:31 2010
@@ -32,21 +32,14 @@ class FileConfigStoreTest extends FunSui
 
     val store = new FileConfigStore
     store.file = new File("activemq.xml")
-    store
 
-    LoggingTracker("config store startup") { tracker=>
-      store.start(tracker.task())
-    }
+    store.start
 
-    expect(List("default")) {
-      store.dispatchQueue.sync {
-        store.listBrokers
-      }
+    expect("default") {
+      store.load(false).id
     }
 
-    LoggingTracker("config store stop") { tracker=>
-      store.stop(tracker.task())
-    }
+    store.stop
   }
 }
 

Modified: activemq/activemq-apollo/trunk/apollo-website/src/main/webapp/documentation/getting-started.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-website/src/main/webapp/documentation/getting-started.md?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-website/src/main/webapp/documentation/getting-started.md (original)
+++ activemq/activemq-apollo/trunk/apollo-website/src/main/webapp/documentation/getting-started.md Fri Dec 10 05:30:31 2010
@@ -145,3 +145,12 @@ The consumer's output should look like:
     Received 1000 messages.
     Received 2000 messages.
     ...
+
+## Web Administration
+
+Apollo provides a simple web interface to monitor the status of the broker.  Once
+the admin interface will be accessible at:
+
+* [http://127.0.0.1:8080/](http://127.0.0.1:8080/)
+
+The default login id and password is `admin` and `password`.

Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1044209&r1=1044208&r2=1044209&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Fri Dec 10 05:30:31 2010
@@ -71,7 +71,7 @@
     <howl-version>0.1.8</howl-version>
     <hsqldb-version>1.7.2.2</hsqldb-version>
     <jdom-version>1.0</jdom-version>
-    <jetty-version>6.1.9</jetty-version>
+    <jetty-version>7.1.6.v20100715</jetty-version>
     <jmock-version>1.0.1</jmock-version>
     <junit-version>4.7</junit-version>
     <jxta-version>2.0</jxta-version>
@@ -102,8 +102,8 @@
     <hawtbuf-version>1.3-SNAPSHOT</hawtbuf-version>
     
     <bdb-version>4.1.6</bdb-version>
-    
-    <jetty-version>6.1.22</jetty-version>
+    <jasypt-version>1.6</jasypt-version>
+
     <scalate-version>1.3.2</scalate-version>
     <scalamd-version>1.2</scalamd-version>