[jboss-dev-forums] [Design the new POJO MicroContainer] - AOP proxies and field injection
alesj
do-not-reply at jboss.com
Wed Mar 19 19:44:39 EDT 2008
I've added org.jboss.test.microcontainer.beans.test.FieldAccessTestCase test.
It checks how beans and field injection play when beans are aspectized.
What I've already mentioned
"alesj" wrote : "kabir.khan at jboss.com" wrote :
| | | if (o instanceof org.jboss.aop.proxy.container.AspectManaged)
| | | {
| | | //It is a proxy
| | | }
| | | else if (o instanceof org.jboss.aop.Advised)
| | | {
| | | //It is woven
| | | }
| | | else
| | | {
| | | //Plain class
| | | }
| | |
|
| Do we need such a check?
| e.g. JoinpointFactory
|
| | // perhaps name param is too much
| | boolean isFieldAccesible(Object target, String name);
| |
| Where AOPJpF would do the above mentioned check, and BasicJpF just returned true.
|
but got no response,
is what this test also exposes.
e.g. this is my simple bean
| public class AccessBean
| {
| public String pubString;
|
| public String getPubString()
| {
| return pubString;
| }
| }
|
and I do field injection
| <bean name="public" class="org.jboss.test.microcontainer.beans.support.AccessBean" access-mode="ALL">
| <property name="pubString">foobar</property>
| </bean>
|
but this is what could happen
| AccessBean pb = getBean("public", AccessBean.class);
| assertEquals("foobar", pb.pubString);
| AbstractTypeTestDelegate.Type type = getType("public");
| assertTrue(pb.getPubString() == null || type != AbstractTypeTestDelegate.Type.PROXY);
|
pb.pubString != pb.getPubString() if pb ~ proxy
Perhaps not knowing that my bean is gonna be matched by some pointcut, hence being aspectized, I'm using a mixture of direct public field access and getter. Expecting that using either is the same. Which is not the case here, as the example shows.
Leave it as it is, or hack something to fail or at least produce a loud warning?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4137928#4137928
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4137928
More information about the jboss-dev-forums
mailing list