Integrating Jolokia REST Bridge for JMX 92/1992/4
authorMadhu Venugopal <mavenugo@gmail.com>
Fri, 18 Oct 2013 07:01:07 +0000 (00:01 -0700)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 18 Oct 2013 20:23:30 +0000 (20:23 +0000)
Jolokia provides remote JMX functionality with JSON messages over REST API.
This change just integrates the Jolokia Servlet with the controller's Web Container.

Change-Id: I5dd12513d29903dbe10aeec9fc34080e5d25730b
Signed-off-by: Madhu Venugopal <mavenugo@gmail.com>
opendaylight/commons/opendaylight/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/northbound/containermanager/src/main/resources/WEB-INF/web.xml
opendaylight/northbound/jolokia/pom.xml [new file with mode: 0644]
opendaylight/northbound/jolokia/src/main/resources/WEB-INF/web.xml [new file with mode: 0644]
pom.xml

index 296250d945a7c797a099ca50280c99056d7fbee8..9c1d752f90806515e91123d62b052738fdcbb5e1 100644 (file)
@@ -52,6 +52,7 @@
     <jersey.version>1.17</jersey.version>
     <virgo.version>3.6.0.RELEASE</virgo.version>
     <geminiweb.version>2.2.0.RELEASE</geminiweb.version>
+    <jolokia.version>1.1.4</jolokia.version>
     <checkstyle.version>2.10</checkstyle.version>
     <testvm.argLine>-Xmx1024m -XX:MaxPermSize=256m</testvm.argLine>
     <yang.version>0.5.9-SNAPSHOT</yang.version>
@@ -85,6 +86,7 @@
     <networkconfig.bridgedomain.northbound.version>0.0.2-SNAPSHOT</networkconfig.bridgedomain.northbound.version>
     <commons.httpclient.version>0.1.1-SNAPSHOT</commons.httpclient.version>
     <concepts.version>0.5.1-SNAPSHOT</concepts.version>
+    <jolokia.bridge.version>0.0.1-SNAPSHOT</jolokia.bridge.version>
   </properties>
 
   <dependencyManagement>
         <!-- the all bundle includes all the necessary plugins -->
         <classifier>all</classifier>
       </dependency>
+      <dependency>
+        <groupId>org.jolokia</groupId>
+        <artifactId>jolokia-osgi</artifactId>
+        <version>${jolokia.version}</version>
+      </dependency>
     </dependencies>
   </dependencyManagement>
 
index 41223579103b65f9fb4b85bc58ca452d074bbc10..05867335b5d8de3e6eec9bca3b870b3859be94a8 100644 (file)
       <artifactId>httpservice-bridge</artifactId>
       <version>0.0.1-SNAPSHOT</version>
     </dependency>
+    <dependency>
+      <groupId>org.jolokia</groupId>
+      <artifactId>jolokia-osgi</artifactId>
+      <version>${jolokia.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>jolokia-bridge</artifactId>
+      <version>${jolokia.bridge.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>connectionmanager.northbound</artifactId>
index 4ad7cf184b3f021d0dff58fe07f027ca49503fb6..b0ad555bee55e17be3611dc6e6fb5dfd8f3d744d 100644 (file)
@@ -108,3 +108,6 @@ controllerTrustStorePassword=
 
 # User Manager configurations
 enableStrongPasswordCheck = false
+
+#Jolokia configurations
+org.jolokia.listenForHttpService=false
index 5e4ad4ea1acc8921e547cf7a7ad7b3645ab72afb..5f74a4419dcb6473fbb73f5a329e7604bafbed62 100644 (file)
@@ -25,7 +25,7 @@ http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
       </init-param>
       <init-param>
         <param-name>cors.allowed.methods</param-name>
-        <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value>
+        <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
       </init-param>
       <init-param>
         <param-name>cors.allowed.headers</param-name>
diff --git a/opendaylight/northbound/jolokia/pom.xml b/opendaylight/northbound/jolokia/pom.xml
new file mode 100644 (file)
index 0000000..7e13f2e
--- /dev/null
@@ -0,0 +1,43 @@
+<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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>commons.opendaylight</artifactId>
+    <version>1.4.1-SNAPSHOT</version>
+    <relativePath>../../commons/opendaylight</relativePath>
+  </parent>
+
+  <artifactId>jolokia-bridge</artifactId>
+  <version>${jolokia.bridge.version}</version>
+  <description>Jolokia bridge web application</description>
+  <packaging>bundle</packaging>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <version>2.4.0</version>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Export-Package>
+            </Export-Package>
+            <Import-Package>
+                javax.servlet,
+                javax.servlet.http,
+                org.eclipse.equinox.http.servlet,
+                org.opendaylight.controller.web,
+                org.osgi.framework,
+                org.jolokia.osgi.servlet,
+                org.apache.catalina.filters,
+                org.slf4j,
+            </Import-Package>
+            <Web-ContextPath>/controller/nb/v2/jolokia</Web-ContextPath>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/opendaylight/northbound/jolokia/src/main/resources/WEB-INF/web.xml b/opendaylight/northbound/jolokia/src/main/resources/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..126396d
--- /dev/null
@@ -0,0 +1,75 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<web-app
+  xmlns="http://java.sun.com/xml/ns/javaee"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+  version="3.0">
+
+  <servlet>
+    <servlet-name>JolokiaServlet</servlet-name>
+    <servlet-class>org.jolokia.osgi.servlet.JolokiaServlet</servlet-class>
+    <load-on-startup>1</load-on-startup>
+  </servlet>
+
+  <servlet-mapping>
+    <servlet-name>JolokiaServlet</servlet-name>
+    <url-pattern>/*</url-pattern>
+  </servlet-mapping>
+
+  <filter>
+    <filter-name>CorsFilter</filter-name>
+    <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
+    <init-param>
+      <param-name>cors.allowed.origins</param-name>
+      <param-value>*</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cors.allowed.methods</param-name>
+      <param-value>GET,POST,HEAD,OPTIONS,PUT,DELETE</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cors.allowed.headers</param-name>
+      <param-value>Content-Type,X-Requested-With,accept,authorization, origin,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cors.exposed.headers</param-name>
+      <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cors.support.credentials</param-name>
+      <param-value>true</param-value>
+    </init-param>
+    <init-param>
+      <param-name>cors.preflight.maxage</param-name>
+      <param-value>10</param-value>
+    </init-param>
+  </filter>
+  <filter-mapping>
+    <filter-name>CorsFilter</filter-name>
+    <url-pattern>/*</url-pattern>
+  </filter-mapping>
+
+  <security-constraint>
+    <web-resource-collection>
+      <web-resource-name>JolokiaService</web-resource-name>
+      <url-pattern>/*</url-pattern>
+    </web-resource-collection>
+    <auth-constraint>
+      <role-name>System-Admin</role-name>
+      <role-name>Network-Admin</role-name>
+    </auth-constraint>
+  </security-constraint>
+
+  <security-role>
+    <role-name>System-Admin</role-name>
+  </security-role>
+
+  <security-role>
+    <role-name>Network-Admin</role-name>
+  </security-role>
+
+  <login-config>
+    <auth-method>BASIC</auth-method>
+    <realm-name>opendaylight</realm-name>
+  </login-config>
+</web-app>
diff --git a/pom.xml b/pom.xml
index 97b308868570b233cbd35be4630b23f64ceb2b65..cd54dd40b4a475dd8555b935090b546da9b52655 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <module>opendaylight/northbound/containermanager</module>
     <module>opendaylight/northbound/networkconfiguration/bridgedomain</module>
     <module>opendaylight/northbound/httpservice-bridge</module>
+    <module>opendaylight/northbound/jolokia</module>
     <module>opendaylight/northbound/connectionmanager</module>
     <module>opendaylight/northbound/usermanager</module>