service-model
Version:
An object oriented web service framework inspired by Windows Communication Foundation.
48 lines (47 loc) • 1.6 kB
JavaScript
/**
* Represents a service in the dispatcher. Exposes the configuration options for the service.
*
* <uml>
* hide members
* hide circle
* RequestDispatcher *-- DispatchService : services
* DispatchService *-- DispatchEndpoint : endpoints
* DispatchService *- InstanceProvider : instanceProvider
* </uml>
*/
var DispatchService = (function () {
function DispatchService(dispatcher, name) {
this.dispatcher = dispatcher;
this.endpoints = [];
/**
* Specifies whether to create an [[OperationContext]] for operations in this service. The default value is 'false'.
*/
this.createOperationContext = false;
if (!dispatcher) {
throw new Error("Missing required parameter 'dispatcher'.");
}
if (!name) {
throw new Error("Missing required parameter 'name'.");
}
this.name = name;
}
/**
* Validates that the service is correctly configured.
*/
DispatchService.prototype.validate = function () {
if (!this.instanceProvider) {
this._throwConfigError("Undefined 'instanceProvider'.");
}
this.endpoints.forEach(function (endpoint) { return endpoint.validate(); });
};
/**
* Throws a configuration error.
* @param message A message to display
* @hidden
*/
DispatchService.prototype._throwConfigError = function (message) {
throw new Error("Service '" + this.name + "' incorrectly configured." + message);
};
return DispatchService;
})();
exports.DispatchService = DispatchService;