docs: function register(jolokia, scope, arguments, callback) {
          if (scope.$$destroyed) {
              // fail fast to prevent registration leaks
              return;
          }
          /*
          if (scope && !Core.isBlank(scope.name)) {
            Core.log.debug("Calling register from scope: ", scope.name);
          } else {
            Core.log.debug("Calling register from anonymous scope");
          }
          */
          if (!angular.isDefined(scope.$jhandle) || !angular.isArray(scope.$jhandle)) {
              //log.debug("No existing handle set, creating one");
              scope.$jhandle = [];
          }
          else {
              //log.debug("Using existing handle set");
          }
          if (angular.isDefined(scope.$on)) {
              scope.$on('$destroy', function (event) {
                  unregister(jolokia, scope);
              });
          }
          var handle = null;
          if ('success' in callback) {
              var cb_1 = callback.success;
              var args_1 = arguments;
              callback.success = function (response) {
                  addResponse(args_1, response);
                  cb_1(response);
              };
          }
          if (angular.isArray(arguments)) {
              if (arguments.length >= 1) {
                  // TODO can't get this to compile in typescript :)
                  //let args = [callback].concat(arguments);
                  var args_2 = [callback];
                  angular.forEach(arguments, function (value) { return args_2.push(value); });
                  //let args = [callback];
                  //args.push(arguments);
                  var registerFn = jolokia.register;
                  handle = registerFn.apply(jolokia, args_2);
                  scope.$jhandle.push(handle);
                  getResponse(jolokia, arguments, callback);
              }
          }
          else {
              handle = jolokia.register(callback, arguments);
              scope.$jhandle.push(handle);
              getResponse(jolokia, arguments, callback);
          }
          return function () {
              if (handle !== null) {
                  scope.$jhandle.remove(handle);
                  jolokia.unregister(handle);
              }
          };
      }