> If I've well understood, every time there is an invocation on the bean
> instance the thread ctx CL (TCCL) must be set to the container CL (CCL),
as
> you suggested above (so for example all the ejbXXX methods, the new
> isModified, etc). My questions:
> 1) how much other code should have the TCCL set to the CCL ? I mean: the
fix
> made in the synchronization int'r in beforeCompletion uses the TCCL not
only
> for the isModified invocation, but also for storeEntity. This calls
ejbStore
> (with the TCCL set to the CCL, which is OK) but also store.storeEntity:
> should this last call have the TCCL set to the CCL or it does not matter ?

That code has the right TCCL since the container invoker sets it. Its only
when threads change (as in commit phase) or if separate threads are used (as
in the passivation).

> What if loads classes doing its job ?
> 2) Which classloader should I use to load classes in initialization code ?
> For example, I load the cache policy class and invoke its constructor
using
> reflection, which CL should I use ? It is enough getClass().forName(cls)
or
> I should use the TCCL (that I should set to which CL ?) ?

Class.forName() is sufficient.

> Question 1 arises from the fact that I could set the TCCL to the CCL
before
> calling contaner.getPersistenceManager.passivate(activate)Entity(Session),

Yes, you should.

> but this can be done once and cleanly in the persistence manager, better
> than in many places that call the persistence manager, what do you think ?

No, since it may already be set before the PM is called, and in those cases
it will be set doubly which is unnecessary.

/Rickard



Reply via email to