Delphi Spring

          今天發現了一個delhpi的Spring框架,而且這家還是易博龍的合作伙伴。

 

          轉自官方wiki。

 

         

Architecture   系統架構

The Delphi Spring Framework consists of the following libraries:

Delphi Spring 框架包含如下這些庫:

  • Spring.Base

Provides the fundamental classes for the framework. Some of them are designed based on the .Net framework.

 

- Spring.Base

提供框架的基本類,其中的一部分是基於.net 框架設計。

  • Spring.Core

Provides the higher level and core features. e.g. Inversion Of Control (IoC) container.

 

-Spring.Core

提供更高層的以及核心特性,例如控制反轉(IoC)容器。

  • Spring.Extensions

Includes some useful features such as Numbering.

 

-Spring.Extensions

包含一些實用功能例如數值處理。

 

 

 

Dependency Injection by the IoC container
IOC容器依賴注入

The following code demonstrates how to use the IoC container: (Register->Build->Resolve->Release)

下面的代碼是使用IoC容器的示例:(註冊-》構建-》解析-》釋放)

// uses Spring.IoC; 
var 
  container: TContainer; 
  customer: TCustomer; 
begin 
  container := TContainer.Create; 
  try 
    container.RegisterComponent<TRealCreditCardService> 
      .Implements<ICreditCardService> 
      .AsSingleton; 
    container.RegisterComponent<TCustomer>; 
    container.Build; 
    customer := container.Resolve<TCustomer>; // Auto-wiring 
    try 
      customer.PayByCreditCard(...); 
    finally 
      container.Release(customer); 
    end; 
  finally 
    container.Free; 
  end; 
end.

 

 

 

       看到了麼,是四大步驟Register->Build->Resolve->Release,註冊->構建->解析->釋放。   Java Spring 出到3了,加入了註解功能以及新的配置方法,只看了看2.5的 ,3 的新增還沒有細看,不知是不是也能支持直接在語言代碼中自動裝配,看到delphi spring確實簡潔,整個的註冊構建和裝配(解析)以及釋放的過程都在代碼中實現,而且很直觀明晰。

 

  

 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章