Not possible at this time as in JBoss, entity class implementations are generated at runtime and that classloader isn't set up for dynamic loadtime transformations at this time.
$instanceof would work, except for the above problem. Sorry.
What you can do is do traditional JBoss interceptors. see standardjboss.xml and you'll see both client and serverside stacks.
Thanks. Maybe I should AOPize the EntityEJB cache instead of AOPizing the entityEJB itself.
I am trying to manipulate some attributes of certain entityEJBs of a J2EE application in a way transparent to the J2EE application. For example, when a CreditCard entityEJB is created the first time, its credit card attribute is encrypted before being storing to database. When the credit card owner or other authorized user accesses the credit card info, the credit card attribute is decrypted.
I am thinking of AOPizing the entityInstancePool or any cache used for entity EJBs. But I am not sure whether it's feasible or it will violate any spec.
By the way, I check the latest JBoss source code and 3.0.x document trying to understand how the entity EJBs are initialized and put in the cache. I don't quite understand the process and classes used by EJB container. Can anyone give me a direction where to look?
Thanks in advance.
This can be solved with an EJB entity bean server-side interceptor. Just have a specific interceptor that checks wither it is a setCCNum or getCCNum and do your thing.
Or maybe you need to be App Server agnostic? Then you're probably screwed.
But these entityEJB setter/getter methods are abstract methods and are not
AOPized now. Is there any other Interceptor which can intercept any setter/getter methods of entity EJB?
Again, look in:
Search for interceptor
Server side interpceptors for Entity beans have been available since JBoss 2.0.
Our forpay doco should also have examples of implementing an interceptor. (I know there is at least a lab in our advanced training for this).
But, if you're stuck with trying to implement a appserver agnostic solution, you are screwed.