Hi all.
I`m writing simplest factory context that takes class name as
String , analyze annotations of this class , instantiate this class , run needed methods of this instance and finally return this instance outside.
I also has requirements to implement destroy() method of the factory context, that will go through all spawned instances and run their respective destroy methods .
My current bottleneck is :
when i instantiate class instance from factory context, i save it inside HashMap in key field as Object and return it outside.
Later, when i need to run destroy on each instance, i`m going through HashMap keys , and at this point, i need to figure out what type each Object is to call its destroy() method.
Because without casting it to this type, i cannot see that such method eve exist.
My question is, how can i save type of the instance in any container in order to use it in the cast later ?
I`ll try to put code here .