Interpreting petshop3.2 rebuilding series with nhib.pdf (2)

Source: Internet
Author: User
His Architecture

Dao

Bll

Entity idao

Web

I personally think that BLL idao should be separated as a project. In this way, the hierarchy is clearer.

Dao implements the idao interface. Bll contains entity classes and corresponding business logic classes, plus an object factory class.
Public   Bool Signin () {

// Validate input

If (Userid. Trim () =   String . Empty) | (Password. Trim () =   String . Empty )) Return   False ;


// Try to sign in with the given credentials

Return (Isignondao) objectfactory. getinstance ( " Signondao " ). Signin ( This );

}

The above method shows how the signon object logs on to the system.

Use the object factory to obtain the DaO instance, convert it into an excuse, and call the corresponding login method.

The object Factory
Using System;

Using System. Web;

Using Spring. context;

Using Spring. Context. Support;


Namespace Petshop. BLL {



Public   Class Objectfactory {



Private   Static Iapplicationcontext CTX;


Static Objectfactory () {

CTX= NewXmlapplicationcontext ("Assembly: // petshop. Dao/petshop/objects. xml");

}


Public   Static Object getinstance ( String Name) {

ReturnCTX. GetObject (name );

}

}

}

A static constructor is used to initialize the petshop. Objects. xml file of the petshop. Dao project. These classes have been initialized.

There is also a static method to return the object corresponding to the name.

Sprint.net

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.