So I made a simple program that allows you to create instances of a ton of classes. Now I'm responsible to send the instances created to a server. I really like the classes constructors so I really didn't want to alter them. How could I listen to this program so that I could know what classes were recently created, i was thinking in using reflection and maybe threads?
Here a shorter example of what i want to accomplish:
public class MainApplicaton{
public static void main(String []args){
ConnectServer.listenToCreatedInstances().
new Vase();
new Dog();
new House();
}
}
package stuff.components;
public class Human{
public Human(){
}
}
package stuff.components;
public class Dog{
public Dog(){
}
}
package stuff.components;
public class House{
public House(){
}
}
Now my listener thread:
public enum ConnectServer {
Server;
public void listenTocreatedIntances(){
//Something happens here
Class c ..
System.out.println("A instance of "+c.getName());
}
}
Aucun commentaire:
Enregistrer un commentaire