views:

166

answers:

3

I am doing device monitoring on a networked system. I need to know how to make Javascript calls on that device via its IP address to get certain status information (this device's status is only available through Javascript APIs, not SNMP, etc). I am working in Java.

ADDED: The specific device is an Amino set-top-box. It has what it calls JMACX: JavaScript Media Access Control Extensions API specification. It allows you within an HTML document to use that API to get MUCH information about the device (cpu usage, channel info, remote-control options, etc.). I need to get this information within a Java program for specific monitoring purposes.

Perhaps possible with HTTP requests?

Any input would be greatly appreciated.

Thanks,

Steve

+1  A: 

Thus, it's essentially a webserver serving HTML pages? You could in theory use URL#openStream() to get an InputStream of any web resource.

But then you have a major problem with Javascript. It runs at the local machine only. You can eventually extract JavaScript functions from the HTML page with help of a HTML parser and invoke them with help of javax.script API, but they will be executed on your machine only (at least, the machine where your Java code is running), not on the remote machine.

BalusC
A: 

I have been using Rhino in Java and it works well. You should be able to load a Javascript API into a context, then create functions to use/call that API.

http://www.mozilla.org/rhino/

jon077
Can you elaborate a little bit more on this? I have been looking at documentation on the web and seem to find little on using context. How would I use this to call Javascript on a networked device?
stjowa
If you just need to be able to use and call javascript, then rhino is a good solution. You load up the JS api, presumably in a JS file either locally or remotely, then you can call functions, etc in it.You may have to create some mock objects if the API assumes certain objects are present.
jon077
A: 

Hi jon077, can you help me with some starting codes so that i can be able to read javascript functions in javascript file from java using rhino

Hari