Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function newClassArray(params) {
var classArray = [];
params.forEach(function(value) {
// TODO: this must be done async
var javaClass = java.callStaticMethodSync("java.lang.Class", "forName", value);
classArray.push(javaClass);
});
var paramsClass = java.newArray("java.lang.Class", classArray);
return paramsClass;
}
MBeanServerConnection.prototype.getAttributes = function(name, attributes, callback) {
var xattributes = java.newArray('java.lang.String', attributes);
// Note: the notation for a string array, which is a parameter to this call, is
// as follows: "[Ljava.lang.String;" ... this is equivalent to a java.lang.String [] parameter
this.javaReflection.invokeMethod(
this.mbeanServerConnection,
'getAttributes',
[ "javax.management.ObjectName", "[Ljava.lang.String;" ], // methodParamsClass
[ name, attributes ], // methodParams
callback
);
};
it("#invoke", function(done) {
var method = "invoke";
var paramsArray = java.newArray("java.lang.Object", [ "params" ]);
var signatureArray = java.newArray("java.lang.String", [ "signature" ]);
var methodParamsClass = [ "javax.management.ObjectName", "java.lang.String", "[Ljava.lang.Object;", "[Ljava.lang.String;" ];
var methodParams = [ "name", "operationName", [ "params" ], [ "signature" ] ];
testReflectionCall(method, methodParamsClass, methodParams, function(obj, method2, methodParamsClass2, methodParams2, callback2) {
var newMethodParams = [ "name", "operationName", paramsArray, signatureArray];
assert.deepEqual(methodParamsClass, methodParamsClass2);
assert.deepEqual(newMethodParams , methodParams2);
done();
});
});
it("#getAttributes", function(done) {
var method = "getAttributes";
var attributesArray = java.newArray("java.lang.String", [ "attribute", "attribute" ]);
var methodParamsClass = [ "javax.management.ObjectName", "[Ljava.lang.String;" ];
var methodParams = [ "name", [ "attribute", "attribute" ] ];
testReflectionCall(method, methodParamsClass, methodParams, function(obj, method2, methodParamsClass2, methodParams2, callback2) {
var newMethodParams = [ "name", attributesArray ];
assert.deepEqual(methodParamsClass, methodParamsClass2);
assert.deepEqual(newMethodParams, methodParams2);
done();
});
});
it("#invoke", function(done) {
var method = "invoke";
var paramsArray = java.newArray("java.lang.Object", [ "params" ]);
var signatureArray = java.newArray("java.lang.String", [ "signature" ]);
var methodParamsClass = [ "javax.management.ObjectName", "java.lang.String", "[Ljava.lang.Object;", "[Ljava.lang.String;" ];
var methodParams = [ "name", "operationName", [ "params" ], [ "signature" ] ];
testReflectionCall(method, methodParamsClass, methodParams, function(obj, method2, methodParamsClass2, methodParams2, callback2) {
var newMethodParams = [ "name", "operationName", paramsArray, signatureArray];
assert.deepEqual(methodParamsClass, methodParamsClass2);
assert.deepEqual(newMethodParams , methodParams2);
done();
});
});
public addPackage(namespace: string, directories: string[], basePackages: string[]): Package {
return new Package(
this.org.addPackageSync(
namespace,
java.newArray("java.lang.String", directories),
java.newArray("java.lang.String", basePackages)
)
);
}
function setContext(paramBlob, mContextManagerUrl, participantUrl) {
var initializeContext = java.newInstanceSync('com.sentillion.sdkweb.webcontextor.WebContextor');
var blob = java.newArray('java.lang.String', [null]);
blob[0] = java.callMethodSync(initializeContext, 'getLastContextBlob');
var contextItems = [];
var _state = 0,
dfn = '',
icn = '',
participantCoupon = '',
contextCoupon = '',
jsonData = {};
if (blob[0] === '' && paramBlob !== '') {
blob[0] = paramBlob;
}
if (mContextManagerUrl === undefined) {
jsonData.statusCode = 500;
jsonData.message = 'Cannot retrieve context manager url.';
toArray(tileStream, function (err, parts) {
var byteArray = [];
for (var k = 0; k < parts.length; k++) {
var part = parts[k];
for (var i = 0; i < part.length; i++) {
var bufferPiece = part[i];
var byte = java.newByte(bufferPiece);
byteArray.push(byte);
}
}
var bytes = java.newArray('byte', byteArray);
newRow.setTileDataSync(bytes);
tileDao.createSync(newRow);
callback(null, self);
});
}).done();
function GetCredentials(callback) {
var self = this;
var credentials = java.newArray("java.lang.String", [ self.username, self.password ]);
java.newInstance("java.util.HashMap", function(err, map) {
if (checkError(err, self)) return;
if (typeof self.username === "string" && typeof self.password === "string") {
var JMXConnector = java.import("javax.management.remote.JMXConnector");
map.put(JMXConnector.CREDENTIALS, credentials, function(err) {
if (checkError(err, self)) return;
callback(map);
});
} else {
callback(map);
}
});
}
function newArray(className, arg) {
var fullName = fullyQualifiedName(className) || className;
return _java.newArray(fullName, arg);
}
Java.newArray = newArray;