1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.MicroKernel
.Facilities
19 using Castle
.Core
.Configuration
;
22 /// Base class for facilities.
24 public abstract class AbstractFacility
: IFacility
, IDisposable
26 private IKernel kernel
;
27 private IConfiguration facilityConfig
;
30 /// Gets the <see cref="IKernel"/> where the facility is registered.
32 /// <value>The <see cref="IKernel"/>.</value>
35 get { return kernel; }
39 /// Gets the facility configuration.
41 /// <value>The <see cref="IConfiguration"/> representing
42 /// the facility configuration.</value>
43 public IConfiguration FacilityConfig
45 get { return facilityConfig; }
49 /// The custom initialization for the Facility.
51 /// <remarks>It must be overriden.</remarks>
52 protected abstract void Init();
54 #region IFacility Members
57 /// Initializes the facility. First it performs the initialization common for all
58 /// facilities, setting the <see cref="Kernel"/> and the
59 /// <see cref="FacilityConfig"/>. After it, the <c>Init</c> method is invoked
60 /// and the custom initilization is perfomed.
62 /// <param name="kernel"></param>
63 /// <param name="facilityConfig"></param>
64 public void Init(IKernel kernel
, IConfiguration facilityConfig
)
67 this.facilityConfig
= facilityConfig
;
73 /// Terminates the Facility, invokind the <see cref="Dispose"/> and setting
74 /// the Kernel to a null reference.
76 public void Terminate()
85 #region IDisposable Members
88 /// Performs the tasks associated with freeing, releasing, or resetting
89 /// the facility resources.
91 /// <remarks>It can be overriden.</remarks>
92 public virtual void Dispose()