I have a jar file, which is used by 2 different applications. In this jar file a have some models annotated with special annotation:
public interface Component {
// title, image and other properties
String getId();
}
@ComponentToParse
public class Component1 implements Component {
//
}
@ComponentToParse
public class Component2 implements Component {
//
}
In first application these models are listed into ComboBox and then id of selected component is copied to clipboard;
In second application i click paste and need to create this Component by id.
So, i need at least two classes:
- Class, which returns all components or return components by some category etc.(DAO, Repository etc)
- Class, which creates components by id.
My current solution is:
- ComponentsRepository (implementation of Repository, has getAll(), getByCategory() and others), it calls ComponentsFactory.createAll() when constructs.
- ComponentsFactory (implementation of Factory, has create(String id) and createAll which return list of all Components). In this class i use reflection methods.
But i think createAll in factory is very bad solution.
What is the correct way to do this?
Aucun commentaire:
Enregistrer un commentaire