service-model
Version:
An object oriented web service framework inspired by Windows Communication Foundation.
122 lines (121 loc) • 3.94 kB
TypeScript
import { EndpointDescription, EndpointBehavior } from "./endpointDescription";
import { Url } from "../url";
import { Type } from "reflect-helper";
import { DispatchService } from "../dispatcher/dispatchService";
/**
* A description of a service.
*
* <uml>
* hide members
* hide circle
* DispatcherFactory *-- ServiceDescription : services
* ServiceDescription *-- EndpointDescription : endpoints
* Type -* ServiceDescription : serviceType
* ServiceDescription *- ServiceBehavior : behaviors
* </uml>
*/
export declare class ServiceDescription {
/**
* The name of the service.
*/
name: string;
/**
* A list of behaviors that can extend the service.
*/
behaviors: ServiceBehavior[];
/**
* A list of endpoints for the service.
*/
endpoints: EndpointDescription[];
/**
* Metadata information for the concrete type that implements the service.
*/
serviceType: Type;
/**
* Must be set to true when type metadata is not available. For example, when using plain JavaScript. By default an
* error is raised if type metadata is not available.
*/
disableMissingMetadataError: boolean;
/**
* A list of contracts implemented by the service.
* @hidden
*/
private _contracts;
/**
* Constructs a [[ServiceDescription]].
* @param serviceType Metadata information for the concrete type that implements the service.
* @param name The name of the service. If not specified, defaults to the name of the service constructor.
*/
constructor(serviceType: Type, name?: string);
/**
* Adds an endpoint to the service.
* @param contractName The name of the service contract handled by the endpoint.
* @param address The base address of the endpoint.
* @param behaviors A list of behaviors to add to the endpoint.
*/
addEndpoint(contractName: string, address: Url | string, behaviors?: EndpointBehavior | EndpointBehavior[]): EndpointDescription;
/**
* Gets a contract implemented on the service, creating it if it has not yet been created.
* @param name The name of the contract.
* @hidden
*/
private _ensureContract(name);
/**
* Returns true if the service implements the contract; otherwise, returns false.
* @param name The name of the contract.
* @hidden
*/
private _hasContract(name);
/**
* Gets a contract implemented on the service.
* @param name The name of the contract.
* @hidden
*/
private _getContract(name);
/**
* Builds out all contracts implemented on the service.
* @hidden
*/
private _buildContracts();
/**
* Returns true if the object is a [[ContractBehavior]].
* @hidden
*/
private _isContractBehavior(obj);
/**
* Returns true if the object is an [[OperationBehavior]].
* @hidden
*/
private _isOperationBehavior(obj);
/**
* Returns true if the object is a [[ServiceBehavior]].
* @hidden
*/
private _isServiceBehavior(obj);
/**
* Gets the target contract for a behavior annotation.
* @hidden
*/
private _getTargetContract(obj);
/**
* Creates the operation description for a method on the service.
* @hidden
*/
private _createOperation(contact, operationAttribute, method);
/**
* Adds any [[OperationBehaviors]] that exist as annotations on the method.
* @hidden
*/
private _addOperationBehaviors(description, method);
}
/**
* Describes a type that can be used to extend the behavior of a service.
*/
export interface ServiceBehavior {
/**
* Applies the a behavior extension to a [[DispatchService]].
* @param description A description of the behavior.
* @param service The runtime service.
*/
applyServiceBehavior(description: ServiceDescription, service: DispatchService): void;
}