• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Introspector calling the Base Class multiple times

 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic