In our project, we have a class KnowledgeBaseManager, which gets used by other classes as follows:
KnowledgeBaseManager manager = KnowledgeBaseManager.get();
manager.foo();
KnowledgeBaseManager holds a static variable standardKnowledgeBaseManager which gets initialized when used for the first time:
class KnowledgeBaseManager {
private static KnowledgeBaseManager standardKnowledgeBaseManager = null;
public static KnowledgeBaseManager get() {
if (standardKnowledgeBaseManager == null) {
standardKnowledgeBaseManager = new KnowledgeBaseManager();
// initialize standardKnowledgeBaseManager with appropriate knowledge base
}
return standardKnowledgeBase;
}
Furthermore, we have a parametrized constructor
public static KnowledgeBaseManager get(OntModel model) {...}
which we use until now just for unit test, where we need a KnowledgeBaseManager with a test knowledge base in the background.
Now, we have the following challenge: For development, we want that the application uses a KB-manager with another knowledge base in the background (because of speed). To be more specific, we build a web application with Wicket. So we want to declare somewhere at the start of the app, which knowledge base and KnowledgeBaseManager is used in the application (depending on wheter we are in development or deployment). The code for using the KB-manager (like
KnowledgeBaseManager manager = KnowledgeBaseManager.get();
now) should not be changed for that.
The question is: what's the best architecture for that?
I was thinking on using a dependency injection framework like PicoContainer or Guice, but don't have any experience with it and I am not sure if that would be overhead for that particular problem. Any suggestions for best practices our case?