Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function createClient(options) {
port = options.port;
urlPath = options.urlPath;
}
return new Client(serviceOrHost, port, protocol, urlPath, options.username, options.password);
return new Client(serviceOrHost, port, protocol, urlPath, options.username, options.password, options.protocolProvider, options.timeout);
}

module.exports = {
Expand Down
2 changes: 2 additions & 0 deletions lib/adapters/javaReflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ JavaReflection.prototype.invokeMethod = function(obj, methodName, paramsClass, p
return paramsClass;
}

if(!obj)
return;
var javaParamsClass = newClassArray(paramsClass);
obj.getClass(function(err, javaClass) {
if (checkError(err, self)) return;
Expand Down
57 changes: 55 additions & 2 deletions lib/adapters/mbeanServerConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,58 @@ MBeanServerConnection.prototype.connect = function(jmxServiceUrl) {
var JMXConnector = java.import("javax.management.remote.JMXConnector");
map.put(JMXConnector.CREDENTIALS, credentials, function(err) {
if (checkError(err, self)) return;
callback(map);
if(self.protocolProvider) {
map.put(self.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, self.protocolProvider, function (err) {
if (checkError(err, self)) return;
if(self.timeout>=0) {
var waitTime=java.newLong(self.timeout);
map.put("jmx.remote.x.request.waiting.timeout",waitTime,function(err){
if (checkError(err, self)) return;
callback(map);
});
return;
}
callback(map);
});
} else {
if(self.timeout>=0)
{
var waitTime=java.newLong(self.timeout);
map.put("jmx.remote.x.request.waiting.timeout",waitTime,function(err){
if (checkError(err, self)) return;
callback(map);
});
return;
}
callback(map);
}
});
} else {
callback(map);
if(self.protocolProvider) {
map.put(self.JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES, self.protocolProvider, function (err) {
if (checkError(err, self)) return;
if(self.timeout>=0) {
var waitTime=java.newLong(self.timeout);
map.put("jmx.remote.x.request.waiting.timeout",waitTime,function(err){
if (checkError(err, self)) return;
callback(map);
});
return;
}
callback(map);
});
} else {
if(self.timeout>=0)
{
var waitTime=java.newLong(self.timeout);
map.put("jmx.remote.x.request.waiting.timeout",waitTime,function(err){
if (checkError(err, self)) return;
callback(map);
});
return;
}
callback(map);
}
}
});
}
Expand Down Expand Up @@ -181,5 +229,10 @@ MBeanServerConnection.prototype.setCredentials = function(username, password) {
this.password = password;
};

MBeanServerConnection.prototype.setOptions = function(protocolProvider, timeout) {
this.protocolProvider=protocolProvider;
this.timeout=timeout;
};

module.exports = MBeanServerConnection;

9 changes: 8 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var JavaJmx = require("./javaJmx"),
util = require("util"),
EventEmitter = require("events").EventEmitter;

function Client(serviceOrHost, port, protocol, urlPath, username, password) {
function Client(serviceOrHost, port, protocol, urlPath, username, password, protocolProvider, timeout) {
var self = this;

function subscribeTo(obj) {
Expand All @@ -24,11 +24,14 @@ function Client(serviceOrHost, port, protocol, urlPath, username, password) {
self.jmxServiceUrl = this.javaJmx.JmxServiceUrl(serviceOrHost, port, protocol, urlPath);
self.username = username;
self.password = password;
self.protocolProvider = protocolProvider;
self.timeout= timeout;
}
util.inherits(Client, EventEmitter);

Client.prototype.connect = function() {
this.javaJmx.setCredentials(this.username, this.password);
this.javaJmx.setOptions(this.protocolProvider,this.timeout);
this.javaJmx.connect(this.jmxServiceUrl);
};

Expand All @@ -40,6 +43,10 @@ Client.prototype.getAttribute = function(mbean, attribute, callback) {
this.javaJmx.getAttribute(mbean, attribute, callback);
};

Client.prototype.getAttributeWObjName=function(objectName,attributeName,callback){
this.javaJmx.getAttributeWObjName(objectName, attributeName, callback);
};

Client.prototype.getDefaultDomain = function(callback) {
this.javaJmx.getDefaultDomain(callback);
};
Expand Down
10 changes: 10 additions & 0 deletions lib/javaJmx.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var java = require("java"),
path = require('path'),
util = require("util"),
EventEmitter = require("events").EventEmitter,
checkError = require("./helpers/error").checkError,
jmxServiceUrlBuilder = require("./adapters/helpers/jmxServiceUrlBuilder"),
MBeanServerConnection = require("./adapters/mbeanServerConnection"),
conversions = require("./adapters/helpers/conversions");
java.classpath.push(path.resolve(__dirname,"../wlclient.jar"));
java.classpath.push(path.resolve(__dirname,"../wljmxclient.jar"));

function JavaJmx(serviceOrHost, port, protocol, urlPath) {
var self = this;
Expand Down Expand Up @@ -53,6 +56,10 @@ JavaJmx.prototype.getAttribute = function(mbean, attributeName, callback) {
});
};

JavaJmx.prototype.getAttributeWObjName=function(objectName,attributeName,callback){
var self = this;
self.mbeanServerConnection.getAttribute(objectName, attributeName, callback);
};
JavaJmx.prototype.getDefaultDomain = function(callback) {
this.mbeanServerConnection.getDefaultDomain(callback);
};
Expand Down Expand Up @@ -168,5 +175,8 @@ JavaJmx.prototype.setCredentials = function(username, password) {
this.mbeanServerConnection.setCredentials(username, password);
};

JavaJmx.prototype.setOptions = function(protocolProvider, timeout){
this.mbeanServerConnection.setOptions(protocolProvider, timeout);
};
module.exports = JavaJmx;

Binary file added wlclient.jar
Binary file not shown.
Binary file added wljmxclient.jar
Binary file not shown.