[jboss-dev-forums] [Design the new POJO MicroContainer] - enums, generics and other animals
adrian@jboss.org
do-not-reply at jboss.com
Thu Mar 6 05:09:19 EST 2008
I don't understand why there is an InjectOption and an InjectionOption?
The reason the ControllerState and ControllerMode are the way they are
is because the MC was originally written on JDK1.4
so they couldn't be written as enums.
Actually, since ControllerState is extensible (you can create your own states)
it can't be an Enum.
All of these should just be enums throughout
Cardinality
FromContext
InjectionOption (already is InjectOption???)
AutowireType
Since we are doing 2.0.0 we could also decde to change ControllerMode to an Enum
as well?
Also the FromContext is a misuse of generics.
The purpose of generics is to produce compile time errors, the way this class
is used, it is simply not possible for the compiler to do so.
It looks to me like the generic is only here to avoid having to manually code
the check/cast of ControllerContext -> KernelControllerContext
but you should do that by hand anyway to give a better error message than CCE
e.g. MetaDataFromContext
| public MetaData internalExecute(ControllerContext context)
| {
| if (context instanceof KernelControllerContext == false)
| throw new IllegalArgumentException("Cannot get metadata from context " + context);
| KernelControllerContext kernelContext = (KernelControllerContext) context;
| return kernelContext.getScopeInfo().getMetaData();
| }
|
In fact, this is wrong anyway, since you can get a ScopeInfo/Metadata
from any context. ;-)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134507#4134507
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4134507
More information about the jboss-dev-forums
mailing list