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 2012/11/27 18:47:13 UTC
svn commit: r1414285 - in /activemq/activemq-apollo/trunk: ./
apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/ apollo-cli/
apollo-distro/ apollo-distro/src/main/descriptors/ apollo-jmx/
apollo-jmx/src/ apollo-jmx/src/main/ apollo-jmx/src...
Author: chirino
Date: Tue Nov 27 17:47:09 2012
New Revision: 1414285
URL: http://svn.apache.org/viewvc?rev=1414285&view=rev
Log:
Fixes APLO-271: Integrate jolokia into Apollo for nice REST based access to JMX.
Added:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/PluginStateSupport.scala
activemq/activemq-apollo/trunk/apollo-jmx/
activemq/activemq-apollo/trunk/apollo-jmx/pom.xml (with props)
activemq/activemq-apollo/trunk/apollo-jmx/src/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/web-module.index
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxResource.scala
activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxWebModule.scala
activemq/activemq-apollo/trunk/apollo-jmx/src/test/
activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/
activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties (with props)
Modified:
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/Broker.scala
activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala
activemq/activemq-apollo/trunk/apollo-cli/pom.xml
activemq/activemq-apollo/trunk/apollo-distro/pom.xml
activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala
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=1414285&r1=1414284&r2=1414285&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 Tue Nov 27 17:47:09 2012
@@ -250,7 +250,7 @@ object Broker extends Log {
*
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
-class Broker() extends BaseService with SecuredResource {
+class Broker() extends BaseService with SecuredResource with PluginStateSupport {
import Broker._
Added: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/PluginStateSupport.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/PluginStateSupport.scala?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/PluginStateSupport.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/PluginStateSupport.scala Tue Nov 27 17:47:09 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.apollo.broker
+
+import java.util.concurrent.ConcurrentHashMap
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+trait PluginStateSupport {
+
+ private val _plugin_state = new ConcurrentHashMap[Class[_], Any]()
+
+ /**
+ * Plugins can associate state data with the virtual host instance
+ * using this method. The factory will be used to create the state
+ * if it does not yet exist.
+ */
+ def plugin_state[T](factory: =>T, clazz:Class[T]):T = {
+ var state = _plugin_state.get(clazz).asInstanceOf[T]
+ if( state == null ) {
+ state = factory
+ if( state != null ) {
+ _plugin_state.put(clazz, state)
+ }
+ }
+ state
+ }
+
+ /**
+ * Used to clear out previously set plugin state.
+ */
+ def clear_plugin_state[T](clazz:Class[T]):T = {
+ _plugin_state.remove(clazz).asInstanceOf[T]
+ }
+
+}
\ No newline at end of file
Modified: activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-broker/src/main/scala/org/apache/activemq/apollo/broker/VirtualHost.scala Tue Nov 27 17:47:09 2012
@@ -82,7 +82,7 @@ object VirtualHost extends Log {
/**
* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
*/
-class VirtualHost(val broker: Broker, val id:String) extends BaseService with SecuredResource {
+class VirtualHost(val broker: Broker, val id:String) extends BaseService with SecuredResource with PluginStateSupport {
import VirtualHost._
override val dispatch_queue:DispatchQueue = createQueue("virtual-host")
@@ -111,31 +111,6 @@ class VirtualHost(val broker: Broker, va
var direct_buffer_allocator:DirectBufferAllocator = null
- private val _plugin_state = new ConcurrentHashMap[Class[_], Any]()
-
- /**
- * Plugins can associate state data with the virtual host instance
- * using this method. The factory will be used to create the state
- * if it does not yet exist.
- */
- def plugin_state[T](factory: =>T, clazz:Class[T]):T = {
- var state = _plugin_state.get(clazz).asInstanceOf[T]
- if( state == null ) {
- state = factory
- if( state != null ) {
- _plugin_state.put(clazz, state)
- }
- }
- state
- }
-
- /**
- * Used to clear out previously set plugin state.
- */
- def clear_plugin_state[T](clazz:Class[T]):T = {
- _plugin_state.remove(clazz).asInstanceOf[T]
- }
-
def resource_kind = VirtualHostKind
@volatile
Modified: activemq/activemq-apollo/trunk/apollo-cli/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-cli/pom.xml?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-cli/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-cli/pom.xml Tue Nov 27 17:47:09 2012
@@ -164,6 +164,12 @@
<dependency>
<groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-jmx</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
<artifactId>apollo-bdb</artifactId>
<version>99-trunk-SNAPSHOT</version>
<scope>test</scope>
Modified: activemq/activemq-apollo/trunk/apollo-distro/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/pom.xml?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/pom.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/pom.xml Tue Nov 27 17:47:09 2012
@@ -92,6 +92,11 @@
<version>99-trunk-SNAPSHOT</version>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-jmx</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ </dependency>
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
Modified: activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml (original)
+++ activemq/activemq-apollo/trunk/apollo-distro/src/main/descriptors/common-bin.xml Tue Nov 27 17:47:09 2012
@@ -59,7 +59,8 @@
<!-- for the webapp -->
<include>org.eclipse.jetty.aggregate:jetty-all-server</include>
- <include>javax.servlet:servlet-api</include>
+ <include>org.eclipse.jetty.orbit:javax.servlet</include>
+
<include>javax.servlet.jsp:jsp-api</include>
<include>com.sun.jersey:jersey-server</include>
<include>com.sun.jersey:jersey-core</include>
@@ -75,7 +76,11 @@
<!-- still needed by swagger -->
<include>org.codehaus.jackson:jackson-mapper-asl</include>
<include>org.codehaus.jackson:jackson-core-asl</include>
-
+
+ <!-- for JMX over REST support -->
+ <include>org.jolokia:jolokia-core</include>
+ <include>com.googlecode.json-simple:json-simple</include>
+
<!-- the logging apis used -->
<include>org.slf4j:slf4j-api</include>
<include>commons-logging:commons-logging</include>
@@ -89,7 +94,7 @@
<include>org.apache.activemq:activemq-jmdns_1.0</include>
<include>org.apache.commons:commons-math</include>
<include>org.fusesource.stompjms:stompjms-client</include>
- <include>org.apache.qpid:qpid-proton</include>
+ <include>org.apache.qpid:proton</include>
</includes>
<excludes>
Added: activemq/activemq-apollo/trunk/apollo-jmx/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jmx/pom.xml?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jmx/pom.xml (added)
+++ activemq/activemq-apollo/trunk/apollo-jmx/pom.xml Tue Nov 27 17:47:09 2012
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-scala</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <relativePath>../apollo-scala</relativePath>
+ </parent>
+
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-jmx</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>${project.artifactId}</name>
+ <description>JMX integration for Apollo</description>
+
+ <dependencies>
+
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-broker</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jolokia</groupId>
+ <artifactId>jolokia-core</artifactId>
+ <version>${jolokia-version}</version>
+ </dependency>
+
+ <!-- Since we implement a jade template to display the LevelDB status -->
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-web</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.orbit</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>${servlet-api-version}</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Scala Support -->
+ <dependency>
+ <groupId>org.scala-lang</groupId>
+ <artifactId>scala-library</artifactId>
+ <scope>compile</scope>
+ <version>${scala-version}</version>
+ </dependency>
+
+ <!-- Testing Dependencies -->
+ <dependency>
+ <groupId>org.scalatest</groupId>
+ <artifactId>scalatest_2.9.2</artifactId>
+ <version>${scalatest-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-broker</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.activemq</groupId>
+ <artifactId>apollo-util</artifactId>
+ <version>99-trunk-SNAPSHOT</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ <version>${junit-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>${slf4j-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+
+ <!-- <plugin>
+ <groupId>org.fusesource.mvnplugins</groupId>
+ <artifactId>maven-fab-plugin</artifactId>
+ <version>${maven-fab-plugin-version}</version>
+ <configuration>
+ <descriptor>
+ <Name>leveldb</Name>
+ <Long-Description></Long-Description>
+ <Extends>${project.groupId}:apollo-cli:${project.version}</Extends>
+ </descriptor>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin> -->
+
+ <plugin>
+ <groupId>org.fusesource.scalate</groupId>
+ <artifactId>maven-scalate-plugin</artifactId>
+ <version>${scalate-version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>precompile</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
Propchange: activemq/activemq-apollo/trunk/apollo-jmx/pom.xml
------------------------------------------------------------------------------
svn:executable = *
Added: activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/web-module.index
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/web-module.index?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/web-module.index (added)
+++ activemq/activemq-apollo/trunk/apollo-jmx/src/main/resources/META-INF/services/org.apache.activemq.apollo/web-module.index Tue Nov 27 17:47:09 2012
@@ -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.broker.jmx.JmxWebModule
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxResource.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxResource.scala?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxResource.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxResource.scala Tue Nov 27 17:47:09 2012
@@ -0,0 +1,102 @@
+/**
+ * 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.apollo.broker.jmx
+
+import org.apache.activemq.apollo.web.resources.Resource
+import javax.ws.rs._
+import scala.Array
+import javax.ws.rs.core.MediaType._
+import core.{Response, Context}
+import javax.servlet.http.{HttpServletRequestWrapper, HttpServletResponse, HttpServletRequest}
+import org.jolokia.http.AgentServlet
+import org.apache.activemq.apollo.broker.Broker
+import collection.mutable.HashMap
+import org.apache.activemq.apollo.web.CustomServletConfig
+import javax.servlet.ServletContext
+import com.sun.jersey.server.impl.ThreadLocalInvoker
+import org.apache.activemq.apollo.util._
+import org.fusesource.hawtdispatch._
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+
+@Path("/jmx")
+@Produces(Array(APPLICATION_JSON))
+case class JmxResource()extends Resource() {
+
+ @GET @Path("{path:.*}")
+ def get(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+ @POST @Path("{path:.*}")
+ def post(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+ @PUT @Path("{path:.*}")
+ def put(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+ @DELETE @Path("{path:.*}")
+ def delete(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+ @OPTIONS @Path("{path:.*}")
+ def options(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+ @HEAD @Path("{path:.*}")
+ def head(@Context ctx:ServletContext, @Context req:HttpServletRequest, @Context resp:HttpServletResponse, @PathParam("path") path:String) = invoke(ctx, req, resp, path)
+
+ def create_servlet(ctx:ServletContext, broker:Broker):AgentServlet = {
+ val settings = new HashMap[String, String]
+ settings.put("mimeType", "application/json")
+ val rc = new AgentServlet
+ rc.init(CustomServletConfig("AgentServlet", ctx, settings))
+ rc
+ }
+
+ def invoke(ctx:ServletContext, req:HttpServletRequest, resp:HttpServletResponse, path:String):String = {
+
+ // Jersey's thread local wrapping messes /w us since we use the http_request
+ // in a different threads. Lets try to unwrap it..
+ val unwrapped_req = try {
+ java.lang.reflect.Proxy.getInvocationHandler(req).asInstanceOf[ThreadLocalInvoker[HttpServletRequest]].get()
+ } catch {
+ case e:Throwable =>
+ req
+ }
+
+ val unwrapped_resp = try {
+ java.lang.reflect.Proxy.getInvocationHandler(resp).asInstanceOf[ThreadLocalInvoker[HttpServletResponse]].get()
+ } catch {
+ case e:Throwable =>
+ resp
+ }
+
+ val wrapped_req = new HttpServletRequestWrapper(unwrapped_req) {
+ override def getPathInfo = path
+ }
+
+
+ FutureResult.unwrap_future_result[Void] {
+ with_broker { broker =>
+ admining(broker) {
+ val rc = FutureResult[Void]()
+ Broker.BLOCKABLE_THREAD_POOL {
+ val servlet = broker.plugin_state(create_servlet(ctx, broker), classOf[AgentServlet])
+ servlet.service(wrapped_req, unwrapped_resp)
+ rc.set(Success(null))
+ }
+ rc
+ }
+ }
+ }
+ ""
+ }
+
+}
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxWebModule.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxWebModule.scala?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxWebModule.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-jmx/src/main/scala/org/apache/activemq/apollo/broker/jmx/JmxWebModule.scala Tue Nov 27 17:47:09 2012
@@ -0,0 +1,34 @@
+/**
+ * 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.apollo.broker.jmx
+
+import org.apache.activemq.apollo.web.WebModule
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+
+object JmxWebModule extends WebModule {
+
+ def root_redirect: String = "broker"
+ def priority: Int = 50
+
+ override def web_resources = Set(
+ classOf[JmxResource]
+ )
+
+}
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties?rev=1414285&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties (added)
+++ activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties Tue Nov 27 17:47:09 2012
@@ -0,0 +1,35 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used during tests..
+#
+log4j.rootLogger=WARN, console, file
+log4j.logger.org.apache.activemq=TRACE
+
+# Console will only display warnnings
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%-5p | %t | %m%n
+log4j.appender.console.threshold=TRACE
+
+# File appender will contain all info messages
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d | %-5p | %m | %c | %t%n
+log4j.appender.file.file=${basedir}/target/test.log
+log4j.appender.file.append=true
Propchange: activemq/activemq-apollo/trunk/apollo-jmx/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:executable = *
Modified: activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-web/src/main/scala/org/apache/activemq/apollo/web/JerseyServlet.scala Tue Nov 27 17:47:09 2012
@@ -30,47 +30,37 @@ import collection.mutable.HashMap
*/
class JerseyServlet extends ServletContainer {
- var original_config: ServletConfig = _
- var custom_config_map = HashMap[String, String]()
- val custom_config: ServletConfig = new ServletConfig {
-
- def getServletName: String = {
- return original_config.getServletName
- }
-
- def getServletContext: ServletContext = {
- return original_config.getServletContext
- }
-
- def getInitParameterNames: Enumeration[String] = {
- import collection.JavaConversions._
- return new java.util.Vector(custom_config_map.keys).elements();
- }
-
- def getInitParameter(s: String): String = {
- return custom_config_map.get(s).getOrElse(null)
- }
-
- }
-
override def init(config: ServletConfig): Unit = {
com.wordnik.swagger.jaxrs.JaxrsApiReader.setFormatString("")
- original_config = config
- custom_config_map.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.ClassNamesResourceConfig")
- custom_config_map.put("com.sun.jersey.config.property.classnames", WebModule.web_resources.map(_.getName).mkString(" "))
- custom_config_map.put("com.sun.jersey.config.feature.Trace", System.getProperty("com.sun.jersey.config.feature.Trace", "false"))
- custom_config_map.put("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.PostReplaceFilter")
- custom_config_map.put("com.sun.jersey.config.feature.Redirect", "true")
- custom_config_map.put("com.sun.jersey.config.feature.FilterForwardOn404", "true")
- custom_config_map.put("com.sun.jersey.config.feature.ImplicitViewables", "true")
- custom_config_map.put("com.sun.jersey.config.property.MediaTypeMappings", """
+ val settings = new HashMap[String, String]
+ settings.put("com.sun.jersey.config.property.resourceConfigClass", "com.sun.jersey.api.core.ClassNamesResourceConfig")
+ settings.put("com.sun.jersey.config.property.classnames", WebModule.web_resources.map(_.getName).mkString(" "))
+ settings.put("com.sun.jersey.config.feature.Trace", System.getProperty("com.sun.jersey.config.feature.Trace", "false"))
+ settings.put("com.sun.jersey.spi.container.ContainerRequestFilters", "com.sun.jersey.api.container.filter.PostReplaceFilter")
+ settings.put("com.sun.jersey.config.feature.Redirect", "true")
+ settings.put("com.sun.jersey.config.feature.FilterForwardOn404", "true")
+ settings.put("com.sun.jersey.config.feature.ImplicitViewables", "true")
+ settings.put("com.sun.jersey.config.property.MediaTypeMappings", """
html : text/html,
xml : application/xml,
json : application/json
""")
- super.init(custom_config)
+ super.init(CustomServletConfig(config.getServletName, config.getServletContext, settings))
+ }
+
+}
+
+case class CustomServletConfig(name:String, context:ServletContext, custom_config_map:HashMap[String, String]) extends ServletConfig {
+ def getServletName: String = name
+ def getServletContext: ServletContext = context
+ def getInitParameterNames: Enumeration[String] = {
+ import collection.JavaConversions._
+ return new java.util.Vector(custom_config_map.keys).elements();
+ }
+ def getInitParameter(s: String): String = {
+ return custom_config_map.get(s).getOrElse(null)
}
+}
-}
\ No newline at end of file
Modified: activemq/activemq-apollo/trunk/pom.xml
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/pom.xml?rev=1414285&r1=1414284&r2=1414285&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/pom.xml (original)
+++ activemq/activemq-apollo/trunk/pom.xml Tue Nov 27 17:47:09 2012
@@ -118,7 +118,8 @@
<jersey-version>1.7</jersey-version>
<snakeyaml-version>1.7</snakeyaml-version>
<swagger-version>1.0.1</swagger-version>
-
+ <jolokia-version>1.0.6</jolokia-version>
+
<selenium-version>2.25.0</selenium-version>
<!-- maven plugin versions -->
@@ -181,6 +182,7 @@
<module>apollo-website</module>
<module>apollo-openwire-generator</module>
<module>apollo-openwire</module>
+ <module>apollo-jmx</module>
<module>apollo-distro</module>
</modules>