I was seeing a ScopeNotFoundException rather than an NPE I think, but
yeah, it happened when a component defaulted to STATELESS scope (in
the absence of an @Scope("MODULE")).  I talked with Jim and we came to
this fix together.

Just so's I understand what you're saying -- the problems you're
describing are theoretical at this point, right?  Because the current
scope factories are trivial in their "construction" (ie, the ctors
don't do anything, nor do the init methods), any races between
ctor/init completion & other code calling into the factory aren't
actually a problem (given the super class's ctor will always be
completed).

That said, agree the code should always do the right thing :)   My
understanding of component instantiation is ctor followed by init
method -- so we could store the injected ScopeFactory in the ctor and
do the register call in the init, and then clear the injected
ScopeFactory reference (avoiding circular references).   Is that what
you're suggesting by "waiting until their init method is called" ?
Jim & I also discussed a more complex solution involving making the
scope registry "watch" for newly created scope factories and register
them, but given the seriousness of the problem, having some solution
checked in seemed expedient.

BTW, does @Init work with inheritance?  Ie, if my super-class has a
method marked @Init, will that method get called before my @Init
method?


On 8/1/06, Jeremy Boynes <[EMAIL PROTECTED]> wrote:
Ken,

I think the factories should wait until their init method is called
otherwise they are registering before they have finished being
initialized. This also allows a "this" reference to leak before the
object has finished being constructed (i.e. it could be invoked
before it is fully instantiated). This problem is in all the recent
scope factory changes.

Will this fix the issue Ant mentioned yesterday where leaving off
@Scope("MODULE") gave a NPE?

--
Jeremy

  public class ModuleScopeObjectFactory implements
ObjectFactory<ModuleScopeContainer> {
+
+    public ModuleScopeObjectFactory(@Autowire ScopeRegistry registry) {
+        registry.registerFactory(Scope.MODULE, this);
+    }
+
+    @Init(eager = true)
+    public void init() {
+    }



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



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

Reply via email to