This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Introspector calling the Base Class multiple times

 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am having a Java Bean C (which extends B which in turn extends A) ...and each of these Classes have the BeanInfo classes .. ABeanInfo , BBeanInfo , CBeanInfo....


And i had written my beaninfos such a way that they are optimised by extending the basebeaninfo and calling super.getPropertyDescriptors and adding them to the Descriptoirs of extra methods like

Class A
{
private String name;
public void getName()
{
}
}

Class B extends A
{
private String city ;
public void getCity
{
}
}

class ABeanInfo extends SimpleBeanInfo
{
public PropertyDescriptors[] getPropertyDescriptors()
{
// Got the property descriptor for name
// return by forming array
}
}

My Class B bean info will look like this

class BBeanInfo extends ABeanInfo
{
public PropertyDescriptors[] getPropertyDescriptors()
{
PropertyDescriptors[] baseDesc = super.getPropertyDescriptors();
// Get the property descriptor for City
// Club the base class desc and the new ones added
// return by forming array
}
}


But when i use Introspector.getBeanInfo(B.class) , the A.getPropertyDescriptors method is getting called twice (One internally by the introspector and the other when my super.get...)

How can this be avoided ?? Ofcourse after the first time , the introspector is caching the instances of BeanInfos...

If this is the implicit behaviour , can i change my BeanInfo classses in such a way that it won't get called
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic