service-model
Version:
An object oriented web service framework inspired by Windows Communication Foundation.
50 lines (49 loc) • 1.6 kB
JavaScript
/**
* Represents an operation on a service endpoint in the dispatcher. Exposes configuration options for the operation.
*
* <uml>
* hide members
* hide circle
* DispatchEndpoint *-- DispatchOperation : operations
* DispatchOperation *-- OperationInvoker : invoker
* DispatchOperation *-- MessageFormatter : formatter
* </uml>
*/
var DispatchOperation = (function () {
/**
* Constructs a dispatch operation.
* @param endpoint The endpoint.
* @param name The name of the operation.
*/
function DispatchOperation(endpoint, name) {
this.endpoint = endpoint;
if (!endpoint) {
throw new Error("Missing required parameter 'endpoint'.");
}
if (!name) {
throw new Error("Missing required parameter 'name'.");
}
this.name = name;
}
/**
* Validates that the operation is correctly configured.
*/
DispatchOperation.prototype.validate = function () {
if (!this.formatter) {
this._throwConfigError("Undefined 'formatter'.");
}
if (!this.invoker) {
this._throwConfigError("Undefined 'invoker'.");
}
};
/**
* Throws a configuration error.
* @param message A message to display
* @hidden
*/
DispatchOperation.prototype._throwConfigError = function (message) {
throw new Error("Operation '" + this.name + "' on service '" + this.endpoint.service.name + "' incorrectly configured. " + message);
};
return DispatchOperation;
})();
exports.DispatchOperation = DispatchOperation;