views:

71

answers:

1

Hi I Have a XML and I am using commons-digester1.8 to create a object of my bean. My bean contains a reference to another Bean which is singleton. Is there any way I can create/get the reference of singleton object and get my bean populated.

My xml contains <>/language tag and for this tag bean has Language.class reference. Language.class is singleton and to get the instance of Language.class, I have to call getInstance(String name) of language class. But When I try d.addObjectCreate("rights/language",Language.class); d.addCallMethod("rights/language", "getInstance",1); d.addCallParam("rights/language",0); It gives an error. Is there a way to achieve this. Thanks, Gagan

A: 

Usually with the singleton design pattern/(design flaw) there's a static method on the class for getting the instance of the singleton:

Language language = Language.getInstance();
language.doSomething();

You seem to be messing round with reflection, is there more to this than you're letting on.

Tom