jolokia
Version:
Implementation of jolokia JMX client
12 lines • 19.5 kB
JavaScript
/**
* Jolokia JavaScript client library
*
* Version 1.0.6
*
* GitHub repository can be found at https://github.com/janjakubnanista/jolokia-js-client
*
* Released under MIT license
*
* Created by Ján Jakub Naništa <jan.jakub.nanista@gmail.com>
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("$")):"function"==typeof define&&define.amd?define(["$"],e):"object"==typeof exports?exports.Jolokia=e(require("$")):t.Jolokia=e(t.$)}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var r=n(2),o=n(1),i=n(4),u=n(3),c=t.exports=function(){r.apply(this,arguments)};u.inherit(c,r),c.prototype.httpRequest=function(t){if(t.processData=!1,t.dataType=t.dataType||"json",t.auth){var e=t.auth.username,n=t.auth.password;t.headers={Authorization:"Basic "+u.base64encode(e+":"+n)},t.xhrFields={withCredentials:!0},delete t.auth}return i(o.ajax(t))}},function(t){t.exports=$},function(t,e,n){"use strict";function r(t){return 200!==t[0].status?c.reject(t[0]):t[0].value}function o(t){return null===t||void 0===t?"[null]":""===t?'""':t.toString()}function i(t,e){var n=[];for(var r in e)n.push(r+"="+e[r]);return n=n.join("&"),n&&(t=-1===t.indexOf("?")?t+"?"+n:t.replace("?","?"+n+"&")),t}var u=n(3),c=n(4),s=t.exports=function(t){"string"==typeof t&&(t={url:t}),t=u.extend({},t),this.options=function(){return u.extend({},t)}};s.escape=function(t){return encodeURIComponent(t.replace(/(["!\/])/g,"!$1"))},s.isError=function(t){return!t.status||200!==t.status},s.toString=function(t){return u.isArray(t)?t.map(o).join(","):o(t)},s.prototype.determineRequestMethod=function(t){var e=u.isArray(t)||t.config||t.type.match(/read/i)&&u.isArray(t.attribute)||t.target?"post":"get";return e},s.prototype.constructUrl=function(t){var e=t.type.toLowerCase(),n=[],r="";return"read"===e?t.attribute?(n=[t.mbean,t.attribute],r=t.path):n=[t.mbean]:"write"===e?(n=[t.mbean,t.attribute,s.toString(t.value)],r=t.path):"exec"===e?(n=[t.mbean,t.operation],t.arguments&&(n=n.concat(t.arguments.map(s.toString)))):"search"===e?n=[t.mbean]:"list"===e&&(r=t.path),u.isArray(r)&&(r=r.map(s.escape).join("/")),n.unshift(e),n=n.map(s.escape),r=r?r.replace(/^\//,""):"",n.join("/")+"/"+r},s.prototype.request=function(t,e){if(e=u.extend({},this.options(),e),!e.url||"string"!=typeof e.url)throw"Invalid URL : "+e.url;var n=(e.method||this.determineRequestMethod(t)).toLowerCase();if("get"!==n&&"post"!==n)throw new Error("Unsupported request method: "+n);if("get"===n){if(u.isArray(t))throw new Error("Cannot use GET with bulk requests");if(t.type.match(/read/i)&&u.isArray(t.attribute))throw new Error("Cannot use GET for read with multiple attributes");if(t.target)throw new Error("Cannot use GET request with proxy mode");if(t.config)throw new Error("Cannot use GET with request specific config")}return e.url=e.url.replace(/\/*$/,"/"),"get"===n?e.url+=this.constructUrl(t,e):e.data=JSON.stringify(t),e.method=n,e.url=i(e.url,e.query||{}),this.httpRequest(e).then(function(t){var n=u.isArray(t)?t:[t];return"function"==typeof e.success&&e.success.call(this,n),n}.bind(this),e.error)},s.prototype.get=function(t,e,n,o){3===arguments.length&&u.isObject(n)?(o=n,n=null):2===arguments.length&&u.isObject(e)&&(o=e,e=null,n=null);var i={type:"read",mbean:t,attribute:e};return n&&(i.path=n),this.request(i,o).then(r)},s.prototype.set=function(t,e,n,o,i){4===arguments.length&&u.isObject(o)&&(i=o,o=null);var c={type:"write",mbean:t,attribute:e,value:n};return o&&(c.path=o),this.request(c,i).then(r)},s.prototype.execute=function(t,e){var n,o={type:"exec",mbean:t,operation:e},i=Array.prototype.slice.call(arguments,0);return i.length>2&&u.isObject(i[i.length-1])&&(n=i.pop()),i.length>2&&(o.arguments=i.slice(2)),this.request(o,n).then(r)},s.prototype.search=function(t,e){var n={type:"search",mbean:t};return this.request(n,e).then(r)},s.prototype.version=function(t){return this.request({type:"version"},t).then(r)},s.prototype.list=function(t,e){1===arguments.length&&!u.isArray(t)&&u.isObject(t)&&(e=t,t=null);var n={type:"list"};return t&&(n.path=t),this.request(n,e).then(r)}},function(t,e){"use strict";e.extend=function(t){var e,n,r=Array.prototype.slice.call(arguments,1);return r.reduce(function(t,r){return null===r||"object"!=typeof r?t:Object.keys(r).reduce(function(t,o){return e=r.__lookupGetter__(o),n=r.__lookupSetter__(o),e||n?(e&&t.__defineGetter__(o,e),n&&t.__defineSetter__(o,n)):t[o]=r[o],t},t)},t)},e.isArray=function(t){return"[object Array]"===Object.prototype.toString.call(t)},e.isObject=function(t){return null!==t&&"object"==typeof t},e.base64encode=function(t){return"undefined"!=typeof window?window.btoa(t):new Buffer(t,"utf8").toString("base64")},e.inherit=function(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t;for(var n in e)"function"==typeof e[n]&&(t[n]=e[n]);return t}},function(t){!function(e){"use strict";"function"==typeof bootstrap?bootstrap("promise",e):t.exports=e()}(function(){"use strict";function t(t){return function(){return Q.apply(t,arguments)}}function e(t){return t===Object(t)}function n(t){return"[object StopIteration]"===ee(t)||t instanceof J}function r(t,e){if(M&&e.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf(ne)){for(var n=[],r=e;r;r=r.source)r.stack&&n.unshift(r.stack);n.unshift(t.stack);var i=n.join("\n"+ne+"\n");t.stack=o(i)}}function o(t){for(var e=t.split("\n"),n=[],r=0;r<e.length;++r){var o=e[r];c(o)||i(o)||!o||n.push(o)}return n.join("\n")}function i(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function u(t){var e=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(e)return[e[1],Number(e[2])];var n=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(n)return[n[1],Number(n[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}function c(t){var e=u(t);if(!e)return!1;var n=e[0],r=e[1];return n===F&&r>=L&&ue>=r}function s(){if(M)try{throw new Error}catch(t){var e=t.stack.split("\n"),n=e[0].indexOf("@")>0?e[1]:e[2],r=u(n);if(!r)return;return F=r[0],r[1]}}function a(t,e,n){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(e+" is deprecated, use "+n+" instead.",new Error("").stack),t.apply(t,arguments)}}function p(t){return t instanceof d?t:g(t)?S(t):O(t)}function f(){function t(t){e=t,i.source=t,K(n,function(e,n){p.nextTick(function(){t.promiseDispatch.apply(t,n)})},void 0),n=void 0,r=void 0}var e,n=[],r=[],o=Y(f.prototype),i=Y(d.prototype);if(i.promiseDispatch=function(t,o,i){var u=H(arguments);n?(n.push(u),"when"===o&&i[1]&&r.push(i[1])):p.nextTick(function(){e.promiseDispatch.apply(e,u)})},i.valueOf=function(){if(n)return i;var t=v(e);return m(t)&&(e=t),t},i.inspect=function(){return e?e.inspect():{state:"pending"}},p.longStackSupport&&M)try{throw new Error}catch(u){i.stack=u.stack.substring(u.stack.indexOf("\n")+1)}return o.promise=i,o.resolve=function(n){e||t(p(n))},o.fulfill=function(n){e||t(O(n))},o.reject=function(n){e||t(R(n))},o.notify=function(t){e||K(r,function(e,n){p.nextTick(function(){n(t)})},void 0)},o}function l(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var e=f();try{t(e.resolve,e.reject,e.notify)}catch(n){e.reject(n)}return e.promise}function h(t){return l(function(e,n){for(var r=0,o=t.length;o>r;r++)p(t[r]).then(e,n)})}function d(t,e,n){void 0===e&&(e=function(t){return R(new Error("Promise does not support operation: "+t))}),void 0===n&&(n=function(){return{state:"unknown"}});var r=Y(d.prototype);if(r.promiseDispatch=function(n,o,i){var u;try{u=t[o]?t[o].apply(r,i):e.call(r,o,i)}catch(c){u=R(c)}n&&n(u)},r.inspect=n,n){var o=n();"rejected"===o.state&&(r.exception=o.reason),r.valueOf=function(){var t=n();return"pending"===t.state||"rejected"===t.state?r:t.value}}return r}function y(t,e,n,r){return p(t).then(e,n,r)}function v(t){if(m(t)){var e=t.inspect();if("fulfilled"===e.state)return e.value}return t}function m(t){return t instanceof d}function g(t){return e(t)&&"function"==typeof t.then}function j(t){return m(t)&&"pending"===t.inspect().state}function b(t){return!m(t)||"fulfilled"===t.inspect().state}function w(t){return m(t)&&"rejected"===t.inspect().state}function k(){re.length=0,oe.length=0,ie||(ie=!0)}function x(t,e){ie&&(oe.push(t),re.push(e&&"undefined"!=typeof e.stack?e.stack:"(no stack) "+e))}function T(t){if(ie){var e=W(oe,t);-1!==e&&(oe.splice(e,1),re.splice(e,1))}}function R(t){var e=d({when:function(e){return e&&T(this),e?e(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return x(e,t),e}function O(t){return d({when:function(){return t},get:function(e){return t[e]},set:function(e,n){t[e]=n},"delete":function(e){delete t[e]},post:function(e,n){return null===e||void 0===e?t.apply(void 0,n):t[e].apply(t,n)},apply:function(e,n){return t.apply(e,n)},keys:function(){return te(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function S(t){var e=f();return p.nextTick(function(){try{t.then(e.resolve,e.reject,e.notify)}catch(n){e.reject(n)}}),e.promise}function E(t){return d({isDef:function(){}},function(e,n){return D(t,e,n)},function(){return p(t).inspect()})}function q(t,e,n){return p(t).spread(e,n)}function A(t){return function(){function e(t,e){var u;if("undefined"==typeof StopIteration){try{u=r[t](e)}catch(c){return R(c)}return u.done?p(u.value):y(u.value,o,i)}try{u=r[t](e)}catch(c){return n(c)?p(c.value):R(c)}return y(u,o,i)}var r=t.apply(this,arguments),o=e.bind(e,"next"),i=e.bind(e,"throw");return o()}}function _(t){p.done(p.async(t)())}function C(t){throw new J(t)}function N(t){return function(){return q([this,U(arguments)],function(e,n){return t.apply(e,n)})}}function D(t,e,n){return p(t).dispatch(e,n)}function U(t){return y(t,function(t){var e=0,n=f();return K(t,function(r,o,i){var u;m(o)&&"fulfilled"===(u=o.inspect()).state?t[i]=u.value:(++e,y(o,function(r){t[i]=r,0===--e&&n.resolve(t)},n.reject,function(t){n.notify({index:i,value:t})}))},void 0),0===e&&n.resolve(t),n.promise})}function $(t){return y(t,function(t){return t=X(t,p),y(U(X(t,function(t){return y(t,V,V)})),function(){return t})})}function P(t){return p(t).allSettled()}function I(t,e){return p(t).then(void 0,void 0,e)}function G(t,e){return p(t).nodeify(e)}var M=!1;try{throw new Error}catch(B){M=!!B.stack}var F,J,L=s(),V=function(){},z=function(){function t(){for(;e.next;){e=e.next;var n=e.task;e.task=void 0;var o=e.domain;o&&(e.domain=void 0,o.enter());try{n()}catch(u){if(i)throw o&&o.exit(),setTimeout(t,0),o&&o.enter(),u;setTimeout(function(){throw u},0)}o&&o.exit()}r=!1}var e={task:void 0,next:null},n=e,r=!1,o=void 0,i=!1;if(z=function(t){n=n.next={task:t,domain:i&&process.domain,next:null},r||(r=!0,o())},"undefined"!=typeof process&&process.nextTick)i=!0,o=function(){process.nextTick(t)};else if("function"==typeof setImmediate)o="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else if("undefined"!=typeof MessageChannel){var u=new MessageChannel;u.port1.onmessage=function(){o=c,u.port1.onmessage=t,t()};var c=function(){u.port2.postMessage(0)};o=function(){setTimeout(t,0),c()}}else o=function(){setTimeout(t,0)};return z}(),Q=Function.call,H=t(Array.prototype.slice),K=t(Array.prototype.reduce||function(t,e){var n=0,r=this.length;if(1===arguments.length)for(;;){if(n in this){e=this[n++];break}if(++n>=r)throw new TypeError}for(;r>n;n++)n in this&&(e=t(e,this[n],n));return e}),W=t(Array.prototype.indexOf||function(t){for(var e=0;e<this.length;e++)if(this[e]===t)return e;return-1}),X=t(Array.prototype.map||function(t,e){var n=this,r=[];return K(n,function(o,i,u){r.push(t.call(e,i,u,n))},void 0),r}),Y=Object.create||function(t){function e(){}return e.prototype=t,new e},Z=t(Object.prototype.hasOwnProperty),te=Object.keys||function(t){var e=[];for(var n in t)Z(t,n)&&e.push(n);return e},ee=t(Object.prototype.toString);J="undefined"!=typeof ReturnValue?ReturnValue:function(t){this.value=t};var ne="From previous event:";p.resolve=p,p.nextTick=z,p.longStackSupport=!1,"object"==typeof process&&process&&process.env&&process.env.Q_DEBUG&&(p.longStackSupport=!0),p.defer=f,f.prototype.makeNodeResolver=function(){var t=this;return function(e,n){e?t.reject(e):t.resolve(arguments.length>2?H(arguments,1):n)}},p.Promise=l,p.promise=l,l.race=h,l.all=U,l.reject=R,l.resolve=p,p.passByCopy=function(t){return t},d.prototype.passByCopy=function(){return this},p.join=function(t,e){return p(t).join(e)},d.prototype.join=function(t){return p([this,t]).spread(function(t,e){if(t===e)return t;throw new Error("Can't join: not the same: "+t+" "+e)})},p.race=h,d.prototype.race=function(){return this.then(p.race)},p.makePromise=d,d.prototype.toString=function(){return"[object Promise]"},d.prototype.then=function(t,e,n){function o(e){try{return"function"==typeof t?t(e):e}catch(n){return R(n)}}function i(t){if("function"==typeof e){r(t,c);try{return e(t)}catch(n){return R(n)}}return R(t)}function u(t){return"function"==typeof n?n(t):t}var c=this,s=f(),a=!1;return p.nextTick(function(){c.promiseDispatch(function(t){a||(a=!0,s.resolve(o(t)))},"when",[function(t){a||(a=!0,s.resolve(i(t)))}])}),c.promiseDispatch(void 0,"when",[void 0,function(t){var e,n=!1;try{e=u(t)}catch(r){if(n=!0,!p.onerror)throw r;p.onerror(r)}n||s.notify(e)}]),s.promise},p.tap=function(t,e){return p(t).tap(e)},d.prototype.tap=function(t){return t=p(t),this.then(function(e){return t.fcall(e).thenResolve(e)})},p.when=y,d.prototype.thenResolve=function(t){return this.then(function(){return t})},p.thenResolve=function(t,e){return p(t).thenResolve(e)},d.prototype.thenReject=function(t){return this.then(function(){throw t})},p.thenReject=function(t,e){return p(t).thenReject(e)},p.nearer=v,p.isPromise=m,p.isPromiseAlike=g,p.isPending=j,d.prototype.isPending=function(){return"pending"===this.inspect().state},p.isFulfilled=b,d.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},p.isRejected=w,d.prototype.isRejected=function(){return"rejected"===this.inspect().state};var re=[],oe=[],ie=!0;p.resetUnhandledRejections=k,p.getUnhandledReasons=function(){return re.slice()},p.stopUnhandledRejectionTracking=function(){k(),ie=!1},k(),p.reject=R,p.fulfill=O,p.master=E,p.spread=q,d.prototype.spread=function(t,e){return this.all().then(function(e){return t.apply(void 0,e)},e)},p.async=A,p.spawn=_,p["return"]=C,p.promised=N,p.dispatch=D,d.prototype.dispatch=function(t,e){var n=this,r=f();return p.nextTick(function(){n.promiseDispatch(r.resolve,t,e)}),r.promise},p.get=function(t,e){return p(t).dispatch("get",[e])},d.prototype.get=function(t){return this.dispatch("get",[t])},p.set=function(t,e,n){return p(t).dispatch("set",[e,n])},d.prototype.set=function(t,e){return this.dispatch("set",[t,e])},p.del=p["delete"]=function(t,e){return p(t).dispatch("delete",[e])},d.prototype.del=d.prototype["delete"]=function(t){return this.dispatch("delete",[t])},p.mapply=p.post=function(t,e,n){return p(t).dispatch("post",[e,n])},d.prototype.mapply=d.prototype.post=function(t,e){return this.dispatch("post",[t,e])},p.send=p.mcall=p.invoke=function(t,e){return p(t).dispatch("post",[e,H(arguments,2)])},d.prototype.send=d.prototype.mcall=d.prototype.invoke=function(t){return this.dispatch("post",[t,H(arguments,1)])},p.fapply=function(t,e){return p(t).dispatch("apply",[void 0,e])},d.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},p["try"]=p.fcall=function(t){return p(t).dispatch("apply",[void 0,H(arguments,1)])},d.prototype.fcall=function(){return this.dispatch("apply",[void 0,H(arguments)])},p.fbind=function(t){var e=p(t),n=H(arguments,1);return function(){return e.dispatch("apply",[this,n.concat(H(arguments))])}},d.prototype.fbind=function(){var t=this,e=H(arguments);return function(){return t.dispatch("apply",[this,e.concat(H(arguments))])}},p.keys=function(t){return p(t).dispatch("keys",[])},d.prototype.keys=function(){return this.dispatch("keys",[])},p.all=U,d.prototype.all=function(){return U(this)},p.allResolved=a($,"allResolved","allSettled"),d.prototype.allResolved=function(){return $(this)},p.allSettled=P,d.prototype.allSettled=function(){return this.then(function(t){return U(X(t,function(t){function e(){return t.inspect()}return t=p(t),t.then(e,e)}))})},p.fail=p["catch"]=function(t,e){return p(t).then(void 0,e)},d.prototype.fail=d.prototype["catch"]=function(t){return this.then(void 0,t)},p.progress=I,d.prototype.progress=function(t){return this.then(void 0,void 0,t)},p.fin=p["finally"]=function(t,e){return p(t)["finally"](e)},d.prototype.fin=d.prototype["finally"]=function(t){return t=p(t),this.then(function(e){return t.fcall().then(function(){return e})},function(e){return t.fcall().then(function(){throw e})})},p.done=function(t,e,n,r){return p(t).done(e,n,r)},d.prototype.done=function(t,e,n){var o=function(t){p.nextTick(function(){if(r(t,i),!p.onerror)throw t;p.onerror(t)})},i=t||e||n?this.then(t,e,n):this;"object"==typeof process&&process&&process.domain&&(o=process.domain.bind(o)),i.then(void 0,o)},p.timeout=function(t,e,n){return p(t).timeout(e,n)},d.prototype.timeout=function(t,e){var n=f(),r=setTimeout(function(){e&&"string"!=typeof e||(e=new Error(e||"Timed out after "+t+" ms"),e.code="ETIMEDOUT"),n.reject(e)},t);return this.then(function(t){clearTimeout(r),n.resolve(t)},function(t){clearTimeout(r),n.reject(t)},n.notify),n.promise},p.delay=function(t,e){return void 0===e&&(e=t,t=void 0),p(t).delay(e)},d.prototype.delay=function(t){return this.then(function(e){var n=f();return setTimeout(function(){n.resolve(e)},t),n.promise})},p.nfapply=function(t,e){return p(t).nfapply(e)},d.prototype.nfapply=function(t){var e=f(),n=H(t);return n.push(e.makeNodeResolver()),this.fapply(n).fail(e.reject),e.promise},p.nfcall=function(t){var e=H(arguments,1);return p(t).nfapply(e)},d.prototype.nfcall=function(){var t=H(arguments),e=f();return t.push(e.makeNodeResolver()),this.fapply(t).fail(e.reject),e.promise},p.nfbind=p.denodeify=function(t){var e=H(arguments,1);return function(){var n=e.concat(H(arguments)),r=f();return n.push(r.makeNodeResolver()),p(t).fapply(n).fail(r.reject),r.promise}},d.prototype.nfbind=d.prototype.denodeify=function(){var t=H(arguments);return t.unshift(this),p.denodeify.apply(void 0,t)},p.nbind=function(t,e){var n=H(arguments,2);return function(){function r(){return t.apply(e,arguments)}var o=n.concat(H(arguments)),i=f();return o.push(i.makeNodeResolver()),p(r).fapply(o).fail(i.reject),i.promise}},d.prototype.nbind=function(){var t=H(arguments,0);return t.unshift(this),p.nbind.apply(void 0,t)},p.nmapply=p.npost=function(t,e,n){return p(t).npost(e,n)},d.prototype.nmapply=d.prototype.npost=function(t,e){var n=H(e||[]),r=f();return n.push(r.makeNodeResolver()),this.dispatch("post",[t,n]).fail(r.reject),r.promise},p.nsend=p.nmcall=p.ninvoke=function(t,e){var n=H(arguments,2),r=f();return n.push(r.makeNodeResolver()),p(t).dispatch("post",[e,n]).fail(r.reject),r.promise},d.prototype.nsend=d.prototype.nmcall=d.prototype.ninvoke=function(t){var e=H(arguments,1),n=f();return e.push(n.makeNodeResolver()),this.dispatch("post",[t,e]).fail(n.reject),n.promise},p.nodeify=G,d.prototype.nodeify=function(t){return t?void this.then(function(e){p.nextTick(function(){t(null,e)})},function(e){p.nextTick(function(){t(e)})}):this};var ue=s();return p})}])});