First of all, maybe I am a lazy, and my blog has not been written for nearly a month. I am sorry to my friends. A lot of things have happened recently. floods in the south, floods in the north, and hot in the north, lanzhou does not know that many teenagers have not encountered a 40-degree high temperature. In fact, this is a talking thing. I have to live my life. I have already slept, and I am afraid I can't sleep. I wrote this post.
To put it bluntly, there is a service locator mode in the design module, which is probably the guy I call him a service locator, agileeas. NET platform service locator also implements this mode in theory. It serves as a supplement to the object control reversal IOC, and completes the object (service) decoupling work together.
The basic idea of the service locator mode is: the service locator knows how to obtain an application.ProgramAll services required. That is to say, in a specific application, the service consumer obtains the specified service implementation through the service locator, so as to implement the service consumer, service definition, and actual service.CodeDecoupling, service consumers can register different implementations on the same interface, so that the implemented functions can be changed without changing the code used.
The function of the Service positioner focuses on service decoupling, while the function of the IOC container lies in the solution of objects. In essence, the service is also an object, in theory, IOC containers can also perform service decoupling. However, in Distributed communication systems with different technologies, IOC decoupling costs are much higher, and service positioner alone are even better, in agileeas. the service locator in the. NET platform also provides the implementation of IOC solution, that is, it can point the service object to a container in IOC.
The above paragraphs are very difficult to find. If the simplest understanding is to use a service locator to isolate service positioning and service implementation, you can use pre-defined service interfaces and configuration files to strip service interfaces from Service implementations. Service implementations can be bound later through service locators at runtime.
Agileeas. the service positioner In the. NET platform can be understood as the implementation of the service positioner mode, or the discovery, positioning, and integration of different services (WebService and remoting) in enterprise applications, from the application perspective, agileeas. the service locator of the net Platform tends to be the latter. Let's take a look at agileeas. NET platform service locator structure:
We can see that the agileeas. NET platform provides the XML WebService,. Net remoting, and local service component three service positioner implementations. Let's take a closer look at the iservicelocator interface:
/// <Summary> /// Service locator interface. /// </Summary> Public Interface Iservicelocator {/// <Summary> /// Locate the specified service. /// </Summary> /// <Param name = "servicename"> service name. </Param> /// <Returns> Service (proxy) object. </Returns> Object Getservice ( String Servicename ); /// <Summary> /// Locate the specified service. /// </Summary> /// <Param name = "servicename"> service name. </Param> /// <Param name = "interfacetype"> service interface. </Param> /// <Returns> Service (proxy) object. </Returns> Object Getservice ( String Servicename, type interfacetype );}
We can know from the iservicelocator interface that SL only provides the service instance or service proxy object that is returned according to the service name and service interface definition for the caller to use.
The interface-driven idea is also fully applied in the service positioner design. for various services provided by the system, the image extraction service interface is required. service consumers directly use the interface to call services, the specific service implementation enables the service locator to dynamically discover and locate the service at runtime.
Currently, agileeas.. NET platform implements XML WebService ,. net remoting and Local Service component locators, the positioning of local components (services) is directly routed to the service components configured in the IOC container, for XML WebService ,. net remoting service, which can be routed to the pre-implemented Service Proxy component in the IOC container, or the Service Proxy component can be directly generated by SL.
Agileeas. NET platform service locator isolates service interfaces and Service implementations through configuration files. The following is an example of a sl configuration file:
< Service Name = "EAS. rmiservice. Service" Service - Type = "Dotnetremoting" Singleton = "True" URL = "TCP: // localhost: 8000/EAS. rmiservice" /> < Service Name ="EAS. filetransservice. Service" Service - Type = "WebService" Singleton = "True" URL = "Http: // localhost: 82/distributed/rmiservice. asmx" /> < Service Name = "EAS. dataaccessservice. Service" Service -Type = "Localcomponent" Component = "Dataaccessor" />
Speaking of this, maybe one person already knows what is going on. Maybe some people are still dancing in the cloud. In fact, I personally do not like this method, here is a simple example of how to use SL to unify local service components, XML WebService, and ,. net remoting service call example. Final advertisement:
QQ: 15118502
Link: agileeas. NET application development platform Introduction
Agile parallel development method of agileeas. net
Agile Software Engineering Lab