Software Layers

Gazel provides a layered software architecture. Here is the list of all available layers in different application types;

Gazel requires you to write your business functionality only in module projects. Other layers are there only for non-functional requirements such as authentication, authorization, monitoring, database connection management, transaction management etc.

IoC Layer

This is a base layer that exists in all types of applications. Gazel uses Castle.Windsor as its IoC Container.

To create a new configuration in this layer, you need to create a class that implements IIoCConfiguration in a configuration or host project. Here is an example for a convention;

public class OperationConvention : IIoCConfiguration { public void Configure(IKernel kernel) { kernel.Register( Classes.FromAssemblyInThisApplication() .AllowMultipleMatches() .Where(t => t.Name.EndsWith("Operation")) .WithServiceSelf() .WithServiceAllInterfaces() .LifestyleTransient() ); } }

This convention would register all types in your application with a transient lifestyle. For more information see Castle.Windsor Documentation.

Data Access Layer

Gazel makes use of Generic Repository Pattern with two interfaces IRepository<T> and ILookup<T>. With their NHibernate implementations NHibernateRepository<T> and NHibernateLookup<T>, Gazel enables your module classes to perform CRUD operations. Fluent NHibernate is used to configure data access layer by conventions.

To create a new configuration in this layer, there are two configuration interfaces:

  • IMappingConfiguration: Helps you to have an access to AutoPersistenceModel instance so that you can create new ORM conventions, or override existing conventions.
  • INHibernateConfiguration: Helps you to have an access to FluentConfiguration instance so that you can configure other things than class mappings.
public class MappingOverrides : IMappingConfiguration { public void Configure(AutoPersistenceModel persistenceModel, IKernel kernel) { persistenceModel .Override<User>(u => u.Table("[User]")) .Override<Product>(aip => aip.Id(x => x.Id).GeneratedBy.Assigned()) ; } }

For more information see Fluent NHibernate Documentation.

Business Logic Layer

This layer is where your business functionality goes. Business logic layer scans your module assemblies and registers your classes to IoC container, configures its methods to be business services, and maps them to database tables.

There is nothing to configure in this layer. To learn how to develop your functional needs in Gazel, have a look at our Getting Started and Features pages.

Service Layer

Service layer is the one that converts your public methods to business services. Gazel uses Routine to make this happen.

To create a new configuration in this layer, there are three configuration interfaces:

  • ICodingStyleConfiguration: Helps you to define new coding styles for your business modules.
  • IServiceConfiguration: Helps you to configure request and response headers of your busines services.
  • IInterceptionConfiguration: Helps you to configure service-level interceptors.
public class ServiceOverrides : ICodingStyleConfiguration, IInterceptionConfiguration { public void Configure(ConventionBasedCodingStyle codingStyle, IKernel kernel) { codingStyle .OperationMarks.Add("Critical", o => o.Name == "Delete") ; } public int InterceptionOrder { get { return Constants.INTERCEPTION_ORDER_DOESNT_MATTER; } } public void Configure(ConventionBasedInterceptionConfiguration interceptionConfiguration, IKernel kernel) { interceptionConfiguration .ServiceInterceptors.Add(c => c .Interceptor(i => i .Before(ctx => { LogManager.Get("Critical").Warn("something critical happened"); }) ).When(o => o.OperationModel.Marks.Contains("Critical")) ) ; } }

Service Client Layer

This layer configures Routine to consume business services internally and is used by web service - service client applications.

Web Service Layer

This renders Web API Controller classes or WCF Service classes and configures them to consume your business services through service client layer. Using this layer, Gazel exposes the business services you want to be publicly available.