I am bit new to patterns and using them. So please pardon my dumb question.
I want to configure an object of a dependency class(say A.) once and use it through out my app. I tried making a singleton wrapper class on top of it, but failed miserably. I tried something like:
public class B {
public static A a = new A();
public static A getInstance() {
return a;
}
private B() {
a.configure();
}
}
I think calling B.getInstance() wont configure the object here. What i want here is to configure A's instance once and use it everywhere.
Would really appreciate help here. Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire