You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@avalon.apache.org by ha...@apache.org on 2003/10/03 05:13:15 UTC

cvs commit: avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Components Entity.cs EntityLocator.cs ErroneousComponent.cs

hammett     2003/10/02 20:13:15

  Modified:    avalon-net/cscontainer/AvalonContainerTest
                        AvalonContainerTest.csproj
                        DependencyHandlingTestCase.cs
               avalon-net/cscontainer/AvalonContainerTest/Module
                        PicoContainerExtension.cs
               avalon-net/cscontainer/AvalonContainer
                        AvalonContainer.csproj Component.cs
                        DefaultContainer.cs LifestyleManager.cs
               avalon-net/cscontainer/AvalonContainer/Factory
                        TransientComponentFactory.cs
               avalon-net/cscontainer/AvalonContainer/Lookup
                        BlindLookupManager.cs DefaultLookupManager.cs
               avalon-net/cscontainer/Samples/bin/Samples
                        Samples.Components.dll
               avalon-net/cscontainer/bin Apache.Avalon.Container.Test.dll
                        Apache.Avalon.Container.dll
                        Apache.Avalon.Framework.dll
               avalon-net/csframework/AvalonFrameworkTest
                        AttributesTestCase.cs
               avalon-net/csframework/AvalonFramework Attributes.cs
                        ContainerUtil.cs
               avalon-net/csframework/bin Apache.Avalon.Framework.Test.dll
                        Apache.Avalon.Framework.dll
  Added:       avalon-net/cscontainer/AvalonContainerTest
                        LookupScopeTestCase.cs
               avalon-net/cscontainer/AvalonContainer/Lookup
                        InternalLookupManager.cs
               avalon-net/cscontainer/AvalonContainerTest/Components
                        Entity.cs EntityLocator.cs ErroneousComponent.cs
  Log:
  Corrected the lookup for dependencies behavior.
  
  Revision  Changes    Path
  1.3       +20 -0     avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/AvalonContainerTest.csproj
  
  Index: AvalonContainerTest.csproj
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/AvalonContainerTest.csproj,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AvalonContainerTest.csproj	27 Sep 2003 23:58:29 -0000	1.2
  +++ AvalonContainerTest.csproj	3 Oct 2003 03:13:14 -0000	1.3
  @@ -114,6 +114,11 @@
                       BuildAction = "Compile"
                   />
                   <File
  +                    RelPath = "LookupScopeTestCase.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
                       RelPath = "PicoContainerExtensionTestCase.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
  @@ -140,6 +145,21 @@
                   />
                   <File
                       RelPath = "Components\Calculator.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Components\Entity.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Components\EntityLocator.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Components\ErroneousComponent.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  
  
  
  1.3       +6 -5      avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/DependencyHandlingTestCase.cs
  
  Index: DependencyHandlingTestCase.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/DependencyHandlingTestCase.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DependencyHandlingTestCase.cs	27 Sep 2003 23:58:29 -0000	1.2
  +++ DependencyHandlingTestCase.cs	3 Oct 2003 03:13:14 -0000	1.3
  @@ -61,12 +61,13 @@
   		[Test]
   		public void ShutDownOrderCheck()
   		{
  -			Assertion.AssertEquals(6, m_container.ShutDownOrder.Length);
  +			Assertion.AssertEquals(9, m_container.ShutDownOrder.Length);
   
  -			Assertion.AssertEquals(typeof(IBus).FullName, m_container.ShutDownOrder[0].Name);
  -			Assertion.AssertEquals(typeof(IVehicle).FullName, m_container.ShutDownOrder[1].Name);
  -			Assertion.AssertEquals(typeof(IRadio).FullName, m_container.ShutDownOrder[2].Name);
  -			Assertion.AssertEquals(typeof(IEngine).FullName, m_container.ShutDownOrder[3].Name);
  +			Assertion.AssertEquals(typeof(IEntityLocator).FullName, m_container.ShutDownOrder[0].Name);
  +			Assertion.AssertEquals(typeof(IBus).FullName, m_container.ShutDownOrder[1].Name);
  +			Assertion.AssertEquals(typeof(IVehicle).FullName, m_container.ShutDownOrder[2].Name);
  +			Assertion.AssertEquals(typeof(IRadio).FullName, m_container.ShutDownOrder[3].Name);
  +			Assertion.AssertEquals(typeof(IEngine).FullName, m_container.ShutDownOrder[4].Name);
   		}
   
   		[Test]
  
  
  
  1.1                  avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/LookupScopeTestCase.cs
  
  Index: LookupScopeTestCase.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  //
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  //
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  //
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  //
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  //    must not be used to endorse or promote products derived from this  software
  //    without  prior written permission. For written permission, please contact
  //    apache@apache.org.
  //
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  //
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  //
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Container.Test
  {
  	using System;
  	using NUnit.Framework;
  
  	using Apache.Avalon.Container.Test.Components;
  
  	/// <summary>
  	/// Assures the component can only lookups his dependencies
  	/// and the returned instances matches theirs lifestyles.
  	/// </summary>
  	[TestFixture]
  	public class LookupScopeTestCase : ContainerTestCase
  	{
  		[Test]
  		public void ErroneousComponentTest()
  		{
  			IAirplane airplane = (IAirplane) 
  				m_container.LookupManager[ typeof(IAirplane).FullName ];
  
  			Assertion.AssertNotNull( airplane );
  			Assertion.Assert( airplane.hasRadio == false );
  		}
  
  		[Test]
  		public void LifestyleCorrectness()
  		{
  			IEntityLocator locator = (IEntityLocator) 
  				m_container.LookupManager[ typeof(IEntityLocator).FullName ];
  
  			Assertion.AssertNotNull( locator );
  
  			object[] entities = new object[3];
  
  			entities[0] = locator.Find(0);
  			entities[1] = locator.Find(1);
  			entities[2] = locator.Find(2);
  
  			Assertion.AssertNotNull( entities[0] );
  			Assertion.AssertNotNull( entities[1] );
  			Assertion.AssertNotNull( entities[2] );
  
  			Assertion.Assert( !entities[0].Equals(entities[1]) );
  			Assertion.Assert( !entities[0].Equals(entities[2]) );
  			Assertion.Assert( !entities[1].Equals(entities[2]) );
  		}
  	}
  }
  
  
  
  1.3       +2 -1      avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Module/PicoContainerExtension.cs
  
  Index: PicoContainerExtension.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Module/PicoContainerExtension.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PicoContainerExtension.cs	25 Sep 2003 01:42:34 -0000	1.2
  +++ PicoContainerExtension.cs	3 Oct 2003 03:13:14 -0000	1.3
  @@ -79,7 +79,8 @@
   
   			if (method != null)
   			{
  -				method.Invoke(instance, new object[] { e.DependencyInstance } );
  +				object depInstance = e.LookupManager[ e.DependencyKey ];
  +				method.Invoke(instance, new object[] { depInstance } );
   			}
   		}
   	}
  
  
  
  1.3       +5 -4      avalon-sandbox/avalon-net/cscontainer/AvalonContainer/AvalonContainer.csproj
  
  Index: AvalonContainer.csproj
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/AvalonContainer.csproj,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AvalonContainer.csproj	25 Sep 2003 01:42:34 -0000	1.2
  +++ AvalonContainer.csproj	3 Oct 2003 03:13:14 -0000	1.3
  @@ -118,10 +118,6 @@
                       BuildAction = "Content"
                   />
                   <File
  -                    RelPath = "TODO.txt"
  -                    BuildAction = "Content"
  -                />
  -                <File
                       RelPath = "Attributes\CustomFactoryBuilder.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
  @@ -208,6 +204,11 @@
                   />
                   <File
                       RelPath = "Lookup\DefaultLookupManager.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Lookup\InternalLookupManager.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  
  
  
  1.2       +1 -1      avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Component.cs
  
  Index: Component.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Component.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Component.cs	22 Sep 2003 23:49:23 -0000	1.1
  +++ Component.cs	3 Oct 2003 03:13:14 -0000	1.2
  @@ -71,7 +71,7 @@
   		public ComponentEntry(AvalonComponentAttribute attribute, Type type, AvalonDependencyAttribute[] dependencies)
   		{
   			m_lifestyle     = attribute.Lifestyle;
  -			m_configName    = attribute.ConfigurationName;
  +			m_configName    = attribute.Name;
   			m_loggerName    = attribute.LoggerName;
   			m_componentType = type;
   			m_dependencies  = dependencies;
  
  
  
  1.4       +1 -1      avalon-sandbox/avalon-net/cscontainer/AvalonContainer/DefaultContainer.cs
  
  Index: DefaultContainer.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/DefaultContainer.cs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultContainer.cs	25 Sep 2003 13:24:25 -0000	1.3
  +++ DefaultContainer.cs	3 Oct 2003 03:13:14 -0000	1.4
  @@ -283,7 +283,7 @@
   			InternalComponentHandler handler = 
   				new InternalComponentHandler( logger, extensionsConfiguration, lifecycleManager );
   
  -			BlindLookupManager lookUpManager = new BlindLookupManager(LookupManager);
  +			InternalLookupManager lookUpManager = new InternalLookupManager();
   			lookUpManager.Add( typeof(IComponentFactoryManager).FullName, m_factoryManager );
   			lookUpManager.Add( typeof(ILoggerManager).FullName, m_loggerManager );
   			lookUpManager.Add( "Container", this );
  
  
  
  1.3       +18 -22    avalon-sandbox/avalon-net/cscontainer/AvalonContainer/LifestyleManager.cs
  
  Index: LifestyleManager.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/LifestyleManager.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LifestyleManager.cs	25 Sep 2003 01:42:34 -0000	1.2
  +++ LifestyleManager.cs	3 Oct 2003 03:13:14 -0000	1.3
  @@ -138,7 +138,7 @@
   					ContainerUtil.EnableLogging(instance, m_loggerManager[entry.LoggerName]);
   				}
   
  -				BlindLookupManager lookupManager = new BlindLookupManager(m_container.LookupManager);
  +				BlindLookupManager lookupManager = new BlindLookupManager(m_container);
   
   				if (entry.Dependencies.Length != 0)
   				{
  @@ -313,14 +313,14 @@
   		}
   
   		private void OnSetupDependencies(object instance, ComponentEntry entry, 
  -			String dependencyRole, String dependencyKey, object dependencyInstance)
  +			String dependencyRole, String dependencyKey, ILookupManager manager)
   		{
   			if (Events[DependenciesEvent] != null)
   			{
   				System.Delegate del = Events[DependenciesEvent];
   				del.Method.Invoke(del.Target, new object[] 
   					{new LifecycleEventArgs(instance, entry, 
  -						dependencyRole, dependencyInstance, dependencyKey)});
  +						dependencyRole, dependencyKey, manager)});
   			}									   
   		}
   		#endregion
  @@ -442,13 +442,9 @@
   						m_logger.Debug("  Dependency: '{0}'", depEntry.ComponentType.FullName);
   					}
   
  -					// "Release" are deferred to container shutdown
  +					lookupManager.Add(dep.Key, dep.DependencyType);
   
  -					object depInstance = depEntry.Handler.GetInstance();
  -					
  -					lookupManager.Add(dep.Key, depInstance);
  -
  -					OnSetupDependencies(instance, entry, depRole, dep.Key, depInstance);
  +					OnSetupDependencies(instance, entry, depRole, dep.Key, lookupManager);
   				}
   			}
   		}
  @@ -487,8 +483,8 @@
   		private object         m_component;
   		private ComponentEntry m_entry;
   		private String         m_dependencyRole;
  -		private object         m_dependencyInstance;
   		private String         m_dependencyKey;
  +		private ILookupManager m_lookupManager;
   
   		internal LifecycleEventArgs(object component, ComponentEntry entry)
   		{
  @@ -497,11 +493,19 @@
   		}
   
   		internal LifecycleEventArgs(object component, ComponentEntry entry, 
  -			String dependencyRole, object dependencyInstance, String dependencyKey) : this(component, entry)
  +			String dependencyRole, String dependencyKey, ILookupManager lookupManager) : this(component, entry)
  +		{
  +			m_dependencyRole = dependencyRole;
  +			m_dependencyKey  = dependencyKey;
  +			m_lookupManager  = lookupManager;
  +		}
  +
  +		public ILookupManager LookupManager
   		{
  -			m_dependencyRole     = dependencyRole;
  -			m_dependencyInstance = dependencyInstance;
  -			m_dependencyKey      = dependencyKey;
  +			get
  +			{
  +				return m_lookupManager;
  +			}
   		}
   
   		public object Component
  @@ -545,14 +549,6 @@
   			get
   			{
   				return m_dependencyKey;
  -			}
  -		}
  -
  -		public object DependencyInstance
  -		{
  -			get
  -			{
  -				return m_dependencyInstance;
   			}
   		}
   	}
  
  
  
  1.2       +8 -1      avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Factory/TransientComponentFactory.cs
  
  Index: TransientComponentFactory.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Factory/TransientComponentFactory.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TransientComponentFactory.cs	22 Sep 2003 23:49:23 -0000	1.1
  +++ TransientComponentFactory.cs	3 Oct 2003 03:13:14 -0000	1.2
  @@ -51,7 +51,14 @@
   		{
   			object instance = base.Create( componentType );
   
  -			m_instances.Add(instance);
  +			// This should be done to reduce the probably of 
  +			// leaks caused by not releasing components.
  +			// If a component doesn't supports Dipose, then 
  +			// we won't keep the instances.
  +			if (ContainerUtil.ExpectsDispose(instance))
  +			{
  +				m_instances.Add(instance);
  +			}
   
   			return instance;
   		}

		public override bool IsOwner( object componentInstance )
  
  
  
  1.3       +17 -55    avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Lookup/BlindLookupManager.cs
  
  Index: BlindLookupManager.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Lookup/BlindLookupManager.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BlindLookupManager.cs	25 Sep 2003 01:42:34 -0000	1.2
  +++ BlindLookupManager.cs	3 Oct 2003 03:13:14 -0000	1.3
  @@ -53,33 +53,19 @@
   	using Apache.Avalon.Framework;
   
   	/// <summary>
  -	/// A blind LookupManager should exposes only dependencies instances.
  +	/// A Blind <see cref="ILookupManager"/> should exposes only dependencies instances.
   	/// </summary>
  -	/// <remarks>
  -	/// Unfortunatelly there are situations where look-up only
  -	/// dependents components is not enough. So a BlindLookupManager can
  -	/// receive a parent <see cref="Apache.Avalon.Framework.ILookupManager"/> 
  -	/// used to delegate the look-up.
  -	/// </remarks>
  -	public class BlindLookupManager : ILookupManager
  +	public class BlindLookupManager : DefaultLookupManager
   	{
  -		private Hashtable      m_instances;
  -		private ILookupManager m_parent;
  +		private Hashtable m_instances;
   
   		/// <summary>
   		/// Constructs a BlindLookupManager.
   		/// </summary>
  -		/// <param name="parent">The parent 
  -		/// <see cref="Apache.Avalon.Framework.ILookupManager"/>. 
  -		/// This can be null.
  -		/// </param>
  -		public BlindLookupManager(ILookupManager parent)
  +		public BlindLookupManager( DefaultContainer container ) : base(container)
   		{
   			// Shall we use a case insensitive hashtable?
   			m_instances = new Hashtable();
  -
  -			// This can be null
  -			m_parent = parent;
   		}
   
   		/// <summary>
  @@ -88,21 +74,21 @@
   		/// expose dependencies instances to the component.
   		/// </summary>
   		/// <param name="role">Role name (Could be anything)</param>
  -		/// <param name="instance">Component instance</param>
  -		public void Add(String role, object instance)
  +		/// <param name="serviceType">Interface service type.</param>
  +		public void Add(String role, Type serviceType )
   		{
   			if ( role == null || role.Length == 0 )
   			{
   				throw new ArgumentNullException( "role" );
   			}
  -			if ( instance == null )
  +			if ( serviceType == null )
   			{
  -				throw new ArgumentNullException( "instance" );
  +				throw new ArgumentNullException( "serviceType" );
   			}
   
   			// TODO: Support for Selectors
   
  -			m_instances.Add( role, instance );
  +			m_instances.Add( role, serviceType );
   		}
   
   		#region ILookupManager Members
  @@ -113,7 +99,7 @@
   		/// <value>The component instance.</value>
   		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
   		/// <exception cref="Apache.Avalon.Framework.LookupException">If the <c>role</c> could not be resolved.</exception>
  -		public object this[String role]
  +		public override object this[String role]
   		{
   			get
   			{
  @@ -122,43 +108,24 @@
   					throw new ArgumentNullException( "role" );
   				}
   
  -				object instance = m_instances[role];
  +				Type service = (Type) m_instances[role];
   
  -				if ( instance == null && m_parent != null )
  +				if ( service == null )
   				{
  -					instance = m_parent[role];
  +					throw new LookupException( role );
   				}
   
  -				if ( instance == null )
  -				{
  -					throw new LookupException( role, "Instance not found." );
  -				}
  -
  -				return instance;
  +				return base[ service.FullName ];
   			}
   		}
   
   		/// <summary>
   		/// Releases the component associated with the given role.
   		/// </summary>
  -		/// <remarks>
  -		/// A BlindLookupManager should not release anything as its not 
  -		/// have ownership of any component.
  -		/// </remarks>
   		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
  -		public void Release(object resource)
  +		public override void Release(object resource)
   		{
  -			// Sanity check
  -			if ( resource == null )
  -			{
  -				throw new ArgumentNullException( "resource" );
  -			}
  -
  -			// TODO: We shall not release dependent components
  -			// but we must release components returned by the parent
  -			// ILookupManager. While this "to do" is not resolved,
  -			// Dispose probabily is not been called for a lot of 
  -			// components
  +			base.Release( resource );
   		}
   
   		/// <summary>
  @@ -167,7 +134,7 @@
   		/// <param name="role">A String identifying the lookup name to check.</param>
   		/// <returns>True if the resource exists; otherwise, false.</returns>
   		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
  -		public bool Contains(String role)
  +		public override bool Contains(String role)
   		{
   			if ( role == null || role.Length == 0 )
   			{
  @@ -175,11 +142,6 @@
   			}
   
   			bool contains = m_instances.Contains( role );
  -
  -			if (!contains && m_parent != null)
  -			{
  -				contains = m_parent.Contains(role);
  -			}
   
   			return contains;
   		}
  
  
  
  1.2       +3 -3      avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Lookup/DefaultLookupManager.cs
  
  Index: DefaultLookupManager.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Lookup/DefaultLookupManager.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultLookupManager.cs	22 Sep 2003 23:49:24 -0000	1.1
  +++ DefaultLookupManager.cs	3 Oct 2003 03:13:14 -0000	1.2
  @@ -69,7 +69,7 @@
   
   		#region ILookupManager Members
   
  -		public object this[ String role ]
  +		public virtual object this[ String role ]
   		{
   			get
   			{
  @@ -91,7 +91,7 @@
   			}
   		}
   
  -		public void Release(object resource)
  +		public virtual void Release(object resource)
   		{
   			if ( resource == null )
   			{
  @@ -107,7 +107,7 @@
   			}
   		}
   
  -		public bool Contains( String role )
  +		public virtual bool Contains( String role )
   		{
   			if ( role == null )
   			{
  
  
  
  1.1                  avalon-sandbox/avalon-net/cscontainer/AvalonContainer/Lookup/InternalLookupManager.cs
  
  Index: InternalLookupManager.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  //
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  //
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  //
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  //
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  //    must not be used to endorse or promote products derived from this  software
  //    without  prior written permission. For written permission, please contact
  //    apache@apache.org.
  //
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  //
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  //
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Container.Lookup
  {
  	using System;
  	using System.Collections;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Container.Services;
  
  	/// <summary>
  	/// Summary description for InternalLookupManager.
  	/// </summary>
  	internal class InternalLookupManager : ILookupManager
  	{
  		private Hashtable m_instances;
  
  		public InternalLookupManager()
  		{
  			m_instances = new Hashtable();
  		}
  
  		/// <summary>
  		/// Adds component instances to this BlindLookupManager. 
  		/// This should be called by the Container Framework in order to
  		/// expose dependencies instances to the component.
  		/// </summary>
  		/// <param name="role">Role name (Could be anything)</param>
  		/// <param name="instance">Component instance</param>
  		public void Add(String role, object instance )
  		{
  			if ( role == null || role.Length == 0 )
  			{
  				throw new ArgumentNullException( "role" );
  			}
  			if ( instance == null )
  			{
  				throw new ArgumentNullException( "instance" );
  			}
  
  			m_instances.Add( role, instance );
  		}
  
  		#region ILookupManager Members
  
  		/// <summary>
  		/// Returns the component associated with the given role.
  		/// </summary>
  		/// <value>The component instance.</value>
  		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
  		/// <exception cref="Apache.Avalon.Framework.LookupException">If the <c>role</c> could not be resolved.</exception>
  		public object this[string role]
  		{
  			get
  			{
  				if ( role == null || role.Length == 0 )
  				{
  					throw new ArgumentNullException("role", "You can't look up using an empty role.");
  				}
  
  				object instance = m_instances[ role ];
  
  				if ( instance == null )
  				{
  					throw new LookupException( role, "Unknown component." );
  				}
  
  				return instance;
  			}
  		}
  
  		/// <summary>
  		/// Releases the component associated with the given role.
  		/// </summary>
  		/// <remarks>
  		/// A InternalLookupManager should not release anything as its not 
  		/// have ownership of any component.
  		/// </remarks>
  		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
  		public void Release(object resource)
  		{
  			
  		}
  
  		/// <summary>
  		/// Checks to see if a component exists for a role.
  		/// </summary>
  		/// <param name="role">A String identifying the lookup name to check.</param>
  		/// <returns>True if the resource exists; otherwise, false.</returns>
  		/// <exception cref="ArgumentNullException">If the <c>role</c> argument is null.</exception>
  		public bool Contains(string role)
  		{
  			return m_instances.Contains( role );
  		}
  
  		#endregion
  	}
  }
  
  
  
  1.4       +4 -5      avalon-sandbox/avalon-net/cscontainer/Samples/bin/Samples/Samples.Components.dll
  
  	<<Binary file>>
  
  
  1.4       +184 -137  avalon-sandbox/avalon-net/cscontainer/bin/Apache.Avalon.Container.Test.dll
  
  	<<Binary file>>
  
  
  1.4       +347 -316  avalon-sandbox/avalon-net/cscontainer/bin/Apache.Avalon.Container.dll
  
  	<<Binary file>>
  
  
  1.4       +24 -15    avalon-sandbox/avalon-net/cscontainer/bin/Apache.Avalon.Framework.dll
  
  	<<Binary file>>
  
  
  1.2       +1 -1      avalon-sandbox/avalon-net/csframework/AvalonFrameworkTest/AttributesTestCase.cs
  
  Index: AttributesTestCase.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/csframework/AvalonFrameworkTest/AttributesTestCase.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AttributesTestCase.cs	22 Sep 2003 23:49:25 -0000	1.1
  +++ AttributesTestCase.cs	3 Oct 2003 03:13:14 -0000	1.2
  @@ -1 +1 @@
  -// ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    apache@apache.org.
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Framework.Test
{
	using System;
	using NUnit.Framework;
	using Apache.Avalon.Framework;
	
	[TestFixture]
	public class AvalonAttributeTest
	{
		[Test]
		public void Service()
		{
			Type type = typeof(IDisposable);
			AvalonServiceAttribute service = new AvalonServiceAttribute( type );
			Assertion.AssertEquals( type, service.ServiceType );
		}

		[Test]
		public void Dependency()
		{
			string name="test";
			Type type = typeof(IDisposable);
			AvalonDependencyAttribute dependency = new AvalonDependencyAttribute(type,name,Optional.False);
			Assertion.AssertEquals( type, dependency.DependencyType );
			Assertion.AssertEquals( name, dependency.Key );
			Assertion.AssertEquals( false, dependency.IsOptional );

			dependency = new AvalonDependencyAttribute(type,null,Optional.True);
			Assertion.AssertEquals( type, dependency.DependencyType );
			Assertion.AssertEquals( type.Name, dependency.Key );
			Assertion.AssertEquals( true, dependency.IsOptional );
		}

		[Test]
		public void Component()
		{
			string name="test";
			AvalonComponentAttribute component = new AvalonComponentAttribute( name, Lifestyle.Singleton );
			Assertion.AssertNotNull( component );

			Assertion.AssertEquals( name, component.ConfigurationName );
			Assertion.AssertEquals( Lifestyle.Singleton, component.Lifestyle );
		}
	}
}
  \ No newline at end of file
  +// ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    apache@apache.org.
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Framework.Test
{
	using System;
	using NUnit.Framework;
	using Apache.Avalon.Framework;
	
	[TestFixture]
	public class AvalonAttributeTest
	{
		[Test]
		public void Service()
		{
			Type type = typeof(IDisposable);
			AvalonServiceAttribute service = new AvalonServiceAttribute( type );
			Assertion.AssertEquals( type, service.ServiceType );
		}

		[Test]
		public void Dependency()
		{
			string name="test";
			Type type = typeof(IDisposable);
			AvalonDependencyAttribute dependency = new AvalonDependencyAttribute(type,name,Optional.False);
			Assertion.AssertEquals( type, dependency.DependencyType );
			Assertion.AssertEquals( name, dependency.Key );
			Assertion.AssertEquals( false, dependency.IsOptional );

			dependency = new AvalonDependencyAttribute(type,null,Optional.True);
			Assertion.AssertEquals( type, dependency.DependencyType );
			Assertion.AssertEquals( type.Name, dependency.Key );
			Assertion.AssertEquals( true, dependency.IsOptional );
		}

		[Test]
		public void Component()
		{
			string name="test";
			AvalonComponentAttribute component = new AvalonComponentAttribute( name, Lifestyle.Singleton );
			Assertion.AssertNotNull( component );

			Assertion.AssertEquals( name, component.Name );
			Assertion.AssertEquals( Lifestyle.Singleton, component.Lifestyle );
		}
	}
}
  \ No newline at end of file
  
  
  
  1.3       +1 -1      avalon-sandbox/avalon-net/csframework/AvalonFramework/Attributes.cs
  
  Index: Attributes.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/csframework/AvalonFramework/Attributes.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Attributes.cs	27 Sep 2003 23:58:29 -0000	1.2
  +++ Attributes.cs	3 Oct 2003 03:13:14 -0000	1.3
  @@ -1 +1 @@
  -// ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    apache@apache.org.
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Framework
{
	using System;

	///<summary>
	/// Attribute used to mark the services that a component implements
	///</summary>	
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=true,Inherited=false)]
	public sealed class AvalonServiceAttribute : Attribute
	{
		private Type m_type;

		///<summary>
		///  Constructor to initialize the service's name.
		///</summary>
		///<param name="type">The type for the service</param>
        ///<exception cref="ArgumentException">If the "type" value is not an interface</exception>
        public AvalonServiceAttribute(Type type)
		{
            if (!type.IsInterface)
            {
                throw new ArgumentException(
                    "The type passed in does not represent an interface",
                    "type" );
            }

			m_type = type;
		}

		///<summary>
		///  The name of the service
		///</summary>
		public Type ServiceType
		{
			get
			{
				return m_type;
			}
		}
	}

	/// <summary>
    /// An enumeration used to mark a dependency as optional or not.
    /// </summary>
	public enum Optional
	{
        /// <summary>
        /// Use "True" if the dependency is not required for the component
        /// to run properly.
        /// </summary>
		True,
        /// <summary>
        /// Use "False" if the component will not work without the dependnecy.
        /// </summary>
		False
	}

	///<summary>
	///  Attribute to mark the dependencies for a component.
	///</summary>
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=true,Inherited=true)]
	public sealed class AvalonDependencyAttribute : Attribute
	{
		private Type m_type;
		private bool m_optional;
		private string m_name;

		///<summary>
		///  Constructor to initialize the dependency's name.
		///</summary>
        ///<param name="type">The type for the dependency</param>
        ///<param name="key">The dependency's lookup key</param>
		///<param name="optional">Whether or not the dependency is optional</param>
		///<exception cref="ArgumentException">If the "type" value is not an interface</exception>
		public AvalonDependencyAttribute(Type type, string key, Optional optional)
		{
            if (!type.IsInterface)
            {
                throw new ArgumentException(
                    "The type passed in does not represent an interface",
                    "type" );
            }

            m_name = (null == key) ? type.Name : key;
			m_optional = (optional == Optional.True);
			m_type = type;
		}

		///<summary>
		///  The lookup name of the dependency
		///</summary>
		public string Key
		{
			get
			{
				return m_name;
			}
		}

		///<summary>
		///  Is this dependency optional?
		///</summary>
		public bool IsOptional
		{
			get
			{
				return m_optional;
			}
		}

		/// <summary>
		///   The dependency type
		/// </summary>
		public Type DependencyType
		{
			get
			{
				return m_type;
			}
		}
	}

    /// <summary>
    /// Enumeration used to mark the component's lifestyle.
    /// </summary>
	public enum Lifestyle
	{
		/// <summary>
        /// Singleton components are instantiated once, and shared
        /// between all clients.
        /// </summary>
		Singleton,
        /// <summary>
        /// Thread components have a unique instance per thread.
        /// </summary>
		Thread,
        /// <summary>
        /// Pooled components have a unique instance per client,
        /// but they are managed in a pool.
        /// </summary>
		Pooled,
        /// <summary>
        /// Transient components are created on demand.
        /// </summary>
		Transient,
		/// <summary>
		/// Custom lifestyle components should be managed by custom component factories.
		/// </summary>
		Custom
	}

	///<summary>
	///  Attribute used to mark a component as an Avalon component.
	///</summary>
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=false,Inherited=false)]
	public sealed class AvalonComponentAttribute : Attribute
	{
		private Lifestyle m_lifestyle;
		private string m_configName;
		private string m_loggerName;

        /// <summary>
        /// Marks a class as a component, providing a configuration name and preferred lifestyle
        /// </summary>
        /// <param name="name">The name used for configuration elements</param>
        /// <param name="lifestyle">The lifestyle used for the component</param>
		public AvalonComponentAttribute( string configName, Lifestyle lifestyle )
		{
			m_lifestyle = lifestyle;
			m_configName = configName;
		}

        /// <summary>
        /// The configuration name assigned to this component.
        /// </summary>
		public string ConfigurationName
		{
			get
			{
				return m_configName;
			}
		}

		/// <summary>
		/// The logger name assigned to this component.
		/// </summary>
		public string LoggerName
		{
			get
			{
				return m_loggerName;
			}
			set
			{
				m_loggerName = value;
			}
		}

        /// <summary>
        /// The lifestyle associated with the component
        /// </summary>
		public Lifestyle Lifestyle
		{
			get
			{
				return m_lifestyle;
			}
		}
	}
}
  +// ============================================================================
//                   The Apache Software License, Version 1.1
// ============================================================================
// 
// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without modifica-
// tion, are permitted provided that the following conditions are met:
// 
// 1. Redistributions of  source code must  retain the above copyright  notice,
//    this list of conditions and the following disclaimer.
// 
// 2. Redistributions in binary form must reproduce the above copyright notice,
//    this list of conditions and the following disclaimer in the documentation
//    and/or other materials provided with the distribution.
// 
// 3. The end-user documentation included with the redistribution, if any, must
//    include  the following  acknowledgment:  "This product includes  software
//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
//    Alternately, this  acknowledgment may  appear in the software itself,  if
//    and wherever such third-party acknowledgments normally appear.
// 
// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
//    must not be used to endorse or promote products derived from this  software 
//    without  prior written permission. For written permission, please contact 
//    apache@apache.org.
// 
// 5. Products  derived from this software may not  be called "Apache", nor may
//    "Apache" appear  in their name,  without prior written permission  of the
//    Apache Software Foundation.
// 
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// 
// This software  consists of voluntary contributions made  by many individuals
// on  behalf of the Apache Software  Foundation. For more  information on the 
// Apache Software Foundation, please see <http://www.apache.org/>.
// ============================================================================

namespace Apache.Avalon.Framework
{
	using System;

	///<summary>
	/// Attribute used to mark the services that a component implements
	///</summary>	
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=true,Inherited=false)]
	public sealed class AvalonServiceAttribute : Attribute
	{
		private Type m_type;

		///<summary>
		///  Constructor to initialize the service's name.
		///</summary>
		///<param name="type">The type for the service</param>
        ///<exception cref="ArgumentException">If the "type" value is not an interface</exception>
        public AvalonServiceAttribute(Type type)
		{
            if (!type.IsInterface)
            {
                throw new ArgumentException(
                    "The type passed in does not represent an interface",
                    "type" );
            }

			m_type = type;
		}

		///<summary>
		///  The name of the service
		///</summary>
		public Type ServiceType
		{
			get
			{
				return m_type;
			}
		}
	}

	/// <summary>
    /// An enumeration used to mark a dependency as optional or not.
    /// </summary>
	public enum Optional
	{
        /// <summary>
        /// Use "True" if the dependency is not required for the component
        /// to run properly.
        /// </summary>
		True,
        /// <summary>
        /// Use "False" if the component will not work without the dependnecy.
        /// </summary>
		False
	}

	///<summary>
	///  Attribute to mark the dependencies for a component.
	///</summary>
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=true,Inherited=true)]
	public sealed class AvalonDependencyAttribute : Attribute
	{
		private Type m_type;
		private bool m_optional;
		private string m_name;

		///<summary>
		///  Constructor to initialize the dependency's name.
		///</summary>
        ///<param name="type">The type for the dependency</param>
        ///<param name="key">The dependency's lookup key</param>
		///<param name="optional">Whether or not the dependency is optional</param>
		///<exception cref="ArgumentException">If the "type" value is not an interface</exception>
		public AvalonDependencyAttribute(Type type, string key, Optional optional)
		{
            if (!type.IsInterface)
            {
                throw new ArgumentException(
                    "The type passed in does not represent an interface",
                    "type" );
            }

            m_name = (null == key) ? type.Name : key;
			m_optional = (optional == Optional.True);
			m_type = type;
		}

		///<summary>
		///  The lookup name of the dependency
		///</summary>
		public string Key
		{
			get
			{
				return m_name;
			}
		}

		///<summary>
		///  Is this dependency optional?
		///</summary>
		public bool IsOptional
		{
			get
			{
				return m_optional;
			}
		}

		/// <summary>
		///   The dependency type
		/// </summary>
		public Type DependencyType
		{
			get
			{
				return m_type;
			}
		}
	}

    /// <summary>
    /// Enumeration used to mark the component's lifestyle.
    /// </summary>
	public enum Lifestyle
	{
		/// <summary>
        /// Singleton components are instantiated once, and shared
        /// between all clients.
        /// </summary>
		Singleton,
        /// <summary>
        /// Thread components have a unique instance per thread.
        /// </summary>
		Thread,
        /// <summary>
        /// Pooled components have a unique instance per client,
        /// but they are managed in a pool.
        /// </summary>
		Pooled,
        /// <summary>
        /// Transient components are created on demand.
        /// </summary>
		Transient,
		/// <summary>
		/// Custom lifestyle components should be managed by custom component factories.
		/// </summary>
		Custom
	}

	///<summary>
	///  Attribute used to mark a component as an Avalon component.
	///</summary>
	[AttributeUsage(AttributeTargets.Class,AllowMultiple=false,Inherited=false)]
	public sealed class AvalonComponentAttribute : Attribute
	{
		private Lifestyle m_lifestyle;
		private string m_name;
		private string m_loggerName;

        /// <summary>
        /// Marks a class as a component, providing a configuration name and preferred lifestyle
        /// </summary>
        /// <param name="name">The component logical name (used for configuration elements)</param>
        /// <param name="lifestyle">The lifestyle used for the component</param>
		public AvalonComponentAttribute( string name, Lifestyle lifestyle )
		{
			m_lifestyle = lifestyle;
			m_name      = name;
		}

        /// <summary>
        /// The configuration name assigned to this component.
        /// </summary>
		public string Name
		{
			get
			{
				return m_name;
			}
		}

		/// <summary>
		/// The logger name assigned to this component.
		/// </summary>
		public string LoggerName
		{
			get
			{
				return m_loggerName;
			}
			set
			{
				m_loggerName = value;
			}
		}

        /// <summary>
        /// The lifestyle associated with the component
        /// </summary>
		public Lifestyle Lifestyle
		{
			get
			{
				return m_lifestyle;
			}
		}
	}
}
  
  
  
  1.2       +13 -2     avalon-sandbox/avalon-net/csframework/AvalonFramework/ContainerUtil.cs
  
  Index: ContainerUtil.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/csframework/AvalonFramework/ContainerUtil.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerUtil.cs	22 Sep 2003 23:49:25 -0000	1.1
  +++ ContainerUtil.cs	3 Oct 2003 03:13:14 -0000	1.2
  @@ -72,7 +72,7 @@
   		/// Supplies specified object with Logger if it implements the
   		/// <see cref="ILogEnabled"/> interface.
   		/// </summary>
  -		/// <param name="component"></param>
  +		/// <param name="component">The component instance</param>
   		/// <param name="logger">The Logger to enable component with.</param>
   		/// <exception cref="ArgumentException">
   		/// If the component is <see cref="ILogEnabled"/> but <see cref="ILogger"/> is null.
  @@ -95,6 +95,18 @@
   		}
   
   		/// <summary>
  +		/// Checks if the specified components supports IStartable
  +		/// or IDisposable interfaces - meaning that it cares about Stop
  +		/// or disposable phases.
  +		/// </summary>
  +		/// <param name="component">The component instance</param>
  +		/// <returns>true if the component wants the shutdown phase.</returns>
  +		public static bool ExpectsDispose(object component)
  +		{
  +			return (component is IStartable) || (component is IDisposable);
  +		}
  +
  +		/// <summary>
   		/// Supplies specified component with <see cref="ILookupManager"/>
   		/// if it implements the <see cref="ILookupEnabled"/> interface.
   		/// </summary>
  @@ -208,7 +220,6 @@
   			if (component is IStartable)
   			{
   				( (IStartable) component).Stop();
  -
   			}
   		}
   
  
  
  
  1.4       +11 -11    avalon-sandbox/avalon-net/csframework/bin/Apache.Avalon.Framework.Test.dll
  
  	<<Binary file>>
  
  
  1.4       +24 -15    avalon-sandbox/avalon-net/csframework/bin/Apache.Avalon.Framework.dll
  
  	<<Binary file>>
  
  
  1.1                  avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Components/Entity.cs
  
  Index: Entity.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  //
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  //
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  //
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  //
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  //    must not be used to endorse or promote products derived from this  software
  //    without  prior written permission. For written permission, please contact
  //    apache@apache.org.
  //
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  //
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  //
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Container.Test
  {
  	using System;
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Summary description for IEntity.
  	/// </summary>
  	public interface IEntity
  	{
  		String Name
  		{
  			get;
  			set;
  		}
  
  		int ID
  		{
  			get;
  		}
  	}
  
  	/// <summary>
  	/// IEntity implementation.
  	/// </summary>
  	[AvalonService( typeof( IEntity ) )]
  	[AvalonComponent( "Entity", Lifestyle.Transient )]
  	public class Entity : IEntity
  	{
  		private String m_name;
  		private int m_id;
  
  		public Entity()
  		{
  			System.Security.Cryptography.RandomNumberGenerator generator = 
  				System.Security.Cryptography.RNGCryptoServiceProvider.Create();
  
  			byte[] intBytes = new byte[4];
  			generator.GetBytes(intBytes);
  
  			m_id = BitConverter.ToInt32(intBytes, 0);
  		}
  
  		#region IEntity Members
  
  		public String Name
  		{
  			get
  			{
  				return m_name;
  			}
  			set
  			{
  				m_name = value;
  			}
  		}
  
  		public int ID
  		{
  			get
  			{
  				return m_id;
  			}
  		}
  
  		#endregion
  	}
  
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Components/EntityLocator.cs
  
  Index: EntityLocator.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  //
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  //
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  //
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  //
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  //    must not be used to endorse or promote products derived from this  software
  //    without  prior written permission. For written permission, please contact
  //    apache@apache.org.
  //
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  //
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  //
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Container.Test
  {
  	using System;
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Summary description for EntityLocator.
  	/// </summary>
  	public interface IEntityLocator
  	{
  		IEntity Find(object id);
  	}
  
  	/// <summary>
  	/// IEntityLocator implementation.
  	/// </summary>
  	[AvalonService( typeof(IEntityLocator) )]
  	[AvalonComponent( "EntityLocator", Lifestyle.Singleton )]
  	[AvalonDependency( typeof(IEntity), "Entity", Optional.False )]
  	public class EntityLocator : IEntityLocator, ILookupEnabled
  	{
  		private ILookupManager m_manager;
  
  		#region IEntityLocator Members
  
  		public IEntity Find(object id)
  		{
  			return (IEntity) m_manager["Entity"];
  		}
  
  		#endregion
  
  		#region ILookupEnabled Members
  
  		public void EnableLookups(ILookupManager manager)
  		{
  			m_manager = manager;
  		}
  
  		#endregion
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/cscontainer/AvalonContainerTest/Components/ErroneousComponent.cs
  
  Index: ErroneousComponent.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  //
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  //
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  //
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  //
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  //
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  //
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"
  //    must not be used to endorse or promote products derived from this  software
  //    without  prior written permission. For written permission, please contact
  //    apache@apache.org.
  //
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  //
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  //
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Container.Test.Components
  {
  	using System;
  	using NUnit.Framework;
  
  	using Apache.Avalon.Framework;
  
  	/// <summary>
  	/// Definition for IAirplane service.
  	/// </summary>
  	public interface IAirplane 
  	{
  		bool hasRadio
  		{
  			get;
  		}
  
  		void LandOff();
  	}
  
  	[AvalonService( typeof(IAirplane) )]
  	[AvalonComponent( "Airplane", Lifestyle.Transient )]
  	public class Airplane : IAirplane, ILookupEnabled
  	{
  		private bool _hasRadio = true;
  
  		public Airplane()
  		{
  		}
  
  		public bool hasRadio
  		{
  			get
  			{
  				return _hasRadio;
  			}
  		}
  
  		public void LandOff()
  		{
  		}
  
  		#region ILookupEnabled Members
  
  		public void EnableLookups(ILookupManager manager)
  		{
  			// This component doesn't have
  			// dependencies and can't lookup anything
  			
  			try
  			{
  				IRadio radio = (IRadio) manager[ typeof(IRadio).FullName ];
  
  				_hasRadio = true;
  			}
  			catch(LookupException)
  			{
  				_hasRadio = false;
  			}
  		}
  
  		#endregion
  	}
  }
  
  
  

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