Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Transient interceptors not being released
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Vladimir Okhotnikov  
View profile  
 More options Nov 6 2012, 3:59 am
From: Vladimir Okhotnikov <vokhotni...@gmail.com>
Date: Tue, 6 Nov 2012 10:59:35 +0200
Local: Tues, Nov 6 2012 3:59 am
Subject: Transient interceptors not being released
Hi

I have a following failing test in an empty project with Windsor 3.1 from NuGet:

        [Test]
        public void TransientInterceptor()
        {
            var interceptorCreated = false;
            var interceptorReleased = false;

            var c = new DefaultKernel();
            c.ComponentCreated += (model, instance) =>
            {
                if (model.Implementation == typeof(AnInterceptor))
                {
                    interceptorCreated = true;
                }
            };
            c.ComponentDestroyed += (model, instance) =>
            {
                if (model.Implementation == typeof(AnInterceptor))
                {
                    interceptorReleased = true;
                }
            };

            c.Register(
                Component.For<AComponent>().LifeStyle.Transient,
                Component.For<AnInterceptor>().LifeStyle.Transient);

            var component = c.Resolve<AComponent>();
            c.ReleaseComponent(component);

            Assert.IsTrue(interceptorCreated);
            Assert.IsTrue(interceptorReleased);
        }

        public class AnInterceptor : IInterceptor
        {
            public void Intercept(IInvocation invocation)
            {
                invocation.Proceed();
            }
        }

        [Interceptor(typeof(AnInterceptor))]
        public class AComponent
        {
            public virtual void Intercepted()
            {
            }
        }

The test fails on the very last line, i.e. ComponentDestroyed for the interceptor is never being called. Is it a bug or am I missing something?

Regards,
Vladimir Okhotnikov


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Okhotnikov  
View profile  
 More options Nov 6 2012, 4:04 am
From: Vladimir Okhotnikov <vokhotni...@gmail.com>
Date: Tue, 6 Nov 2012 01:04:07 -0800 (PST)
Local: Tues, Nov 6 2012 4:04 am
Subject: Re: Transient interceptors not being released

Oops, forgot that microkernel does not work with interceptors. Still, this
one fails:

        [Test]
        public void TransientInterceptor()
        {
            var interceptorCreated = false;
            var interceptorReleased = false;

            var c = new WindsorContainer();
            c.Kernel.ComponentCreated += (model, instance) =>
            {
                if (model.Implementation == typeof(AnInterceptor))
                {
                    interceptorCreated = true;
                }
            };
            c.Kernel.ComponentDestroyed += (model, instance) =>
            {
                if (model.Implementation == typeof(AnInterceptor))
                {
                    interceptorReleased = true;
                }
            };

            c.Register(
                Component.For<AComponent>().LifeStyle.Transient,
                Component.For<AnInterceptor>().LifeStyle.Transient);

            var component = c.Resolve<AComponent>();
            c.Kernel.ReleaseComponent(component);

            Assert.IsTrue(interceptorCreated);
            Assert.IsTrue(interceptorReleased);
        }

вторник, 6 ноября 2012 г., 10:59:53 UTC+2 пользователь Vladimir Okhotnikov
написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Krzysztof Kozmic  
View profile  
 More options Nov 6 2012, 4:04 am
From: Krzysztof Kozmic <krzysztof.koz...@gmail.com>
Date: Tue, 6 Nov 2012 19:04:06 +1000
Local: Tues, Nov 6 2012 4:04 am
Subject: Re: Transient interceptors not being released

Vladimir,

your interceptor wasn't released, because it was never tracked in the first place.
It's not disposable, has no custom decommission steps, and no dependencies that requires decommission.

There's no reason for it to be tracked.

--
Krzysztof Kozmic


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Vladimir Okhotnikov  
View profile   Translate to Translated (View Original)
 More options Nov 6 2012, 4:10 am
From: Vladimir Okhotnikov <vokhotni...@gmail.com>
Date: Tue, 6 Nov 2012 01:10:33 -0800 (PST)
Local: Tues, Nov 6 2012 4:10 am
Subject: Re: Transient interceptors not being released

Indeed, adding IDisposable makes the test pass. Many thanks, Krzysztof

вторник, 6 ноября 2012 г., 11:04:17 UTC+2 пользователь Krzysztof Koźmic
написал:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »