From what I have read this isn't supported by the CDI spec:
But I was wondering if there is any way around this, for example some way to programmatically bind an interceptor to an object created in a producer method. I know I can create a wrapper object around my actual object, and assuming the wrapper object is itself a CDI bean, I can then intercept the calls to the wrapper object, but is there any other way to do this?
So I guess I should assume from the lack of replies that this isn't possible? Creating a delegate class works I guess. I think I understand why this wouldn't be supported as you wouldn't be able to use dynamic sub-classes, but wouldn't it be beneficial to support this with a proxy class if the producer method returns an interface? And are there any plans to do so?
AFAIK it's not supported indeed. But the wrapper/delegate class bean will work. I don't think there are any plans for this. Feel free to file a feature request and/or watch CDI-59 for any progress...
|Retrieving data ...|