Skip to content

Commit

Permalink
Fix #21
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Apr 19, 2013
1 parent a529785 commit 803e264
Show file tree
Hide file tree
Showing 7 changed files with 164 additions and 8 deletions.
8 changes: 8 additions & 0 deletions hawtio-default/pom.xml
Expand Up @@ -52,17 +52,25 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-maven-indexer</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-json-schema-mbean</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-local-jvm-mbean</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.fusesource.insight</groupId>
<artifactId>insight-log4j</artifactId>
Expand Down
7 changes: 0 additions & 7 deletions hawtio-web/pom.xml
Expand Up @@ -64,13 +64,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.hawt</groupId>
<artifactId>hawtio-plugin-mbean</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>


<!-- Camel module -->
<!--
Expand Down
4 changes: 4 additions & 0 deletions hawtio-web/src/main/webapp/app/jvm/doc/help.md
@@ -0,0 +1,4 @@
### Jetty

This plugin lists local JVMs running on your machine and allows you to install the Jolokia JVM agent into a running JVM and connect to it.

40 changes: 40 additions & 0 deletions hawtio-web/src/main/webapp/app/jvm/html/jvms.html
@@ -0,0 +1,40 @@
<div ng-controller="JVM.JVMsController">

<div class="logbar">
<div class="wiki logbar-container">
<ul class="nav nav-tabs">
<li class="pull-right">
<a href='' ng-click="fetch()"><i class="icon-refresh"></i> Refresh</a>
</li>
</ul>
</div>
</div>

<div class="wiki-fixed row-fluid">
<table class='centered table table-bordered table-condensed table-striped'>
<thead>
<tr>
<th>PID</th>
<th>Name</th>
<th>Agent URL</th>
<th></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="jvm in data">
<td>{{jvm.id}}</td>
<td>{{jvm.alias}}</td>
<td><a href='' title="Connect to this agent" ng-click="connectTo(jvm.agentUrl)">{{jvm.agentUrl}}</a></td>
<td>
<a class='btn' href="" title="Stop Agent" ng-show="jvm.agentUrl" ng-click="stopAgent(jvm.id)"><i class="icon-stop"></i></a>
<a class='btn' href="" title="Start Agent" ng-hide="jvm.agentUrl" ng-click="startAgent(jvm.id)"><i class="icon-play"></i></a>
</td>
</tr>

</tbody>
</table>

</div>


</div>
30 changes: 30 additions & 0 deletions hawtio-web/src/main/webapp/app/jvm/js/jvmPlugin.ts
@@ -0,0 +1,30 @@
module Jvm {

var pluginName = 'jvm';

angular.module(pluginName, ['bootstrap', 'ngResource', 'datatable', 'hawtioCore']).
config(($routeProvider) => {
$routeProvider.
when('/jvms', {templateUrl: 'app/jvm/html/jvms.html'});
}).
constant('mbeanName', 'io.hawt.jvm.local:type=JVMList').
run(($location, workspace, viewRegistry, layoutFull) => {

viewRegistry[pluginName] = layoutFull;

workspace.topLevelTabs.push({
content: "JVMs",
title: "View local JVMs and connect hawtio to them",
isValid: (workspace) => workspace.treeContainsDomainAndProperties('io.hawt.jvm.local', {type: 'JVMList'}),
href: () => '#/jvms',
isActive: (workspace: Workspace) => workspace.isLinkActive("jvms")

});

});



hawtioPluginLoader.addModule(pluginName);

}
47 changes: 47 additions & 0 deletions hawtio-web/src/main/webapp/app/jvm/js/jvms.ts
@@ -0,0 +1,47 @@
module JVM {

export function JVMsController($scope, $window, jolokia, mbeanName) {

$scope.data = [];


$scope.fetch = () => {
jolokia.request({
type: 'exec', mbean: mbeanName,
operation: 'listLocalJVMs()',
arguments: []
}, onSuccess(render));
}

$scope.stopAgent = (pid) => {
jolokia.request({
type: 'exec', mbean: mbeanName,
operation: 'stopAgent(java.lang.String)',
arguments: [pid]
}, onSuccess($scope.fetch));
}

$scope.startAgent = (pid) => {
jolokia.request({
type: 'exec', mbean: mbeanName,
operation: 'startAgent(java.lang.String)',
arguments: [pid]
}, onSuccess($scope.fetch));
}

$scope.connectTo = (url) => {
$window.open("?url=" + encodeURIComponent(url));
}


function render(response) {
console.log("Got: ", response);
$scope.data = response.value
$scope.$apply();
}

$scope.fetch();
}


}
36 changes: 35 additions & 1 deletion hawtio-web/src/main/webapp/css/site-base.css
Expand Up @@ -1052,4 +1052,38 @@ div.hawtio-form-tabs ul.nav-tabs li.active a {

li.stacktrace {
line-height: 10px;
}
}

ul.jvm-list {
margin-top: 20px;
list-style-type: none;
width: 80%;
}

ul.jvm-list li {
margin-top: 5px;
margin-bottom: 10px;
padding: 5px;
border: 1px solid #D4D4D4;
border-radius: 4px;
box-shadow: 0 -10px 10px -10px rgba(0, 0, 0, 0.1);
}

ul.jvm-list li div.inline-block {
width: 100%;
}

ul.jvm-list li div.inline-block div {
overflow: hidden;
text-overflow: ellipsis;
}


ul.jvm-list li div.inline-block div.pull-left {
width: 50%;
}

ul.jvm-list li div.inline-block div.pull-right {
width: 50%;
}

0 comments on commit 803e264

Please sign in to comment.