As part of an structural refactor, we moved our application EAR building technique from a custom, weird Ant script to a full Maven solution.
The final structure used to be a EAR containing a single EJB build by merging two EJBs; the application core and the customer-specific implementation which may define some decorators.
The new structure we wanted to put in place was rather an EAR containing the two EJBs side-by-side. This works mostly as expected except for the interceptors and decorators.
In the customer-specific implementation, we define decorators that looks like this:
import javax.annotation.Priority;
import javax.decorator.Decorator;
import javax.decorator.Delegate;
import javax.inject.Inject;
import javax.interceptor.Interceptor;
@Decorator
@Priority(Interceptor.Priority.APPLICATION)
public class ServiceDecorator implements ServiceInterface {
@Inject
@Delegate
ServiceBean delegate;
Upon startup on Wildfly 10.1, Weld (2.3.5-Final, shipped with Wildfly) reports that the decorator is indeed enabled but it never seems to be able to bind the decorator to the service which reside in the core implementation.
DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-6) WELD-000104: Enabled decorator types for Weld BeanManager for /opt/wildfly/standalone/deployments/app.ear/core.jar [bean count=2]:
- class ServiceDecorator
[...]
DEBUG [org.jboss.weld.Bootstrap] (MSC service thread 1-6) WELD-000108: Decorator: Decorator [class ServiceDecorator] decorates [Service] with delegate type [ServiceBean] and delegate qualifiers [@Default]
We even tracked down the code in Weld core and we have indeed seen that the decorator is globally enabled () but never bound to the service since the core implementation bean manager does not see the decorator bean.
We also tried moving the decorator in a regular lib jar and got the same result. Interceptors were also attempted as well as using the @Specialize annotation, all to no avail...
So, in summary, is there any way to define a decorator or interceptor in an EJB to enhance the behavior of a service located in another EJB when both are contained in the same EAR?