[jboss-dev-forums] [Design the new POJO MicroContainer] - Re: Case sensitivity in injecting a bean's property

scott.stark@jboss.org do-not-reply at jboss.com
Mon Jan 22 15:31:40 EST 2007


Then we need to look at how the kernel behaves with beans like:


  | public class BeanWithStates
  | {
  |    public String getstate()
  |    {
  |       return "state";
  |    }
  |    public void setstate(String s)
  |    {
  |    }
  | 
  |    public int getState()
  |    {
  |       return 0;
  |    }
  |    public void setState(int s)
  |    {
  |    }
  | }
  | 

The java.beans.Introspector does not pickup different properties state and State for this:

  | package javabean;
  | 
  | import java.beans.BeanInfo;
  | import java.beans.Introspector;
  | import java.beans.PropertyDescriptor;
  | 
  | import org.junit.Test;
  | 
  | public class TestIntrospector
  | {
  |    @Test
  |    public void testBeanPropertyCase()
  |       throws Exception
  |    {
  |       BeanInfo beanWithStatesInfo = Introspector.getBeanInfo(BeanWithStates.class);
  |       PropertyDescriptor[] props = beanWithStatesInfo.getPropertyDescriptors();
  |       System.out.println("BeanWithStates properties:");
  |       for(PropertyDescriptor p : props)
  |       {
  |          System.out.println(p.getName()+", read: "+p.getReadMethod()+", write: "+p.getWriteMethod());
  |       }
  |    }
  | }
  | 
  | BeanWithStates properties:
  | class, read: public final native java.lang.Class java.lang.Object.getClass(), write: null
  | state, read: public java.lang.String javabean.BeanWithStates.getstate(), write: public void javabean.BeanWithStates.setstate(java.lang.String)
  | 

Instead, it only finds state, but does use the setter/getter that is consistent with the mbean naming conventions. I guess one would have to supply a class level java.beans.BeanInfo to have access to both state and State as properties.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004985#4004985

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4004985



More information about the jboss-dev-forums mailing list