https://github.com/hal/dmr.js
DMR in plain JS
https://github.com/hal/dmr.js
Last synced: about 1 year ago
JSON representation
DMR in plain JS
- Host: GitHub
- URL: https://github.com/hal/dmr.js
- Owner: hal
- Created: 2013-04-08T09:03:19.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2013-08-08T06:24:58.000Z (almost 13 years ago)
- Last Synced: 2025-02-24T16:39:28.346Z (over 1 year ago)
- Language: Java
- Size: 160 KB
- Stars: 1
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# dmr.js
JavaScript library to execute operations on the JBoss AS7 DMR API.
For an introduction to DMR please refer to the [JBoss Wiki](https://docs.jboss.org/author/display/AS7/Detyped+management+and+the+jboss-dmr+library)
## Prerequistes
- node.js
- npm
- maven
- JDK 7
## General Usage
### Import the dmr.js library
```
[...]
```
### DMR Invocation from JavaScript
```javascript
// access EC2 demo instance
http = new XMLHttpRequest();
http.withCredentials = true;
http.open("POST", "http://as7-preview.dyndns.org:9990/management", true);
// async response handler
http.onreadystatechange =function()
{
if (http.readyState==4 && http.status==200)
{
// decode response
response = dmr.ModelNode.fromBase64(http.responseText);
alert(response.get("result").asString());
}
}
// content type headers for DMR API
http.setRequestHeader("Content-type","application/dmr-encoded");
http.setRequestHeader("Accept","application/dmr-encoded");
// create an operation
op = new dmr.ModelNode();
op.get("operation").set("read-attribute");
op.get("address").setEmptyList();
op.get("name").set("release-version");
// send as base64 encoded
http.send(op.toBase64String());
```
## Running the demo
```
cd scripts
npm install
```
### Build the JS module
```
mvn clean install
```
### Serve the files
```
node scripts/server.js
```
### Point your browser to
[http://localhost:9000/App.html](http://localhost:9000/App.html)
## Known Issues
### CORS Problems
- It requires a patched AS7 instance if not running on the same host.
- Some browsers require extra steps to get the authentication working, but Firefox should work out of the box.
For a good summary of all the challenges see [Harald's Post](http://hpehl.info/independent-jboss-admin-console.html)