avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: avalon-sandbox/avalon-net/Castle/MicroKernel/Avalon/Logger ILoggerManager.cs
Date Tue, 20 Apr 2004 03:37:49 GMT
hammett     2004/04/19 20:37:49

  Modified:    avalon-net/Castle/MicroKernel
                        Apache.Avalon.Castle.MicroKernel.csproj
                        AvalonKernel.cs BaseKernel.cs DefaultKernel.cs
                        Kernel.cs
               avalon-net/Castle/MicroKernel/MicroKernelTest
                        Apache.Avalon.Castle.MicroKernel.Test.csproj
                        DefaultConfigurationManagerTestCase.cs
               avalon-net/Castle/MicroKernel/Model/Default
                        DefaultComponentModelBuilder.cs
  Added:       avalon-net/Castle/MicroKernel IKernelSubsystem.cs
                        KernelConstants.cs
               avalon-net/Castle/MicroKernel/Subsystems
                        AbstractSubsystem.cs
               avalon-net/Castle/MicroKernel/Subsystems/Configuration/Default
                        AvalonConfigurationSectionHandler.cs
                        ContainerConfiguration.cs
                        DefaultConfigurationManager.cs
               avalon-net/Castle/MicroKernel/Subsystems/Configuration
                        IConfigurationManager.cs
               avalon-net/Castle/MicroKernel/Subsystems/Context/Default
                        ContextManager.cs
               avalon-net/Castle/MicroKernel/Subsystems/Context
                        IContextManager.cs
               avalon-net/Castle/MicroKernel/Subsystems/Logger/Default
                        AvalonLoggerSectionHandler.cs
                        LoggerConfiguration.cs LoggerManager.cs
               avalon-net/Castle/MicroKernel/Subsystems/Logger
                        ILoggerManager.cs
  Removed:     avalon-net/Castle/MicroKernel/Avalon/Configuration/Default
                        AvalonConfigurationSectionHandler.cs
                        ContainerConfiguration.cs
                        DefaultConfigurationManager.cs
               avalon-net/Castle/MicroKernel/Avalon/Configuration
                        IConfigurationManager.cs
               avalon-net/Castle/MicroKernel/Avalon/Context/Default
                        ContextManager.cs
               avalon-net/Castle/MicroKernel/Avalon/Context
                        IContextManager.cs
               avalon-net/Castle/MicroKernel/Avalon/Logger/Default
                        LoggerManager.cs
               avalon-net/Castle/MicroKernel/Avalon/Logger
                        ILoggerManager.cs
  Log:
  More test cases. Completed ConfigurationManager and LoggerManager implementation. Still
a ContextManager to do.
  
  Revision  Changes    Path
  1.6       +63 -38    avalon-sandbox/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj
  
  Index: Apache.Avalon.Castle.MicroKernel.csproj
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/Apache.Avalon.Castle.MicroKernel.csproj,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Apache.Avalon.Castle.MicroKernel.csproj	18 Apr 2004 03:31:31 -0000	1.5
  +++ Apache.Avalon.Castle.MicroKernel.csproj	20 Apr 2004 03:37:48 -0000	1.6
  @@ -119,72 +119,42 @@
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "IResolver.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Kernel.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Aspects\AspectInvocationHandler.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Aspects\AspectPointCutFlags.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Aspects\IAspect.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Assemble\Assembler.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Avalon\Configuration\IConfigurationManager.cs"
  +                    RelPath = "IKernelSubsystem.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Configuration\Default\AvalonConfigurationSectionHandler.cs"
  +                    RelPath = "IResolver.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Configuration\Default\ContainerConfiguration.cs"
  +                    RelPath = "Kernel.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Configuration\Default\DefaultConfigurationManager.cs"
  +                    RelPath = "KernelConstants.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Context\IContextManager.cs"
  +                    RelPath = "Aspects\AspectInvocationHandler.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Context\Default\ContextManager.cs"
  +                    RelPath = "Aspects\AspectPointCutFlags.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Logger\ILoggerManager.cs"
  +                    RelPath = "Aspects\IAspect.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Avalon\Logger\Default\LoggerManager.cs"
  +                    RelPath = "Assemble\Assembler.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  @@ -415,6 +385,61 @@
                   />
                   <File
                       RelPath = "Model\Default\DefaultDependencyModel.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\AbstractSubsystem.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Configuration\IConfigurationManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Configuration\Default\AvalonConfigurationSectionHandler.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Configuration\Default\ContainerConfiguration.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Configuration\Default\DefaultConfigurationManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Context\IContextManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Context\Default\ContextManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Logger\ILoggerManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Logger\Default\AvalonLoggerSectionHandler.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Logger\Default\LoggerConfiguration.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Subsystems\Logger\Default\LoggerManager.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  
  
  
  1.3       +0 -20     avalon-sandbox/avalon-net/Castle/MicroKernel/AvalonKernel.cs
  
  Index: AvalonKernel.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/AvalonKernel.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AvalonKernel.cs	18 Apr 2004 03:31:31 -0000	1.2
  +++ AvalonKernel.cs	20 Apr 2004 03:37:48 -0000	1.3
  @@ -18,8 +18,6 @@
   
   	using Apache.Avalon.Castle.MicroKernel.Concerns;
   	using Apache.Avalon.Castle.MicroKernel.Model;
  -	using Apache.Avalon.Castle.MicroKernel.Configuration;
  -	using Apache.Avalon.Castle.MicroKernel.Logger;
   
   	/// <summary>
   	/// Specialization of Kernel to support 
  @@ -33,24 +31,6 @@
   		ConcernManager Concerns
   		{
   			get;
  -		}
  -
  -		/// <summary>
  -		/// 
  -		/// </summary>
  -		IConfigurationManager ConfigurationManager
  -		{
  -			get;
  -			set;
  -		}
  -
  -		/// <summary>
  -		/// 
  -		/// </summary>
  -		ILoggerManager LoggerManager
  -		{
  -			get;
  -			set;
   		}
   	}
   }
  
  
  
  1.4       +28 -0     avalon-sandbox/avalon-net/Castle/MicroKernel/BaseKernel.cs
  
  Index: BaseKernel.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/BaseKernel.cs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- BaseKernel.cs	3 Apr 2004 23:03:02 -0000	1.3
  +++ BaseKernel.cs	20 Apr 2004 03:37:48 -0000	1.4
  @@ -34,6 +34,8 @@
   
   		protected Hashtable m_services;
   
  +		protected Hashtable m_subsystems;
  +
   		protected Hashtable m_dependencyToSatisfy;
   
   		protected IHandlerFactory m_handlerFactory;
  @@ -52,6 +54,7 @@
   			m_components = new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
   			m_services = new Hashtable();
   			m_dependencyToSatisfy = new Hashtable();
  +			m_subsystems = new Hashtable();
   			m_handlerFactory = new Handler.Default.SimpleHandlerFactory();
   			m_lifestyleManagerFactory = new Lifestyle.Default.SimpleLifestyleManagerFactory();
   			m_componentModelBuilder = new Model.Default.DefaultComponentModelBuilder( this );
  @@ -120,6 +123,21 @@
   		}
   
   		/// <summary>
  +		/// Adds a subsystem.
  +		/// </summary>
  +		/// <param name="key">Name of this subsystem</param>
  +		/// <param name="system">Subsystem implementation</param>
  +		public void AddSubsystem( String key, IKernelSubsystem system )
  +		{
  +			AssertUtil.ArgumentNotNull( key, "key" );
  +			AssertUtil.ArgumentNotNull( system, "system" );
  +
  +			system.Init( this );
  +
  +			m_subsystems[ key ] = system;
  +		}
  +
  +		/// <summary>
   		/// 
   		/// </summary>
   		public IHandler this [ String key ]
  @@ -227,6 +245,16 @@
   		public IHandler GetHandlerForService( Type service )
   		{
   			return (IHandler) m_services[ service ];
  +		}
  +
  +		/// <summary>
  +		/// Returns a registered subsystem;
  +		/// </summary>
  +		/// <param name="key">Key used when registered subsystem</param>
  +		/// <returns>Subsystem implementation</returns>
  +		public IKernelSubsystem GetSubsystem( String key )
  +		{
  +			return (IKernelSubsystem) m_subsystems[ key ];
   		}
   
   		#endregion
  
  
  
  1.3       +7 -38     avalon-sandbox/avalon-net/Castle/MicroKernel/DefaultKernel.cs
  
  Index: DefaultKernel.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/DefaultKernel.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultKernel.cs	18 Apr 2004 03:31:31 -0000	1.2
  +++ DefaultKernel.cs	20 Apr 2004 03:37:48 -0000	1.3
  @@ -18,8 +18,9 @@
   
   	using Apache.Avalon.Castle.MicroKernel.Concerns;
   	using Apache.Avalon.Castle.MicroKernel.Model;
  -	using Apache.Avalon.Castle.MicroKernel.Configuration;
  -	using Apache.Avalon.Castle.MicroKernel.Logger;
  +	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 
  @@ -29,10 +30,6 @@
   	{
   		protected ConcernManager m_concerns = new ConcernManager();
   
  -		protected IConfigurationManager m_configManager;
  -
  -		protected ILoggerManager m_loggerManager;
  -
   		/// <summary>
   		/// 
   		/// </summary>
  @@ -40,6 +37,10 @@
   		{
   			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
  @@ -53,38 +54,6 @@
   			get
   			{
   				return m_concerns;
  -			}
  -		}
  -
  -		/// <summary>
  -		/// 
  -		/// </summary>
  -		public IConfigurationManager ConfigurationManager
  -		{
  -			get
  -			{
  -				return m_configManager;
  -			}
  -			set
  -			{
  -				AssertUtil.ArgumentNotNull( value, "value" );
  -				m_configManager = value;
  -			}
  -		}
  -
  -		/// <summary>
  -		/// 
  -		/// </summary>
  -		public ILoggerManager LoggerManager
  -		{
  -			get
  -			{
  -				return m_loggerManager;
  -			}
  -			set
  -			{
  -				AssertUtil.ArgumentNotNull( value, "value" );
  -				m_loggerManager = value;
   			}
   		}
   
  
  
  
  1.3       +14 -0     avalon-sandbox/avalon-net/Castle/MicroKernel/Kernel.cs
  
  Index: Kernel.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/Kernel.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Kernel.cs	3 Apr 2004 23:03:02 -0000	1.2
  +++ Kernel.cs	20 Apr 2004 03:37:48 -0000	1.3
  @@ -41,6 +41,13 @@
   		void AddAspect( AspectPointCutFlags flags, IAspect aspect );
   
   		/// <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>
   		/// IComponentModel instance builder.
   		/// </summary>
   		IComponentModelBuilder ModelBuilder
  @@ -107,5 +114,12 @@
   		/// <param name="service">The service interface</param>
   		/// <returns>IHandler implementation</returns>
   		IHandler GetHandlerForService( Type service );
  +
  +		/// <summary>
  +		/// Returns a registered subsystem;
  +		/// </summary>
  +		/// <param name="key">Key used when registered subsystem</param>
  +		/// <returns>Subsystem implementation</returns>
  +		IKernelSubsystem GetSubsystem( String key );
   	}
   }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/IKernelSubsystem.cs
  
  Index: IKernelSubsystem.cs
  ===================================================================
  // 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);
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/KernelConstants.cs
  
  Index: KernelConstants.cs
  ===================================================================
  // 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 KernelConstants.
  	/// </summary>
  	public abstract class KernelConstants
  	{
  		public static readonly String CONFIGURATION = "configuration";
  
  		public static readonly String LOGGER = "logger";
  
  		public static readonly String CONTEXT = "context";
  	}
  }
  
  
  
  1.2       +5 -0      avalon-sandbox/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj
  
  Index: Apache.Avalon.Castle.MicroKernel.Test.csproj
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/MicroKernelTest/Apache.Avalon.Castle.MicroKernel.Test.csproj,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Apache.Avalon.Castle.MicroKernel.Test.csproj	18 Apr 2004 03:26:02 -0000	1.1
  +++ Apache.Avalon.Castle.MicroKernel.Test.csproj	20 Apr 2004 03:37:48 -0000	1.2
  @@ -144,6 +144,11 @@
                       BuildAction = "Compile"
                   />
                   <File
  +                    RelPath = "LoggerManagerTestCase.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
                       RelPath = "SimpleComponentFactoryTestCase.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
  
  
  
  1.2       +2 -2      avalon-sandbox/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultConfigurationManagerTestCase.cs
  
  Index: DefaultConfigurationManagerTestCase.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/MicroKernelTest/DefaultConfigurationManagerTestCase.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultConfigurationManagerTestCase.cs	18 Apr 2004 03:26:02 -0000	1.1
  +++ DefaultConfigurationManagerTestCase.cs	20 Apr 2004 03:37:48 -0000	1.2
  @@ -22,8 +22,8 @@
   	using Apache.Avalon.Castle.MicroKernel;
   	using Apache.Avalon.Castle.MicroKernel.Model;
   	using Apache.Avalon.Castle.MicroKernel.Model.Default;
  -	using Apache.Avalon.Castle.MicroKernel.Configuration;
  -	using Apache.Avalon.Castle.MicroKernel.Configuration.Default;
  +	using Apache.Avalon.Castle.MicroKernel.Subsystems.Configuration;
  +	using Apache.Avalon.Castle.MicroKernel.Subsystems.Configuration.Default;
   	using Apache.Avalon.Castle.MicroKernel.Test.Components;
   
   	/// <summary>
  
  
  
  1.3       +50 -11    avalon-sandbox/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs
  
  Index: DefaultComponentModelBuilder.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/MicroKernel/Model/Default/DefaultComponentModelBuilder.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultComponentModelBuilder.cs	18 Apr 2004 03:31:31 -0000	1.2
  +++ DefaultComponentModelBuilder.cs	20 Apr 2004 03:37:48 -0000	1.3
  @@ -20,6 +20,10 @@
   
   	using Apache.Avalon.Framework;
   
  +	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>
  @@ -49,20 +53,55 @@
   			IConstructionModel constructionModel = 
   				new DefaultConstructionModel( implementation, data.Constructor, data.PropertiesInfo
);
   
  -			DefaultComponentModel model = new DefaultComponentModel( 
  -				data.Name,
  -				service, 
  -				data.SupportedLifestyle, 
  -				new ConsoleLogger( service.Name, LoggerLevel.Debug ), 
  -				new DefaultConfiguration(), 
  -				new DefaultContext(), 
  -				data.DependencyModel, 
  -				constructionModel );
  -
  -			return model;
  +			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 );
   		}
   
   		#endregion
  +
  +		protected virtual ILogger CreateLogger( ComponentData data )
  +		{
  +			ILoggerManager loggerManager = (ILoggerManager) 
  +				m_kernel.GetSubsystem( KernelConstants.LOGGER );
  +
  +			if(loggerManager != null)
  +			{
  +				return loggerManager.CreateLogger( 
  +					data.Name, data.Implementation.Name, data.AvalonLogger );
  +			}
  +			else
  +			{
  +				return new ConsoleLogger( data.Name, LoggerLevel.Info );
  +			}
  +		}
  +
  +		protected virtual IConfiguration CreateConfiguration( ComponentData data )
  +		{
  +			IConfigurationManager configManager = (IConfigurationManager) 
  +				m_kernel.GetSubsystem( KernelConstants.CONFIGURATION );
  +
  +			if( configManager != null )
  +			{
  +				return configManager.GetConfiguration( data.Name );
  +			}
  +			else
  +			{
  +				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 )
   		{
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/AbstractSubsystem.cs
  
  Index: AbstractSubsystem.cs
  ===================================================================
  // 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.Subsystems
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for AbstractSubsystem.
  	/// </summary>
  	public abstract class AbstractSubsystem : IKernelSubsystem
  	{
  		private Kernel m_kernel;
  
  		public AbstractSubsystem()
  		{
  		}
  
  		#region IKernelSubsystem Members
  
  		public void Init(Kernel kernel)
  		{
  			AssertUtil.ArgumentNotNull( kernel, "kernel" );
  
  			m_kernel = kernel;
  		}
  
  		#endregion
  
  		protected virtual Kernel Kernel
  		{
  			get
  			{
  				return m_kernel;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Configuration/Default/AvalonConfigurationSectionHandler.cs
  
  Index: AvalonConfigurationSectionHandler.cs
  ===================================================================
  // 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.Subsystems.Configuration.Default
  {
  	using System;
  	using System.Configuration;
  	using System.Xml;
  
  	/// <summary>
  	/// Implementation of <see cref="System.Configuration.IConfigurationSectionHandler"/>
  	/// to allow natural mapping of a section in the configuration file associated with an

  	/// AppDomain to a <see cref="ContainerConfiguration"/>.
  	/// </summary>
  	public class AvalonConfigurationSectionHandler : IConfigurationSectionHandler
  	{
  		/// <summary>
  		/// The static name of the section in the configuration file.
  		/// </summary>
  		private static readonly String SECTION_NAME = "castle.container";
  
  		public AvalonConfigurationSectionHandler()
  		{
  		}
  
  		/// <summary>
  		/// Returns the default name of the section in the
  		/// configuration file.
  		/// </summary>
  		internal static String Section
  		{
  			get
  			{
  				return SECTION_NAME;
  			}
  		}
  
  		#region IConfigurationSectionHandler Members
  
  		/// <summary>
  		/// Invoke by Configuration API - Should return any object represeting the
  		/// actual configuration
  		/// </summary>
  		/// <param name="parent">If hierarquical configuration is being used, 
  		/// a non-null ContainerConfiguration to be overrided.
  		/// </param>
  		/// <param name="configContext">API specific.</param>
  		/// <param name="section">The <see cref="XmlNode"/> to be parsed.</param>
  		/// <returns>A ContainerConfiguration instance.</returns>
  		public object Create(object parent, object configContext, XmlNode section)
  		{
  			return new ContainerConfiguration(
  				(ContainerConfiguration) parent, section);
  		}
  
  		#endregion
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Configuration/Default/ContainerConfiguration.cs
  
  Index: ContainerConfiguration.cs
  ===================================================================
  // 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.Subsystems.Configuration.Default
  {
  	using System;
  	using System.Xml;
  	using System.IO;
  
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Keeps the container configuration.
  	/// </summary>
  	public class ContainerConfiguration
  	{
  		private IConfiguration m_configuration;
  
  		/// <summary>
  		/// Constructs a ContainerConfiguration with an optional parent.
  		/// </summary>
  		/// <param name="parent">The ContainerConfiguration parent. Can be null</param>
  		public ContainerConfiguration(ContainerConfiguration parent)
  		{
  		}
  
  		/// <summary>
  		/// Constructs a ContainerConfiguration with an optional parent.
  		/// </summary>
  		/// <param name="parent">The ContainerConfiguration parent. Can be null</param>
  		/// <param name="section">XmlNode to be parsed.</param>
  		public ContainerConfiguration(ContainerConfiguration parent, XmlNode section) : this(
parent )
  		{
  			if ( section == null )
  			{
  				throw new ArgumentNullException( "section" );
  			}
  
  			Deserialize( section );
  		}
  
  		/// <summary>
  		/// Constructs a ContainerConfiguration with the
  		/// <see cref="XmlNode"/> to be parsed.
  		/// </summary>
  		/// <param name="parent">The ContainerConfiguration parent. Can be null</param>
  		/// <param name="section">XmlNode to be parsed.</param>
  		public ContainerConfiguration(XmlNode section) : this(null, section)
  		{
  		}
  
  		/// <summary>
  		/// Constructs a ContainerConfiguration with the filename containing
  		/// the xml to be parsed.
  		/// </summary>
  		/// <param name="filename">The filename to be parsed.</param>
  		public ContainerConfiguration(String filename) : this(null as ContainerConfiguration)
  		{
  			ParseFromFile(filename);
  		}
  
  		/// <summary>
  		/// Parses a configuration file. Looks for a node 
  		/// 'configuration/avalon.container'
  		/// </summary>
  		/// <param name="filename">The xml full file name</param>
  		private void ParseFromFile(String filename)
  		{
  			XmlTextReader reader = new XmlTextReader(
  				new FileStream(filename, FileMode.Open, FileAccess.Read));
  
  			XmlDocument doc = new XmlDocument() ;
  			doc.Load(reader);
  
  			XmlNode avalonNode = 
  				doc.SelectSingleNode("configuration/" + AvalonConfigurationSectionHandler.Section);
  
  			Deserialize( avalonNode );
  		}
  
  		/// <summary>
  		/// 
  		/// </summary>
  		/// <param name="section"></param>
  		private void Deserialize( XmlNode section )
  		{
  			m_configuration = DefaultConfigurationSerializer.Deserialize( section );
  		}
  
  		/// <summary>
  		/// 
  		/// </summary>
  		public IConfiguration Configuration
  		{
  			get
  			{
  				return m_configuration;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Configuration/Default/DefaultConfigurationManager.cs
  
  Index: DefaultConfigurationManager.cs
  ===================================================================
  // 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.Subsystems.Configuration.Default
  {
  	using System;
  	using System.Configuration;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Castle.MicroKernel.Model;
  	using Apache.Avalon.Castle.MicroKernel.Subsystems;
  
  	/// <summary>
  	/// The default implementation of IConfigurationManager uses the 
  	/// .config associated with the AppDomain to extract the components
  	/// configurations
  	/// </summary>
  	public class DefaultConfigurationManager : AbstractSubsystem, IConfigurationManager
  	{
  		protected ContainerConfiguration m_config;
  
  		public DefaultConfigurationManager()
  		{
  			m_config = (ContainerConfiguration) ConfigurationSettings.GetConfig( 
  				AvalonConfigurationSectionHandler.Section );
  		}
  
  		#region IConfigurationManager Members
  
  		public IConfiguration GetConfiguration( String componentName )
  		{
  			AssertUtil.ArgumentNotNull( componentName, "componentName" );
  
  			return m_config.Configuration.GetChild( componentName, true );
  		}
  
  		#endregion
  	}
  }
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Configuration/IConfigurationManager.cs
  
  Index: IConfigurationManager.cs
  ===================================================================
  // 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.Subsystems.Configuration
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Castle.MicroKernel.Model;
  
  	/// <summary>
  	/// Summary description for IConfigurationManager.
  	/// </summary>
  	public interface IConfigurationManager : IKernelSubsystem
  	{
  		/// <summary>
  		/// Implementation should return a configuration for 
  		/// the component.
  		/// </summary>
  		/// <param name="model"></param>
  		/// <returns></returns>
  		IConfiguration GetConfiguration( String componentName );
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Context/Default/ContextManager.cs
  
  Index: ContextManager.cs
  ===================================================================
  // 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.Subsystems.Context.Default
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Summary description for ContextManager.
  	/// </summary>
  	public class ContextManager : AbstractSubsystem, IContextManager
  	{
  		public ContextManager()
  		{
  			CreateDefault
  		}
  
  		#region IContextManager Members
  
  		public IContext CreateContext(AvalonContextAttribute contextAtt, AvalonEntryAttribute[]
entries)
  		{
  			if (contextAtt != null)
  			{
  				return CreateCustomContext(contextAtt, entries);
  			}
  			else
  			{
  				return CreateDefaultContext(entries);
  			}
  		}
  		
  		#endregion
  
  		protected IContext CreateCustomContext(AvalonContextAttribute contextAtt, AvalonEntryAttribute[]
entries)
  		{
  			return null;
  		}
  
  		protected IContext CreateDefaultContext(AvalonEntryAttribute[] entries)
  		{
  			DefaultContext context = new DefaultContext();
  
  			foreach(AvalonEntryAttribute entry in entries)
  			{
  				
  			}
  
  			context.MakeReadOnly();
  
  			return context;
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Context/IContextManager.cs
  
  Index: IContextManager.cs
  ===================================================================
  // 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.Subsystems.Context
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Summary description for IContextManager.
  	/// </summary>
  	public interface IContextManager : IKernelSubsystem
  	{
  		IContext CreateContext(AvalonContextAttribute contextAtt, AvalonEntryAttribute[] entries);
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Logger/Default/AvalonLoggerSectionHandler.cs
  
  Index: AvalonLoggerSectionHandler.cs
  ===================================================================
  // 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.Subsystems.Logger.Default
  {
  	using System;
  	using System.Configuration;
  
  	/// <summary>
  	/// Summary description for AvalonLoggerSectionHandler.
  	/// </summary>
  	public class AvalonLoggerSectionHandler : IConfigurationSectionHandler
  	{
  		/// <summary>
  		/// The static name of the section in the configuration file.
  		/// </summary>
  		private static readonly String SECTION_NAME = "castle.logger";
  
  		public AvalonLoggerSectionHandler()
  		{
  		}
  
  		/// <summary>
  		/// Returns the default name of the section in the
  		/// configuration file.
  		/// </summary>
  		internal static String Section
  		{
  			get
  			{
  				return SECTION_NAME;
  			}
  		}
  
  		#region IConfigurationSectionHandler Members
  
  		public object Create(object parent, object configContext, System.Xml.XmlNode section)
  		{
  			return new LoggerConfiguration(section);
  		}
  
  		#endregion
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Logger/Default/LoggerConfiguration.cs
  
  Index: LoggerConfiguration.cs
  ===================================================================
  // 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.Subsystems.Logger.Default
  {
  	using System;
  	using System.Collections;
  	using System.Xml;
  
  	using Apache.Avalon.Framework;
  
  	internal enum LoggerType
  	{
  		Console,
  		Null,
  		Log4net,
  		Diagnostics
  	}
  
  	/// <summary>
  	/// Summary description for LoggerConfiguration.
  	/// </summary>
  	public class LoggerConfiguration
  	{
  		private static readonly String LOG_LEVEL = "level";
  
  		private static readonly String DEFAULT_LOG_LEVEL = "info";
  
  		private static readonly String LOG_TYPE = "type";
  		
  		private static readonly String DEFAULT_LOG_TYPE = "console";
  
  		private static readonly String DEFAULT_NAME = "Castle.Microkernel";
  
  		private LoggerLevel m_logLevel;
  
  		private ILogger m_logType;
  
  		/// <summary>
  		/// 
  		/// </summary>
  		/// <param name="section"></param>
  		public LoggerConfiguration(XmlNode section)
  		{
  			IConfiguration config = 
  				DefaultConfigurationSerializer.Deserialize( section );
  
  			IConfiguration logLevelConfig = config.GetChild( LOG_LEVEL, true );
  			IConfiguration logTypeConfig = config.GetChild( LOG_TYPE, true );
  
  			String level = (String) logLevelConfig.GetValue( typeof(String), DEFAULT_LOG_LEVEL );
  			String type = (String) logTypeConfig.GetValue( typeof(String), DEFAULT_LOG_TYPE );
  
  			m_logLevel = ConvertToLogLevel( level );
  			m_logType = BuildLogType( type );
  		}
  
  		private LoggerLevel ConvertToLogLevel( String level )
  		{
  			try
  			{
  				return (LoggerLevel) Enum.Parse( typeof(LoggerLevel), level, true );
  			}
  			catch(Exception ex)
  			{
  				throw new ConfigurationException(
  					"Could not convert specified logger level to a known one", ex);
  			}
  		}
  
  		private ILogger BuildLogType( String type )
  		{
  			LoggerType loggerType = LoggerType.Console;
  
  			try
  			{
  				loggerType = (LoggerType) Enum.Parse( typeof(LoggerType), type, true );
  			}
  			catch(Exception ex)
  			{
  				throw new ConfigurationException(
  					"Could not convert specified logger type to a known one", ex);
  			}
  
  			switch(loggerType)
  			{
  				case LoggerType.Log4net: // Not sure if its good to depend on log4net
  				case LoggerType.Console:
  					return new ConsoleLogger(DEFAULT_NAME, m_logLevel);
  				case LoggerType.Diagnostics:
  					return new DiagnosticsLogger(DEFAULT_NAME);
  				//case LoggerType.Log4net:
  					// ILog log = LogManager.GetLogger(DEFAULT_NAME);
  					// m_rootLogger = new Log4netLogger(log, DEFAULT_NAME);
  				//	break;
  				case LoggerType.Null:
  					return new NullLogger();
  			}
  
  			return null;
  		}
  
  		public ILogger RootLogger
  		{
  			get
  			{
  				return m_logType;
  			}
  		}
  
  		public LoggerLevel LoggerLevel
  		{
  			get
  			{
  				return m_logLevel;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Logger/Default/LoggerManager.cs
  
  Index: LoggerManager.cs
  ===================================================================
  // 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.Subsystems.Logger.Default
  {
  	using System;
  	using System.Configuration;
  
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// This is a very simplistic implementation of ILoggerManager
  	/// that creates loggers based on a root ILogger implementation.
  	/// To choose a implementation for ILogger it reads from the
  	/// configuration of the current AppDomain 
  	/// </summary>
  	public class LoggerManager : AbstractSubsystem, ILoggerManager
  	{
  		private LoggerConfiguration m_configuration;
  
  		public LoggerManager()
  		{
  			m_configuration = (LoggerConfiguration)
  				ConfigurationSettings.GetConfig( AvalonLoggerSectionHandler.Section );
  		}
  
  		#region ILoggerManager Members
  
  		public ILogger CreateLogger(String loggerName, String implementationName, AvalonLoggerAttribute
loggerAtt)
  		{
  			String name = null;
  
  			if (loggerAtt != null)
  			{
  				name = loggerAtt.Name;
  			}
  			if (name == null || name.Length == 0)
  			{
  				name = loggerName;
  			}
  			if (name == null || name.Length == 0)
  			{
  				name = implementationName;
  			}
  
  			return m_configuration.RootLogger.CreateChildLogger( name );
  		}
  
  		#endregion
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Castle/MicroKernel/Subsystems/Logger/ILoggerManager.cs
  
  Index: ILoggerManager.cs
  ===================================================================
  // 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.Subsystems.Logger
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Castle.MicroKernel.Model;
  
  	/// <summary>
  	/// Summary description for ILoggerManager.
  	/// </summary>
  	public interface ILoggerManager : IKernelSubsystem
  	{
  		ILogger CreateLogger( String loggerName, String implementationName, AvalonLoggerAttribute
loggerAtt );
  	}
  }
  
  
  

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


Mime
View raw message