Skip navigation
2015

This feature has been implemented in the master branch for a while (Weld 3 alpha releases), but now it has been backported into the 2.2 branch and 2.2.10.Final is the first stable version of Weld with this simplified and unified configuration.

 

The Problem

Up to now, the configuration of Weld was a little bit difficult to use. There are several configurable components, each one was using a specific source of configuration (system property, marker file, properties file, etc.). The idea of WELD-1791 was to unify the configuration and still remain backward compatible if possible.

 

The Solution

First, every configurable option has a configuration key associated. There is a single place where all configuration keys are defined - see the org.jboss.weld.config.ConfigurationKey javadoc or 19.1. Weld configuration. Each configuration property (e.g. value for a configuration key) can be specified:

  1. in a properties file named weld.properties (highest priority),
  2. as a system property,
  3. by a bootstrap configuration provided by an integrator (lowest priority).

If a configuration key is set in multiple sources (e.g. as a system property and in a properties file), the value from the source with higher priority is taken, other values are ignored. Unsupported configuration keys are also ignored. On the other hand, if an invalid configuration property value is set (e.g. the key expects an integer and recieves a string), the container automatically detects the problem and treats it as a deployment problem.

 

Example

Say we want to disable the concurrent deployment, so that Weld loads and deploys beans sequentially (19.1.2. Concurrent deployment configuration). At the same time, we'd like to enable the relaxed construction (feature previously called "unsafe proxies"; 19.1.1. Relaxed construction). And finally, we would also like to dump the generated bytecode of client proxies and enhanced subclasses (19.1.6. Debugging generated bytecode).

 

Before

What do we need to do in Weld before 2.2.10?

  1. Concurrent deployment - create a properties file org.jboss.weld.bootstrap.properties and set concurrentDeployment key to false (or use integrator API)
  2. Relaxed construction - create a marker file META-INF/org.jboss.weld.enableUnsafeProxies
  3. Dump generated bytecode - set system property org.jboss.weld.proxy.dump to the desired path

 

Now

The simplest solution would be to create a file named weld.properties and place it on the classpath:

org.jboss.weld.bootstrap.concurrentDeployment=false
org.jboss.weld.construction.relaxed=true
org.jboss.weld.proxy.dump=/home/mkouba/proxies






Of course, we could also use system properties or integrator API for all or some of the keys.

 

Exceptions

Unfortunately, there are always exceptions. First, for org.jboss.weld.xml.disableValidating key it's only possible to use system properties. However, this key is rather obscure and will not be used very often. Also web-specific settings are not part of the "core" configuration (e.g. 19.3. Mapping CDI contexts to HTTP requests).

Filter Blog

By date:
By tag: