I have a class X which has say do method.
I have another two classes A & B in which object of X is created.
Is there any way by which I can find out whether x’s do() is getting called by A or B.
I do not want to use parameter in do() method. Anything from call trace or something?
I am using struts2, Spring. So any help from frameworks???
I want to implement some logic in do() based on whether its called from A or B.
I understand this looks wired but existing logic will can be quickly tweeted to work for this.
The scenario is,
I have two actions A & B which calls the service X.
X is intercepted by Spring AOP to add filters and passed to DAO’s.
If A calls X then show all data i.e do not apply filter, if B calls X then show data only of logged in user.
X is already intercepted for adding some other filters, so it will be easy to add one more filter. Also this filter is present centrally so all A’s or B’s call X and thus X will do the work accordingly.
I found much better way here, have a instance variable inside X and A’s instance of X will have value ‘a’ and so on.
So now I will be able to distinguish between A’s call of X and B’s call of X.
Does it make sense?