Skip to content

Commit

Permalink
Cache JMX PID and current container name once we've fetched 'em
Browse files Browse the repository at this point in the history
  • Loading branch information
gashcrumb committed Oct 15, 2013
1 parent 0d8628e commit eb8b42a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
15 changes: 9 additions & 6 deletions hawtio-web/src/main/webapp/app/fabric/js/fabricPlugin.ts
Expand Up @@ -4,6 +4,8 @@ module Fabric {

export var templatePath = 'app/fabric/html/';

export var currentContainerId = '';


angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop', 'wiki']).config(($routeProvider) => {
$routeProvider.
Expand Down Expand Up @@ -85,13 +87,14 @@ module Fabric {
viewRegistry['createFabric'] = layoutFull;

pageTitle.addTitleElement( ():string => {
var id = '';
try {
id = jolokia.getAttribute(Fabric.managerMBean, 'CurrentContainerName', {timeout: 1});
} catch (e) {
// ignore
if (Fabric.currentContainerId === '') {
try {
Fabric.currentContainerId = jolokia.getAttribute(Fabric.managerMBean, 'CurrentContainerName', {timeout: 1});
} catch (e) {
// ignore
}
}
return id;
return Fabric.currentContainerId;
});

workspace.topLevelTabs.push( {
Expand Down
21 changes: 12 additions & 9 deletions hawtio-web/src/main/webapp/app/jmx/js/jmxPlugin.ts
@@ -1,6 +1,8 @@
module Jmx {
var pluginName = 'jmx';

export var currentProcessId = '';

angular.module(pluginName, ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.modal', 'ngResource', 'ngGrid', 'hawtioCore', 'hawtio-ui']).config(($routeProvider) => {
$routeProvider.
when('/jmx/attributes', {templateUrl: 'app/jmx/html/attributes.html'}).
Expand All @@ -26,16 +28,17 @@ module Jmx {


pageTitle.addTitleElement(():string => {
var id = ''
try {
id = jolokia.getAttribute('java.lang:type=Runtime', 'Name');
} catch (e) {
// ignore
}
if (id && id.has("@")) {
id = "pid:" + id.split("@")[0];
if (Jmx.currentProcessId === '') {
try {
Jmx.currentProcessId = jolokia.getAttribute('java.lang:type=Runtime', 'Name');
} catch (e) {
// ignore
}
if ( Jmx.currentProcessId && Jmx.currentProcessId.has("@")) {
Jmx.currentProcessId = "pid:" + Jmx.currentProcessId.split("@")[0];
}
}
return id;
return Jmx.currentProcessId;
});


Expand Down

0 comments on commit eb8b42a

Please sign in to comment.