Integrate thrift0.9.2 generated WCF intermediate code with spring.services-complex architecture for simple code and high maintainability

Source: Internet
Author: User

Reference page:

Http://www.yuanjiaocheng.net/CSharp/csharp-class.html

Http://www.yuanjiaocheng.net/CSharp/csharp-variable.html

Http://www.yuanjiaocheng.net/CSharp/Csharp-data-types.html

Http://www.yuanjiaocheng.net/CSharp/cshart-value-reference-type.html

Http://www.yuanjiaocheng.net/CSharp/Csharp-keys.html

Recently have been looking at the relevant articles about thrift, the content of the basic is the surface. Once the specific use of the actual project, you will encounter a variety of problems!

For example: Thrift server-side carrier selection, intermediate code generation options (Async ASYNCCTP WCF, and so on), the implementation of the server-side and client-base framework selection, and hosting the combination of the various layers of the IOC architecture.

In fact, these things, the content is quite many. Maybe you read this article on a lot of thrift must be to do some of the basics to understand, there are windowsservices, WCF, spring.net!

Here, I use C # as a server and customer, of course, the server side of the published interface client does not care what language you are. Just thrift the compiler to generate the corresponding intermediate code and then write the code accordingly OK.

Here's the code structure I chose:

Server-side carrier I chose Windows Services, and the compiler was definitely using the official newest thrift0.9.2 (I chose WCF when the code was generated), and as for Thrift's infrastructure, I chose. NET Thrift and Thrift.server and Thrift.client (the client can support multiple server-side configurations This is what I'm looking for), the IOC framework, in fact the ready-made injection framework is much more, what autoface,unity, Spring.net and so on; in fact, ultimately we choose these dependency injections to be clear: (personal view) make our architecture looser, code more beautiful, code less, highly reusable, and easier to maintain. In fact, no matter what the choice is, the purpose of clear your choice is at a glance. Here my choice certainly is spring.net, because it has to wcf,webservice,windowsservice,remoting and so on special support spring.services. Another reason is too much, let me save a lot of code, so that the original bloated WCF code becomes clear, and it also unifies the dependency injection of all projects.

Where the Thrift Code Generation command is: Thrift-gen CSHARP:WCF *.thrift

Now you don't see the content of spring, it's supposed to be about combining loose code with a final product. So it involves a lot of spring configuration. And will eventually be visible only in the ServerHost project's app. config.

Of course, the code inside is quite small, because spring.services inside the integration, and a package, ServerHost inside the code will not change, the only thing you have to do is how to integrate the various modules with the configuration .

From the present structure depending on the look is very simple, it is not, to really integrate them together to do a lot of configuration and debugging work

Here's a look at the generated DLL file:

This is just a DLL file, I believe I used spring to know. Spring brings the gospel to code and structure, but the writing of configuration files and the debugging and integration of the entire framework is a headache.

However, with. NET open source, the project architecture and scalability, distributed, maintainability requirements are also slowly reflected.

So do. NET students, do not just see. NET agile development, to see it has more ambitious goals (distributed, cloud storage, search engines, etc.), and to achieve this goal, we must pay attention to a variety of third-party development middleware, regardless of its prototype is Java development, PHP developed, Developed in other languages. The most important thing is that it can bring us what we want, it can make our program not difficult to maintain, let the system like a baby can gradually grow, rather than other languages replaced, or a variety of repetitive development.

Integrate thrift0.9.2 generated WCF intermediate code with spring.services-complex architecture for simple code and high maintainability

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.