MetaData based annotations in EJB3 container
adrian.brock Nov 24, 2007 12:36 PMI've committed this change. It's not really the full thing.
Instead of using metadata directly, I've had to hack a subclass of AOP's
AnnotationRepository.
This is because
1) There are many places in EJB3 using the annotation repository directly
instead of advisor(container).resolveAnnotation or invocation.resolveAnnotation.
These just need fixing
2) The use of metadata rather than AnnotationRepository is not complete
in aop advisor's.
Both of these need fixing.
I also don't register the metadata in the metadata repository yet.
This is because I couldn't locate a reliable place to do the (un)register
where it wouldn't leak.
The ejb3 container lifecyle handling needs tidying up (defining properly?).
Anyway, what this gives is a simple hierarchy of metadata contexts.
There is the class context which just loads annotations from the bean class.
Above this is a more complicated instance context which has two retrievals
A normal MemoryMetaDataLoader which works like the old AnnotationRepository
and an EJBMetaDataLoader which loads from the metadata dynamically.
There is a test in the ejb3 project "changexml" which changes the SecurityDomain
in the xml metadata dynamically and shows you get a security exception
when you define one on an ejb that didn't previously have one.
Improvements to come:
Besides what is mentioned above, the the EJBMetaDataLoader could do with
some using the cache version of the MetaDataContext. I didn't do this
because there's no easy way in the current unified metadata to get a notification
when it changes so you can invalidate the cache.
There should also be other contexts like "application" and 'deployment"
where metadata can come from the ear or ejb.jar level.
e.g. There should also be a loader that loads the security domain annotation
from JBossMetaData.getSecurityDomain() which is a deployment level
rather than ejb level (which overrides it) config.
And potentially things like thread/transaction local contexts
so you could override certain metadata for just one invocation.
But before implementing that, things like the security annotations,
need meta annotating with
@org.jboss.metadata.spi.Restricted
such that you can't override security config this way. ;-)