java - AOP for third-party classes -


I have used AOP within spring, there is no real problem, mainly for transaction management, for which it is a Works of attraction

My question is ... The examples I have seen for AOP have so far been to point to a client whom you have created yourself in a third party library. It is possible to point out a class, for example the database connection Rg. The reference is that I want to create some logs and gather information when an oracle data source calls the database, which is unfortunately contained within the heap of the oracle class files. How will you direct this class / method when SQL is executed?

I think this will work: <

  • To start your datacours
  • Apply one aspect against the getConnection () method on your datasource
  • In your advice, return a new category ("logging connection") Connection that applies and assigns all methods for a "real" wrapped connection (I believe this is a decorator pattern)
  • which Mr. logging code you "Logingknekshn" Class
  • Keep in mind that this approach creates a proxy of the original data source and the representatives for each method call. In the context of database operation it should not create too much overhead. You want to be very careful what your code is doing, not to throw an exception and stop the connection from behaving appropriately. Perhaps try / hold / use at the end and call the call to "real" connection representatives in your last block.

    Using another completely different approach aspect and knitting load-time will be done. In this way you can decorate the class with classroom functionality and load the class loader as well.


    Comments