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 2004/02/29 22:43:37 UTC

cvs commit: avalon-sandbox/avalon-net/Activation/Default/Lifestyles AbstractLifestyleManager.cs SingletonLifestyleManager.cs TransientLifestyleManager.cs

hammett     2004/02/29 13:43:37

  Modified:    avalon-net/Castle/Castle Apache.Avalon.Castle.csproj
               avalon-net/Castle/Castle/Default/Runtime DefaultRuntime.cs
               avalon-net/Composition/ModelDefault DefaultState.cs
  Added:       avalon-net/Activation/Activation
                        Apache.Avalon.Activation.csproj
                        ApplianceException.cs ApplianceRuntimeException.cs
                        AssemblyInfo.cs IAppliance.cs IComponentFactory.cs
                        ILifestyleFactory.cs ILifestyleManager.cs
                        IRuntimeFactory.cs LifecycleException.cs
                        LifestyleRuntimeException.cs
                        TransientRuntimeException.cs
               avalon-net/Activation/Default AbstractAppliance.cs
                        Apache.Avalon.Activation.Default.csproj
                        AssemblyInfo.cs DefaultAppliance.cs DefaultBlock.cs
                        DefaultComponentFactory.cs
                        DefaultLifestyleFactory.cs DefaultLookupManager.cs
                        DefaultRuntime.cs DefaultRuntimeFactory.cs
               avalon-net/Activation/Default/Lifestyles
                        AbstractLifestyleManager.cs
                        SingletonLifestyleManager.cs
                        TransientLifestyleManager.cs
  Log:
  Activation package (port of java). Castle: components are being deployed by now.
  
  Revision  Changes    Path
  1.3       +10 -0     avalon-sandbox/avalon-net/Castle/Castle/Apache.Avalon.Castle.csproj
  
  Index: Apache.Avalon.Castle.csproj
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/Castle/Apache.Avalon.Castle.csproj,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Apache.Avalon.Castle.csproj	29 Feb 2004 18:07:16 -0000	1.2
  +++ Apache.Avalon.Castle.csproj	29 Feb 2004 21:43:37 -0000	1.3
  @@ -129,6 +129,16 @@
                       Project = "{F64EB1C1-A909-41AD-AAF8-B17B64D1BE93}"
                       Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                   />
  +                <Reference
  +                    Name = "Apache.Avalon.Activation"
  +                    Project = "{28197CC9-90EC-4C70-905A-C07155EE5958}"
  +                    Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
  +                />
  +                <Reference
  +                    Name = "Apache.Avalon.Activation.Default"
  +                    Project = "{E311F863-2E58-4466-94A2-31A68B341C87}"
  +                    Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
  +                />
               </References>
           </Build>
           <Files>
  
  
  
  1.2       +19 -6     avalon-sandbox/avalon-net/Castle/Castle/Default/Runtime/DefaultRuntime.cs
  
  Index: DefaultRuntime.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/Castle/Default/Runtime/DefaultRuntime.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRuntime.cs	28 Feb 2004 22:15:42 -0000	1.1
  +++ DefaultRuntime.cs	29 Feb 2004 21:43:37 -0000	1.2
  @@ -17,8 +17,9 @@
   	using System;
   
   	using Apache.Avalon.Castle.ManagementExtensions;
  +	using Apache.Avalon.Castle.Util;
   	using Apache.Avalon.Composition.Model;
  -
  +	using RuntimeImpl = Apache.Avalon.Activation.Default.DefaultRuntime;
   
   	/// <summary>
   	/// Summary description for DefaultRuntime.
  @@ -26,6 +27,8 @@
   	[ManagedComponent]
   	public class DefaultRuntime : ManagedService, IRuntime
   	{
  +		private RuntimeImpl m_runtime;
  +
   		public DefaultRuntime()
   		{
   		}
  @@ -35,28 +38,38 @@
   		[ManagedOperation]
   		public void Decommission(IDeploymentModel model)
   		{
  -			// TODO:  Add DefaultRuntime.Decommission implementation
  +			m_runtime.Decommission( model );
   		}
   
   		[ManagedOperation]
   		public void Commission(IDeploymentModel model)
   		{
  -			// TODO:  Add DefaultRuntime.Commission implementation
  +			m_runtime.Commission( model );
   		}
   
   		[ManagedOperation]
   		public void Release(IDeploymentModel model, object instance)
   		{
  -			// TODO:  Add DefaultRuntime.Release implementation
  +			m_runtime.Release( model, instance );
   		}
   
   		[ManagedOperation]
   		public object Resolve(IDeploymentModel model)
   		{
  -			// TODO:  Add DefaultRuntime.Resolve implementation
  -			return null;
  +			return m_runtime.Resolve( model );;
   		}
   
   		#endregion
  +	
  +		public override void Start()
  +		{
  +			base.Start();
  +
  +			ISystemContext context = (ISystemContext) 
  +				MXUtil.GetAttribute( server, CastleConstants.ORCHESTRATOR_NAME, 
  +				"SystemContext" );
  +
  +			m_runtime = new RuntimeImpl( context );
  +		}
   	}
   }
  
  
  
  1.2       +2 -2      avalon-sandbox/avalon-net/Composition/ModelDefault/DefaultState.cs
  
  Index: DefaultState.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Composition/ModelDefault/DefaultState.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultState.cs	28 Feb 2004 22:15:42 -0000	1.1
  +++ DefaultState.cs	29 Feb 2004 21:43:37 -0000	1.2
  @@ -26,7 +26,7 @@
   	/// <version>  $Revision$ $Date$
   	/// </version>
   	
  -	class DefaultState
  +	public class DefaultState
   	{
   		/// <summary> Return the enabled state of the state.</summary>
   		/// <returns> TRUE if the state has been enabled else FALSE
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/Apache.Avalon.Activation.csproj
  
  Index: Apache.Avalon.Activation.csproj
  ===================================================================
  <VisualStudioProject>
      <CSHARP
          ProjectType = "Local"
          ProductVersion = "7.10.3077"
          SchemaVersion = "2.0"
          ProjectGuid = "{28197CC9-90EC-4C70-905A-C07155EE5958}"
      >
          <Build>
              <Settings
                  ApplicationIcon = ""
                  AssemblyKeyContainerName = ""
                  AssemblyName = "Apache.Avalon.Activation"
                  AssemblyOriginatorKeyFile = ""
                  DefaultClientScript = "JScript"
                  DefaultHTMLPageLayout = "Grid"
                  DefaultTargetSchema = "IE50"
                  DelaySign = "false"
                  OutputType = "Library"
                  PreBuildEvent = ""
                  PostBuildEvent = ""
                  RootNamespace = "Apache.Avalon.Activation"
                  RunPostBuildEvent = "OnBuildSuccess"
                  StartupObject = ""
              >
                  <Config
                      Name = "Debug"
                      AllowUnsafeBlocks = "false"
                      BaseAddress = "285212672"
                      CheckForOverflowUnderflow = "false"
                      ConfigurationOverrideFile = ""
                      DefineConstants = "DEBUG;TRACE"
                      DocumentationFile = ""
                      DebugSymbols = "true"
                      FileAlignment = "4096"
                      IncrementalBuild = "false"
                      NoStdLib = "false"
                      NoWarn = ""
                      Optimize = "false"
                      OutputPath = "..\bin\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
                      TreatWarningsAsErrors = "false"
                      WarningLevel = "4"
                  />
                  <Config
                      Name = "Release"
                      AllowUnsafeBlocks = "false"
                      BaseAddress = "285212672"
                      CheckForOverflowUnderflow = "false"
                      ConfigurationOverrideFile = ""
                      DefineConstants = "TRACE"
                      DocumentationFile = ""
                      DebugSymbols = "false"
                      FileAlignment = "4096"
                      IncrementalBuild = "false"
                      NoStdLib = "false"
                      NoWarn = ""
                      Optimize = "true"
                      OutputPath = "bin\Release\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
                      TreatWarningsAsErrors = "false"
                      WarningLevel = "4"
                  />
              </Settings>
              <References>
                  <Reference
                      Name = "System"
                      AssemblyName = "System"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
                  />
                  <Reference
                      Name = "System.Data"
                      AssemblyName = "System.Data"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
                  />
                  <Reference
                      Name = "System.XML"
                      AssemblyName = "System.XML"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
                  />
                  <Reference
                      Name = "Apache.Avalon.Composition.Model"
                      Project = "{39F7BD57-6B26-4CDA-94D4-7C552DF22CD5}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
              </References>
          </Build>
          <Files>
              <Include>
                  <File
                      RelPath = "ApplianceException.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "ApplianceRuntimeException.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "AssemblyInfo.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "IAppliance.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "IComponentFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "ILifestyleFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "ILifestyleManager.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "IRuntimeFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "LifecycleException.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "LifestyleRuntimeException.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "TransientRuntimeException.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
              </Include>
          </Files>
      </CSHARP>
  </VisualStudioProject>
  
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/ApplianceException.cs
  
  Index: ApplianceException.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for ApplianceException.
  	/// </summary>
  	[Serializable]
  	public class ApplianceException : System.Exception
  	{
  		public ApplianceException(String message) : base(message)
  		{
  		}
  
  		public ApplianceException(String message, Exception inner) : base(message,inner)
  		{
  		}
  
  		public ApplianceException(System.Runtime.Serialization.SerializationInfo info, 
  			System.Runtime.Serialization.StreamingContext context) : base(info, context)
  		{
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/ApplianceRuntimeException.cs
  
  Index: ApplianceRuntimeException.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for ApplianceRuntimeException.
  	/// </summary>
  	[Serializable]
  	public class ApplianceRuntimeException : System.Exception
  	{
  		public ApplianceRuntimeException(String message) : base(message)
  		{
  		}
  
  		public ApplianceRuntimeException(String message, Exception inner) : base(message,inner)
  		{
  		}
  
  		public ApplianceRuntimeException(System.Runtime.Serialization.SerializationInfo info, 
  			System.Runtime.Serialization.StreamingContext context) : base(info, context)
  		{
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/AssemblyInfo.cs
  
  Index: AssemblyInfo.cs
  ===================================================================
  // Copyright 2004 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.
  
  using System.Reflection;
  using System.Runtime.CompilerServices;
  
  [assembly: AssemblyTitle("AvalonFramework")]
  [assembly: AssemblyDescription("Avalon Framework defines the lifecycle interfaces and contracts that all components must obey.")]
  [assembly: AssemblyConfiguration("")]
  [assembly: AssemblyCompany("Apache Software Foundation")]
  [assembly: AssemblyProduct("Avalon Framework")]
  [assembly: AssemblyCopyright("Copyright (c) 2003 Apache Software Foundation")]
  [assembly: AssemblyTrademark("")]
  [assembly: AssemblyCulture("")]		
  [assembly: AssemblyVersion("1.0.0.0")]
  
  #if STRONG
  [assembly: AssemblyDelaySign(false)]
  [assembly: AssemblyKeyFile("../../../../ApacheAvalon.snk")]
  [assembly: AssemblyKeyName("")]
  #endif
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/IAppliance.cs
  
  Index: IAppliance.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// An Appliance is the basic tool merlin wraps around a component to
  	/// provide support for lifecycle and lifestyle management. Different
  	/// implementations of Appliance can be plugged into the merlin system
  	/// to allow merlin to manage a variety of components.
  	///
  	/// The name appliance is used to call up an association with a kitchen
  	/// utility like a microwave. Merlin acts as a chef in his kitchen, and uses
  	/// various appliances to "cook up" various components as the restaurant
  	/// customers (which can be other components or systems on the other end
  	/// on the planet) ask for them.
  	/// 
  	///	An appliance manages the establishment of a component
  	/// type relative to a deployment criteria. Once established, an appliance
  	/// provides support for the deployment of component instances on request.
  	/// An appliance is responsible for component lifestyle and lifecycle
  	/// management during the deployment and decommission cycles.
  	/// </summary>
  	public interface IAppliance : ICommissionable, IResolver
  	{
  
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/IComponentFactory.cs
  
  Index: IComponentFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// A factory that provides object instantiation. A instance factory will
  	/// typically encapsulate component constuction semantic, lifecycle processing
  	/// and end-of-life processing.
  	/// </summary>
  	public interface IComponentFactory
  	{
  		/// <summary>
  		/// Creation of a new instance including all deployment stage handling.
  		/// </summary>
  		/// <returns>the new instance</returns>
  		/// <exception cref="Exception">If errors occur</exception>
  		object Incarnate();
  
  		/// <summary>
  		/// Termination of the instance including all end-of-life processing.
  		/// </summary>
  		/// <param name="instance">the component instance</param>
  		void Etherialize( object instance );
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/ILifestyleFactory.cs
  
  Index: ILifestyleFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// A factory enabling the establishment of runtime handlers.
  	/// </summary>
  	public interface ILifestyleFactory
  	{
  		/// <summary>
  		/// Create a new lifestyle manager.
  		/// </summary>
  		/// <param name="model">the component model</param>
  		/// <returns>the runtime appliance</returns>
  		ILifestyleManager CreateLifestyleManager( IComponentModel model );		
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/ILifestyleManager.cs
  
  Index: ILifestyleManager.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// A lifestyle handler provides support for a 
  	/// particular lifestyle policy.
  	/// </summary>
  	public interface ILifestyleManager : ICommissionable, IResolver
  	{
  		/// <summary>
  		/// Release and finalize the supplied object.
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		void Finalize( object instance );
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/IRuntimeFactory.cs
  
  Index: IRuntimeFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// A factory enabling the establishment of runtime handlers.
  	/// </summary>
  	public interface IRuntimeFactory
  	{
  		/// <summary>
  		/// Resolve a runtime handler for a model.
  		/// </summary>
  		/// <param name="model">the deployment model</param>
  		/// <returns>the runtime appliance</returns>
  		IAppliance GetRuntime( IDeploymentModel model );
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/LifecycleException.cs
  
  Index: LifecycleException.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for LifecycleException.
  	/// </summary>
  	[Serializable]
  	public class LifecycleException : ApplianceException
  	{
  		public LifecycleException(String message) : base(message)
  		{
  		}
  
  		public LifecycleException(String message, Exception inner) : base(message,inner)
  		{
  		}
  
  		public LifecycleException(System.Runtime.Serialization.SerializationInfo info, 
  			System.Runtime.Serialization.StreamingContext context) : base(info, context)
  		{
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/LifestyleRuntimeException.cs
  
  Index: LifestyleRuntimeException.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for LifestyleRuntimeException.
  	/// </summary>
  	[Serializable]
  	public class LifestyleRuntimeException : ApplianceRuntimeException
  	{
  		public LifestyleRuntimeException(String message) : base(message)
  		{
  		}
  
  		public LifestyleRuntimeException(System.Runtime.Serialization.SerializationInfo info, 
  			System.Runtime.Serialization.StreamingContext context) : base(info, context)
  		{
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Activation/TransientRuntimeException.cs
  
  Index: TransientRuntimeException.cs
  ===================================================================
  // Copyright 2004 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.Activation
  {
  	using System;
  
  	/// <summary>
  	/// Summary description for TransientRuntimeException.
  	/// </summary>
  	[Serializable]
  	public class TransientRuntimeException : System.Exception
  	{
  		public TransientRuntimeException(String message, long delay ) : base(message)
  		{
  		}
  
  		public TransientRuntimeException(System.Runtime.Serialization.SerializationInfo info, 
  			System.Runtime.Serialization.StreamingContext context) : base(info, context)
  		{
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/AbstractAppliance.cs
  
  Index: AbstractAppliance.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Activation;
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Abstract appliance.
  	/// </summary>
  	public abstract class AbstractAppliance : IAppliance
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private IDeploymentModel m_model;
  
  		private ILogger m_logger;
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public AbstractAppliance( IDeploymentModel model )
  		{
  			if( null == model ) 
  			{
  				throw new ArgumentNullException( "model" );
  			}
  
  			m_model = model;
  			m_logger = model.Logger;
  		}
  
  		#region ICommissionable Members
  
  		/// <summary>
  		/// Decommission the appliance.  Once an appliance is 
  		/// decommissioned it may be re-commissioned.
  		/// </summary>
  		public abstract void Decommission();
  
  		/// <summary>
  		/// Commission the appliance. 
  		/// </summary>
  		public abstract void Commission();
  
  		#endregion
  
  		#region IResolver Members
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		public abstract void Release(object instance);
  
  		/// <summary>
  		/// Resolve a object to a value.
  		/// </summary>
  		/// <returns>the resolved object</returns>
  		public abstract object Resolve();
  
  		#endregion
  
  		//-------------------------------------------------------------------
  		// implementation
  		//-------------------------------------------------------------------
  
  		protected ILogger Logger
  		{
  			get
  			{
  				return m_logger;
  			}
  		}
  
  		/// <summary>
  		/// Return the model backing the handler.
  		/// </summary>
  		protected IDeploymentModel DeploymentModel
  		{
  			get
  			{
  				return m_model;
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Object
  		//-------------------------------------------------------------------
  
  		public override String ToString()
  		{
  			return "appliance:" + DeploymentModel.QualifiedName;
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/Apache.Avalon.Activation.Default.csproj
  
  Index: Apache.Avalon.Activation.Default.csproj
  ===================================================================
  <VisualStudioProject>
      <CSHARP
          ProjectType = "Local"
          ProductVersion = "7.10.3077"
          SchemaVersion = "2.0"
          ProjectGuid = "{E311F863-2E58-4466-94A2-31A68B341C87}"
      >
          <Build>
              <Settings
                  ApplicationIcon = ""
                  AssemblyKeyContainerName = ""
                  AssemblyName = "Apache.Avalon.Activation.Default"
                  AssemblyOriginatorKeyFile = ""
                  DefaultClientScript = "JScript"
                  DefaultHTMLPageLayout = "Grid"
                  DefaultTargetSchema = "IE50"
                  DelaySign = "false"
                  OutputType = "Library"
                  PreBuildEvent = ""
                  PostBuildEvent = ""
                  RootNamespace = "Apache.Avalon.Activation.Default"
                  RunPostBuildEvent = "OnBuildSuccess"
                  StartupObject = ""
              >
                  <Config
                      Name = "Debug"
                      AllowUnsafeBlocks = "false"
                      BaseAddress = "285212672"
                      CheckForOverflowUnderflow = "false"
                      ConfigurationOverrideFile = ""
                      DefineConstants = "DEBUG;TRACE"
                      DocumentationFile = ""
                      DebugSymbols = "true"
                      FileAlignment = "4096"
                      IncrementalBuild = "false"
                      NoStdLib = "false"
                      NoWarn = ""
                      Optimize = "false"
                      OutputPath = "..\bin\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
                      TreatWarningsAsErrors = "false"
                      WarningLevel = "4"
                  />
                  <Config
                      Name = "Release"
                      AllowUnsafeBlocks = "false"
                      BaseAddress = "285212672"
                      CheckForOverflowUnderflow = "false"
                      ConfigurationOverrideFile = ""
                      DefineConstants = "TRACE"
                      DocumentationFile = ""
                      DebugSymbols = "false"
                      FileAlignment = "4096"
                      IncrementalBuild = "false"
                      NoStdLib = "false"
                      NoWarn = ""
                      Optimize = "true"
                      OutputPath = "bin\Release\"
                      RegisterForComInterop = "false"
                      RemoveIntegerChecks = "false"
                      TreatWarningsAsErrors = "false"
                      WarningLevel = "4"
                  />
              </Settings>
              <References>
                  <Reference
                      Name = "System"
                      AssemblyName = "System"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll"
                  />
                  <Reference
                      Name = "System.Data"
                      AssemblyName = "System.Data"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll"
                  />
                  <Reference
                      Name = "System.XML"
                      AssemblyName = "System.XML"
                      HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
                  />
                  <Reference
                      Name = "Apache.Avalon.Activation"
                      Project = "{28197CC9-90EC-4C70-905A-C07155EE5958}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
                  <Reference
                      Name = "Apache.Avalon.Composition.Model"
                      Project = "{39F7BD57-6B26-4CDA-94D4-7C552DF22CD5}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
                  <Reference
                      Name = "Apache.Avalon.Framework"
                      AssemblyName = "Apache.Avalon.Framework"
                      HintPath = "..\..\Castle\bin\Apache.Avalon.Framework.dll"
                  />
                  <Reference
                      Name = "Apache.Avalon.Meta"
                      Project = "{1AFD63DC-D552-49B7-9088-03C1A4DED598}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
                  <Reference
                      Name = "Apache.Avalon.Composition.Data"
                      Project = "{0DB30CF7-345A-414C-8D35-10EF99911827}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
                  <Reference
                      Name = "Apache.Avalon.Composition.Model.Default"
                      Project = "{F64EB1C1-A909-41AD-AAF8-B17B64D1BE93}"
                      Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                  />
              </References>
          </Build>
          <Files>
              <Include>
                  <File
                      RelPath = "AbstractAppliance.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "AssemblyInfo.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultAppliance.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultBlock.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultComponentFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultLifestyleFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultLookupManager.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultRuntime.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "DefaultRuntimeFactory.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "Lifestyles\AbstractLifestyleManager.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "Lifestyles\SingletonLifestyleManager.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
                  <File
                      RelPath = "Lifestyles\TransientLifestyleManager.cs"
                      SubType = "Code"
                      BuildAction = "Compile"
                  />
              </Include>
          </Files>
      </CSHARP>
  </VisualStudioProject>
  
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/AssemblyInfo.cs
  
  Index: AssemblyInfo.cs
  ===================================================================
  // Copyright 2004 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.
  
  using System.Reflection;
  using System.Runtime.CompilerServices;
  
  [assembly: AssemblyTitle("AvalonFramework")]
  [assembly: AssemblyDescription("Avalon Framework defines the lifecycle interfaces and contracts that all components must obey.")]
  [assembly: AssemblyConfiguration("")]
  [assembly: AssemblyCompany("Apache Software Foundation")]
  [assembly: AssemblyProduct("Avalon Framework")]
  [assembly: AssemblyCopyright("Copyright (c) 2003 Apache Software Foundation")]
  [assembly: AssemblyTrademark("")]
  [assembly: AssemblyCulture("")]		
  [assembly: AssemblyVersion("1.0.0.0")]
  
  #if STRONG
  [assembly: AssemblyDelaySign(false)]
  [assembly: AssemblyKeyFile("../../../../ApacheAvalon.snk")]
  [assembly: AssemblyKeyName("")]
  #endif
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultAppliance.cs
  
  Index: DefaultAppliance.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Composition.Model;
  	using Apache.Avalon.Composition.Model.Default;
  
  	/// <summary>
  	/// Summary description for DefaultAppliance.
  	/// </summary>
  	public class DefaultAppliance : AbstractAppliance
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private IComponentModel m_model;
  
  		private ILifestyleManager m_lifestyle;
  
  		private DefaultState m_commissioned = new DefaultState();
  
  		private long m_delay = 0;
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public DefaultAppliance( IComponentModel model, ILifestyleManager lifestyle ) : base(model)
  		{
  			m_model = model;
  			m_lifestyle = lifestyle;
  		}
  
  		//-------------------------------------------------------------------
  		// Commissionable
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Commission the appliance. 
  		/// </summary>
  		public override void Commission() 
  		{
  			lock( m_commissioned )
  			{
  				if( m_commissioned.Enabled ) return;
  
  				try
  				{
  					m_delay = m_model.DeploymentTimeout;
  					m_lifestyle.Commission();
  					m_delay = 0;
  					m_commissioned.Enabled = true;
  				}
  				finally
  				{
  					m_delay = 0;
  				}
  			}
  		}
  
  		/// <summary>
  		/// Decommission the appliance.  Once an appliance is 
  		/// decommissioned it may be re-commissioned.
  		/// </summary>
  		public override void Decommission()
  		{
  			lock( m_commissioned )
  			{
  				if( !m_commissioned.Enabled ) return;
  				m_lifestyle.Decommission();
  				m_commissioned.Enabled = false;
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Resolver
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Resolve a object to a value.
  		/// </summary>
  		/// <returns> the resolved object</returns>
  		public override object Resolve()
  		{
  			if( ComponentModel.TypeDescriptor.Info.GetAttribute( "urn:activation:proxy", "true" ).Equals( "false" ) )
  			{
  				return Resolve( false );
  			}
  			else        
  			{
  				return Resolve( true );
  			}
  		}
  
  		protected virtual object Resolve( bool proxy )
  		{
  			if( !proxy )
  			{
  				if( m_delay > 0 )
  				{
  					String error = "appliance.error.resolve.transient " + this.ToString() + " " + m_delay;
  					throw new TransientRuntimeException( error, m_delay );
  				}
  				else if( !m_commissioned.Enabled )
  				{
  					String error = "appliance.error.resolve.non-commission-state " + this.ToString();
  					throw new ApplicationException( error );
  				}
  				else
  				{
  					return m_lifestyle.Resolve();
  				}
  			}
  
  			throw new ArgumentException( "proxy" );
  
  			/*
  			else
  			{
  				ComponentModel model = getComponentModel();
  				Logger logger = model.getLogger().getChildLogger( "proxy" );
  				ApplianceInvocationHandler handler = 
  				new ApplianceInvocationHandler( this, logger );
  
  				try
  				{
  					return Proxy.newProxyInstance( 
  					model.getDeploymentClass().getClassLoader(),
  					model.getInterfaces(),
  					handler );
  				}
  				catch( Throwable e )
  				{
  					final String error = 
  					"Proxy establishment failure in block: " + this;
  					throw new ApplianceException( error, e );
  				}
  			}*/
  		}
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		public override void Release( object instance )
  		{
  			if( null == instance ) return;
  			if( !m_commissioned.Enabled ) return;
  
  			/*if( Proxy.isProxyClass( instance.getClass() ) )
  			{
  				ApplianceInvocationHandler handler = 
  				(ApplianceInvocationHandler) Proxy.getInvocationHandler( instance );
  				handler.release();
  			}
  			else*/
  			{
  				m_lifestyle.Release( instance );
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// implementation
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Return the model backing the handler.
  		/// </summary>
  		protected IComponentModel ComponentModel
  		{
  			get
  			{
  				return m_model;
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Object
  		//-------------------------------------------------------------------
  
  		public override String ToString()
  		{
  			return "appliance:" + ComponentModel.QualifiedName;
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultBlock.cs
  
  Index: DefaultBlock.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  	using System.Collections;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Composition.Model;
  	using Apache.Avalon.Composition.Model.Default;
  
  	/// <summary>
  	/// Summary description for DefaultBlock.
  	/// </summary>
  	public class DefaultBlock : AbstractAppliance
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private IContainmentModel m_model;
  
  		private ISystemContext m_system;
  
  		private DefaultState m_commissioned = new DefaultState();
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public DefaultBlock( ISystemContext system, IContainmentModel model ) : base( model )
  		{
  			m_model = model;
  			m_system = system;
  		}
  
  		//-------------------------------------------------------------------
  		// Commissionable
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Commission the appliance. 
  		/// </summary>
  		public override void Commission()
  		{
  			lock( m_commissioned )
  			{
  				if( m_commissioned.Enabled ) return;
  
  				try
  				{
  					/*
  					ILogger log = m_model.Logger.CreateChildLogger( "proxy" );
  					final BlockInvocationHandler handler = 
  					new BlockInvocationHandler( log, this );
  					final Class[] classes = getInterfaceClasses();
  	            
  					m_proxy = Proxy.newProxyInstance( 
  					m_model.getClassLoaderModel().getClassLoader(),
  					classes,
  					handler );*/
  
  					m_commissioned.Enabled = true;
  				}
  				catch( Exception e )
  				{
  					String error = "Composite service establishment failure in block: " + this;
  					throw new ApplianceRuntimeException( error, e );
  				}
  			}
  		}
  
  		/// <summary>
  		/// Decommission the appliance.  Once an appliance is 
  		/// decommissioned it may be re-commissioned.
  		/// </summary>
  		public override void Decommission()
  		{
  			lock( m_commissioned )
  			{
  				if( !m_commissioned.Enabled ) return;
  				/*if( null != m_proxy )
  				{
  					m_proxy = null;
  				}*/
  				m_commissioned.Enabled = false;
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Resolver
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Resolve a object to a value.
  		/// </summary>
  		/// <returns></returns>
  		public override object Resolve() 
  		{
  			if( !m_commissioned.Enabled )
  			{
  				String error = "block.error.resolve.non-commission-state " + this.ToString();
  				throw new ApplicationException( error );
  			}
  			// return m_proxy;
  			return this;
  		}
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		public override void Release( object instance )
  		{
  			// ignore
  		}
  
  		//-------------------------------------------------------------------
  		// implementation
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Return the model backing the handler.
  		/// </summary>
  		protected IContainmentModel ContainmentModel
  		{
  			get
  			{
  				return m_model;
  			}
  		}
  
  		private Type[] InterfaceTypes
  		{
  			get
  			{
  				IContainmentModel model = ContainmentModel;
  				ArrayList list = new ArrayList();
  				IServiceModel[] services = model.ServiceModels;
  				for( int i=0; i < services.Length; i++ )
  				{
  					IServiceModel service = services[i];
  					list.Add( service.ServiceClass );
  				}
  				return (Type[]) list.ToArray( typeof(Type) );
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Object
  		//-------------------------------------------------------------------
  
  		public override String ToString()
  		{
  			return "block:" + ContainmentModel.QualifiedName;
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultComponentFactory.cs
  
  Index: DefaultComponentFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Meta;
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for DefaultComponentFactory.
  	/// </summary>
  	public class DefaultComponentFactory : IComponentFactory
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private ISystemContext m_system;
  
  		private IComponentModel m_model;
  
  		private ILogger m_logger;
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Creation of a new component factory.
  		/// </summary>
  		/// <param name="system">the system context</param>
  		/// <param name="model">the component model</param>
  		public DefaultComponentFactory( ISystemContext system, IComponentModel model )
  		{
  			m_system = system;
  			m_model = model;
     			m_logger = model.Logger.CreateChildLogger( "lifecycle" );
  		}
  
  		#region IComponentFactory Members
  
  		public object Incarnate()
  		{
  			Type type = m_model.DeploymentType;
  			ILogger logger = m_model.Logger;
  			IConfiguration config = m_model.Configuration;
  			// Parameters params = m_model.getParameters();
  			ILookupManager manager = new DefaultLookupManager( m_model );
  			IContext context = TargetContext;
  
  			// Object instance = instantiate( 
  			// 	clazz, logger, config, params, context, manager );
  
  			Object instance = Activator.CreateInstance( type );
  
  			try
  			{
  				ContainerUtil.EnableLogging( instance, logger );
  				ApplyContext( instance, context );
  				ContainerUtil.Service( instance, manager );
  				ContainerUtil.Configure( instance, config );
  				// ContainerUtil.parameterize( instance, params );
  
  				//
  				// handle lifecycle extensions
  				//
  
  				ApplyCreateStage( instance, true );
  
  				//
  				// complete intialization
  				//
  
  				ContainerUtil.Initialize( instance );
  				ContainerUtil.Start( instance );
  
  				return instance;
  			}
  			catch( Exception e )
  			{
  				String error = "lifestyle.error.new " +  m_model.QualifiedName;
  				throw new LifecycleException( error, e );
  			}		
  		}
  
  		public void Etherialize(object instance)
  		{
  			try
  			{
  				ApplyCreateStage( instance, false );
  			}
  			catch( Exception )
  			{
  				// will not happen
  			}
  			finally
  			{
  				try
  				{
  					ContainerUtil.Shutdown( instance );
  				}
  				catch( Exception e )
  				{
  					if( Logger.IsWarnEnabled )
  					{
  						String warning = "Ignoring component source shutdown error.";
  						Logger.Warn( warning, e );
  					}
  				}
  			}		
  		}
  		#endregion
  
  		protected ILogger Logger
  		{
  			get
  			{
  				return m_logger;
  			}
  		}
  
  		private IContext TargetContext
  		{
  			get
  			{
  				IContextModel model = m_model.ContextModel;
  				
  				if( null == model ) 
  				{
  					return null;
  				}
  
  				return model.Context;
  			}
  		}
  
  		private void ApplyCreateStage( Object instance, bool flag ) 
  		{
  			StageDescriptor[] stages = m_model.TypeDescriptor.Stages;
  			if( ( stages.Length > 0 ) && Logger.IsDebugEnabled )
  			{
  				Logger.Debug( "stage count: " + stages.Length );
  			}
  
  			for( int i=0; i<stages.Length; i++ )
  			{
  				StageDescriptor stage = stages[i];
  				IComponentModel provider = GetStageProvider( stage );
  				/*
  				Class c = provider.getDeploymentClass();
  
  				if( Creator.class.isAssignableFrom( c ) )
  				{
  					getLogger().debug( "processing create: " + c.getName() );
  
  					Creator handler = getCreator( provider );
  					Context context = m_model.getContextModel().getContext();
  
  					try
  					{
  						if( flag )
  						{
  							if( getLogger().isDebugEnabled() )
  							{
  								int id = System.identityHashCode( instance );
  								getLogger().debug( "applying create stage to: " + id );
  							}
  							try
  							{
  								handler.create( instance, context );
  							}
  							catch( Throwable e )
  							{
  								final String error =
  								"Create stage error raised by extension.";
  								throw new LifecycleException( error, e );
  							}
  						}
  						else
  						{
  							if( getLogger().isDebugEnabled() )
  							{
  								int id = System.identityHashCode( instance );
  								getLogger().debug( "applying destroy stage to: " + id );
  							}
  							handler.destroy( instance, context );
  						}
  					}
  					catch( Throwable e )
  					{
  						final String error = 
  						REZ.getString( 
  							"lifecycle.error.stage.creator", stage.getKey() );
  						if( flag )
  						{
  							throw new LifecycleException( error, e );
  						}
  						else
  						{
  							getLogger().warn( error, e );
  						}
  					}
  					finally
  					{
  						provider.release( handler );
  					}
  				}
  
  				if( flag && LifecycleCreateExtension.class.isAssignableFrom( c ) )
  				{
  					LifecycleCreateExtension handler = 
  					getLifecycleCreateExtension( provider );
  
  					try
  					{
  						if( getLogger().isDebugEnabled() )
  						{
  							int id = System.identityHashCode( instance );
  							getLogger().debug( "applying model create stage to: " + id );
  						}
  						handler.create( m_model, stage, instance );
  					}
  					catch( Throwable e )
  					{
  						final String error =
  						"Create stage extension error.";
  						throw new LifecycleException( error, e );
  					}
  					finally
  					{
  						provider.release( handler );
  					}
  				}
  				else if( !flag && LifecycleDestroyExtension.class.isAssignableFrom( c ) )
  				{
  					LifecycleDestroyExtension handler = 
  					getLifecycleDestroyExtension( provider );
  
  					try
  					{
  						if( getLogger().isDebugEnabled() )
  						{
  							int id = System.identityHashCode( instance );
  							getLogger().debug( "applying model destroy stage to: " + id );
  						}
  						handler.destroy( m_model, stage, instance );
  					}
  					catch( Throwable e )
  					{
  						if( getLogger().isWarnEnabled() )
  						{
  							final String error = 
  							"Ignoring destroy stage error";
  							getLogger().warn( error, e );
  						}
  					}
  					finally
  					{
  						provider.release( handler );
  					}
  				}*/
  			}
  		}
  
  		/*
  		private Creator getCreator( DeploymentModel provider ) 
  		{
  			try
  			{
  				return (Creator) provider.resolve();
  			}
  			catch( Throwable e )
  			{
  				final String error = 
  				"Unable to resolve creation stage provider.";
  				throw new LifecycleException( error, e );
  			}
  		}
  
  		private LifecycleCreateExtension getLifecycleCreateExtension( 
  		DeploymentModel provider ) 
  		{
  			try
  			{
  				return (LifecycleCreateExtension) provider.resolve();
  			}
  			catch( Throwable e )
  			{
  				final String error = 
  				"Unable to resolve lifecycle creation extension provider.";
  				throw new LifecycleException( error, e );
  			}
  		}
  
  		private LifecycleDestroyExtension getLifecycleDestroyExtension( 
  		DeploymentModel provider ) 
  		{
  			try
  			{
  				return (LifecycleDestroyExtension) provider.resolve();
  			}
  			catch( Throwable e )
  			{
  				final String error = 
  				"Unable to resolve lifecycle destroy extension provider.";
  				throw new LifecycleException( error, e );
  			}
  		}*/
  
  		private IComponentModel GetStageProvider( StageDescriptor stage ) 
  		{
  			String key = stage.Key;
  			IStageModel model = m_model.GetStageModel( stage );
  			IDeploymentModel provider = model.Provider;
  			if( provider is IComponentModel )
  			{
  				return (IComponentModel) provider;
  			}
  			else
  			{
  				String error = "lifecycle.error.invalid-stage-provider " + key;
  				throw new ApplicationException( error );
  			}
  		}
  
  		private void ApplyContext( Object instance, IContext context ) 
  		{
  			if( null == context ) 
  			{	
  				return;
  			}
  
  			IContextModel model = m_model.ContextModel;
  			if( model == null ) 
  			{
  				return;
  			}
  
  			IDeploymentModel provider = model.Provider;
  			if( null == provider )
  			{
  				//
  				// its classic avalon
  				//
  
  				try
  				{
  					ContainerUtil.Contextualize( instance, context );
  				}
  				catch( Exception e )
  				{
  					String error = "lifecycle.error.avalon-contextualization " + m_model.QualifiedName;
  					throw new LifecycleException( error, e );
  				}
  			}
  			else
  			{
  				try
  				{
  					IContextualizationHandler handler =
  						(IContextualizationHandler) provider.Resolve();
  					handler.Contextualize( instance, context );
  				}
  				catch( Exception e )
  				{
  					String error = "lifecycle.error.custom-contextualization" + m_model.QualifiedName;
  					throw new LifecycleException( error, e );
  				}
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultLifestyleFactory.cs
  
  Index: DefaultLifestyleFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Composition.Model;
  	using Apache.Avalon.Activation.Default.Lifestyles;
  
  	/// <summary>
  	/// A factory enabling the establishment of runtime handlers.
  	/// </summary>
  	public class DefaultLifestyleFactory : ILifestyleFactory
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private ISystemContext m_system;
  
  		/// <summary>
  		/// Creation of a new default lifestyle factory.
  		/// </summary>
  		/// <param name="system">the system context</param>
  		public DefaultLifestyleFactory( ISystemContext system )
  		{
  			m_system = system;
  		}
  
  		#region ILifestyleFactory Members
  
  		public ILifestyleManager CreateLifestyleManager(IComponentModel model)
  		{
  			IComponentFactory factory = new DefaultComponentFactory( m_system, model );
  			return CreateLifestyleManager( model, factory );
  		}
  
  		#endregion
  
  		/// <summary>
  		/// Create a new lifestyle manager.
  		/// </summary>
  		/// <param name="model">the component model</param>
  		/// <param name="factory">the component factory</param>
  		/// <returns>the lifestyle manager</returns>
  		protected ILifestyleManager CreateLifestyleManager( IComponentModel model, IComponentFactory factory )
  		{
  			Lifestyle lifestyle = model.TypeDescriptor.Info.Lifestyle;
  
  			if( lifestyle == Lifestyle.Singleton )
  			{
  				return new SingletonLifestyleManager( model, factory );
  			}
  			else if( lifestyle == Lifestyle.Thread )
  			{
  				// return new ThreadLifestyleManager( model, factory );
  				String error = "Unsupported lifestyle [" + lifestyle + "].";
  				throw new ArgumentException( error );
  			}
  			else if( lifestyle == Lifestyle.Transient )
  			{
  				return new TransientLifestyleManager( model, factory );
  			}
  			else
  			{
  				//
  				// TODO
  				// check if the key is an artifact reference and if 
  				// so, try to load up a lifestyle factory and delegate the 
  				// request
  				//
  
  				String error = "Unsupported lifestyle [" + lifestyle + "].";
  				throw new ArgumentException( error );
  			}
  		}
  
  		private IComponentFactory CreateComponentFactory( IComponentModel model )
  		{
  			//
  			// TODO
  			// check for a custom component factory artifact reference
  			// and load via avalon-repository if non null
  			//
  
  			return new DefaultComponentFactory( m_system, model );
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultLookupManager.cs
  
  Index: DefaultLookupManager.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  	using System.Collections;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for DefaultLookupManager.
  	/// </summary>
  	public class DefaultLookupManager : ILookupManager
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private IComponentModel m_model;
  
  		private ILogger m_logger;
  
  		/// <summary>
  		/// A table of identity hashcode integers of established objects 
  		/// that map to the lookup key that was uased to establish the object.
  		/// Used to track which model is providing an object when we 
  		/// handle release of objects.
  		/// </summary>
  		private Hashtable m_table;
  
  		/// <summary>
  		/// A table of dependency models keyed by lookup key.
  		/// </summary>
  		private Hashtable m_map;
  
  		/// <summary>
  		/// Construct a new ServiceManager.
  		/// </summary>
  		/// <param name="model">component model of the component that is to be services</param>
  		public DefaultLookupManager( IComponentModel model )
  		{
  			if( model == null )
  			{
  				throw new ArgumentNullException( "model" );
  			}
  
  			m_model = model;
  			m_logger = model.Logger;
  
  			m_map = new Hashtable();
  			IDependencyModel[] dependencies = model.DependencyModels;
  			
  			foreach(IDependencyModel dependency in dependencies)
  			{
  				String key = dependency.Dependency.Key;
  				m_map[ key ] = dependency;
  			}
  		}
  
  		#region ILookupManager Members
  
  		public object this[string role]
  		{
  			get
  			{
  				if( role == null )
  				{
  					throw new ArgumentNullException( "role" );
  				}
  
  				if( !Contains( role ) )
  				{
  					String error = "Unknown key: " + role;
  					throw new LookupException( role, error );
  				}
  
  				//
  				// locate the provider model that is prividing components
  				// for this dependency
  				//
  
  				IDependencyModel dependency = (IDependencyModel) m_map[ role ];
  				IDeploymentModel provider = dependency.Provider;
  				if( null == provider )
  				{
  					String error = "service.error.null-provider " + role;
  					throw new ApplicationException( error );
  				}
  
  				//
  				// get a proxy to the service from the provider
  				// (note that it is up to a provider to determine if
  				// a proxy if generated based on its service export 
  				// parameters)
  				//
  
  				try
  				{
  					Object instance = provider.Resolve();
  
  					//
  					// otherwise we need to hold a reference linking the 
  					// object with the source provider
  					//
  
  					String id = "" + instance.GetHashCode();
  					m_table[ id ] = role;
  					if( Logger.IsDebugEnabled )
  					{
  						String message = "resolved service [" 
  						+ id 
  						+ "] for the role [" 
  						+ role 
  						+ "].";
  						Logger.Debug( message );
  					}
  
  					return instance;
  				}
  				catch( Exception e )
  				{
  					//
  					// TODO: framework states that ServiceException is thrown
  					// if the service is not found - and in this case that isn't 
  					// the issue - in effect we have a good key, but we simply
  					// have not been able to go from key to instance -
  					// should look into some more concrete subtypes of 
  					// ServiceException
  
  					String error = "Unexpected runtime error while attempting to resolve service for key: " + role;
  					throw new FatalServiceException( role, error, e );
  				}
  			}
  		}
  
  		public void Release(object instance)
  		{
  			if( instance == null ) return;
  
  			//
  			// otherwise we need to locate the source ourselves
  			//
  
  			String id = "" + instance.GetHashCode();
  			String key = (String) m_table[ id ];
  			
  			if( key == null )
  			{
  				if( Logger.IsWarnEnabled )
  				{
  					String warning = 
  						"Unrecognized object identity [" 
  						+ id 
  						+ "]. "
  						+ "Either this object was not provided by this service manager "
  						+ "or it has already been released.";
  					Logger.Warn( warning );
  				}
  				return;
  			}
  
  			IDependencyModel dependency = (IDependencyModel) m_map[ key ];
  			IDeploymentModel provider = dependency.Provider;
  			if( provider == null )
  			{
  				if( Logger.IsErrorEnabled )
  				{
  					String error = 
  						"Unable to release component as no provider could be found for the key ["
  						+ key
  						+ "].";
  					Logger.Warn( error );
  				}
  				return;
  			}
  
  			provider.Release( instance );
  			if( Logger.IsDebugEnabled )
  			{
  				String message = 
  								 "released service [" 
  								 + id 
  								 + "] from the key [" 
  								 + key 
  								 + "].";
  				Logger.Debug( message );
  			}
  
  			m_table.Remove( id );
  		}
  
  		public bool Contains(string role)
  		{
  			if( role == null )
  			{
  				return false;
  			}
  			return m_map.Contains( role );
  		}
  
  		#endregion
  
  		private ILogger Logger
  		{
  			get
  			{
  				return m_logger;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultRuntime.cs
  
  Index: DefaultRuntime.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for DefaultRuntime.
  	/// </summary>
  	public class DefaultRuntime : IRuntime
  	{
  		//--------------------------------------------------------------
  		// immutable state
  		//--------------------------------------------------------------
  
  		private IRuntimeFactory m_runtimeFactory;
  
  		/// <summary>
  		/// Creation of a new system context.
  		/// </summary>
  		/// <param name="system">the system context</param>
  		public DefaultRuntime( ISystemContext system )
  		{
  			if( system == null )
  			{
  				throw new ArgumentNullException( "system" );
  			}
  			m_runtimeFactory = new DefaultRuntimeFactory( system );
  		}
  
  		#region IRuntime Members
  
  		public void Decommission(IDeploymentModel model)
  		{
  			RuntimeFactory.GetRuntime( model ).Decommission();
  		}
  
  		public void Commission(IDeploymentModel model)
  		{
  			RuntimeFactory.GetRuntime( model ).Commission();
  		}
  
  		public void Release(IDeploymentModel model, object instance)
  		{
  			RuntimeFactory.GetRuntime( model ).Release( instance );
  		}
  
  		public object Resolve(IDeploymentModel model)
  		{
  			return RuntimeFactory.GetRuntime( model ).Resolve();;
  		}
  
  		#endregion
  
  		protected IRuntimeFactory RuntimeFactory
  		{
  			get
  			{
  				return m_runtimeFactory;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/DefaultRuntimeFactory.cs
  
  Index: DefaultRuntimeFactory.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default
  {
  	using System;
  	using System.Collections;
  
  	using Apache.Avalon.Activation;
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for DefaultRuntimeFactory.
  	/// </summary>
  	public class DefaultRuntimeFactory : IRuntimeFactory
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private ISystemContext m_system;
  
  		private Hashtable m_map = new Hashtable();
  
  		private ILifestyleFactory m_factory;
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public DefaultRuntimeFactory( ISystemContext system )
  		{
  			m_system = system;
  			m_factory = new DefaultLifestyleFactory( m_system );
  		}
  
  		#region IRuntimeFactory Members
  
  		public IAppliance GetRuntime(Apache.Avalon.Composition.Model.IDeploymentModel model)
  		{
  			lock(m_map)
  			{
  				IAppliance runtime = GetRegisteredRuntime( model );
  
  				if( null != runtime ) 
  					return runtime;
  
  				//
  				// create the runtime
  				// check the model for an overriding runtime using the 
  				// standard runtime as the default (not implemented
  				// yet)
  				//
  
  				if( model is IComponentModel )
  				{
  					IComponentModel component = (IComponentModel) model;
  					ILifestyleManager manager = 
  						m_factory.CreateLifestyleManager( component );
  					runtime = NewComponentRuntime( component, manager );
  				}
  				else if( model is IContainmentModel )
  				{
  					IContainmentModel containment = (IContainmentModel) model;
  					runtime = NewContainmentRuntime( containment );
  				}
  				else
  				{
  					String error = "runtime.error.unknown-model " + model.ToString();
  					throw new ModelRuntimeException( error );
  				}
  
  				RegisterRuntime( model, runtime );
  				return runtime;
  			}
  		}
  
  		#endregion
  
  		/// <summary>
  		/// Resolve a runtime handler for a component model.
  		/// </summary>
  		/// <param name="model">the containment model</param>
  		/// <param name="manager"></param>
  		/// <returns>the runtime handler</returns>
  		protected IAppliance NewComponentRuntime( IComponentModel model, ILifestyleManager manager )
  		{
  			return new DefaultAppliance( model, manager );
  		}
  
  		/// <summary>
  		/// Resolve a runtime handler for a containment model.
  		/// </summary>
  		/// <param name="model">the containment model</param>
  		/// <returns> runtime handler</returns>
  		protected IAppliance NewContainmentRuntime( IContainmentModel model )
  		{
  			return new DefaultBlock( m_system, model );
  		}
  
  		/// <summary>
  		/// Lookup a runtime relative to the model name.
  		/// </summary>
  		/// <param name="model">the deployment model</param>
  		/// <returns>matching runtime (possibly null)</returns>
  		private IAppliance GetRegisteredRuntime( IDeploymentModel model )
  		{
  			return (IAppliance) m_map[ model.QualifiedName ];
  		}
  
  		private void RegisterRuntime( IDeploymentModel model, IAppliance runtime )
  		{
  			m_map[ model.QualifiedName ] = runtime;
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/Lifestyles/AbstractLifestyleManager.cs
  
  Index: AbstractLifestyleManager.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default.Lifestyles
  {
  	using System;
  
  	using Apache.Avalon.Framework;
  	using Apache.Avalon.Meta;
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for AbstractLifestyleManager.
  	/// </summary>
  	public abstract class AbstractLifestyleManager : ILifestyleManager
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private IComponentModel m_model;
  
  		private IComponentFactory m_factory;
  
  		private ILogger m_logger;
  
  		// private final ReferenceQueue m_liberals = new ReferenceQueue();
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Creation of a new instance.
  		/// </summary>
  		/// <param name="model">the component model</param>
  		/// <param name="factory">the component factory</param>
  		public AbstractLifestyleManager( IComponentModel model, IComponentFactory factory )
  		{
  			m_factory = factory;
  			m_model = model;
  			m_logger = model.Logger;
  		}
  
  		~AbstractLifestyleManager()
  		{
  			Decommission();
  		}
  
  		#region ILifestyleManager Members
  
  		public virtual void Finalize(object instance)
  		{
  			lock( m_factory )
  			{
  				if( instance != null )
  				{
  					m_factory.Etherialize( instance );
  				}
  			}
  		}
  
  		#endregion
  
  		#region ICommissionable Members
  
  		public abstract void Commission();
  		
  		public abstract void Decommission();
  
  		#endregion
  
  		#region IResolver Members
  
  		public void Release( object instance )
  		{
  			try
  			{
  				ApplyExtensionStages( instance, false );
  			}
  			catch( Exception e )
  			{
  				String error = "Ignoring error returned from release extension.";
  				Logger.Error( error, e );
  			}
  			HandleRelease( instance );
  		}
  
  		public object Resolve()
  		{
  			Object instance = HandleResolve();
  			return ApplyExtensionStages( instance, true );
  		}
  
  		#endregion
  
  		//-------------------------------------------------------------------
  		// implementation
  		//-------------------------------------------------------------------
  
  		protected abstract Object HandleResolve();
  
  		protected abstract void HandleRelease( Object instance );
  
  		protected ILogger Logger
  		{
  			get
  			{
  				return m_logger;
  			}
  		}
  
  		protected IComponentModel ComponentModel
  		{ 
  			get
  			{
  				return m_model;
  			}
  		}
  
  		protected IComponentFactory ComponentFactory
  		{ 
  			get
  			{
  				return m_factory;
  			}
  		}
  
  		private Object ApplyExtensionStages( object instance, bool flag ) 
  		{
  			StageDescriptor[] stages = m_model.TypeDescriptor.Stages;
  
  			for( int i=0; i<stages.Length; i++ )
  			{
  				StageDescriptor descriptor = stages[i];
  				IStageModel stage = m_model.GetStageModel( descriptor );
  
  				IComponentModel provider = GetStageProvider( stage );
  				// Class c = provider.getDeploymentClass();
  
  				/*
  				if( Accessor.class.isAssignableFrom( c ) )
  				{
  					Accessor handler = (Accessor) provider.resolve();
  					try
  					{
  						Context context = m_model.getContextModel().getContext();
  						if( flag )
  						{
  							if( getLogger().isDebugEnabled() )
  							{
  								int id = System.identityHashCode( instance );
  								getLogger().debug( "applying access stage to: " + id );
  							}
  							handler.access( instance, context );
  						}
  						else
  						{
  							if( getLogger().isDebugEnabled() )
  							{
  								int id = System.identityHashCode( instance );
  								getLogger().debug( "applying release stage to: " + id );
  							}
  							handler.release( instance, context );
  						}
  					}
  					catch( Throwable e )
  					{
  						final String error = 
  							REZ.getString( 
  							"lifecycle.stage.accessor.error",
  							stage.getStage().getKey() );
  						if( flag )
  						{
  							throw new LifecycleException( error, e );
  						}
  						else
  						{
  							getLogger().warn( error, e );
  						}
  					}
  					finally
  					{
  						provider.release( handler );
  					}
  				}*/
  			}
  			return instance;
  		}
  
  		private IComponentModel GetStageProvider( IStageModel stage )
  		{
  			try
  			{
  				return (IComponentModel) stage.Provider;
  			}
  			catch( Exception e )
  			{
  				String error = 
  					"Unable to resolve access stage provider.";
  				throw new LifecycleException( error, e );
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/Lifestyles/SingletonLifestyleManager.cs
  
  Index: SingletonLifestyleManager.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default.Lifestyles
  {
  	using System;
  
  	using Apache.Avalon.Composition.Data;
  	using Apache.Avalon.Composition.Model;
  	using Apache.Avalon.Meta;
  
  	/// <summary>
  	/// Summary description for SingletonLifestyleManager.
  	/// </summary>
  	public class SingletonLifestyleManager : AbstractLifestyleManager
  	{
  		private WeakReference m_reference;
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public SingletonLifestyleManager( IComponentModel model, IComponentFactory factory ) : base(model,factory)
  		{
  		}
  
  		//-------------------------------------------------------------------
  		// Commissionable
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Commission the runtime handler. 
  		/// </summary>
  		public override void Commission() 
  		{
  			if( ComponentModel.ActivationPolicy == ActivationPolicy.Startup )
  			{
  				RefreshReference();
  			}
  		}
  
  		/// <summary>
  		/// Invokes the decommissioning phase.  Once a handler is
  		/// decommissioned it may be re-commissioned.
  		/// </summary>
  		public override void Decommission()
  		{
  			if( m_reference != null )
  			{
  				Finalize( m_reference.Target );
  				m_reference = null;
  			}
  		}
  
  		//-------------------------------------------------------------------
  		// Resolver
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Resolve a object to a value relative to a supplied set of interface classes.
  		/// </summary>
  		/// <returns>the resolved object</returns>
  		protected override object HandleResolve() 
  		{
  			object instance = null;
  
  			if( m_reference == null )
  			{
  				return RefreshReference();
  			}
  			else
  			{
  				instance = m_reference.Target;
  				if( instance == null )
  				{
  					return RefreshReference();
  				}
  				else
  				{
  					return instance;
  				}
  			}
  		}
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		protected override void HandleRelease( object instance )
  		{
  			// continue with the current singleton reference
  		}
  
  		//-------------------------------------------------------------------
  		// LifecycleManager
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance">the object to be released</param>
  		public override void Finalize( object instance )
  		{
  			ComponentFactory.Etherialize( instance );
  			m_reference = null;
  		}
  
  		//-------------------------------------------------------------------
  		// implementation
  		//-------------------------------------------------------------------
  
  		private Object RefreshReference()
  		{
  			IComponentFactory factory = ComponentFactory;
  			lock( factory )
  			{
  				Object instance = factory.Incarnate();
  				m_reference = new WeakReference( instance );
  				return instance;
  			}
  		}
  	}
  }
  
  
  
  1.1                  avalon-sandbox/avalon-net/Activation/Default/Lifestyles/TransientLifestyleManager.cs
  
  Index: TransientLifestyleManager.cs
  ===================================================================
  // Copyright 2004 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.Activation.Default.Lifestyles
  {
  	using System;
  	using System.Collections;
  
  	using Apache.Avalon.Composition.Model;
  
  	/// <summary>
  	/// Summary description for TransientLifestyleManager.
  	/// </summary>
  	public class TransientLifestyleManager : AbstractLifestyleManager
  	{
  		//-------------------------------------------------------------------
  		// immutable state
  		//-------------------------------------------------------------------
  
  		private ArrayList m_list = new ArrayList();
  
  		//-------------------------------------------------------------------
  		// constructor
  		//-------------------------------------------------------------------
  
  		public TransientLifestyleManager( IComponentModel model, IComponentFactory factory ) : base( model, factory )
  		{
  		}
  
  		//-------------------------------------------------------------------
  		// Commissionable
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Commission the appliance. 
  		/// </summary>
  		public override void Commission() 
  		{
  			// TODO: setup a background thread to check queues for 
  			// released references and remove them from our list, otherwise we
  			// have a memory leak due to accumulation of weak references
  		}
  
  		/// <summary>
  		/// Decommission the appliance.  Once an appliance is 
  		/// decommissioned it may be re-commissioned.
  		/// </summary>
  		public override void Decommission()
  		{
  			foreach(WeakReference reference in m_list)
  			{
  				Finalize( reference.Target );
  			}
  			m_list.Clear();
  		}
  
  		//-------------------------------------------------------------------
  		// Resolver
  		//-------------------------------------------------------------------
  
  		/// <summary>
  		/// Resolve a object to a value relative to a supplied set of 
  		/// interface classes.
  		/// </summary>
  		/// <returns>the resolved object</returns>
  		protected override Object HandleResolve()
  		{
  			object instance = ComponentFactory.Incarnate();
  			WeakReference reference = new WeakReference( instance );
  			m_list.Add( reference );
  			return instance;
  		}
  
  		/// <summary>
  		/// Release an object
  		/// </summary>
  		/// <param name="instance"> the object to be released</param>
  		protected override void HandleRelease( Object instance )
  		{
  			Finalize( instance );
  		}
  	}
  }
  
  
  

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