activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1127956 - in /activemq/activemq-apollo/trunk: apollo-util/src/main/scala/org/apache/activemq/apollo/util/ apollo-web/src/main/resources/META-INF/services/ apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/ apollo-w...
Date Thu, 26 May 2011 15:10:23 GMT
Author: chirino
Date: Thu May 26 15:10:22 2011
New Revision: 1127956

URL: http://svn.apache.org/viewvc?rev=1127956&view=rev
Log:
Extension modules can now contribute resources to the web interface.  The broker resource
had to be relocated to /broker prefix.

Added:
    activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/
    activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/
    activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/modules.index
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ExtensionModule.scala
      - copied, changed from r1127908, activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Module.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala
    activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
    activemq/activemq-apollo/trunk/apollo-website/src/documentation/management-api.md

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Module.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Module.scala?rev=1127956&r1=1127955&r2=1127956&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Module.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/Module.scala
Thu May 26 15:10:22 2011
@@ -29,6 +29,7 @@ import Module._
  */
 abstract class Module {
   def xml_packages:Array[String] = Array()
+  def web_resources:Map[String, ()=>AnyRef] = Map()
 }
 
 /**

Added: activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/modules.index
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/modules.index?rev=1127956&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/modules.index
(added)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/resources/META-INF/services/org.apache.activemq.apollo/modules.index
Thu May 26 15:10:22 2011
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+org.apache.activemq.apollo.web.ExtensionModule
\ No newline at end of file

Copied: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ExtensionModule.scala
(from r1127908, 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/ExtensionModule.scala?p2=activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/ExtensionModule.scala&p1=activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/RootResource.scala&r1=1127908&r2=1127956&rev=1127956&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/ExtensionModule.scala
Thu May 26 15:10:22 2011
@@ -1,8 +1,4 @@
-package org.apache.activemq.apollo.web.resources
-
-import javax.ws.rs._
-import core.Response.Status._
-import com.sun.jersey.api.view.ImplicitProduces
+package org.apache.activemq.apollo.web
 
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
@@ -20,28 +16,14 @@ import com.sun.jersey.api.view.ImplicitP
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+import org.apache.activemq.apollo.util.Module
+import resources.BrokerResource
+
 /**
- *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
-@Path("/")
-case class RootResource() extends Resource() {
-
-  @GET
-  @Path("/")
-  @Produces(Array("application/json", "application/xml","text/xml","text/html"))
-  def post_connection_shutdown_and_redirect():Unit = {
-    result(strip_resolve("broker"))
-  }
-
-  @Path("{name}")
-  def path(@PathParam("name") name:String):AnyRef = {
-    name match {
-      case "broker" => new BrokerResource(this)
-      case _ =>
-        result(NOT_FOUND)
-    }
-
-  }
+class ExtensionModule extends Module {
 
-}
+  def create_broker_resource() = new BrokerResource
+  override def web_resources = Map("broker" -> create_broker_resource _ )
+}
\ No newline at end of file

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala?rev=1127956&r1=1127955&r2=1127956&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/BrokerResource.scala
Thu May 26 15:10:22 2011
@@ -37,7 +37,7 @@ import security.{SecurityContext, Author
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
  */
 @Produces(Array("application/json", "application/xml","text/xml", "text/html;qs=5"))
-case class BrokerResource(parent:Resource) extends Resource(parent) {
+case class BrokerResource extends Resource {
 
   @Path("config")
   def config_resource:ConfigurationResource = {

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=1127956&r1=1127955&r2=1127956&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
Thu May 26 15:10:22 2011
@@ -1,9 +1,3 @@
-package org.apache.activemq.apollo.web.resources
-
-import javax.ws.rs._
-import core.Response.Status._
-import com.sun.jersey.api.view.ImplicitProduces
-
 /**
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -20,6 +14,30 @@ import com.sun.jersey.api.view.ImplicitP
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.activemq.apollo.web.resources
+
+import javax.ws.rs._
+import core.Response.Status._
+import core.{UriInfo, Context}
+import org.apache.activemq.apollo.util.ModuleRegistry
+import collection.mutable.HashMap
+import javax.servlet.http.HttpServletRequest
+import com.sun.jersey.server.impl.ThreadLocalInvoker
+
+object RootResource {
+
+  // Load up all extension module web resources..
+  val web_resources:Map[String, ()=>AnyRef] = {
+    val rc = HashMap[String, ()=>AnyRef]()
+    for (m <- ModuleRegistry.singletons ) {
+      m.web_resources.foreach { case (key,value) =>
+        rc.put(key, value)
+      }
+    }
+    rc.toMap
+  }
+
+}
 /**
  *
  * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
@@ -27,6 +45,8 @@ import com.sun.jersey.api.view.ImplicitP
 @Path("/")
 case class RootResource() extends Resource() {
 
+  import RootResource._
+
   @GET
   @Path("/")
   @Produces(Array("application/json", "application/xml","text/xml","text/html"))
@@ -36,12 +56,26 @@ case class RootResource() extends Resour
 
   @Path("{name}")
   def path(@PathParam("name") name:String):AnyRef = {
-    name match {
-      case "broker" => new BrokerResource(this)
-      case _ =>
-        result(NOT_FOUND)
+
+    // Jersey's thread local wrapping messes /w us since we may use the http_request
+    // in a different thread.  Lets try to unwrap it..
+    try {
+      val invoker = java.lang.reflect.Proxy.getInvocationHandler(http_request).asInstanceOf[ThreadLocalInvoker[HttpServletRequest]]
+      http_request = invoker.get()
+    } catch {
+      case e:Throwable => e.printStackTrace()
     }
 
+    web_resources.get(name).map{func =>
+      val resource = func()
+      resource match {
+        case resource:Resource=>
+          // Wishing jersey would just re-inject the sub resources
+          resource.copy(this)
+        case _ =>
+      }
+      resource
+    }.getOrElse(result(NOT_FOUND))
   }
 
 }

Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala?rev=1127956&r1=1127955&r2=1127956&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/resources/Support.scala
Thu May 26 15:10:22 2011
@@ -70,7 +70,7 @@ object Resource {
  */
 @ImplicitProduces(Array("text/html;qs=5"))
 @Produces(Array("application/json", "application/xml","text/xml"))
-abstract class Resource(private val parent:Resource=null) extends Logging {
+abstract class Resource(parent:Resource=null) extends Logging {
   import Resource._
 
   @Context
@@ -79,15 +79,12 @@ abstract class Resource(private val pare
   var http_request: HttpServletRequest = null
 
   if( parent!=null ) {
-    this.uri_info = parent.uri_info
-    this.http_request = parent.http_request
+    copy(parent)
+  }
 
-    try {
-      val invoker = Proxy.getInvocationHandler(http_request).asInstanceOf[ThreadLocalInvoker[HttpServletRequest]]
-      http_request = invoker.get()
-    } catch {
-      case e:Throwable => e.printStackTrace()
-    }
+  def copy(other:Resource) = {
+    this.uri_info = other.uri_info
+    this.http_request = other.http_request
   }
 
   def result(value:Status, message:Any=null):Nothing = {

Modified: activemq/activemq-apollo/trunk/apollo-website/src/documentation/management-api.md
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-website/src/documentation/management-api.md?rev=1127956&r1=1127955&r2=1127956&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-website/src/documentation/management-api.md (original)
+++ activemq/activemq-apollo/trunk/apollo-website/src/documentation/management-api.md Thu
May 26 15:10:22 2011
@@ -22,7 +22,7 @@ user credentials which have administrati
 The user credentials should be supplied using via HTTP basic
 authentication. Example:
 
-    $ curl -u "admin:password" http://localhost:61680/
+    $ curl -u "admin:password" http://localhost:61680/broker
 
 ### JSON Representation
 
@@ -35,15 +35,15 @@ append `.json` to the URL to get the JSO
 Example:
 
     $ curl -H "Accept: application/json" -u "admin:password" \
-    http://localhost:61680/
+    http://localhost:61680/broker
 
-    $ curl -u "admin:password" http://localhost:61680/.json
+    $ curl -u "admin:password" http://localhost:61680/broker.json
 
 ### Broker Management
 
 The route for managing the broker is:
 
-    /
+    /broker
 
 Doing a GET against it will provide information about the broker's
 
@@ -55,7 +55,7 @@ Doing a GET against it will provide info
   
 Example:
 
-    $ curl -u "admin:password" http://localhost:61680/.json
+    $ curl -u "admin:password" http://localhost:61680/broker.json
 
 Results in a [Broker Status](./api/apollo-dto/org/apache/activemq/apollo/dto/BrokerStatusDTO.html)
:
 
@@ -82,12 +82,12 @@ Results in a [Broker Status](./api/apoll
 
 The route for managing a connector is:
 
-    /connectors/:id
+    /broker/connectors/:id
 
 Example:
 
     $ curl -u "admin:password"
-    http://localhost:61680/connectors/stomp.json
+    http://localhost:61680/broker/connectors/stomp.json
 
 Results in a [Connector Status](./api/apollo-dto/org/apache/activemq/apollo/dto/ConnectorStatusDTO.html):
 
@@ -108,12 +108,12 @@ Results in a [Connector Status](./api/ap
 
 The route for managing a connection is:
 
-    /connections/:id
+    /broker/connections/:id
 
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/connections/5.json
+    http://localhost:61680/broker/connections/5.json
 
 Results in a [Connection Status](./api/apollo-dto/org/apache/activemq/apollo/dto/ConnectionStatusDTO.html):
 
@@ -136,25 +136,25 @@ Results in a [Connection Status](./api/a
 
 To shutdown a connection send a POST to:
 
-    /connections/:id/action/shutdown
+    /broker/connections/:id/action/shutdown
 
 Example:
 
     curl -X POST -u "admin:password" \
-    http://localhost:61680/connections/5/action/shutdown.json
+    http://localhost:61680/broker/connections/5/action/shutdown.json
 
 
 ### Virtual Host Management
 
 The route for managing a virtual host is:
 
-    /virtual-hosts/:name
+    /broker/virtual-hosts/:name
 
 Where `:name` is the id of a virtual host configured in the broker.
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/virtual-hosts/localhost.json
+    http://localhost:61680/broker/virtual-hosts/localhost.json
 
 Results in a [Virtual Host Status](./api/apollo-dto/org/apache/activemq/apollo/dto/VirtualHostStatusDTO.html):
 
@@ -179,14 +179,14 @@ Results in a [Virtual Host Status](./api
 
 The route for managing a virtual host's Store is:
 
-    /virtual-hosts/:name/store
+    /broker/virtual-hosts/:name/store
 
 Where `:name` is the id of a virtual host configured in the broker.
 
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/virtual-hosts/localhost/store.json
+    http://localhost:61680/broker/virtual-hosts/localhost/store.json
 
 Results in a [Store Status](./api/apollo-dto/org/apache/activemq/apollo/dto/StoreStatusDTO.html):
 
@@ -227,7 +227,7 @@ Results in a [Store Status](./api/apollo
 
 The route for managing a virtual host's Queue is:
 
-    /virtual-hosts/:name/queues/:qid
+    /broker/virtual-hosts/:name/queues/:qid
 
 Where `:name` is the id of a virtual host configured in the broker and `:qid` is the id
 of the queue.
@@ -235,7 +235,7 @@ of the queue.
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/virtual-hosts/localhost/queues/1.json
+    http://localhost:61680/broker/virtual-hosts/localhost/queues/1.json
 
 Results in a [Queue Status](./api/apollo-dto/org/apache/activemq/apollo/dto/QueueStatusDTO.html):
 
@@ -311,7 +311,7 @@ Results in a [Queue Status](./api/apollo
 
 The route for managing a virtual host's Topic is:
 
-    /virtual-hosts/:name/topics/:tid
+    /broker/virtual-hosts/:name/topics/:tid
 
 Where `:name` is the id of a virtual host configured in the broker and `:tid` is the id
 of the topic.
@@ -319,7 +319,7 @@ of the topic.
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/virtual-hosts/localhost/topics/1.json
+    http://localhost:61680/broker/virtual-hosts/localhost/topics/1.json
 
 Results in a [Topic Status](./api/apollo-dto/org/apache/activemq/apollo/dto/TopicStatusDTO.html):
 
@@ -355,12 +355,12 @@ Results in a [Topic Status](./api/apollo
 
 To get current runtime configuration of the broker GET:
 
-    /config/runtime
+    /broker/config/runtime
 
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/config/runtime.json
+    http://localhost:61680/broker/config/runtime.json
 
 Results in a [Broker Configuration](./api/apollo-dto/org/apache/activemq/apollo/dto/BrokerDTO.html):
 
@@ -454,13 +454,13 @@ Results in a [Broker Configuration](./ap
 You can get aggregate queue statistics at either the broker or virtual host level by
 using one of the following URL routes:
 
-    /queue-metrics
-    /virtual-hosts/:name/queue-metrics
+    /broker/queue-metrics
+    /broker/virtual-hosts/:name/queue-metrics
 
 Example:
 
     $ curl -u "admin:password" \
-    http://localhost:61680/queue-metrics.json
+    http://localhost:61680/broker/queue-metrics.json
 
 Results in an [Aggregate of Queue Metrics](./api/apollo-dto/org/apache/activemq/apollo/dto/AggregateQueueMetricsDTO.html):
 



Mime
View raw message