Description
As proposed to the CDI EG for the CDI-2.0 specification.
Sometimes you have to provide a producer for a class with non-private, non-static final classes. In those cases the CDI spec defines that a UnproxyableResolutionException needs to be thrown. And for a good reason. Usually this should be avoided but sometimes the code containing those final methods is not under your control. E.g. ThreadPoolExecutor, ConcurrentHashMap as of Java7 or if you need to integrate with some legacy applications.
In all those cases it would be great to have an exclude list for that rule.
The mechanism proposed to the CDI EG is to have a 2-phase configuration:
1.) system.env and system.settings to define 'global' allowProxying classes. This is needed if the whole deployable is not under your control. E.g. when installing a WAR or EAR which contains a ConcurrentHashMap producer on a container running Java7 or later. Usage:
-Djavax.enterprise.inject.allowProxying.classes=com.acme.MyClass1,org.some.OtherClass
and
export JAVAX_ENTERPRISE_INJECT_ALLOWPROXYING_CLASSES=net.some.OtherClass3,com.acme.YetAnotherClass
2.) Adding the allow in some beans.xml. This is for cases where you have to integrate another jar or class which is not under your control but the app itself is yours.
<beans> <allowProxying> <class>net.some.MoreClass</class> </allowProxying> </beans>
All the given classes will simply get added to to a big Set<String> at boot time and for those classes the UnproxyableResolutionException will get supressed. (We might log out an info msg instead).
Attachments
Issue Links
- incorporates
-
OWB-1105 add an exclude list config for classes which have final methods but shall considered proxyable nonetheless
- Closed