Hi;

I tested your concern about calling business method from constructor.Problem 
is that, I am creating Proxy for beans at first injection. After that this 
proxy instance is cached and reused after injections. So, its constructor is 
called at most once

Look at BeanManagerImpl#proxyMap and BeanManagerImpl#getReference


So I think that you are not able to execute any business method from 
constructor :) It is true that "instance" is not created by the JVM before 
going out from constructor.(This is reasonable from Java Language side!)

Thanks;

--Gurkan



________________________________
From: Eric Covener <[email protected]>
To: [email protected]
Sent: Thu, October 29, 2009 3:44:34 PM
Subject: intercepted methods called during constructor

I've been fooling around with Interceptors and noticed some
unintuitive  behavior when calling methods from a beans constructor
that should be intercepted.

For the first request, I see the shuffle method is intercepted.
Refreshing the JSP for a new RequestScoped instance of Foo causes no
interception at all!

@Named
@RequestScoped
public class Foo {

public Foo() {
...
shuffle();
}

@SomeInterceptorBinding
public void shuffle() {

}

}

If this is just undefined behavior, I think it's important to at least
make it internally consistent with respect what I guess is the re-use
of the proxy so we're either always/never intercepteed in this case.

Thoughts?

-- 
Eric Covener
[email protected]



      

Reply via email to