avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject svn commit: rev 43398 - in avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel: . Assemble Factory/Default Handler Handler/Default
Date Sun, 05 Sep 2004 22:48:16 GMT
Author: hammett
Date: Sun Sep  5 15:48:15 2004
New Revision: 43398

Added:
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/BaseComponentFactory.cs
  (contents, props changed)
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandler.cs
  (contents, props changed)
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandlerFactory.cs
Removed:
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/SimpleComponentFactory.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/SimpleHandler.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/SimpleHandlerFactory.cs
Modified:
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Assemble/Assembler.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ComponentInstanceBurden.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ConcernChainComponentFactory.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandler.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandlerFactory.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs
   avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln
Log:
More and more refactor.

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj
Sun Sep  5 15:48:15 2004
@@ -249,17 +249,17 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Factory\Default\ComponentInstanceBurden.cs"
+                    RelPath = "Factory\Default\BaseComponentFactory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Factory\Default\ConcernChainComponentFactory.cs"
+                    RelPath = "Factory\Default\ComponentInstanceBurden.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Factory\Default\SimpleComponentFactory.cs"
+                    RelPath = "Factory\Default\ConcernChainComponentFactory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
@@ -309,22 +309,22 @@
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Handler\Default\DefaultHandler.cs"
+                    RelPath = "Handler\Default\BaseHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Handler\Default\DefaultHandlerFactory.cs"
+                    RelPath = "Handler\Default\BaseHandlerFactory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Handler\Default\SimpleHandler.cs"
+                    RelPath = "Handler\Default\DefaultHandler.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />
                 <File
-                    RelPath = "Handler\Default\SimpleHandlerFactory.cs"
+                    RelPath = "Handler\Default\DefaultHandlerFactory.cs"
                     SubType = "Code"
                     BuildAction = "Compile"
                 />

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Assemble/Assembler.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Assemble/Assembler.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Assemble/Assembler.cs	Sun
Sep  5 15:48:15 2004
@@ -31,12 +31,8 @@
 	/// <summary>
 	/// Summary description for Assembler.
 	/// </summary>
-	public class Assembler
+	public abstract class Assembler
 	{
-		private Assembler()
-		{
-		}
-
 		/// <summary>
 		/// 
 		/// </summary>

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs	Sun Sep  5
15:48:15 2004
@@ -51,7 +51,7 @@
 			m_key2Handler = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
 			m_subsystems = new Hashtable();
 			m_facilities = new Hashtable();
-			HandlerFactory = new SimpleHandlerFactory();
+			HandlerFactory = new BaseHandlerFactory();
 			ModelBuilder = new DefaultComponentModelBuilder(this);
 			LifestyleManagerFactory = new SimpleLifestyleManagerFactory();
 
@@ -126,10 +126,11 @@
 		}
 
 		/// <summary>
-		/// 
+		/// Adds a <see cref="IKernelFacility"/> implementation to 
+		/// the kernel.
 		/// </summary>
-		/// <param name="key"></param>
-		/// <param name="facility"></param>
+		/// <param name="key">Facility id</param>
+		/// <param name="facility">Facility instance</param>
 		public virtual void AddFacility(String key, IKernelFacility facility)
 		{
 			AssertUtil.ArgumentNotNull(key, "key");
@@ -141,9 +142,9 @@
 		}
 
 		/// <summary>
-		/// 
+		/// Removes a <see cref="IKernelFacility"/> from the kernel.
 		/// </summary>
-		/// <param name="key"></param>
+		/// <param name="key">Facility id</param>
 		public virtual void RemoveFacility(String key)
 		{
 			AssertUtil.ArgumentNotNull(key, "key");
@@ -165,7 +166,7 @@
 
 		public IHandler GetHandler(String key, object criteria)
 		{
-			// TODO: IHandler GetHandler( String key, object criteria )
+			// TODO: Delegates invocation to LookupSubsystem
 			return null;
 		}
 

Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/BaseComponentFactory.cs
==============================================================================
--- (empty file)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/BaseComponentFactory.cs
Sun Sep  5 15:48:15 2004
@@ -0,0 +1,156 @@
+ // Copyright 2004 The Apache Software Foundation
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Apache.Avalon.Castle.MicroKernel.Factory.Default
+{
+	using System;
+	using System.Collections;
+
+	using Apache.Avalon.Castle.MicroKernel.Assemble;
+	using Apache.Avalon.Castle.MicroKernel.Handler;
+	using Apache.Avalon.Castle.MicroKernel.Model;
+
+	/// <summary>
+	/// Summary description for SimpleComponentFactory.
+	/// </summary>
+	public class BaseComponentFactory : IComponentFactory
+	{
+		private Hashtable m_instance2Burden = new Hashtable();
+		protected IKernel m_kernel;
+		protected IHandler m_handler;
+		protected IComponentModel m_componentModel;
+		protected Hashtable m_serv2handler;
+
+		public BaseComponentFactory(IKernel kernel, IHandler handler,
+		                            IComponentModel componentModel,
+		                            Hashtable serv2handler)
+		{
+			AssertUtil.ArgumentNotNull(kernel, "kernel");
+			AssertUtil.ArgumentNotNull(componentModel, "componentModel");
+			AssertUtil.ArgumentNotNull(serv2handler, "serv2handler");
+
+			m_kernel = kernel;
+			m_handler = handler;
+			m_componentModel = componentModel;
+			m_serv2handler = serv2handler;
+		}
+
+		#region IComponentFactory Members
+
+		public virtual Object Incarnate()
+		{
+			try
+			{
+				ComponentInstanceBurden burden = new ComponentInstanceBurden();
+
+				object[] arguments = BuildArguments(burden);
+
+				Object instance = Activator.CreateInstance(m_componentModel.ConstructionModel.Implementation,
arguments);
+
+				SetupProperties(instance, burden);
+				AssociateBurden(instance, burden);
+				instance = RaiseWrapEvent(instance);
+				RaiseComponentReadyEvent(instance);
+
+				return instance;
+			}
+			catch(Exception ex)
+			{
+				throw new HandlerException("Exception while attempting to instantiate type", ex);
+			}
+		}
+
+		public virtual void Etherialize(object instance)
+		{
+			if (instance == null)
+			{
+				return;
+			}
+
+			RaiseComponentReleasedEvent(instance);
+			instance = RaiseUnWrapEvent(instance);
+			ReleaseBurden(instance);
+		}
+
+		#endregion
+
+		private void AssociateBurden(object instance, ComponentInstanceBurden burden)
+		{
+			if (burden.HasBurden)
+			{
+				m_instance2Burden.Add(instance, burden);
+			}
+		}
+
+		private void ReleaseBurden(object instance)
+		{
+			if (m_instance2Burden.ContainsKey(instance))
+			{
+				ComponentInstanceBurden burden =
+					(ComponentInstanceBurden) m_instance2Burden[ instance ];
+
+				burden.ReleaseBurden();
+
+				m_instance2Burden.Remove(instance);
+			}
+		}
+
+		protected virtual object[] BuildArguments(ComponentInstanceBurden burden)
+		{
+			return Assembler.BuildConstructorArguments(
+				m_componentModel, burden, new ResolveTypeHandler(ResolveType));
+		}
+
+		protected virtual void SetupProperties(object instance, ComponentInstanceBurden burden)
+		{
+			Assembler.AssembleProperties(
+				instance, m_componentModel, burden, new ResolveTypeHandler(ResolveType));
+		}
+
+		private void ResolveType(IComponentModel model, Type typeRequest,
+		                         String argumentOrPropertyName, object key, out object value)
+		{
+			value = null;
+
+			if (m_serv2handler.ContainsKey(typeRequest))
+			{
+				IHandler handler = (IHandler) m_serv2handler[ typeRequest ];
+				value = handler.Resolve();
+
+				ComponentInstanceBurden burden = (ComponentInstanceBurden) key;
+				burden.AddBurden(value, handler);
+			}
+		}
+
+		protected virtual object RaiseWrapEvent(object instance)
+		{
+			return m_kernel.RaiseWrapEvent(m_handler, instance);
+		}
+
+		protected virtual object RaiseUnWrapEvent(object instance)
+		{
+			return m_kernel.RaiseUnWrapEvent(m_handler, instance);
+		}
+
+		protected virtual void RaiseComponentReadyEvent(object instance)
+		{
+			m_kernel.RaiseComponentReadyEvent(m_handler, instance);
+		}
+
+		protected virtual void RaiseComponentReleasedEvent(object instance)
+		{
+			m_kernel.RaiseComponentReleasedEvent(m_handler, instance);
+		}
+	}
+}
\ No newline at end of file

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ComponentInstanceBurden.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ComponentInstanceBurden.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ComponentInstanceBurden.cs
Sun Sep  5 15:48:15 2004
@@ -1,87 +1,78 @@
-// Copyright 2004 The Apache Software Foundation
-// 
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-// 
-//     http://www.apache.org/licenses/LICENSE-2.0
-// 
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-namespace Apache.Avalon.Castle.MicroKernel.Factory.Default
-{
-	using System;
-	using System.Collections;
-
-	/// <summary>
-	/// ComponentInstanceBurden is responsible for keep tracking 
-	/// of dependencies assembled by the container - not by 
-	/// the component code - and release it correctly on disposal
-	/// </summary>
-	public class ComponentInstanceBurden
-	{
-		private ArrayList m_list = new ArrayList();
-
-		public ComponentInstanceBurden()
-		{
-		}
-
-		public void AddBurden( Object instance, IHandler handler )
-		{
-			m_list.Add( new BurdenData( instance, handler ) );
-		}
-
-		public bool HasBurden
-		{
-			get
-			{
-				return m_list.Count != 0;
-			}
-		}
-
-		public void ReleaseBurden()
-		{
-			foreach( BurdenData data in m_list )
-			{
-				data.Handler.Release( data.Instance );
-			}
-
-			m_list.Clear();
-		}
-	}
-
-	class BurdenData 
-	{
-		private object m_instance;
-		private IHandler m_handler;
-
-		public BurdenData( object instance, IHandler handler )
-		{
-			AssertUtil.ArgumentNotNull( instance, "instance" );
-			AssertUtil.ArgumentNotNull( handler, "handler" );
-
-			m_instance = instance;
-			m_handler = handler;
-		}
-
-		public object Instance
-		{
-			get
-			{
-				return m_instance;
-			}
-		}
-
-		public IHandler Handler
-		{
-			get
-			{
-				return m_handler;
-			}
-		}
-	}
-}
+ // Copyright 2004 The Apache Software Foundation
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Apache.Avalon.Castle.MicroKernel.Factory.Default
+{
+	using System;
+	using System.Collections;
+
+	/// <summary>
+	/// ComponentInstanceBurden is responsible for keep track 
+	/// of dependencies assembled by the container - not by 
+	/// the component code - and release them on owner disposal
+	/// </summary>
+	public class ComponentInstanceBurden
+	{
+		private IList m_list = new ArrayList();
+
+		public ComponentInstanceBurden()
+		{
+		}
+
+		public void AddBurden(Object instance, IHandler handler)
+		{
+			m_list.Add(new BurdenData(instance, handler));
+		}
+
+		public bool HasBurden
+		{
+			get { return m_list.Count != 0; }
+		}
+
+		public void ReleaseBurden()
+		{
+			foreach(BurdenData data in m_list)
+			{
+				data.Handler.Release(data.Instance);
+			}
+
+			m_list.Clear();
+		}
+	}
+
+	internal class BurdenData
+	{
+		private object m_instance;
+		private IHandler m_handler;
+
+		public BurdenData(object instance, IHandler handler)
+		{
+			AssertUtil.ArgumentNotNull(instance, "instance");
+			AssertUtil.ArgumentNotNull(handler, "handler");
+
+			m_instance = instance;
+			m_handler = handler;
+		}
+
+		public object Instance
+		{
+			get { return m_instance; }
+		}
+
+		public IHandler Handler
+		{
+			get { return m_handler; }
+		}
+	}
+}
\ No newline at end of file

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ConcernChainComponentFactory.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ConcernChainComponentFactory.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/ConcernChainComponentFactory.cs
Sun Sep  5 15:48:15 2004
@@ -20,28 +20,36 @@
 	using Apache.Avalon.Castle.MicroKernel.Concerns;
 
 	/// <summary>
-	/// Summary description for ConcernChainComponentFactory.
+	/// Sits on the place of a standard <see cref="IComponentFactory"/>
+	/// but makes the process of construction and destruction pass through 
+	/// a Concern Chain. 
+	/// <para>The actual construction should happen when the CreationConcern
+	/// invokes the delegate factory. The same for the destruction phase.</para>
 	/// </summary>
+	/// <remarks>
+	/// It is important to invoke the delegate factory for creation and destruction 
+	/// of a component instance as it will fire the proper events in the correct order.
+	/// </remarks>
 	public class ConcernChainComponentFactory : IComponentFactory
 	{
 		private IConcern m_commissionChain;
 		private IConcern m_decomissionChain;
 		private IComponentModel m_model;
-		private IComponentFactory m_innerFactory;
+		private IComponentFactory m_delegateFactory;
 
 		public ConcernChainComponentFactory(
 			IConcern commissionChain, IConcern decomissionChain, 
-			IComponentModel model, IComponentFactory innerFactory)
+			IComponentModel model, IComponentFactory delegateFactory)
 		{
 			AssertUtil.ArgumentNotNull( commissionChain, "commissionChain" );
 			AssertUtil.ArgumentNotNull( decomissionChain, "decomissionChain" );
 			AssertUtil.ArgumentNotNull( model, "model" );
-			AssertUtil.ArgumentNotNull( innerFactory, "innerFactory" );
+			AssertUtil.ArgumentNotNull( delegateFactory, "delegateFactory" );
 
 			m_commissionChain = commissionChain;
 			m_decomissionChain = decomissionChain;
 			m_model = model;
-			m_innerFactory = innerFactory;
+			m_delegateFactory = delegateFactory;
 		}
 
 		#region IComponentFactory Members
@@ -50,7 +58,7 @@
 		{
 			ICreationConcern creationConcern = (ICreationConcern) m_commissionChain;
 
-			object instance = creationConcern.Apply( m_model, m_innerFactory );
+			object instance = creationConcern.Apply( m_model, m_delegateFactory );
 
 			creationConcern.Apply( m_model, instance );
 
@@ -67,7 +75,7 @@
 			{
 				if (concern is IDestructionConcern)
 				{
-					(concern as IDestructionConcern).Apply( m_model, m_innerFactory, instance );
+					(concern as IDestructionConcern).Apply( m_model, m_delegateFactory, instance );
 					break;
 				}
 				

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/AbstractHandler.cs
Sun Sep  5 15:48:15 2004
@@ -47,7 +47,6 @@
         public AbstractHandler(IComponentModel model)
         {
             AssertUtil.ArgumentNotNull(model, "model");
-
             m_componentModel = model;
         }
 

Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandler.cs
==============================================================================
--- (empty file)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandler.cs
Sun Sep  5 15:48:15 2004
@@ -0,0 +1,108 @@
+ // Copyright 2004 The Apache Software Foundation
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Apache.Avalon.Castle.MicroKernel.Handler.Default
+{
+	using System;
+
+	using Apache.Avalon.Castle.MicroKernel.Model;
+	using Apache.Avalon.Castle.MicroKernel.Factory.Default;
+
+	/// <summary>
+	/// Provides a fully functional component handler.
+	/// </summary>
+	public class BaseHandler : AbstractHandler
+	{
+		/// <summary>
+		/// 
+		/// </summary>
+		/// <param name="model"></param>
+		public BaseHandler(IComponentModel model) : base(model)
+		{
+		}
+
+		#region IHandler Members
+
+		public override void Init(IKernel kernel)
+		{
+			base.Init(kernel);
+
+			// Now we check with the kernel if 
+			// we have the necessary implementations 
+			// for the services requested by the constructor
+
+			EnsureDependenciesCanBeSatisfied();
+			CreateComponentFactoryAndLifestyleManager();
+		}
+
+		#endregion
+
+		protected virtual void EnsureDependenciesCanBeSatisfied()
+		{
+			foreach(IDependencyModel dependency in ComponentModel.Dependencies)
+			{
+				AddDependency(dependency.Service);
+			}
+		}
+
+		protected virtual void AddDependency(Type service)
+		{
+			if (Kernel.HasService(service))
+			{
+				m_serv2handler[ service ] = Kernel.GetHandlerForService(service);
+			}
+			else
+			{
+				// This handler is considered invalid
+				// until dependencies are satisfied
+				SetNewState(State.WaitingDependency);
+				Dependencies.Add(service);
+
+				// Register ourself in the kernel
+				// to be notified if the dependency is satified
+				Kernel.AddDependencyListener(
+					service,
+					new DependencyListenerDelegate(DependencySatisfied));
+			}
+		}
+
+		/// <summary>
+		/// Delegate implementation invoked by kernel
+		/// when one of registered dependencies were satisfied by 
+		/// new components registered.
+		/// </summary>
+		/// <param name="service"></param>
+		/// <param name="handler"></param>
+		private void DependencySatisfied(Type service, IHandler handler)
+		{
+			m_serv2handler[ service ] = handler;
+
+			Dependencies.Remove(service);
+
+			if (Dependencies.Count == 0)
+			{
+				SetNewState(State.Valid);
+			}
+		}
+
+		protected virtual void CreateComponentFactoryAndLifestyleManager()
+		{
+			IComponentFactory factory = new BaseComponentFactory(
+				Kernel, this, ComponentModel, m_serv2handler);
+
+			m_lifestyleManager = Kernel.LifestyleManagerFactory.Create(
+				factory, ComponentModel);
+		}
+	}
+}
\ No newline at end of file

Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandlerFactory.cs
==============================================================================
--- (empty file)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/BaseHandlerFactory.cs
Sun Sep  5 15:48:15 2004
@@ -0,0 +1,44 @@
+// Copyright 2004 The Apache Software Foundation
+// 
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// 
+//     http://www.apache.org/licenses/LICENSE-2.0
+// 
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+namespace Apache.Avalon.Castle.MicroKernel.Handler.Default
+{
+	using System;
+
+	using Apache.Avalon.Castle.MicroKernel.Model;
+
+	/// <summary>
+	/// Summary description for BaseHandlerFactory.
+	/// </summary>
+	public class BaseHandlerFactory : IHandlerFactory
+	{
+		public BaseHandlerFactory()
+		{
+		}
+
+		#region IHandlerFactory Members
+
+		public virtual IHandler CreateHandler( IComponentModel model )
+		{
+			return new BaseHandler( model );
+		}
+
+        public virtual void ReleaseHandler( IHandler handler )
+        {
+			handler.Dispose();
+        }
+
+		#endregion
+	}
+}

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandler.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandler.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandler.cs
Sun Sep  5 15:48:15 2004
@@ -21,7 +21,7 @@
 	/// <summary>
 	/// Summary description for DefaultHandler.
 	/// </summary>
-	public class DefaultHandler : SimpleHandler
+	public class DefaultHandler : BaseHandler
 	{
 		public DefaultHandler( IComponentModel model ) : base( model )
 		{
@@ -29,12 +29,12 @@
 
 		protected override void CreateComponentFactoryAndLifestyleManager()
 		{
-			IComponentFactory innerFactory = new SimpleComponentFactory( 
+			IComponentFactory delegateFactory = new BaseComponentFactory( 
 				Kernel, this, ComponentModel, m_serv2handler );
 
 			if (Kernel is IAvalonKernel)
 			{
-				IAvalonKernel kernel = (IAvalonKernel) Kernel;
+				IAvalonKernel kernel = Kernel as IAvalonKernel;
 
 				IConcern commissionChain = kernel.Concerns.GetCommissionChain( kernel );
 				IConcern decommissionChain = kernel.Concerns.GetDecommissionChain( kernel );
@@ -42,14 +42,14 @@
 				ConcernChainComponentFactory factory = 
 					new ConcernChainComponentFactory( 
 						commissionChain, decommissionChain, 
-						ComponentModel, innerFactory );
+						ComponentModel, delegateFactory );
 
-				innerFactory = factory;
+				delegateFactory = factory;
 			}
 
 			m_lifestyleManager = 
 				Kernel.LifestyleManagerFactory.Create( 
-					innerFactory, ComponentModel );
+					delegateFactory, ComponentModel );
 		}
 	}
 }

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandlerFactory.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandlerFactory.cs
(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/DefaultHandlerFactory.cs
Sun Sep  5 15:48:15 2004
@@ -16,13 +16,12 @@
 {
 	using System;
 
-	using Apache.Avalon.Framework;
 	using Apache.Avalon.Castle.MicroKernel.Model;
 
 	/// <summary>
 	/// Summary description for DefaultHandlerFactory.
 	/// </summary>
-	public class DefaultHandlerFactory : IHandlerFactory
+	public class DefaultHandlerFactory : BaseHandlerFactory
 	{
 		public DefaultHandlerFactory()
 		{
@@ -30,15 +29,10 @@
 
 		#region IHandlerFactory Members
 
-		public virtual IHandler CreateHandler( IComponentModel model )
+		public override IHandler CreateHandler( IComponentModel model )
 		{
 			return new DefaultHandler( model );
 		}
-
-        public virtual void ReleaseHandler( IHandler handler )
-        {
-        	handler.Dispose();
-        }
 
 		#endregion
 	}

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs	Sun Sep  5 15:48:15
2004
@@ -52,8 +52,18 @@
 		/// </summary>
 		IHandler this[String key] { get; }
 
+		/// <summary>
+		/// Adds a <see cref="IKernelFacility"/> implementation to 
+		/// the kernel.
+		/// </summary>
+		/// <param name="key">Facility id</param>
+		/// <param name="kernelFacility">Facility instance</param>
         void AddFacility( String key, IKernelFacility kernelFacility );
 
+		/// <summary>
+		/// Removes a <see cref="IKernelFacility"/> from the kernel.
+		/// </summary>
+		/// <param name="key">Facility id</param>
         void RemoveFacility( String key );
 
         /// <summary>

Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln
==============================================================================
--- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln	(original)
+++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln	Sun Sep
 5 15:48:15 2004
@@ -7,6 +7,14 @@
 	ProjectSection(ProjectDependencies) = postProject
 	EndProjectSection
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.Windsor", "..\Windsor\Windsor\Apache.Avalon.Castle.Windsor.csproj",
"{E60B95FF-FDB6-4DE2-844D-1C0D5695FF09}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.Windsor.Test",
"..\Windsor\WindsorTest\Apache.Avalon.Castle.Windsor.Test.csproj", "{D39DB46B-C162-41DD-861E-17675BC60461}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
 Global
 	GlobalSection(SolutionConfiguration) = preSolution
 		Debug = Debug
@@ -21,6 +29,14 @@
 		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug.Build.0 = Debug|.NET
 		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release.ActiveCfg = Release|.NET
 		{50442F0D-987F-4A8D-B38C-DFA855B9249E}.Release.Build.0 = Release|.NET
+		{E60B95FF-FDB6-4DE2-844D-1C0D5695FF09}.Debug.ActiveCfg = Debug|.NET
+		{E60B95FF-FDB6-4DE2-844D-1C0D5695FF09}.Debug.Build.0 = Debug|.NET
+		{E60B95FF-FDB6-4DE2-844D-1C0D5695FF09}.Release.ActiveCfg = Release|.NET
+		{E60B95FF-FDB6-4DE2-844D-1C0D5695FF09}.Release.Build.0 = Release|.NET
+		{D39DB46B-C162-41DD-861E-17675BC60461}.Debug.ActiveCfg = Debug|.NET
+		{D39DB46B-C162-41DD-861E-17675BC60461}.Debug.Build.0 = Debug|.NET
+		{D39DB46B-C162-41DD-861E-17675BC60461}.Release.ActiveCfg = Release|.NET
+		{D39DB46B-C162-41DD-861E-17675BC60461}.Release.Build.0 = Release|.NET
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 	EndGlobalSection

---------------------------------------------------------------------
To unsubscribe, e-mail: cvs-unsubscribe@avalon.apache.org
For additional commands, e-mail: cvs-help@avalon.apache.org


Mime
View raw message