lundi 23 février 2015

Java code reflection and generation of façades for redirection of classes

I have a bunch of classes in a huge product that I do not want to use and instead I want to redirect their uses to different classes. These classes (and interfaces) are mostly logging classes. E.g., org.apache.log4j classes were (long time ago) taken and imported into source under different package name, like foo.org.apache.log4j.


Now, I want to use some of the components that use these imported and renamed classes but without these imported and renamed classes. This is because the imported source is old and lacks functionality, so I cannot use it as it is. Also, having two different log4j implementations, the old imported one and original log4j, creates problems during configuration, etc.


My battle plan, so far, is to exclude the undesirable dependencies in pom.xml and somehow auto-generate façades that would replace the undesirable classes and would redirect to the original library. E.g., foo.org.apache.log4j.Logger would be replaced by a façade that inherits from org.apache.log4j.Logger.


Now, is there any kind of library or tool that would make it easy to traverse all existing classes defined by foo.org.apache.log4j and allow me to generate these façades?






Aucun commentaire:

Enregistrer un commentaire