hammett     2004/03/06 07:44:41

  Modified:    avalon-net/Activation/Default
                        Apache.Avalon.Activation.Default.csproj
                        DefaultAppliance.cs DefaultBlock.cs
                        DefaultRuntimeFactory.cs
               avalon-net/Castle/CastleTest/Components Vehicle.cs
               avalon-net/Castle/Castle Apache.Avalon.Castle.csproj
               avalon-net/Castle/Castle/Core Orchestrator.cs
               avalon-net/Castle/bin apache.avalon.castle.config
               avalon-net/Composition/ModelDefault
                        DefaultContainmentModel.cs StandardModelFactory.cs
               avalon-net/DynamicProxy Apache.Avalon.DynamicProxy.csproj
                        ProxyGenerator.cs
  Added:       avalon-net/Castle/Castle/Core/Proxies
                        ManagedObjectProxyGenerator.cs
               avalon-net/Castle/Castle/Default/Runtime CastleRuntime.cs
  Removed:     avalon-net/Castle/Castle/Core/Proxies
                        AbstractManagedObjectProxy.cs
                        LoggingManagerProxy.cs RuntimeProxy.cs
  Log:
  Bug fixes (Begin to separeta Default Activation and Castle Activation in different 
assemblies)
  Castle will be able to support them both.
  
  Revision  Changes    Path
  1.2       +11 -1     
avalon-sandbox/avalon-net/Activation/Default/Apache.Avalon.Activation.Default.csproj
  
  Index: Apache.Avalon.Activation.Default.csproj
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Activation/Default/Apache.Avalon.Activation.Default.csproj,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Apache.Avalon.Activation.Default.csproj   29 Feb 2004 21:43:37 -0000      1.1
  +++ Apache.Avalon.Activation.Default.csproj   6 Mar 2004 15:44:41 -0000       1.2
  @@ -76,7 +76,7 @@
                   />
                   <Reference
                       Name = "System.XML"
  -                    AssemblyName = "System.XML"
  +                    AssemblyName = "System.Xml"
                       HintPath = 
"C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
                   />
                   <Reference
  @@ -109,12 +109,22 @@
                       Project = "{F64EB1C1-A909-41AD-AAF8-B17B64D1BE93}"
                       Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                   />
  +                <Reference
  +                    Name = "Apache.Avalon.DynamicProxy"
  +                    AssemblyName = "Apache.Avalon.DynamicProxy"
  +                    HintPath = "..\..\Castle\bin\Apache.Avalon.DynamicProxy.dll"
  +                />
               </References>
           </Build>
           <Files>
               <Include>
                   <File
                       RelPath = "AbstractAppliance.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "ApplianceInvocationHandler.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  
  
  
  1.2       +10 -37    avalon-sandbox/avalon-net/Activation/Default/DefaultAppliance.cs
  
  Index: DefaultAppliance.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Activation/Default/DefaultAppliance.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultAppliance.cs       29 Feb 2004 21:43:37 -0000      1.1
  +++ DefaultAppliance.cs       6 Mar 2004 15:44:41 -0000       1.2
  @@ -58,7 +58,10 @@
                {
                        lock( m_commissioned )
                        {
  -                             if( m_commissioned.Enabled ) return;
  +                             if( m_commissioned.Enabled ) 
  +                             {
  +                                     return;
  +                             }
   
                                try
                                {
  @@ -82,7 +85,10 @@
                {
                        lock( m_commissioned )
                        {
  -                             if( !m_commissioned.Enabled ) return;
  +                             if( !m_commissioned.Enabled ) 
  +                             {
  +                                     return;
  +                             }
                                m_lifestyle.Decommission();
                                m_commissioned.Enabled = false;
                        }
  @@ -127,31 +133,7 @@
                                        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 );
  -                             }
  -                     }*/
  +                     throw new ArgumentException("proxy not supported");
                }
   
                /// <summary>
  @@ -163,16 +145,7 @@
                        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 );
  -                     }
  +                     m_lifestyle.Release( instance );
                }
   
                //-------------------------------------------------------------------
  
  
  
  1.2       +63 -14    avalon-sandbox/avalon-net/Activation/Default/DefaultBlock.cs
  
  Index: DefaultBlock.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Activation/Default/DefaultBlock.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultBlock.cs   29 Feb 2004 21:43:37 -0000      1.1
  +++ DefaultBlock.cs   6 Mar 2004 15:44:41 -0000       1.2
  @@ -16,10 +16,12 @@
   {
        using System;
        using System.Collections;
  +     using System.Reflection;
   
        using Apache.Avalon.Framework;
        using Apache.Avalon.Composition.Model;
        using Apache.Avalon.Composition.Model.Default;
  +     using Apache.Avalon.DynamicProxy;
   
        /// <summary>
        /// Summary description for DefaultBlock.
  @@ -30,6 +32,8 @@
                // immutable state
                //-------------------------------------------------------------------
   
  +             private object m_proxy;
  +
                private IContainmentModel m_model;
   
                private ISystemContext m_system;
  @@ -61,16 +65,13 @@
   
                                try
                                {
  -                                     /*
  -                                     ILogger log = 
m_model.Logger.CreateChildLogger( "proxy" );
  -                                     final BlockInvocationHandler handler = 
  -                                     new BlockInvocationHandler( log, this );
  -                                     final Class[] classes = getInterfaceClasses();
  +                                     if (InterfaceTypes.Length != 0)
  +                                     {
  +                                             BlockInvocationHandler handler = 
  +                                                     new BlockInvocationHandler( 
this );
                    
  -                                     m_proxy = Proxy.newProxyInstance( 
  -                                     m_model.getClassLoaderModel().getClassLoader(),
  -                                     classes,
  -                                     handler );*/
  +                                             m_proxy = ProxyGenerator.CreateProxy( 
InterfaceTypes, handler );
  +                                     }
   
                                        m_commissioned.Enabled = true;
                                }
  @@ -91,10 +92,10 @@
                        lock( m_commissioned )
                        {
                                if( !m_commissioned.Enabled ) return;
  -                             /*if( null != m_proxy )
  +                             if( null != m_proxy )
                                {
                                        m_proxy = null;
  -                             }*/
  +                             }
                                m_commissioned.Enabled = false;
                        }
                }
  @@ -114,8 +115,7 @@
                                String error = 
"block.error.resolve.non-commission-state " + this.ToString();
                                throw new ApplicationException( error );
                        }
  -                     // return m_proxy;
  -                     return this;
  +                     return m_proxy;
                }
   
                /// <summary>
  @@ -134,7 +134,7 @@
                /// <summary>
                /// Return the model backing the handler.
                /// </summary>
  -             protected IContainmentModel ContainmentModel
  +             protected internal IContainmentModel ContainmentModel
                {
                        get
                        {
  @@ -166,5 +166,54 @@
                {
                        return "block:" + ContainmentModel.QualifiedName;
                }
  +     }
  +
  +     /// <summary>
  +     /// 
  +     /// </summary>
  +     public class BlockInvocationHandler : IInvocationHandler
  +     {
  +             private DefaultBlock m_block;
  +
  +             public BlockInvocationHandler( DefaultBlock block )
  +             {
  +                     if (block == null)
  +                     {
  +                             throw new ArgumentNullException("block");
  +                     }
  +
  +                     m_block = block;
  +             }
  +             
  +             #region IInvocationHandler Members
  +
  +             public object Invoke(object proxy, MethodBase method, params object[] 
arguments)
  +             {
  +                     IContainmentModel model = m_block.ContainmentModel;
  +                     Type targetType = method.DeclaringType;
  +                     IServiceModel service = model.GetServiceModel( targetType );
  +
  +                     if (service == null)
  +                     {
  +                             throw new ApplianceException("Unable to resolve an 
provider for the interface " + targetType);
  +                     }
  +
  +                     IDeploymentModel provider = service.ServiceProvider;
  +
  +                     Object target = provider.Resolve();
  +
  +                     Type[] parameters = new Type[arguments.Length];
  +                     
  +                     for(int i=0; i < arguments.Length; i++ )
  +                     {
  +                             parameters[i] = arguments[i].GetType();
  +                     }
  +
  +                     MethodInfo targetMethod = targetType.GetMethod( method.Name, 
parameters );
  +
  +                     return targetMethod.Invoke( target, arguments );
  +             }
  +
  +             #endregion
        }
   }
  
  
  
  1.2       +2 -0      
avalon-sandbox/avalon-net/Activation/Default/DefaultRuntimeFactory.cs
  
  Index: DefaultRuntimeFactory.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Activation/Default/DefaultRuntimeFactory.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultRuntimeFactory.cs  29 Feb 2004 21:43:37 -0000      1.1
  +++ DefaultRuntimeFactory.cs  6 Mar 2004 15:44:41 -0000       1.2
  @@ -54,7 +54,9 @@
                                IAppliance runtime = GetRegisteredRuntime( model );
   
                                if( null != runtime ) 
  +                             {
                                        return runtime;
  +                             }
   
                                //
                                // create the runtime
  
  
  
  1.4       +15 -1     
avalon-sandbox/avalon-net/Castle/CastleTest/Components/Vehicle.cs
  
  Index: Vehicle.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleTest/Components/Vehicle.cs,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Vehicle.cs        28 Feb 2004 22:15:35 -0000      1.3
  +++ Vehicle.cs        6 Mar 2004 15:44:41 -0000       1.4
  @@ -52,7 +52,7 @@
        [AvalonComponent( "Vehicle", Lifestyle.Transient )]
        [AvalonDependency( typeof(IEngine), "Engine", Optional.False)]
        [AvalonDependency( typeof(IRadio), "Radio", Optional.False)]
  -     public class Vehicle : IVehicle, ILookupEnabled
  +     public class Vehicle : IVehicle, ILookupEnabled, IStartable
        {
                private IEngine m_engine;
                private IRadio  m_radio;
  @@ -91,6 +91,20 @@
                        Assertion.Equals( typeof(IEngine), manager["Engine"].GetType() 
);
                        Assertion.Equals( typeof(IRadio), manager["Radio"].GetType() );
                }
  +
  +             #region IStartable Members
  +
  +             public void Start()
  +             {
  +                     
  +             }
  +
  +             public void Stop()
  +             {
  +                     
  +             }
  +
  +             #endregion
        }
   
        [AvalonService( typeof(IEngine) )]
  
  
  
  1.4       +11 -11    
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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Apache.Avalon.Castle.csproj       29 Feb 2004 21:43:37 -0000      1.3
  +++ Apache.Avalon.Castle.csproj       6 Mar 2004 15:44:41 -0000       1.4
  @@ -139,6 +139,11 @@
                       Project = "{E311F863-2E58-4466-94A2-31A68B341C87}"
                       Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
                   />
  +                <Reference
  +                    Name = "Apache.Avalon.DynamicProxy"
  +                    AssemblyName = "Apache.Avalon.DynamicProxy"
  +                    HintPath = "..\bin\Apache.Avalon.DynamicProxy.dll"
  +                />
               </References>
           </Build>
           <Files>
  @@ -264,17 +269,7 @@
                       BuildAction = "Compile"
                   />
                   <File
  -                    RelPath = "Core\Proxies\AbstractManagedObjectProxy.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Core\Proxies\LoggingManagerProxy.cs"
  -                    SubType = "Code"
  -                    BuildAction = "Compile"
  -                />
  -                <File
  -                    RelPath = "Core\Proxies\RuntimeProxy.cs"
  +                    RelPath = "Core\Proxies\ManagedObjectProxyGenerator.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  @@ -320,6 +315,11 @@
                   />
                   <File
                       RelPath = "Default\Repository\DefaultRepository.cs"
  +                    SubType = "Code"
  +                    BuildAction = "Compile"
  +                />
  +                <File
  +                    RelPath = "Default\Runtime\CastleRuntime.cs"
                       SubType = "Code"
                       BuildAction = "Compile"
                   />
  
  
  
  1.6       +5 -7      avalon-sandbox/avalon-net/Castle/Castle/Core/Orchestrator.cs
  
  Index: Orchestrator.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/Castle/Castle/Core/Orchestrator.cs,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Orchestrator.cs   29 Feb 2004 22:05:01 -0000      1.5
  +++ Orchestrator.cs   6 Mar 2004 15:44:41 -0000       1.6
  @@ -261,7 +261,8 @@
   
                        if ( m_runtime == null )
                        {
  -                             m_runtime = new RuntimeProxy( Server, Runtime );
  +                             m_runtime = (IRuntime) 
ManagedObjectProxyGenerator.CreateProxy( 
  +                                     Runtime, Server, typeof(IRuntime) );
                        }
                }
   
  @@ -271,7 +272,8 @@
   
                        if ( m_loggingManager == null )
                        {
  -                             m_loggingManager = new LoggingManagerProxy( Server, 
LoggerManager );
  +                             m_loggingManager = (ILoggingManager) 
ManagedObjectProxyGenerator.CreateProxy( 
  +                                     LoggerManager, Server, typeof(ILoggingManager) 
);
                        }
                }
   
  @@ -296,11 +298,7 @@
                        {
                                m_logger.Debug("Invoking RegisterForPhases on {0}", 
name);
   
  -                             Server.Invoke( 
  -                                     name, 
  -                                     "RegisterForPhases", 
  -                                     new object[] { m_notificationSystem }, 
  -                                     new Type[] { 
typeof(OrchestratorNotificationSystem) } );
  +                             MXUtil.InvokeOn( Server, name, "RegisterForPhases", 
m_notificationSystem );
   
                                m_logger.Debug("Done");
                        }
  
  
  
  1.6       +1 -1      avalon-sandbox/avalon-net/Castle/bin/apache.avalon.castle.config
  
  Index: apache.avalon.castle.config
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/bin/apache.avalon.castle.config,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- apache.avalon.castle.config       29 Feb 2004 18:07:17 -0000      1.5
  +++ apache.avalon.castle.config       6 Mar 2004 15:44:41 -0000       1.6
  @@ -75,7 +75,7 @@
                                        </mcomponent>
                                        
                                        <!-- Runtime implementation -->
  -                                     <mcomponent 
type="Apache.Avalon.Castle.Default.Runtime.DefaultRuntime, Apache.Avalon.Castle"
  +                                     <mcomponent 
type="Apache.Avalon.Castle.Default.Runtime.SimpleRuntime, Apache.Avalon.Castle"
                                                
name="apache.avalon.castle:name=Runtime">
                                        </mcomponent>                           
                                
  
  
  
  1.3       +1 -12     
avalon-sandbox/avalon-net/Composition/ModelDefault/DefaultContainmentModel.cs
  
  Index: DefaultContainmentModel.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Composition/ModelDefault/DefaultContainmentModel.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefaultContainmentModel.cs        29 Feb 2004 18:07:17 -0000      1.2
  +++ DefaultContainmentModel.cs        6 Mar 2004 15:44:41 -0000       1.3
  @@ -71,29 +71,18 @@
                // immutable state
                //--------------------------------------------------------------
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 
'm_compositionListeners '. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
  -             //UPGRADE_NOTE: The initialization of  'm_compositionListeners' was 
moved to method 'InitBlock'. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1005"'
                // private System.Collections.IList m_compositionListeners;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 'm_assembly 
'. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
  -             //UPGRADE_NOTE: The initialization of  'm_assembly' was moved to 
method 'InitBlock'. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1005"'
                private DefaultState m_assembly;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 'm_models '. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
  -             //UPGRADE_NOTE: The initialization of  'm_models' was moved to method 
'InitBlock'. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1005"'
                private System.Collections.IDictionary m_models;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 'm_context 
'. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
                private IContainmentContext m_context;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 'm_partition 
'. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
                private String m_partition;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 'm_services 
'. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
                private IServiceModel[] m_services;
                
  -             //UPGRADE_NOTE: Final was removed from the declaration of 
'm_commissioned '. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1003"'
  -             //UPGRADE_NOTE: The initialization of  'm_commissioned' was moved to 
method 'InitBlock'. 
'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1005"'
                private DefaultState m_commissioned;
                
                //--------------------------------------------------------------
  
  
  
  1.3       +1 -2      
avalon-sandbox/avalon-net/Composition/ModelDefault/StandardModelFactory.cs
  
  Index: StandardModelFactory.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Composition/ModelDefault/StandardModelFactory.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- StandardModelFactory.cs   29 Feb 2004 18:07:17 -0000      1.2
  +++ StandardModelFactory.cs   6 Mar 2004 15:44:41 -0000       1.3
  @@ -75,7 +75,6 @@
                        {
                                return m_logger;
                        }
  -                     
                }
   
                /// <summary> Creation of a new root containment model using 
  
  
  
  1.2       +1 -1      
avalon-sandbox/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj
  
  Index: Apache.Avalon.DynamicProxy.csproj
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/DynamicProxy/Apache.Avalon.DynamicProxy.csproj,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Apache.Avalon.DynamicProxy.csproj 6 Mar 2004 03:29:20 -0000       1.1
  +++ Apache.Avalon.DynamicProxy.csproj 6 Mar 2004 15:44:41 -0000       1.2
  @@ -36,7 +36,7 @@
                       NoStdLib = "false"
                       NoWarn = ""
                       Optimize = "false"
  -                    OutputPath = "bin\Debug\"
  +                    OutputPath = "..\bin\"
                       RegisterForComInterop = "false"
                       RemoveIntegerChecks = "false"
                       TreatWarningsAsErrors = "false"
  
  
  
  1.2       +4 -0      avalon-sandbox/avalon-net/DynamicProxy/ProxyGenerator.cs
  
  Index: ProxyGenerator.cs
  ===================================================================
  RCS file: /home/cvs/avalon-sandbox/avalon-net/DynamicProxy/ProxyGenerator.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProxyGenerator.cs 6 Mar 2004 03:29:20 -0000       1.1
  +++ ProxyGenerator.cs 6 Mar 2004 15:44:41 -0000       1.2
  @@ -61,6 +61,10 @@
                        {
                                throw new ArgumentNullException("handler");
                        }
  +                     if (interfaces.Length == 0)
  +                     {
  +                             throw new ArgumentException("Can't deal with a empty 
interface array");
  +                     }
   
                        AssemblyName assemblyName = new AssemblyName();
                        assemblyName.Name = "DynamicAssemblyProxyGen";
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/Castle/Core/Proxies/ManagedObjectProxyGenerator.cs
  
  Index: ManagedObjectProxyGenerator.cs
  ===================================================================
  // Copyright 2004 The Apache Software Foundation
  // 
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  // 
  //     http://www.apache.org/licenses/LICENSE-2.0
  // 
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  namespace Apache.Avalon.Castle.Core.Proxies
  {
        using System;
        using System.Reflection;
  
        using Apache.Avalon.DynamicProxy;
        using Apache.Avalon.Castle.ManagementExtensions;
        using Apache.Avalon.Castle.Util;
  
        /// <summary>
        /// Summary description for ManagedObjectProxyGenerator.
        /// </summary>
        public sealed class ManagedObjectProxyGenerator
        {
                private ManagedObjectProxyGenerator()
                {
                }
  
                /// <summary>
                /// 
                /// </summary>
                /// <param name="name"></param>
                /// <param name="server"></param>
                /// <param name="implementedInterface"></param>
                /// <returns></returns>
                public static object CreateProxy( ManagedObjectName name, 
                        MServer server, Type implementedInterface )
                {
                        ManagedObjectInvocationHandler handler = 
                                new ManagedObjectInvocationHandler( name, server );
  
                        return ProxyGenerator.CreateProxy( new Type[] { 
implementedInterface }, handler );
                }
        }
  
        /// <summary>
        /// 
        /// </summary>
        internal class ManagedObjectInvocationHandler : IInvocationHandler
        {
                /// <summary>
                /// 
                /// </summary>
                private ManagedObjectName m_target;
                
                /// <summary>
                /// 
                /// </summary>
                private MServer m_server;
  
                /// <summary>
                /// 
                /// </summary>
                /// <param name="target"></param>
                /// <param name="server"></param>
                public ManagedObjectInvocationHandler(ManagedObjectName target, 
MServer server)
                {
                        if (target == null)
                        {
                                throw new ArgumentNullException("target");
                        }
                        if (server== null)
                        {
                                throw new ArgumentNullException("server");
                        }
  
                        m_target = target;
                        m_server = server;
                }
  
                #region IInvocationHandler Members
  
                /// <summary>
                /// 
                /// </summary>
                /// <param name="proxy"></param>
                /// <param name="method"></param>
                /// <param name="arguments"></param>
                /// <returns></returns>
                public object Invoke(object proxy, MethodBase method, params object[] 
arguments)
                {
                        if (method.IsSpecialName)
                        {
                                if (method.Name.StartsWith("set_"))
                                {
                                        MXUtil.SetAttribute( m_server, m_target, 
method.Name.Substring(4), arguments[0] );
                                }
                                else if (method.Name.StartsWith("get_"))
                                {
                                        return MXUtil.GetAttribute( m_server, 
m_target, method.Name.Substring(4) );
                                }
                        }
                        else
                        {
                                return MXUtil.InvokeOn( m_server, m_target, 
method.Name, arguments );
                        }
  
                        return null;
                }
  
                #endregion
  
        }
  }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/Castle/Default/Runtime/CastleRuntime.cs
  
  Index: CastleRuntime.cs
  ===================================================================
  // Copyright 2004 The Apache Software Foundation
  // 
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  // 
  //     http://www.apache.org/licenses/LICENSE-2.0
  // 
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  namespace Apache.Avalon.Castle.Default.Runtime
  {
        using System;
  
        using Apache.Avalon.Castle.ManagementExtensions;
        using Apache.Avalon.Castle.Util;
        using Apache.Avalon.Composition.Model;
        using Apache.Avalon.Activation.Default;
  
        /// <summary>
        /// Summary description for CastleRuntime.
        /// </summary>
        [ManagedComponent]
        public class CastleRuntime : ManagedService, IRuntime
        {
                private ISystemContext m_context;
  
                public CastleRuntime()
                {
                }
  
                #region IRuntime Members
  
                [ManagedOperation]
                public void Decommission(IDeploymentModel model)
                {
                        // m_runtime.Decommission( model );
                }
  
                [ManagedOperation]
                public void Commission(IDeploymentModel model)
                {
                        // m_runtime.Commission( model );
                }
  
                [ManagedOperation]
                public void Release(IDeploymentModel model, object instance)
                {
                        // m_runtime.Release( model, instance );
                }
  
                [ManagedOperation]
                public object Resolve(IDeploymentModel model)
                {
                        // return m_runtime.Resolve( model );;
                        return null;
                }
  
                #endregion
        
                public override void Start()
                {
                        base.Start();
  
                        m_context = (ISystemContext) MXUtil.GetAttribute( 
                                Server, CastleConstants.ORCHESTRATOR_NAME, 
"SystemContext" );
                }
        }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to