Author: hammett Date: Mon Aug 30 07:56:39 2004 New Revision: 37207 Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/DefaultAvalonKernel.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IAvalonKernel.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IContainerFacility.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs (contents, props changed) avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultAvalonKernelTestCase.cs Removed: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/AvalonKernel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/DefaultKernel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Kernel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultKernelTestCase.cs Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/BaseKernel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ConcernManager.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/AbstractConcern.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/EnableLookupConcern.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/StartConcern.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ICommissionConcern.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/IConcern.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/SimpleComponentFactory.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/SimpleHandler.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/IHandler.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelSubsystem.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IResolver.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernel.sln avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AbstractHandlerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AssemblerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/BaseKernelTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/ConcernManagerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Concerns/AbstractConcernTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultComponentModelBuilderTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DependencyDisposeTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventManagerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventSubsystemTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Lifestyle/LifestyleManagerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/LoggerManagerTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/SimpleComponentFactoryTestCase.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IComponentModel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IConstructionModel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IDependencyModel.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/ModelBuilderException.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/AbstractSubsystem.cs avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/Events/Default/EventManager.cs Log: Refactoring 1
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 Mon Aug 30 07:56:39 2004 @@ -104,32 +104,37 @@ BuildAction = "Compile" /> <File - RelPath = "AvalonKernel.cs" + RelPath = "BaseKernel.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "BaseKernel.cs" + RelPath = "DefaultAvalonKernel.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "DefaultKernel.cs" + RelPath = "IAvalonKernel.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "IKernelSubsystem.cs" + RelPath = "IContainerFacility.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "IResolver.cs" + RelPath = "IKernel.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "IKernelSubsystem.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "Kernel.cs" + RelPath = "IResolver.cs" SubType = "Code" BuildAction = "Compile" /> 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 Mon Aug 30 07:56:39 2004 @@ -16,18 +16,16 @@ { using System; using System.Collections; - using System.Collections.Specialized; - using Apache.Avalon.DynamicProxy; using Apache.Avalon.Castle.MicroKernel.Model; using Apache.Avalon.Castle.MicroKernel.Subsystems.Lookup.Default; using Apache.Avalon.Castle.MicroKernel.Subsystems.Events; using Apache.Avalon.Castle.MicroKernel.Subsystems.Events.Default; /// <summary> - /// Summary description for BaseKernel. + /// Base implementation of <see cref="IKernel"/> /// </summary> - public class BaseKernel : Kernel + public class BaseKernel : IKernel { protected Hashtable m_components; @@ -39,10 +37,10 @@ protected IHandlerFactory m_handlerFactory; - protected ILifestyleManagerFactory m_lifestyleManagerFactory; - protected IComponentModelBuilder m_componentModelBuilder; + protected ILifestyleManagerFactory m_lifestyleManagerFactory; + /// <summary> /// /// </summary> @@ -54,20 +52,19 @@ m_handlerFactory = new Handler.Default.SimpleHandlerFactory(); m_dependencyToSatisfy = new Hashtable(); m_componentModelBuilder = new Model.Default.DefaultComponentModelBuilder( this ); - m_lifestyleManagerFactory = new Lifestyle.Default.SimpleLifestyleManagerFactory(); - - AddSubsystem( KernelConstants.LOOKUP, new LookupCriteriaMatcher() ); - AddSubsystem( KernelConstants.EVENTS, new EventManager() ); - } - + m_lifestyleManagerFactory = new Lifestyle.Default.SimpleLifestyleManagerFactory(); + + InitializeSubsystems(); + } + #region Kernel Members - /// <summary> - /// - /// </summary> - /// <param name="key"></param> - /// <param name="service"></param> - /// <param name="implementation"></param> + /// <summary> + /// Adds a component to kernel. + /// </summary> + /// <param name="key">The unique key that identifies the component</param> + /// <param name="service">The service exposed by this component</param> + /// <param name="implementation">The actual implementation</param> public void AddComponent( String key, Type service, Type implementation ) { AssertUtil.ArgumentNotNull( key, "key" ); @@ -98,33 +95,6 @@ } /// <summary> - /// - /// </summary> - /// <param name="flags"></param> - /// <param name="aspect"></param> - public void AddAspect( AspectPointCutFlags flags, IAspect aspect ) - { - AssertUtil.ArgumentNotNull( aspect, "aspect" ); - - /* - if ((AspectPointCutFlags.Before & flags) != 0) - { - lock(m_aspectBefore) - { - m_aspectBefore.Add( aspect ); - } - } - if ((AspectPointCutFlags.After & flags) != 0) - { - lock(m_aspectAfter) - { - m_aspectAfter.Add( aspect ); - } - } - */ - } - - /// <summary> /// Adds a subsystem. /// </summary> /// <param name="key">Name of this subsystem</param> @@ -198,20 +168,6 @@ } } - public IAspect[] GetAspects( AspectPointCutFlags pointcut ) - { - if (pointcut == AspectPointCutFlags.Before) - { - return (IAspect[]) m_aspectBefore.ToArray( typeof(IAspect) ); - } - else if (pointcut == AspectPointCutFlags.After) - { - return (IAspect[]) m_aspectAfter.ToArray( typeof(IAspect) ); - } - - return new IAspect[0]; - } - /// <summary> /// /// </summary> @@ -266,6 +222,15 @@ } #endregion + + /// <summary> + /// + /// </summary> + protected virtual void InitializeSubsystems() + { + AddSubsystem( KernelConstants.LOOKUP, new LookupCriteriaMatcher() ); + AddSubsystem( KernelConstants.EVENTS, new EventManager() ); + } private void OnNewHandler( String key, Type service, Type implementation, IHandler handler ) { Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ConcernManager.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ConcernManager.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ConcernManager.cs Mon Aug 30 07:56:39 2004 @@ -94,7 +94,7 @@ } } - public IConcern GetCommissionChain( Kernel kernel ) + public IConcern GetCommissionChain( IKernel kernel ) { ArrayList concerns = new ArrayList( m_commissionConcerns ); concerns.Insert( 0, m_creationConcern ); @@ -112,7 +112,7 @@ return next; } - public IConcern GetDecommissionChain( Kernel kernel ) + public IConcern GetDecommissionChain( IKernel kernel ) { ArrayList concerns = new ArrayList( m_decommissionConcerns ); concerns.Add( m_destructionConcern ); Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/AbstractConcern.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/AbstractConcern.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/AbstractConcern.cs Mon Aug 30 07:56:39 2004 @@ -24,7 +24,7 @@ public abstract class AbstractConcern : IConcern { protected IConcern m_next; - protected Kernel m_kernel; + protected IKernel m_kernel; public AbstractConcern(IConcern next) { @@ -33,12 +33,12 @@ #region IConcern Members - public virtual void Init(Kernel kernel) + public virtual void Init( IKernel kernel ) { m_kernel = kernel; } - public virtual void Apply(IComponentModel model, object component) + public virtual void Apply( IComponentModel model, object component ) { if (Next != null) { Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/EnableLookupConcern.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/EnableLookupConcern.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/EnableLookupConcern.cs Mon Aug 30 07:56:39 2004 @@ -68,10 +68,10 @@ /// </summary> public class LookupManager : ILookupManager { - Kernel m_kernel; + IKernel m_kernel; HybridDictionary m_key2handler = new HybridDictionary(); - public LookupManager( Kernel kernel, IDependencyModel[] dependencies ) + public LookupManager( IKernel kernel, IDependencyModel[] dependencies ) { m_kernel = kernel; Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/StartConcern.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/StartConcern.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/Default/StartConcern.cs Mon Aug 30 07:56:39 2004 @@ -1,38 +1,35 @@ -// 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.Concerns.Default -{ - using System; - - using Apache.Avalon.Framework; - using Apache.Avalon.Castle.MicroKernel.Model; - - /// <summary> - /// Summary description for StartConcern. - /// </summary> - public class StartConcern : AbstractConcern, ICommissionConcern - { - public StartConcern(IConcern next) : base(next) - { - } - - public override void Apply(IComponentModel model, object component) - { - ContainerUtil.Start( component ); - - base.Apply( model, component ); - } - } -} +using Apache.Avalon.Castle.MicroKernel.Model; +using Apache.Avalon.Framework; +// 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.Concerns.Default +{ + /// <summary> + /// Summary description for StartConcern. + /// </summary> + public class StartConcern : AbstractConcern, ICommissionConcern + { + public StartConcern(IConcern next) : base(next) + { + } + + public override void Apply(IComponentModel model, object component) + { + ContainerUtil.Start(component); + + base.Apply(model, component); + } + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ICommissionConcern.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ICommissionConcern.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/ICommissionConcern.cs Mon Aug 30 07:56:39 2004 @@ -1,25 +1,23 @@ -// 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.Concerns -{ - using System; - - /// <summary> - /// Summary description for ICommissionConcern. - /// </summary> - public interface ICommissionConcern : IConcern - { - } -} + // 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.Concerns +{ + /// <summary> + /// Summary description for ICommissionConcern. + /// </summary> + public interface ICommissionConcern : IConcern + { + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/IConcern.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/IConcern.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Concerns/IConcern.cs Mon Aug 30 07:56:39 2004 @@ -23,7 +23,7 @@ /// </summary> public interface IConcern { - void Init( Kernel kernel ); + void Init( IKernel kernel ); void Apply( IComponentModel model, object component ); Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/DefaultAvalonKernel.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/DefaultAvalonKernel.cs Mon Aug 30 07:56:39 2004 @@ -0,0 +1,62 @@ +// 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 +{ + using System; + + using Apache.Avalon.Castle.MicroKernel.Concerns; + using Apache.Avalon.Castle.MicroKernel.Model; + using Apache.Avalon.Castle.MicroKernel.Subsystems.Configuration.Default; + using Apache.Avalon.Castle.MicroKernel.Subsystems.Logger.Default; + using Apache.Avalon.Castle.MicroKernel.Subsystems.Context.Default; + + /// <summary> + /// Specialization of BaseKernel to adhere to Avalon + /// constraints and semantics. + /// </summary> + public class DefaultAvalonKernel : BaseKernel, IAvalonKernel + { + protected ConcernManager m_concerns = new ConcernManager(); + + /// <summary> + /// + /// </summary> + public DefaultAvalonKernel() + { + m_handlerFactory = new Handler.Default.DefaultHandlerFactory(); + m_lifestyleManagerFactory = new Lifestyle.Default.SimpleLifestyleManagerFactory(); + + AddSubsystem( KernelConstants.CONFIGURATION, new DefaultConfigurationManager() ); + AddSubsystem( KernelConstants.LOGGER, new LoggerManager() ); + // AddSubsystem( KernelConstants.CONTEXT, new ContextManager() ); + } + + #region AvalonKernel Members + + /// <summary> + /// Manages the concerns related + /// to Avalon Framework + /// </summary> + public ConcernManager Concerns + { + get + { + return m_concerns; + } + } + + #endregion + } +} Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/SimpleComponentFactory.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/SimpleComponentFactory.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Factory/Default/SimpleComponentFactory.cs Mon Aug 30 07:56:39 2004 @@ -27,23 +27,23 @@ /// </summary> public class SimpleComponentFactory : IComponentFactory { - protected IAspect[] m_before; - protected IAspect[] m_after; + // protected IAspect[] m_before; + // protected IAspect[] m_after; protected IComponentModel m_componentModel; protected Hashtable m_serv2handler; private Hashtable m_instances = new Hashtable(); - public SimpleComponentFactory( IAspect[] before, IAspect[] after, + public SimpleComponentFactory( /*IAspect[] before, IAspect[] after, */ IComponentModel componentModel, Hashtable serv2handler) { - AssertUtil.ArgumentNotNull( before, "before" ); - AssertUtil.ArgumentNotNull( after, "after" ); + // AssertUtil.ArgumentNotNull( before, "before" ); + // AssertUtil.ArgumentNotNull( after, "after" ); AssertUtil.ArgumentNotNull( componentModel, "componentModel" ); AssertUtil.ArgumentNotNull( serv2handler, "serv2handler" ); - m_before = before; - m_after = after; + // m_before = before; + // m_after = after; m_componentModel = componentModel; m_serv2handler = serv2handler; } @@ -60,12 +60,13 @@ Object instance = Activator.CreateInstance( m_componentModel.ConstructionModel.Implementation, arguments ); + /* if (m_before.Length != 0 || m_after.Length != 0 ) { instance = DynamicProxy.ProxyGenerator.CreateProxy( new Type[] { m_componentModel.Service }, new Aspects.AspectInvocationHandler( m_before, m_after, instance ) ); - } + }*/ SetupProperties( instance, burden ); 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 Mon Aug 30 07:56:39 2004 @@ -25,7 +25,7 @@ /// </summary> public abstract class AbstractHandler : IHandler { - protected Kernel m_kernel; + protected IKernel m_kernel; protected IComponentModel m_componentModel; @@ -53,7 +53,7 @@ #region IHandler Members - public virtual void Init( Kernel kernel ) + public virtual void Init( IKernel kernel ) { m_kernel = kernel; } 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 Mon Aug 30 07:56:39 2004 @@ -32,13 +32,13 @@ protected override void CreateComponentFactoryAndLifestyleManager() { IComponentFactory innerFactory = new Factory.Default.SimpleComponentFactory( - m_kernel.GetAspects(AspectPointCutFlags.Before), - m_kernel.GetAspects(AspectPointCutFlags.After), + // m_kernel.GetAspects(AspectPointCutFlags.Before), + // m_kernel.GetAspects(AspectPointCutFlags.After), m_componentModel, m_serv2handler); - if (m_kernel is AvalonKernel) + if (m_kernel is IAvalonKernel) { - AvalonKernel kernel = (AvalonKernel) m_kernel; + IAvalonKernel kernel = (IAvalonKernel) m_kernel; IConcern commissionChain = kernel.Concerns.GetCommissionChain( kernel ); IConcern decommissionChain = kernel.Concerns.GetDecommissionChain( kernel ); Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/SimpleHandler.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/SimpleHandler.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/Default/SimpleHandler.cs Mon Aug 30 07:56:39 2004 @@ -36,7 +36,7 @@ #region IHandler Members - public override void Init( Kernel kernel ) + public override void Init( IKernel kernel ) { base.Init(kernel); @@ -101,8 +101,8 @@ protected virtual void CreateComponentFactoryAndLifestyleManager() { IComponentFactory factory = new Factory.Default.SimpleComponentFactory( - m_kernel.GetAspects(AspectPointCutFlags.Before), - m_kernel.GetAspects(AspectPointCutFlags.After), + // m_kernel.GetAspects(AspectPointCutFlags.Before), + // m_kernel.GetAspects(AspectPointCutFlags.After), m_componentModel, m_serv2handler); m_lifestyleManager = m_kernel.LifestyleManagerFactory.Create( Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/IHandler.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/IHandler.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Handler/IHandler.cs Mon Aug 30 07:56:39 2004 @@ -25,7 +25,7 @@ /// /// </summary> /// <param name="kernel"></param> - void Init( Kernel kernel ); + void Init( IKernel kernel ); /// <summary> /// Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IAvalonKernel.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IAvalonKernel.cs Mon Aug 30 07:56:39 2004 @@ -0,0 +1,36 @@ +// 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 +{ + using System; + + using Apache.Avalon.Castle.MicroKernel.Concerns; + using Apache.Avalon.Castle.MicroKernel.Model; + + /// <summary> + /// Specialization of Kernel to support + /// avalon semantics + /// </summary> + public interface IAvalonKernel : IKernel + { + /// <summary> + /// Manages the concerns related to Avalon Framework + /// </summary> + ConcernManager Concerns + { + get; + } + } +} Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IContainerFacility.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IContainerFacility.cs Mon Aug 30 07:56:39 2004 @@ -0,0 +1,30 @@ +// 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 +{ + using System; + + /// <summary> + /// Summary description for IContainerFacility. + /// </summary> + public interface IContainerFacility + { + /// <summary> + /// + /// </summary> + /// <param name="kernel"></param> + void Init( IKernel kernel ); + } +} Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernel.cs Mon Aug 30 07:56:39 2004 @@ -0,0 +1,103 @@ + // 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 +{ + using System; + + using Apache.Avalon.Castle.MicroKernel.Model; + + public delegate void DependencyListenerDelegate(Type service, IHandler handler); + + /// <summary> + /// Defines the Kernel service + /// </summary> + public interface IKernel + { + /// <summary> + /// Adds a component to kernel. + /// </summary> + /// <param name="key">The unique key that identifies the component</param> + /// <param name="service">The service exposed by this component</param> + /// <param name="implementation">The actual implementation</param> + void AddComponent(String key, Type service, Type implementation); + + /// <summary> + /// IComponentModel instance builder. + /// </summary> + IComponentModelBuilder ModelBuilder { get; set; } + + /// <summary> + /// Obtains a component handler using the + /// unique component key + /// </summary> + IHandler this[String key] { get; } + + /// <summary> + /// + /// </summary> + /// <param name="key"></param> + /// <param name="criteria"></param> + /// <returns></returns> + IHandler GetHandler(String key, object criteria); + + /// <summary> + /// Gets or Sets the IHandlerFactory implementation + /// </summary> + IHandlerFactory HandlerFactory { get; set; } + + /// <summary> + /// Gets or Sets the ILifestyleManagerFactory implementation + /// </summary> + ILifestyleManagerFactory LifestyleManagerFactory { get; set; } + + /// <summary> + /// Returns true if kernel "knows" the specified + /// service + /// </summary> + /// <param name="service">The service interface</param> + /// <returns>true if is already registered</returns> + bool HasService(Type service); + + /// <summary> + /// Used by handlers to register itself as + /// and dependency to be satisfied. + /// </summary> + /// <param name="service">The service interface</param> + /// <param name="depDelegate">Delegate to be invoked</param> + void AddDependencyListener(Type service, DependencyListenerDelegate depDelegate); + + /// <summary> + /// Returns a IHandler implementation for + /// the specified service + /// </summary> + /// <param name="service">The service interface</param> + /// <returns>IHandler implementation</returns> + IHandler GetHandlerForService(Type service); + + /// <summary> + /// Adds a subsystem. + /// </summary> + /// <param name="key">Name of this subsystem</param> + /// <param name="system">Subsystem implementation</param> + void AddSubsystem(String key, IKernelSubsystem system); + + /// <summary> + /// Returns a registered subsystem; + /// </summary> + /// <param name="key">Key used when registered subsystem</param> + /// <returns>Subsystem implementation</returns> + IKernelSubsystem GetSubsystem(String key); + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelSubsystem.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelSubsystem.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IKernelSubsystem.cs Mon Aug 30 07:56:39 2004 @@ -1,26 +1,24 @@ -// 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 -{ - using System; - - /// <summary> - /// Summary description for IKernelSubsystem. - /// </summary> - public interface IKernelSubsystem - { - void Init(Kernel kernel); - } -} + // 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 +{ + /// <summary> + /// Summary description for IKernelSubsystem. + /// </summary> + public interface IKernelSubsystem + { + void Init(IKernel kernel); + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IResolver.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IResolver.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/IResolver.cs Mon Aug 30 07:56:39 2004 @@ -1,28 +1,26 @@ -// 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 -{ - using System; - - /// <summary> - /// Summary description for IResolver. - /// </summary> - public interface IResolver - { - object Resolve(); - - void Release( object instance ); - } -} + // 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 +{ + /// <summary> + /// Summary description for IResolver. + /// </summary> + public interface IResolver + { + object Resolve(); + + void Release(object instance); + } +} \ No newline at end of file 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 Mon Aug 30 07:56:39 2004 @@ -1,29 +1,37 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel", "Apache.Avalon.Castle.MicroKernel.csproj", "{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel.Test", "MicroKernelTest\Apache.Avalon.Castle.MicroKernel.Test.csproj", "{50442F0D-987F-4A8D-B38C-DFA855B9249E}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release - EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.ActiveCfg = Debug|.NET - {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.Build.0 = Debug|.NET - {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.ActiveCfg = Release|.NET - {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.Build.0 = Release|.NET - {50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug.ActiveCfg = Debug|.NET - {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 - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution - EndGlobalSection -EndGlobal +Microsoft Visual Studio Solution File, Format Version 8.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel", "Apache.Avalon.Castle.MicroKernel.csproj", "{1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.MicroKernel.Test", "MicroKernelTest\Apache.Avalon.Castle.MicroKernel.Test.csproj", "{50442F0D-987F-4A8D-B38C-DFA855B9249E}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.Avalon.Castle.Facilities.Aspects", "..\Facilities\Aspects\Apache.Avalon.Castle.Facilities.Aspects.csproj", "{17546A9D-FAE9-42D1-BF36-740187216D34}" + ProjectSection(ProjectDependencies) = postProject + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfiguration) = preSolution + Debug = Debug + Release = Release + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.ActiveCfg = Debug|.NET + {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Debug.Build.0 = Debug|.NET + {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.ActiveCfg = Release|.NET + {1E57B734-BA4B-4ADE-B4C2-78C7D4993AD4}.Release.Build.0 = Release|.NET + {50442F0D-987F-4A8D-B38C-DFA855B9249E}.Debug.ActiveCfg = Debug|.NET + {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 + {17546A9D-FAE9-42D1-BF36-740187216D34}.Debug.ActiveCfg = Debug|.NET + {17546A9D-FAE9-42D1-BF36-740187216D34}.Debug.Build.0 = Debug|.NET + {17546A9D-FAE9-42D1-BF36-740187216D34}.Release.ActiveCfg = Release|.NET + {17546A9D-FAE9-42D1-BF36-740187216D34}.Release.Build.0 = Release|.NET + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AbstractHandlerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AbstractHandlerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AbstractHandlerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -30,7 +30,7 @@ [TestFixture] public class AbstractHandlerTestCase : Assertion { - private Kernel kernel = new DefaultKernel(); + private IKernel kernel = new DefaultAvalonKernel(); private Type service = typeof( IMailService ); private Type implementation = typeof( SimpleMailService ); private IComponentModel model; Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj Mon Aug 30 07:56:39 2004 @@ -124,17 +124,17 @@ BuildAction = "Compile" /> <File - RelPath = "DefaultComponentModelBuilderTestCase.cs" + RelPath = "DefaultAvalonKernelTestCase.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "DefaultConfigurationManagerTestCase.cs" + RelPath = "DefaultComponentModelBuilderTestCase.cs" SubType = "Code" BuildAction = "Compile" /> <File - RelPath = "DefaultKernelTestCase.cs" + RelPath = "DefaultConfigurationManagerTestCase.cs" SubType = "Code" BuildAction = "Compile" /> Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AssemblerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AssemblerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/AssemblerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -30,7 +30,7 @@ [TestFixture] public class AssemblerTestCase : Assertion { - private AvalonKernel m_kernel = new DefaultKernel(); + private IAvalonKernel m_kernel = new DefaultAvalonKernel(); private DefaultComponentModelBuilder m_builder; Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/BaseKernelTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/BaseKernelTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/BaseKernelTestCase.cs Mon Aug 30 07:56:39 2004 @@ -68,58 +68,41 @@ handler.Release( service ); } - /// <summary> - /// Adds a InterceptionAspect to calling chain and check if is has been called - /// during method execution - /// </summary> + /* [Test] - public void AddingAspect() + public void FacilityEvents() { BaseKernel container = new BaseKernel(); + MockFacility facility = new MockFacility(); - InterceptionAspect aspect = new InterceptionAspect(); + container.RegisterFacility( facility ); - container.AddAspect( - AspectPointCutFlags.Before|AspectPointCutFlags.After, - aspect ); + Assert( facility.OnInitCalled ); - container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); + container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailServiceWithLogger) ); + + Assert( facility.ComponentAddedCalled ); IHandler handler = container[ "a" ]; IMailService service = handler.Resolve() as IMailService; + Assert( facility.ComponentCreatedCalled ); + AssertNotNull( service ); - service.Send("hammett at apache dot org", "johndoe at yahoo dot org", "Aloha!", "What's up?"); + service.Send("hammett at apache dot org", + "johndoe at yahoo dot org", "Aloha!", "What's up?"); handler.Release( service ); - AssertEquals( 2, aspect.m_invocations.Count ); - AssertEquals( "Before Send", aspect.m_invocations[0] ); - AssertEquals( "After Send", aspect.m_invocations[1] ); + Assert( facility.ComponentReleasedCalled ); } - public class InterceptionAspect : IAspect + public class MockFacility : IContainerFacility { - public ArrayList m_invocations = new ArrayList(); - - public void Perform( AspectPointCutFlags pointcut, - object componentInstance, - MethodBase method, - object returnValue, - Exception exception, - params object[] arguments) - { - if (pointcut == AspectPointCutFlags.Before) - { - m_invocations.Add("Before " + method.Name); - } - else if (pointcut == AspectPointCutFlags.After) - { - m_invocations.Add("After " + method.Name); - } - } + } + */ } } Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/ConcernManagerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/ConcernManagerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/ConcernManagerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -27,12 +27,12 @@ [TestFixture] public class ConcernManagerTestCase : Assertion { - private Kernel m_kernel; + private IKernel m_kernel; [SetUp] public void CreateKernel() { - m_kernel = new DefaultKernel(); + m_kernel = new DefaultAvalonKernel(); } [Test] Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Concerns/AbstractConcernTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Concerns/AbstractConcernTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Concerns/AbstractConcernTestCase.cs Mon Aug 30 07:56:39 2004 @@ -28,7 +28,7 @@ /// </summary> public abstract class AbstractConcernTestCase : Assertion { - protected Kernel m_kernel = new DefaultKernel(); + protected IKernel m_kernel = new DefaultAvalonKernel(); public abstract IConcern Create(); Added: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultAvalonKernelTestCase.cs ============================================================================== --- (empty file) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultAvalonKernelTestCase.cs Mon Aug 30 07:56:39 2004 @@ -0,0 +1,153 @@ +using Apache.Avalon.Castle.MicroKernel.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.Test +{ + using System; + + using NUnit.Framework; + + using Apache.Avalon.Castle.MicroKernel.Test.Components; + + /// <summary> + /// Summary description for DefaultAvalonKernelTestCase. + /// </summary> + [TestFixture] + public class DefaultAvalonKernelTestCase : Assertion + { + [Test] + public void Creation() + { + IAvalonKernel kernel = new DefaultAvalonKernel(); + AssertNotNull(kernel); + } + + /// <summary> + /// Just a simple Service resolution. + /// No concerns or aspects involved. + /// </summary> + [Test] + public void SimpleUsage() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "a", typeof(IMailService), typeof(SimpleMailService) ); + + IHandler handler = container[ "a" ]; + + IMailService service = handler.Resolve() as IMailService; + + AssertNotNull( service ); + + service.Send("hammett at apache dot org", "johndoe at yahoo dot org", "Aloha!", "What's up?"); + + handler.Release( service ); + } + + [Test] + public void SimpleAvalonComponent() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService2) ); + + IHandler handler = container[ "a" ]; + + IMailService service = handler.Resolve() as IMailService; + + AssertNotNull( service ); + + AvalonMailService realInstance = (AvalonMailService) service; + + Assert( realInstance.initialized ); + Assert( realInstance.configured ); + Assert( !realInstance.disposed ); + + service.Send("hammett at apache dot org", "johndoe at yahoo dot org", "Aloha!", "What's up?"); + + handler.Release( service ); + + Assert( realInstance.disposed ); + } + + [Test] + public void AvalonComponentWithUnsatisfiedDependencies() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "b", typeof(ISpamService), typeof(AvalonSpamService) ); + + IHandler handler = container[ "b" ]; + + try + { + ISpamService service = handler.Resolve() as ISpamService; + Fail("Dependencies unsatisfied for this component. Resolve should fail."); + } + catch(HandlerException) + { + // Expected. + } + } + + [Test] + public void AvalonComponentWithDependencies() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService) ); + container.AddComponent( "b", typeof(ISpamService), typeof(AvalonSpamService) ); + + IHandler handler = container[ "b" ]; + + ISpamService service = handler.Resolve() as ISpamService; + AssertNotNull( service ); + + service.AnnoyPeople( "Work at home and earn a thousand dollars per second!" ); + + handler.Release( service ); + } + + [Test] + public void HybridAvalonComponent() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService) ); + container.AddComponent( "b", typeof(ISpamService), typeof(AvalonSpamService2) ); + + IHandler handler = container[ "b" ]; + + ISpamService service = handler.Resolve() as ISpamService; + AssertNotNull( service ); + + service.AnnoyPeople( "Work at home and earn a thousand dollars per second!" ); + + handler.Release( service ); + } + + [Test] + public void HybridAvalonComponentUsingSetters() + { + IAvalonKernel container = new DefaultAvalonKernel(); + container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService) ); + container.AddComponent( "b", typeof(ISpamService2), typeof(AvalonSpamService3) ); + + IHandler handler = container[ "b" ]; + + ISpamService service = handler.Resolve() as ISpamService; + AssertNotNull( service ); + + service.AnnoyPeople( "Work at home and earn a thousand dollars per second!" ); + + handler.Release( service ); + } + } +} Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultComponentModelBuilderTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultComponentModelBuilderTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultComponentModelBuilderTestCase.cs Mon Aug 30 07:56:39 2004 @@ -29,7 +29,7 @@ [TestFixture] public class DefaultComponentModelBuilderTestCase : Assertion { - private Kernel m_kernel; + private IKernel m_kernel; [SetUp] public void CreateKernel() Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DependencyDisposeTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DependencyDisposeTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/DependencyDisposeTestCase.cs Mon Aug 30 07:56:39 2004 @@ -31,7 +31,7 @@ [Test] public void SingletonDependencyDisposal() { - AvalonKernel container = new DefaultKernel(); + IAvalonKernel container = new DefaultAvalonKernel(); container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService) ); container.AddComponent( "b", typeof(ISpamService2), typeof(AvalonSpamService3) ); @@ -52,7 +52,7 @@ [Test] public void TransientDependencyDisposal() { - AvalonKernel container = new DefaultKernel(); + IAvalonKernel container = new DefaultAvalonKernel(); container.AddComponent( "a", typeof(IMailService), typeof(AvalonMailService2) ); container.AddComponent( "b", typeof(ISpamService2), typeof(AvalonSpamService3) ); @@ -69,6 +69,5 @@ Assert( "A transient component should have been disposed", mailService.disposed ); } - } } Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventManagerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventManagerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventManagerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -28,23 +28,23 @@ [TestFixture] public class EventManagerTestCase : Assertion { - private Kernel m_kernel; + private IKernel m_kernel; private bool m_invoked = false; [SetUp] public void CreateKernel() { - m_kernel = new DefaultKernel(); + m_kernel = new DefaultAvalonKernel(); } [Test] public void TestUsage() { - EventManager manager = new EventManager(); + IEventManager manager = new EventManager(); manager.Init( m_kernel ); - manager.ComponentAdded += new KernelDelegate(Evento); - manager.ComponentDestroyed += new KernelDelegate(Evento); + manager.ComponentAdded += new KernelDelegate(TheEvent); + manager.ComponentDestroyed += new KernelDelegate(TheEvent); Assert( !m_invoked ); @@ -62,7 +62,7 @@ Assert( m_invoked ); } - public void Evento( EventManagerData data ) + public void TheEvent( EventManagerData data ) { m_invoked = true; } Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventSubsystemTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventSubsystemTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/EventSubsystemTestCase.cs Mon Aug 30 07:56:39 2004 @@ -35,7 +35,7 @@ [Test] public void TestComponentAddedEvent() { - Kernel kernel = new DefaultKernel(); + IKernel kernel = new DefaultAvalonKernel(); IEventManager eventManager = (IEventManager) kernel.GetSubsystem( KernelConstants.EVENTS ); eventManager.ComponentAdded += new KernelDelegate(OnComponentAdded); @@ -53,7 +53,7 @@ [Test] public void TestComponentCreatedEvent() { - Kernel kernel = new DefaultKernel(); + IKernel kernel = new DefaultAvalonKernel(); IEventManager eventManager = (IEventManager) kernel.GetSubsystem( KernelConstants.EVENTS ); eventManager.ComponentCreated += new KernelDelegate(OnComponentCreated); @@ -75,7 +75,7 @@ [Test] public void TestComponentDestroyedEvent() { - Kernel kernel = new DefaultKernel(); + IKernel kernel = new DefaultAvalonKernel(); IEventManager eventManager = (IEventManager) kernel.GetSubsystem( KernelConstants.EVENTS ); eventManager.ComponentDestroyed += new KernelDelegate(OnComponentDestroyed); Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Lifestyle/LifestyleManagerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Lifestyle/LifestyleManagerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/Lifestyle/LifestyleManagerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -28,14 +28,14 @@ [TestFixture] public class LifestyleManagerTestCase : Assertion { - private AvalonKernel m_kernel; + private IAvalonKernel m_kernel; private IComponent m_instance3; [SetUp] public void CreateContainer() { - m_kernel = new DefaultKernel(); + m_kernel = new DefaultAvalonKernel(); } [Test] Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/LoggerManagerTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/LoggerManagerTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/LoggerManagerTestCase.cs Mon Aug 30 07:56:39 2004 @@ -31,7 +31,7 @@ [Test] public void TestUsage() { - Kernel kernel = new BaseKernel(); + IKernel kernel = new BaseKernel(); LoggerManager manager = new LoggerManager(); kernel.AddSubsystem( KernelConstants.LOGGER, manager ); @@ -44,7 +44,7 @@ [Test] public void TestCreateLogger() { - Kernel kernel = new BaseKernel(); + IKernel kernel = new BaseKernel(); LoggerManager manager = new LoggerManager(); kernel.AddSubsystem( KernelConstants.LOGGER, manager ); Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/SimpleComponentFactoryTestCase.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/SimpleComponentFactoryTestCase.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/MicroKernelTest/SimpleComponentFactoryTestCase.cs Mon Aug 30 07:56:39 2004 @@ -53,7 +53,7 @@ IComponentModel model = new DefaultComponentModelBuilder(kernel).BuildModel( "a", service, implementation ); SimpleComponentFactory factory = new SimpleComponentFactory( - new IAspect[0], new IAspect[0], model, new Hashtable() ); + /*new IAspect[0], new IAspect[0],*/ model, new Hashtable() ); Object instance = factory.Incarnate(); @@ -81,7 +81,7 @@ serv2Handler[ serviceDep ] = kernel.GetHandlerForService( serviceDep ); SimpleComponentFactory factory = new SimpleComponentFactory( - new IAspect[0], new IAspect[0], model, serv2Handler ); + /*new IAspect[0], new IAspect[0],*/ model, serv2Handler ); Object instance = factory.Incarnate(); @@ -116,7 +116,7 @@ serv2Handler[ serviceDep2 ] = kernel.GetHandlerForService( serviceDep2 ); SimpleComponentFactory factory = new SimpleComponentFactory( - new IAspect[0], new IAspect[0], model, serv2Handler ); + /*new IAspect[0], new IAspect[0],*/ model, serv2Handler ); Object instance = factory.Incarnate(); Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModel.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModel.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModel.cs Mon Aug 30 07:56:39 2004 @@ -1,140 +1,141 @@ -// 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.Model.Default -{ - using System; - - using Apache.Avalon.Framework; - using Apache.Avalon.Castle.MicroKernel.Model; - - /// <summary> - /// Summary description for DefaultComponentModel. - /// </summary> - public class DefaultComponentModel : IComponentModel - { - private Type m_service; - private String m_name; - private Lifestyle m_lifestyle; - private ILogger m_logger; - private IConfiguration m_config; - private IContext m_context; - private IDependencyModel[] m_dependencies; - private IConstructionModel m_constructionModel; - - public DefaultComponentModel( - String name, - Type service, - Lifestyle lifestyle, - ILogger logger, - IConfiguration configuration, - IContext context, - IDependencyModel[] dependencies, - IConstructionModel constructionModel) - { - AssertUtil.ArgumentNotNull( name, "name" ); - AssertUtil.ArgumentNotNull( service, "service" ); - AssertUtil.ArgumentNotNull( logger, "logger" ); - AssertUtil.ArgumentNotNull( configuration, "configuration" ); - AssertUtil.ArgumentNotNull( context, "context" ); - AssertUtil.ArgumentNotNull( dependencies, "dependencies" ); - AssertUtil.ArgumentNotNull( constructionModel, "constructionModel" ); - - m_name = name; - m_service = service; - m_lifestyle = lifestyle; - m_logger = logger; - m_config = configuration; - m_context = context; - m_dependencies = dependencies; - m_constructionModel = constructionModel; - } - - #region IComponentModel Members - - public String Name - { - get - { - return m_name; - } - } - - public Type Service - { - get - { - return m_service; - } - } - - public Lifestyle SupportedLifestyle - { - get - { - return m_lifestyle; - } - } - - public ILogger Logger - { - get - { - return m_logger; - } - set - { - m_logger = value; - } - } - - public IConfiguration Configuration - { - get - { - return m_config; - } - set - { - m_config = value; - } - } - - public IContext Context - { - get - { - return m_context; - } - } - - public IDependencyModel[] Dependencies - { - get - { - return m_dependencies; - } - } - - public IConstructionModel ConstructionModel - { - get - { - return m_constructionModel; - } - } - - #endregion - } -} + // 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.Model.Default +{ + using System; + + using Apache.Avalon.Framework; + using Apache.Avalon.Castle.MicroKernel.Model; + + /// <summary> + /// Summary description for DefaultComponentModel. + /// </summary> + public class DefaultComponentModel : IComponentModel + { + private Type m_service; + private String m_name; + private Lifestyle m_lifestyle; + private Activation m_activation; + private ILogger m_logger; + private IConfiguration m_config; + private IContext m_context; + private IDependencyModel[] m_dependencies; + private IConstructionModel m_constructionModel; + + protected DefaultComponentModel() + { + m_context = new DefaultContext(); + } + + public DefaultComponentModel( + ComponentData data, + Type service, + ILogger logger, + IConfiguration configuration, + IConstructionModel constructionModel) : this() + { + AssertUtil.ArgumentNotNull(data, "data"); + AssertUtil.ArgumentNotNull(service, "service"); + AssertUtil.ArgumentNotNull(logger, "logger"); + AssertUtil.ArgumentNotNull(configuration, "configuration"); + AssertUtil.ArgumentNotNull(constructionModel, "constructionModel"); + + m_name = data.Name; + m_service = service; + m_lifestyle = data.SupportedLifestyle; + m_activation = data.AvalonComponent.Activation; + m_logger = logger; + m_config = configuration; + m_dependencies = data.DependencyModel; + m_constructionModel = constructionModel; + } + + public DefaultComponentModel( + String name, + Type service, + Lifestyle lifestyle, + ILogger logger, + IConfiguration configuration, + IDependencyModel[] dependencies, + IConstructionModel constructionModel) : this() + { + AssertUtil.ArgumentNotNull(name, "name"); + AssertUtil.ArgumentNotNull(service, "service"); + AssertUtil.ArgumentNotNull(logger, "logger"); + AssertUtil.ArgumentNotNull(configuration, "configuration"); + AssertUtil.ArgumentNotNull(dependencies, "dependencies"); + AssertUtil.ArgumentNotNull(constructionModel, "constructionModel"); + + m_name = name; + m_service = service; + m_lifestyle = lifestyle; + m_logger = logger; + m_config = configuration; + m_dependencies = dependencies; + m_constructionModel = constructionModel; + } + + #region IComponentModel Members + + public String Name + { + get { return m_name; } + } + + public Type Service + { + get { return m_service; } + } + + public Lifestyle SupportedLifestyle + { + get { return m_lifestyle; } + } + + public Activation ActivationPolicy + { + get { return m_activation; } + } + + public ILogger Logger + { + get { return m_logger; } + set { m_logger = value; } + } + + public IConfiguration Configuration + { + get { return m_config; } + set { m_config = value; } + } + + public IContext Context + { + get { return m_context; } + } + + public IDependencyModel[] Dependencies + { + get { return m_dependencies; } + } + + public IConstructionModel ConstructionModel + { + get { return m_constructionModel; } + } + + #endregion + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs Mon Aug 30 07:56:39 2004 @@ -22,16 +22,15 @@ using Apache.Avalon.Castle.MicroKernel.Subsystems.Configuration; using Apache.Avalon.Castle.MicroKernel.Subsystems.Logger; - using Apache.Avalon.Castle.MicroKernel.Subsystems.Context; /// <summary> /// Summary description for DefaultComponentModelBuilder. /// </summary> public class DefaultComponentModelBuilder : IComponentModelBuilder { - private Kernel m_kernel; + private IKernel m_kernel; - public DefaultComponentModelBuilder(Kernel kernel) + public DefaultComponentModelBuilder( IKernel kernel ) { m_kernel = kernel; } @@ -54,13 +53,9 @@ new DefaultConstructionModel( implementation, data.Constructor, data.PropertiesInfo ); ILogger logger = CreateLogger( data ); - IContext context = CreateContext(); IConfiguration config = CreateConfiguration( data ); - return new DefaultComponentModel( - data.Name, service, data.SupportedLifestyle, - logger, config, new DefaultContext(), - data.DependencyModel, constructionModel ); + return new DefaultComponentModel( data, service, logger, config, constructionModel ); } #endregion @@ -94,13 +89,6 @@ { return new DefaultConfiguration(); } - } - - protected virtual IContext CreateContext() - { - // IContext context = - // m_kernel.ContextManager.CreateContext( data.AvalonContext, data.ContextEntries ); - return new DefaultContext(); } protected void InspectAvalonAttributes( ComponentData componentData ) Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IComponentModel.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IComponentModel.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IComponentModel.cs Mon Aug 30 07:56:39 2004 @@ -1,68 +1,72 @@ -// 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.Model -{ - using System; - - using Apache.Avalon.Framework; - - /// <summary> - /// Summary description for IComponentModel. - /// </summary> - public interface IComponentModel - { - String Name - { - get; - } - - Lifestyle SupportedLifestyle - { - get; - } - - Type Service - { - get; - } - - ILogger Logger - { - get; - set; - } - - IConfiguration Configuration - { - get; - set; - } - - IContext Context - { - get; - } - - IDependencyModel[] Dependencies - { - get; - } - - IConstructionModel ConstructionModel - { - get; - } - } -} + // 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.Model +{ + using System; + + using Apache.Avalon.Framework; + + /// <summary> + /// Holds information necessary for the lifetime of the component. + /// </summary> + public interface IComponentModel + { + /// <summary> + /// Component name + /// </summary> + String Name { get; } + + /// <summary> + /// Desired lifecycle + /// </summary> + Lifestyle SupportedLifestyle { get; } + + /// <summary> + /// Desired activation policy + /// </summary> + Activation ActivationPolicy { get; } + + /// <summary> + /// Service being exposed by the component + /// </summary> + Type Service { get; } + + /// <summary> + /// ILogger implementation + /// </summary> + ILogger Logger { get; set; } + + /// <summary> + /// Configuration node for the component + /// </summary> + IConfiguration Configuration { get; set; } + + /// <summary> + /// Context for the component + /// </summary> + IContext Context { get; } + + /// <summary> + /// List of dependencies declared by the component + /// </summary> + IDependencyModel[] Dependencies { get; } + + /// <summary> + /// Information to allow the correct construction + /// of the component + /// </summary> + IConstructionModel ConstructionModel { get; } + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IConstructionModel.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IConstructionModel.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IConstructionModel.cs Mon Aug 30 07:56:39 2004 @@ -1,40 +1,41 @@ -// 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.Model -{ - using System; - using System.Reflection; - - /// <summary> - /// Summary description for IConstructionModel. - /// </summary> - public interface IConstructionModel - { - Type Implementation - { - get; - } - - ConstructorInfo SelectedConstructor - { - get; - } - - PropertyInfo[] SelectedProperties - { - get; - } - } -} + // 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.Model +{ + using System; + using System.Reflection; + + /// <summary> + /// Holds the information to allow the container to + /// correctly instantiate the component implementation. + /// </summary> + public interface IConstructionModel + { + /// <summary> + /// Implementation type + /// </summary> + Type Implementation { get; } + + /// <summary> + /// The best constructor selected. + /// </summary> + ConstructorInfo SelectedConstructor { get; } + + /// <summary> + /// Properties that will be used to satisfy dependencies. + /// </summary> + PropertyInfo[] SelectedProperties { get; } + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IDependencyModel.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IDependencyModel.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/IDependencyModel.cs Mon Aug 30 07:56:39 2004 @@ -1,39 +1,40 @@ -// 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.Model -{ - using System; - - /// <summary> - /// Summary description for IDependencyModel. - /// </summary> - public interface IDependencyModel - { - Type Service - { - get; - } - - String LookupKey - { - get; - } - - bool Optional - { - get; - } - } -} + // 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.Model +{ + using System; + + /// <summary> + /// Holds the dependency information as + /// requested by the component. + /// </summary> + public interface IDependencyModel + { + /// <summary> + /// Type of the service registered as a dependency. + /// </summary> + Type Service { get; } + + /// <summary> + /// Name that will be used to request this dependency. + /// </summary> + String LookupKey { get; } + + /// <summary> + /// Is this dependency optional? + /// </summary> + bool Optional { get; } + } +} \ No newline at end of file Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/ModelBuilderException.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/ModelBuilderException.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Model/ModelBuilderException.cs Mon Aug 30 07:56:39 2004 @@ -17,7 +17,8 @@ using System; /// <summary> - /// Summary description for ModelBuilderException. + /// Exception throwed if the <see cref="IComponentModelBuilder"/> + /// fail to collect the necessary information. /// </summary> [Serializable] public class ModelBuilderException : System.Exception Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/AbstractSubsystem.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/AbstractSubsystem.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/AbstractSubsystem.cs Mon Aug 30 07:56:39 2004 @@ -21,7 +21,7 @@ /// </summary> public abstract class AbstractSubsystem : IKernelSubsystem { - private Kernel m_kernel; + private IKernel m_kernel; public AbstractSubsystem() { @@ -29,7 +29,7 @@ #region IKernelSubsystem Members - public void Init(Kernel kernel) + public void Init( IKernel kernel ) { AssertUtil.ArgumentNotNull( kernel, "kernel" ); @@ -38,7 +38,7 @@ #endregion - protected virtual Kernel Kernel + protected virtual IKernel Kernel { get { Modified: avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/Events/Default/EventManager.cs ============================================================================== --- avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/Events/Default/EventManager.cs (original) +++ avalon/trunk/central/laboratory/avalon-net/Castle/MicroKernel/Subsystems/Events/Default/EventManager.cs Mon Aug 30 07:56:39 2004 @@ -95,7 +95,6 @@ public void OnComponentDestroyed( EventManagerData data ) { RaiseEvent( ComponentDestroyedEvent, data ); - } #endregion --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]