hammett     2003/12/28 10:57:12

  Modified:    avalon-net/Castle/CastleManagementExtensionsTest
                        AssemblyInfo.cs MDefaultRegistryTestCase.cs
               avalon-net/Castle/CastleManagementExtensionsTest/Components
                        DummySmtpServer.cs
               avalon-net/Castle/CastleManagementExtensions AssemblyInfo.cs
                        MServerFactory.cs ManagementInfo.cs
               avalon-net/Castle/CastleManagementExtensions/Default
                        MDefaultRegistry.cs MDefaultServer.cs MInspector.cs
               avalon-net/Castle/CastleManagementExtensions/Default/Strategy
                        ReflectionInvokerStrategy.cs
  Added:       avalon-net/Castle/CastleManagementExtensionsTest
                        InterfacedComponentTestCase.cs
               avalon-net/Castle/CastleManagementExtensionsTest/Components
                        DummyLifecycledService.cs DummyService.cs
                        ISomeService.cs
               avalon-net/Castle/CastleManagementExtensions
                        MRegistrationListener.cs
               avalon-net/Castle/CastleManagementExtensions/Exception
                        DomainAlreadyExistsException.cs
  Log:
  Added Registration events capabilities.
  
  Revision  Changes    Path
  1.2       +47 -0     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/AssemblyInfo.cs
  
  Index: AssemblyInfo.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/AssemblyInfo.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AssemblyInfo.cs   27 Dec 2003 03:13:29 -0000      1.1
  +++ AssemblyInfo.cs   28 Dec 2003 18:57:12 -0000      1.2
  @@ -1,3 +1,50 @@
  +// ============================================================================
  +//                   The Apache Software License, Version 1.1
  +// ============================================================================
  +// 
  +// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  +// 
  +// Redistribution and use in source and binary forms, with or without modifica-
  +// tion, are permitted provided that the following conditions are met:
  +// 
  +// 1. Redistributions of  source code must  retain the above copyright  notice,
  +//    this list of conditions and the following disclaimer.
  +// 
  +// 2. Redistributions in binary form must reproduce the above copyright notice,
  +//    this list of conditions and the following disclaimer in the documentation
  +//    and/or other materials provided with the distribution.
  +// 
  +// 3. The end-user documentation included with the redistribution, if any, must
  +//    include  the following  acknowledgment:  "This product includes  software
  +//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +//    Alternately, this  acknowledgment may  appear in the software itself,  if
  +//    and wherever such third-party acknowledgments normally appear.
  +// 
  +// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  +//    must not be used to endorse or promote products derived from this  software 
  +//    without  prior written permission. For written permission, please contact 
  +//    [EMAIL PROTECTED]
  +// 
  +// 5. Products  derived from this software may not  be called "Apache", nor may
  +//    "Apache" appear  in their name,  without prior written permission  of the
  +//    Apache Software Foundation.
  +// 
  +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  +// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  +// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  +// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  +// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  +// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  +// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  +// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +// 
  +// This software  consists of voluntary contributions made  by many individuals
  +// on  behalf of the Apache Software  Foundation. For more  information on the 
  +// Apache Software Foundation, please see <http://www.apache.org/>.
  +// ============================================================================
  +
   using System.Reflection;
   using System.Runtime.CompilerServices;
   
  
  
  
  1.2       +19 -1     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/MDefaultRegistryTestCase.cs
  
  Index: MDefaultRegistryTestCase.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/MDefaultRegistryTestCase.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MDefaultRegistryTestCase.cs       27 Dec 2003 03:13:29 -0000      1.1
  +++ MDefaultRegistryTestCase.cs       28 Dec 2003 18:57:12 -0000      1.2
  @@ -63,7 +63,7 @@
                [Test]
                public void TestUse()
                {
  -                     MDefaultRegistry registry = new MDefaultRegistry();
  +                     MDefaultRegistry registry = new MDefaultRegistry(new 
MDefaultServer());
                        AssertEquals( 0, registry.Count );
   
                        DummyHttpServer instance = new DummyHttpServer();
  @@ -81,6 +81,24 @@
                        registry.UnregisterManagedObject( name );
   
                        AssertEquals( 0, registry.Count );
  +             }
  +
  +             [Test]
  +             public void TestRegistration()
  +             {
  +                     MDefaultRegistry registry = new MDefaultRegistry(new 
MDefaultServer());
  +
  +                     DummyLifecycledService service = new DummyLifecycledService();
  +
  +                     ManagedObjectName name = new 
ManagedObjectName("domain.org:name=Service");
  +
  +                     registry.RegisterManagedObject( service, name );
  +                     registry.UnregisterManagedObject( name );
  +
  +                     AssertEquals( 0, service.beforeRegisterCalled );
  +                     AssertEquals( 1, service.afterRegisterCalled );
  +                     AssertEquals( 2, service.beforeDeregisterCalled );
  +                     AssertEquals( 3, service.afterDeregisterCalled );
                }
        }
   }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/InterfacedComponentTestCase.cs
  
  Index: InterfacedComponentTestCase.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions.Test
  {
        using System;
  
        using NUnit.Framework;
  
        using Apache.Avalon.Castle.ManagementExtensions.Default;
        using Apache.Avalon.Castle.ManagementExtensions.Test.Components;
  
        /// <summary>
        /// Summary description for InterfacedComponentTestCase.
        /// </summary>
        [TestFixture]
        public class InterfacedComponentTestCase : Assertion
        {
                [Test]
                public void TestInfoObtation()
                {
                        MDefaultServer server = new MDefaultServer();
  
                        ManagedObjectName name1 = new 
ManagedObjectName("domain.org:type=dummyService");
  
                        try
                        {
                                Type serviceType = typeof(DummyService);
  
                                Object service = server.Instantiate( 
serviceType.Assembly.FullName, serviceType.FullName );
                                server.RegisterManagedObject( service, name1 );
  
                                ManagementInfo info = server.GetManagementInfo( name1 
);
                                AssertNotNull( info );
                                AssertEquals( 1, info.Operations.Count );
                                AssertEquals( 1, info.Attributes.Count );
                        }
                        finally
                        {
                                server.UnregisterManagedObject( name1 );
                        }
                }
        }
  }
  
  
  
  1.2       +1 -1      
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/Components/DummySmtpServer.cs
  
  Index: DummySmtpServer.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/Components/DummySmtpServer.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DummySmtpServer.cs        27 Dec 2003 03:13:29 -0000      1.1
  +++ DummySmtpServer.cs        28 Dec 2003 18:57:12 -0000      1.2
  @@ -117,7 +117,7 @@
   
                                info.Operations.Add(new ManagementOperation("Start"));
                                info.Operations.Add(new ManagementOperation("Stop"));
  -                             info.Attributes.Add(new ManagementAttribute("Port"));
  +                             info.Attributes.Add(new ManagementAttribute("Port", 
typeof(int)));
   
                                return info;
                        }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/Components/DummyLifecycledService.cs
  
  Index: DummyLifecycledService.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions.Test.Components
  {
        using System;
  
        using NUnit.Framework;
  
        using Apache.Avalon.Castle.ManagementExtensions;
  
        /// <summary>
        /// Summary description for DummyLifecycledService.
        /// </summary>
        [ManagedComponent]
        public class DummyLifecycledService : MRegistrationListener
        {
                private int state = 0;
                
                public int beforeRegisterCalled;
                public int afterRegisterCalled;
                public int beforeDeregisterCalled;
                public int afterDeregisterCalled;
  
                public DummyLifecycledService()
                {
                }
  
                [ManagedOperation]
                public void Start()
                {
                }
  
                [ManagedOperation]
                public void Stop()
                {
                }
  
                #region MRegistrationListener Members
  
                public void BeforeRegister(MServer server, ManagedObjectName name)
                {
                        Assertion.AssertNotNull(server);
                        Assertion.AssertNotNull(name);
  
                        beforeRegisterCalled = state++;
                }
  
                public void AfterDeregister()
                {
                        afterDeregisterCalled = state++;
                }
  
                public void AfterRegister()
                {
                        afterRegisterCalled = state++;
                }
  
                public void BeforeDeregister()
                {
                        beforeDeregisterCalled = state++;
                }
  
                #endregion
        }
  }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/Components/DummyService.cs
  
  Index: DummyService.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions.Test.Components
  {
        using System;
  
        /// <summary>
        /// Summary description for DummyService.
        /// </summary>
        [ManagedComponent]
        public class DummyService : ISomeService
        {
                public DummyService()
                {
                }
  
                #region ISomeService Members
  
                [ManagedOperation]
                public void DoWork()
                {
                }
  
                [ManagedAttribute]
                public int Port
                {
                        get
                        {
                                return 0;
                        }
                        set
                        {
                        }
                }
  
                #endregion
        }
  }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensionsTest/Components/ISomeService.cs
  
  Index: ISomeService.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions.Test.Components
  {
        using System;
  
        /// <summary>
        /// Summary description for ISomeService.
        /// </summary>
        public interface ISomeService
        {
                void DoWork();
  
                int Port
                {
                        get;
                        set;
                }
        }
  }
  
  
  
  1.2       +47 -2     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/AssemblyInfo.cs
  
  Index: AssemblyInfo.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/AssemblyInfo.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AssemblyInfo.cs   27 Dec 2003 03:13:29 -0000      1.1
  +++ AssemblyInfo.cs   28 Dec 2003 18:57:12 -0000      1.2
  @@ -1,3 +1,50 @@
  +// ============================================================================
  +//                   The Apache Software License, Version 1.1
  +// ============================================================================
  +// 
  +// Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  +// 
  +// Redistribution and use in source and binary forms, with or without modifica-
  +// tion, are permitted provided that the following conditions are met:
  +// 
  +// 1. Redistributions of  source code must  retain the above copyright  notice,
  +//    this list of conditions and the following disclaimer.
  +// 
  +// 2. Redistributions in binary form must reproduce the above copyright notice,
  +//    this list of conditions and the following disclaimer in the documentation
  +//    and/or other materials provided with the distribution.
  +// 
  +// 3. The end-user documentation included with the redistribution, if any, must
  +//    include  the following  acknowledgment:  "This product includes  software
  +//    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  +//    Alternately, this  acknowledgment may  appear in the software itself,  if
  +//    and wherever such third-party acknowledgments normally appear.
  +// 
  +// 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  +//    must not be used to endorse or promote products derived from this  software 
  +//    without  prior written permission. For written permission, please contact 
  +//    [EMAIL PROTECTED]
  +// 
  +// 5. Products  derived from this software may not  be called "Apache", nor may
  +//    "Apache" appear  in their name,  without prior written permission  of the
  +//    Apache Software Foundation.
  +// 
  +// THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  +// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  +// FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  +// APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  +// INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  +// DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  +// OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  +// ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  +// (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  +// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  +// 
  +// This software  consists of voluntary contributions made  by many individuals
  +// on  behalf of the Apache Software  Foundation. For more  information on the 
  +// Apache Software Foundation, please see <http://www.apache.org/>.
  +// ============================================================================
  +
   using System.Reflection;
   using System.Runtime.CompilerServices;
   
  @@ -9,9 +56,7 @@
   [assembly: AssemblyCopyright("")]
   [assembly: AssemblyTrademark("")]
   [assembly: AssemblyCulture("")]              
  -
   [assembly: AssemblyVersion("1.0.0.0")]
  -
   [assembly: AssemblyDelaySign(false)]
   [assembly: AssemblyKeyFile("")]
   [assembly: AssemblyKeyName("")]
  
  
  
  1.2       +56 -1     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/MServerFactory.cs
  
  Index: MServerFactory.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/MServerFactory.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MServerFactory.cs 27 Dec 2003 03:13:29 -0000      1.1
  +++ MServerFactory.cs 28 Dec 2003 18:57:12 -0000      1.2
  @@ -48,6 +48,7 @@
   namespace Apache.Avalon.Castle.ManagementExtensions
   {
        using System;
  +     using System.Collections;
        using System.Configuration;
        using System.Security.Policy;
   
  @@ -60,6 +61,9 @@
        {
                public static readonly String CustomServerConfigurationKey = 
"MServerFactory";
   
  +             private static readonly Hashtable domains = Hashtable.Synchronized(
  +                     new Hashtable(CaseInsensitiveHashCodeProvider.Default, 
CaseInsensitiveComparer.Default));
  +
                private MServerFactory()
                {
                }
  @@ -89,6 +93,11 @@
                                throw new ArgumentNullException("domain");
                        }
   
  +                     if (domains.Contains(domain))
  +                     {
  +                             throw new DomainAlreadyExistsException(domain);
  +                     }
  +
                        String typeName = 
ConfigurationSettings.AppSettings[CustomServerConfigurationKey];
                        Type serverType = null;
   
  @@ -129,6 +138,10 @@
                                object remoteInstance = 
newDomain.CreateInstanceAndUnwrap(
                                        serverType.Assembly.FullName, 
serverType.FullName);
   
  +                             // Register the domain
  +
  +                             domains.Add(domain, new DomainInfo( domain, 
remoteInstance as MServer, newDomain) );
  +
                                // As this already method "unwraps" the target object, 
its safe
                                // to return it - in an "wrapped" object we should 
invoke the 
                                // class's constructor
  @@ -139,6 +152,10 @@
                        {
                                object localInstance = 
Activator.CreateInstance(serverType);
   
  +                             // Register the domain
  +
  +                             domains.Add(domain, new DomainInfo( domain, 
localInstance as MServer ) );
  +
                                return (MServer) localInstance;
                        }
                }
  @@ -152,8 +169,46 @@
                {
                        if (server != null)
                        {
  -                             // TODO: Release (unload) the server's appdomain, if 
exists
  +                             foreach(DomainInfo info in domains.Values)
  +                             {
  +                                     if (info.Server == server)
  +                                     {
  +                                             domains.Remove( info.Name );
  +
  +                                             if (info.DedicatedDomain != null)
  +                                             {
  +                                                     AppDomain.Unload( 
info.DedicatedDomain );
  +                                             }
  +
  +                                             break;
  +                                     }
  +                             }
                        }
  +             }
  +     }
  +
  +     /// <summary>
  +     /// Holds registered domains information.
  +     /// </summary>
  +     class DomainInfo
  +     {
  +             public String Name;
  +             public AppDomain DedicatedDomain;
  +             public MServer Server;
  +
  +             private DomainInfo(String name)
  +             {
  +                     this.Name = name;
  +             }
  +
  +             public DomainInfo(String name, MServer Server) : this(name)
  +             {
  +                     this.Server = Server;
  +             }
  +
  +             public DomainInfo(String name, MServer Server, AppDomain domain) : 
this(name, Server)
  +             {
  +                     this.DedicatedDomain = domain;
                }
        }
   }
  
  
  
  1.2       +24 -10    
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/ManagementInfo.cs
  
  Index: ManagementInfo.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/ManagementInfo.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ManagementInfo.cs 27 Dec 2003 03:13:29 -0000      1.1
  +++ ManagementInfo.cs 28 Dec 2003 18:57:12 -0000      1.2
  @@ -158,19 +158,27 @@
        [Serializable]
        public class ManagementAttribute : ManagementObject
        {
  -             public ManagementAttribute()
  -             {
  -             }
  +             protected Type type;
   
  -             public ManagementAttribute(String name)
  +             public ManagementAttribute(String name, Type attType)
                {
                        Name = name;
  +                     type = attType;
                }
   
  -             public ManagementAttribute(String name, String description)
  +             public ManagementAttribute(String name, String description, Type 
attType)
                {
                        Name = name;
                        Description = description;
  +                     type = attType;
  +             }
  +
  +             public Type AttributeType
  +             {
  +                     get
  +                     {
  +                             return type;
  +                     }
                }
        }
   
  @@ -178,30 +186,36 @@
        /// 
        /// </summary>
        [Serializable]
  -     public class ManagementObjectCollection : DictionaryBase, IEnumerable
  +     public class ManagementObjectCollection : NameObjectCollectionBase, IEnumerable
        {
  -             public ManagementObjectCollection()
  +             public ManagementObjectCollection() : 
  +                     base(CaseInsensitiveHashCodeProvider.Default, 
CaseInsensitiveComparer.Default)
                {
                }
   
                public void Add(ManagementObject obj)
                {
  -                     base.InnerHashtable.Add(obj.Name, obj);
  +                     base.BaseAdd(obj.Name, obj);
                }
   
                public ManagementObject this[String name]
                {
                        get
                        {
  -                             return (ManagementObject) base.InnerHashtable[name];
  +                             return (ManagementObject) base.BaseGet(name);
                        }
                }
   
  +             public bool Contains(String name)
  +             {
  +                     return BaseGet(name) != null;
  +             }
  +
                #region IEnumerable Members
   
                public new IEnumerator GetEnumerator()
                {
  -                     return base.InnerHashtable.Values.GetEnumerator();
  +                     return base.BaseGetAllValues().GetEnumerator();
                }
   
                #endregion
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/MRegistrationListener.cs
  
  Index: MRegistrationListener.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions
  {
        using System;
  
        /// <summary>
        /// Summary description for MRegistrationListener.
        /// </summary>
        public interface MRegistrationListener
        {
                void BeforeRegister(MServer server, ManagedObjectName name);
  
                void AfterRegister();
  
                void BeforeDeregister();
  
                void AfterDeregister();
        }
  }
  
  
  
  1.3       +87 -7     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MDefaultRegistry.cs
  
  Index: MDefaultRegistry.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MDefaultRegistry.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MDefaultRegistry.cs       27 Dec 2003 15:33:32 -0000      1.2
  +++ MDefaultRegistry.cs       28 Dec 2003 18:57:12 -0000      1.3
  @@ -54,12 +54,20 @@
        /// TODO: Implement a lyfecycle for registering managed components.
        /// </summary>
        [ManagedComponent]
  -     public class MDefaultRegistry : MRegistry
  +     public class MDefaultRegistry : MarshalByRefObject, MRegistry
        {
                protected DomainCollection domains = new DomainCollection();
   
  -             public MDefaultRegistry()
  +             protected MServer server;
  +
  +             public MDefaultRegistry(MServer server)
                {
  +                     if (server == null)
  +                     {
  +                             throw new ArgumentNullException("server");
  +                     }
  +
  +                     this.server = server;
                }
   
                #region MRegistry Members
  @@ -115,14 +123,29 @@
   
                        Entry entry = new Entry(instance, dynamic);
   
  -                     lock(domain)
  +                     try
                        {
  -                             if (domain.Contains(name))
  +                             MRegistrationListener registration = instance as 
MRegistrationListener;
  +
  +                             InvokeBeforeRegister(registration, name);
  +
  +                             lock(domain)
                                {
  -                                     throw new 
InstanceAlreadyRegistredException(name.ToString());
  +                                     if (domain.Contains(name))
  +                                     {
  +                                             throw new 
InstanceAlreadyRegistredException(name.ToString());
  +                                     }
  +
  +                                     domain.Add(name, entry);
                                }
   
  -                             domain.Add(name, entry);
  +                             InvokeAfterRegister(registration);
  +                     }
  +                     catch(Exception e)
  +                     {
  +                             domain.Remove(name);
  +
  +                             throw e;
                        }
   
                        return new ManagedInstance(instance.GetType().FullName, name);
  @@ -168,7 +191,18 @@
                        try
                        {
                                Domain domain = FindDomain(domainName);
  -                             domain.Remove(name);
  +                             Entry entry = domain[name];
  +
  +                             if (entry != null)
  +                             {
  +                                     MRegistrationListener listener = 
entry.Instance as MRegistrationListener;
  +
  +                                     InvokeBeforeDeregister(listener);
  +
  +                                     domain.Remove(name);
  +
  +                                     InvokeAfterDeregister(listener);
  +                             }
                        }
                        catch(InvalidDomainException)
                        {
  @@ -314,6 +348,52 @@
                        }
   
                        return entry;
  +             }
  +
  +             private void InvokeBeforeRegister(MRegistrationListener listener, 
ManagedObjectName name)
  +             {
  +                     if (listener != null)
  +                     {
  +                             listener.BeforeRegister(server, name);
  +                     }
  +             }
  +
  +             private void InvokeAfterRegister(MRegistrationListener listener)
  +             {
  +                     if (listener != null)
  +                     {
  +                             listener.AfterRegister();
  +                     }
  +             }
  +
  +             private void InvokeBeforeDeregister(MRegistrationListener listener)
  +             {
  +                     if (listener != null)
  +                     {
  +                             try
  +                             {
  +                                     listener.BeforeDeregister();
  +                             }
  +                             catch(Exception)
  +                             {
  +                                     // An exception here shall not stop us from 
continue
  +                             }
  +                     }
  +             }
  +
  +             private void InvokeAfterDeregister(MRegistrationListener listener)
  +             {
  +                     if (listener != null)
  +                     {
  +                             try
  +                             {
  +                                     listener.AfterDeregister();
  +                             }
  +                             catch(Exception)
  +                             {
  +                                     // An exception here shall not stop us from 
continue
  +                             }
  +                     }
                }
        }
   }
  
  
  
  1.3       +2 -12     
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MDefaultServer.cs
  
  Index: MDefaultServer.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MDefaultServer.cs,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MDefaultServer.cs 27 Dec 2003 15:33:32 -0000      1.2
  +++ MDefaultServer.cs 28 Dec 2003 18:57:12 -0000      1.3
  @@ -59,19 +59,9 @@
   
                public MDefaultServer()
                {
  -                     registry = new Default.MDefaultRegistry();
  +                     // TODO: Allow customisation of MRegistry
   
  -                     SetupRegistry();
  -             }
  -
  -             public MDefaultServer(MRegistry registry)
  -             {
  -                     if (registry == null)
  -                     {
  -                             throw new ArgumentNullException("registry");
  -                     }
  -
  -                     this.registry = registry;
  +                     registry = new Default.MDefaultRegistry(this);
   
                        SetupRegistry();
                }
  
  
  
  1.2       +1 -1      
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MInspector.cs
  
  Index: MInspector.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/MInspector.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MInspector.cs     27 Dec 2003 03:13:29 -0000      1.1
  +++ MInspector.cs     28 Dec 2003 18:57:12 -0000      1.2
  @@ -153,7 +153,7 @@
   
                                        ManagedAttributeAttribute att = 
(ManagedAttributeAttribute) atts[0];
   
  -                                     ManagementAttribute attribute = new 
ManagementAttribute(minfo.Name, att.Description);
  +                                     ManagementAttribute attribute = new 
ManagementAttribute(minfo.Name, att.Description, minfo.PropertyType);
   
                                        info.Attributes.Add(attribute);
                                }
  
  
  
  1.2       +1 -1      
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/Strategy/ReflectionInvokerStrategy.cs
  
  Index: ReflectionInvokerStrategy.cs
  ===================================================================
  RCS file: 
/home/cvs/avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Default/Strategy/ReflectionInvokerStrategy.cs,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ReflectionInvokerStrategy.cs      27 Dec 2003 03:13:29 -0000      1.1
  +++ ReflectionInvokerStrategy.cs      28 Dec 2003 18:57:12 -0000      1.2
  @@ -164,7 +164,7 @@
   
                        ManagementAttribute attribute = (ManagementAttribute) 
info.Attributes[name];
   
  -                     if (attribute != null)
  +                     if (attribute == null)
                        {
                                throw new 
InvalidOperationException(String.Format("Attribute {0} doesn't exists.", name));
                        }
  
  
  
  1.1                  
avalon-sandbox/avalon-net/Castle/CastleManagementExtensions/Exception/DomainAlreadyExistsException.cs
  
  Index: DomainAlreadyExistsException.cs
  ===================================================================
  // ============================================================================
  //                   The Apache Software License, Version 1.1
  // ============================================================================
  // 
  // Copyright (C) 2002-2003 The Apache Software Foundation. All rights reserved.
  // 
  // Redistribution and use in source and binary forms, with or without modifica-
  // tion, are permitted provided that the following conditions are met:
  // 
  // 1. Redistributions of  source code must  retain the above copyright  notice,
  //    this list of conditions and the following disclaimer.
  // 
  // 2. Redistributions in binary form must reproduce the above copyright notice,
  //    this list of conditions and the following disclaimer in the documentation
  //    and/or other materials provided with the distribution.
  // 
  // 3. The end-user documentation included with the redistribution, if any, must
  //    include  the following  acknowledgment:  "This product includes  software
  //    developed  by the  Apache Software Foundation  (http://www.apache.org/)."
  //    Alternately, this  acknowledgment may  appear in the software itself,  if
  //    and wherever such third-party acknowledgments normally appear.
  // 
  // 4. The names "Jakarta", "Avalon", "Excalibur" and "Apache Software Foundation"  
  //    must not be used to endorse or promote products derived from this  software 
  //    without  prior written permission. For written permission, please contact 
  //    [EMAIL PROTECTED]
  // 
  // 5. Products  derived from this software may not  be called "Apache", nor may
  //    "Apache" appear  in their name,  without prior written permission  of the
  //    Apache Software Foundation.
  // 
  // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
  // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  // FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
  // APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
  // INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
  // DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
  // OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
  // ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
  // (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
  // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  // 
  // This software  consists of voluntary contributions made  by many individuals
  // on  behalf of the Apache Software  Foundation. For more  information on the 
  // Apache Software Foundation, please see <http://www.apache.org/>.
  // ============================================================================
  
  namespace Apache.Avalon.Castle.ManagementExtensions
  {
        using System;
  
        /// <summary>
        /// Summary description for DomainAlreadyExistsException.
        /// </summary>
        [Serializable]
        public class DomainAlreadyExistsException : System.Exception
        {
                public DomainAlreadyExistsException(String domain) : base(domain)
                {
                }
        }
  }
  
  
  

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

Reply via email to