Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added more data to the karaf server page & made it more async
- Loading branch information
Showing
1 changed file
with
57 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,68 @@ | ||
module Karaf { | ||
|
||
export function ServerController($scope, $location, workspace:Workspace, jolokia) { | ||
|
||
$scope.data = { | ||
name: "", | ||
version: "", | ||
state: "", | ||
root: "", | ||
location: "", | ||
sshPort: "", | ||
rmiRegistryPort: "", | ||
rmiServerPort: "", | ||
pid: ""}; | ||
|
||
function render(response) { | ||
console.log("Response is " + response); | ||
|
||
// grab the first mbean as there should ideally only be one karaf in the JVM | ||
if (angular.isArray(response)) { | ||
var mbean = response[0]; | ||
if (mbean) { | ||
var instances = jolokia.getAttribute(mbean, "Instances", onSuccess(null)); | ||
if (instances) { | ||
console.log("Instances is " + instances); | ||
// the name is the first child | ||
$scope.data.name = "TODO"; | ||
// TODO: we need to get version from another mbean | ||
$scope.data.version = "TODO"; | ||
$scope.data.state = instances['root'].State; | ||
$scope.data.root = "TODO"; | ||
$scope.data.location = instances['root'].Location; | ||
$scope.data.sshPort = "TODO"; | ||
$scope.data.rmiRegistryPort = "TODO"; | ||
$scope.data.rmiServerPort = "TODO"; | ||
$scope.data.pid = instances['root'].Pid; | ||
} | ||
} | ||
} | ||
export function ServerController($scope, $location, workspace:Workspace, jolokia) { | ||
|
||
// ensure web page is updated | ||
Core.$apply($scope); | ||
} | ||
$scope.data = { | ||
name: "", | ||
version: "", | ||
state: "", | ||
root: "", | ||
location: "", | ||
sshPort: "", | ||
rmiRegistryPort: "", | ||
rmiServerPort: "", | ||
pid: ""}; | ||
|
||
// TODO: we need the framework and version from another mbean | ||
$scope.$on('jmxTreeUpdated', reloadFunction); | ||
$scope.$watch('workspace.tree', reloadFunction); | ||
|
||
function loadData() { | ||
console.log("Loading Karaf data..."); | ||
jolokia.search("org.apache.karaf:type=admin,*", onSuccess(render)); | ||
} | ||
// TODO: we need the framework and version from another mbean | ||
|
||
function reloadFunction() { | ||
// if the JMX tree is reloaded its probably because a new MBean has been added or removed | ||
// so lets reload, asynchronously just in case | ||
setTimeout(loadData, 50); | ||
} | ||
|
||
function loadData() { | ||
console.log("Loading Karaf data..."); | ||
jolokia.search("org.apache.karaf:type=admin,*", onSuccess(render)); | ||
} | ||
|
||
$scope.$on('jmxTreeUpdated', reloadFunction); | ||
$scope.$watch('workspace.tree', reloadFunction); | ||
function render(response) { | ||
console.log("Response is " + response); | ||
|
||
function reloadFunction() { | ||
// if the JMX tree is reloaded its probably because a new MBean has been added or removed | ||
// so lets reload, asynchronously just in case | ||
setTimeout(loadData, 50); | ||
// grab the first mbean as there should ideally only be one karaf in the JVM | ||
if (angular.isArray(response)) { | ||
var mbean = response[0]; | ||
if (mbean) { | ||
jolokia.getAttribute(mbean, "Instances", onSuccess(onInstances)); | ||
} | ||
} | ||
|
||
// ensure web page is updated | ||
Core.$apply($scope); | ||
} | ||
|
||
function onInstances(instances) { | ||
if (instances) { | ||
console.log("Instances is " + JSON.stringify(instances)); | ||
// the name is the first child | ||
var rootInstance = instances['root']; | ||
$scope.data.name = rootInstance.Name; | ||
$scope.data.state = rootInstance.State; | ||
$scope.data.root = rootInstance["Is Root"]; | ||
$scope.data.location = rootInstance.Location; | ||
$scope.data.sshPort = rootInstance["SSH Port"]; | ||
$scope.data.rmiRegistryPort = rootInstance["RMI Registry Port"]; | ||
$scope.data.rmiServerPort = rootInstance["RMI Server Port"]; | ||
$scope.data.pid = rootInstance.Pid; | ||
|
||
// TODO: we need to get version from another mbean | ||
$scope.data.version = ""; | ||
|
||
Core.$apply($scope); | ||
} | ||
} | ||
} | ||
} |