News - tagged as "release"

Weld 3.0.0.Beta1

2016-12-19   release   Martin Kouba

I am very pleased to announce the first Beta version of Weld 3.0.0 (CDI 2.0). See also the release details. Thanks to everyone involved in this release!

This is an important milestone. CDI 2.0 is now considered "feature complete" and so the next Weld 3 versions should be mostly dedicated to cleanup and optimization. The next version will be Weld 3.0.0.CR1 (ETA in mid January). Finally, we would like to release Weld 3.0.0.Final in early February.

New and noteworthy

  • javax.enterprise.inject.spi.InterceptionFactory implementation (WELD-2257)

  • ProcessSyntheticObserverMethod container lifecycle event (WELD-2279)

  • BeforeDestroyed event fired before a context is actually destroyed (WELD-2269)

  • "trimmed" bean archives (WELD-2268)

  • context control - ActivateRequestContext interceptor binding (WELD-2267) and RequestContextController built-in bean (WELD-2266)

  • ProcessSyntheticBean container lifecycle event (WELD-2265)

  • few proposals did not make it into CDI 2.0 and so we enhanced the Weld API:

    • org.jboss.weld.inject.WeldInstance (already part of Weld 2.4 API)

    • org.jboss.weld.interceptor.WeldInvocationContext allows to obtain a set of interceptor bindings for a lifecycle callback, business method, timeout method, or constructor (see also CDI-468)

    • org.jboss.weld.bootstrap.event.WeldAfterBeanDiscovery allows to obtain an InterceptorConfigurator to configure a new Interceptor bean

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.1.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.4.1.Final

2016-11-18   release   Martin Kouba

The development of Weld 3 (CDI 2) is underway. However, we don’t forget about the maintenance of the stable branch of Weld! So I am very pleased to announce the first bugfix version of Weld 2.4 (CDI 1.2). See also the release details. Thanks to everyone involved in this release!

Notable fixes and improvements:

  • removed false positive warning about Jandex version used (WELD-2231)

  • fixed Groovy support - only filter out relevant methods from Groovy objects when generating bean proxies (WELD-2255)

  • optimized proxy class generation for "large classes" (WELD-2244)

  • improved the way Weld configuration info is logged (WELD-2238)

  • Weld SE

    • added support for nested directories in uber jars, e.g. Spring Boot jar (WELD-2254)

    • allow to use CDI.getBeanManager() after BeforeBeanDiscovery is fired (WELD-2256)

    • don’t abort container initialization if JandexClassFileServices is unable to load an annotation (WELD-2232)

  • Weld Servlet - document the usage of org.jboss.weld.environment.container.class init param (WELD-2236)

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.1.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.4.0.Final

2016-9-13   release   Martin Kouba

I am very pleased to announce the first stable version of Weld 2.4 (CDI 1.2). See also the release details. From now on, 2.4 is the current stable version of Weld and 2.3 is not actively developed anymore. Thanks to everyone involved in this release!

Most of the new features were already introduced in First release candidate of Weld 2.4. To sum it up:

  • Removed dependency on com.google.guava:guava

  • Enhanced version of javax.enterprise.inject.Instance

  • Veto AnnotatedType not annotated with a bean defining annotation

  • @ActivateRequestScope interceptor binding moved to Weld API and renamed to @ActivateRequestContext

  • Improved rolling upgrades support

  • Events - reflect the output of CDI-494

  • Probe - allow to filter unused beans

  • Cleanup, cleanup, cleanup…​

  • Initial Java 9 support

Moreover, 2.4.0.Final allows to export the Probe development tool data (to be discussed in one of the following blog posts) and fixes a minor problem in non-EE environments (see also WELD-2227).

In the coming weeks, the Weld team is also going to publish "Weld tips" - a series of concise articles. The intention is to familiarize developers with less known Weld features. There will be no hot news, just useful existing features (repetition is the mother of wisdom ;-).

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.1.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


First release candidate of Weld 2.4

2016-8-19   release   Martin Kouba

I am pleased to announce the first release candidate of Weld 2.4 (CDI 1.2). See also the release details. Thanks to everyone involved in this release!

Removed dependency on com.google.guava:guava

Weld does not depend on com.google.guava:guava anymore (actually, Weld 3 does not depend on guava since 3.0.0.Alpha2). This significantly reduces the footprint of both Weld SE and Weld Servlet. The dependency is also not bundled with shaded artifacts for Weld SE and Weld Servlet.

Enhanced version of javax.enterprise.inject.Instance

Weld now provides org.jboss.weld.inject.WeldInstance - an enhanced version of javax.enterprise.inject.Instance. There are three additional methods - getHandler(), handlers() and isResolvable(). A handler allows to inspect the metadata of the relevant bean and to destroy the underlying contextual instance. isResolvable() is just a convenient method - a replacement for !isUnsatisfied() && !isAmbiguous(). For more details see also the reference guide.

WeldInstance is automatically available in Weld SE and Weld Servlet where the Weld API is always on the class path. It is also available in Weld-powered EE containers. In this case, users would have to compile their application against the Weld API and exclude the Weld API artifact from the deployment (e.g. use provided scope in Maven).

This functionality is based on a new proposal for CDI-589.

Veto AnnotatedType not annotated with bean defining annotation

Sometimes it might be useful to process all types during bootstrap, i.e. fire/observe ProcessAnnotatedType event for each Java class discovered, but veto types which are not annotated with a bean defining annotation. The main reason is that not all classes that meet all of the necessary conditions are intended to become beans. And so vetoing such types helps to conserve memory used by the container. Note that if you use bean-discovey-mode=annotated (implicit bean archive) then no ProcessAnnotatedType will be fired for any such type because it’s not discovered at all. And there might be portable extensions which use ProcessAnnotatedType to extract some important information from classes which are not beans.

Therefore, Weld allows to use bean-discovey-mode=all (explicit bean archive) and veto types without a bean defining annotation whose AnnotatedType#getJavaClass().getName() matches a regular expression. In other words, a type is vetoed if its name matches a regular expression and at the same time is not annotated with a bean defining annotation. This functionality is implemented as a built-in portable extension processing all types from all bean archives (it was already doable using an extension but we believe it’s more convenient to have this functionality out of the box).

This is a workaround for problems of bean-discovey-mode=annotated mentioned in CDI-420.

@ActivateRequestScope moved to Weld API

This interceptor binding can be used to activate the request scope within a business method invocation. It was previously part of the Weld SE but we believe it might be useful in any environment. See also WELD-2150.

Improved rolling upgrades support

Lenny Primak (a Weld community member - thanks for the report again!) struggled with rolling upgrades on certain application servers (Payara, GlassFish). Therefore, a new configuration property was introduced. This property allows to specify a delimiter which is used to abbreviate a bean archive identifier (which is usually derived from the archive name) before used as a part of an identifier of an internal component (such as bean). See also the reference guide and WELD-2064.

Events - reflect the output of CDI-494

This change reflects the clarification around Event operations - "A wildcard type is not considered an unresolvable type variable". See also WELD-2137 and CDI-494. Simply said, the snippet below and similar ones should now work:

@Inject Event<List<?>> event;
    
    public void fireLists() {
      List<String> stringList = new ArrayList<>();
      event.fire(stringList);
      List<Integer> intList = new ArrayList<>();
      event.fire(intList);
    }
    
    void observeAllLists(@Observes List<?> anyList) {
      // Will be notified
    }

Probe - allow to filter unused beans

The Probe development tool now identifies beans which are most likely unused (a bean is considered unused if it has no direct dependents, does not declare any observer or producer methods, is not annotated with @Named and is not a built-in bean, extension, interceptor or decorator). This might be useful to identify types suitable for vetoing as mentioned in [_veto_code_annotatedtype_code_not_annotated_with_bean_defining_annotation].

Cleanup

Weld has underwent an internal cleanup. A lot of deprecated and unused classes were removed.

Initial Java 9 support

It’s now possible to build Weld with Java 9. Note that this does not mean that Weld is modularized in a Jigsaw way. It’s just the first step on a long road ;-).

Bugs

Last but not least - a few bugs were killed. Weld SE - provided ClassLoader is also used to load extensions (WELD-2209). AnnotatedTypeValidator does consider extended interfaces (WELD-2221). Invocation of a JDK8 default method should be intercepted (this only works if using jboss-classfilewriter 1.2.0.Beta1+, WELD-2093).

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.3.5.Final

2016-7-1   release , plans   Martin Kouba

The next version of the stable 2.3 branch has been released! See also the release details. Thanks to everyone involved in this release!

We plan to create the 2.4 branch of Weld within a few weeks. Weld 2.4 will remain a CDI 1.2 implementation. We would like to do some cleanup (e.g. remove deprecated classes from Weld SE), enhance the API and also add some new features. See also the list of issues for 2.4.0.CR1.

Notable bugfixes and improvements:

  • fixed static disposer method invocation (WELD-2176)

  • fixed private observer/producer/disposer invocation on a bean with decorator (WELD-2179)

  • fixed Instance.destroy() for dependent session beans (WELD-2148)

  • fixed ArraySet.hashCode() to comply with java.util.Set.hashCode() contract (WELD-2185)

  • log veto actions and modifications of lists returned by AfterTypeDiscovery (WELD-2170, WELD-2171)

  • log a warning when a class is annotated with a scope but does not declare an appropriate constructor (WELD-2178)

  • support extension deployed in multiple WARs in an EAR (WELD-2143)

  • detect non-unique BeanDeploymentArchive identifier (WELD-2165)

  • Weld Servlet

    • fixed extraction of bean archive id - problem occures with embedded Jetty (WELD-2161)

    • improve the way JandexDiscoveryStrategy identifies an annotation annotated with @NormalScope (WELD-2160)

    • weld-servlet-core declares dependency on weld-core-jsf

  • Weld SE

    • do not pass system properties to Weld configuration (WELD-2146)

  • Probe - allow to test bean availability in a given bean archive

    • check for example the availability of an alternative in the demo application

  • many documentation and reference guide updates

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 3.0.0.Alpha16

2016-4-28   release , cdi2   Martin Kouba

The next experimental Weld version has been released! See also the release details. Thanks to everyone involved in this release!

This release includes a lot of bugfixes and improvements (e.g. all the notable tasks implemented in the latest stable version: Weld 2.3.4.Final). However, the main goal of this release is to align with CDI API 2.0.Alpha4, and in particular to implement the current version of "metadata builders" API (CDI-558). So that everyone can play with the API, discover possibilities and find potential issues. Note that this release also introduces a non-standard experimental feature: Weld SE synthetic container lifecycle event observers. So it should be even easier to get started - no extension class is needed in Weld SE.

Metadata configurators - basic ideas

Note that we don’t use the term "builder" because there is no build() method in the API. Also note that the API is not intended to cover every possible case. Instead, we would like to help with common tasks. And if necessary, an extension developer can always use the original replacement methods for more complicated stuff.

IMPORTANT POINTS:

  • an extension developer receives a configurator instance from a container lifecycle event

  • a configurator instance is always automatically processed at the end of the observer invocation

  • for bean discovery events (all events starting with Process):

    • configureX() methods return the same configurator instance (for the given observer method invocation)

    • the configurator is initialized/preconfigured with the component being processed, e.g. ProcessAnnotatedType.configureAnnotatedType() returns a configurator initialized with ProcessAnnotatedType.getAnnotatedType()

    • the result of the configurator will automatically replace the original component (e.g. AnnotatedType in case of ProcessAnnotatedType)

    • replacement methods (e.g. ProcessAnnotatedType.setAnnotatedType()) should not be used together with configurators (CDI-596)

  • for application lifecycle events (e.g. AfterBeanDiscovery):

    • addX() methods always return a new configurator instance

    • the configurator is always uninitialized/empty, but we should probably define some default values wherever it makes sense (e.g. Reception for observer methods)

    • the result of the configurator will be automatically added (e.g. Bean in case of AfterBeanDiscovery.addBean())

We have prepared some simple examples - see below. More advanced examples can be found in the TCK test cases. And as usual - feel free to add comments to this blog post. Any feedback is appreciated!

BeforeBeanDiscovery example

@Singleton
    class MyService {
        // This class is not placed in a bean archive
    }
    
    class MyExtension implements Extension {
    
        void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event) {
            // Add MyService to the set of discovered classes and replace @Singleton with @ApplicationScoped
            event.addAnnotatedType(MyService.class.getName(), MyService.class)
                   .remove(Singleton.class)
                   .add(ApplicationScoped.Literal.INSTANCE);
        }
    }

ProcessAnnotatedType example

class MyExtension implements Extension {
    
        void processAnnotatedType(@Observes @WithAnnotations({ Observes.class, ObservesAsync.class }) ProcessAnnotatedType<?> event) {
            // Add interceptor binding to all methods annotated with @Observes or @ObservesAsync
            event.configureAnnotatedType()
                    .filterMethods(MyExtension::isObserver)
                    .forEach(methodConfigurator -> methodConfigurator.add(Monitored.Literal.INSTANCE))
        }
    
        static boolean isObserver(AnnotatedMethod<?> annotatedMethod) {
            return annotatedMethod.isAnnotationPresent(Observes.class) || annotatedMethod.isAnnotationPresent(ObservesAsync.class);
        }
    }

ProcessBeanAttributes example

class MyExtension implements Extension {
    
        void processBeanAttributes(@Observes ProcessBeanAttributes<?> event) {
            // For all beans remove the IllegalBeanType from the set of bean types
            if (event.getBeanAttributes().getTypes().contains(IllegalBeanType.class)) {
                Set<Type> legalTypes = new HashSet(event.getBeanAttributes().getTypes());
                legalTypes.remove(IllegalBeanType.class);
                event.configureBeanAttributes().types(legalTypes);
            }
        }
    }

AfterBeanDiscovery example

class MyExtension implements Extension {
    
        void afterBeanDiscovery(@Observes AfterBeanDiscovery event) {
            //  Add a new synthetic observer method - no need to use the fluent API
            ObserverMethodConfigurator<Foo> configurator = event.<Foo>addObserverMethod();
            configurator.observedType(Foo.class);
            configurator.reception(Reception.ALWAYS);
            configurator.transactionPhase(TransactionPhase.IN_PROGRESS);
            configurator.notifyWith((foo) -> System.out.println("Foo observed: " + foo));
    
            // Add dependent bean - Integer between 0 and 999
            event.addBean().addType(Integer.class).addQualifier(Random.Literal.INSTANCE)
                    .produceWith(() -> new java.util.Random().nextInt(1000))
        }
    }

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.3.4.Final

2016-4-22   release   Martin Kouba

Weld 2.3.4.Final the next version of the stable 2.3 branch has been released! See also the release details. Thanks to everyone involved in this release!

Notable bugfixes and improvements:

  • log important actions performed by extensions (WELD-2134)

    • for example, if you want to track down all extensions modifying AnnotatedType definitions, then enable the debug logging for Weld and look for messages containing ProcessAnnotatedType.setAnnotatedType() called by …​

  • Conversations - allow to configure the default timeout and the concurrent access timeout (WELD-2113)

  • recover if a transaction is in progress but a JTA Synchronization callback cannot be registered (WELD-2120)

  • EJB proxies do not implement private methods anymore (WELD-2119)

  • interceptor instances used for @AroundConstruct are now reused for other types of interception (WELD-2131)

  • Weld Servlet

    • fixed handling of archives from WEB-INF/lib on Tomcat 8 with unpackWARs=false (WELD-2122)

    • WeldTerminalListener should not throw NPE if injection into listeners is not supported (WELD-2123)

  • Weld SE

    • improved support of implicit bean archives (WELD-2129)

    • there are two new built-in interceptor bindings - @ActivateRequestScope and @ActivateThreadScope - to activate the request scope or the thread scope within a business method invocation

    • Weld builder allows to configure bean archive isolation, development mode and registration of shutdown hook manually (WELD-2135)

    • a basic nested archive support was added (WELD-1930)

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.3.3.Final

2016-2-12   release   Martin Kouba

Weld 2.3.3.Final the next bug-fix version of the stable 2.3 branch has been released! See also the release details. Thanks to everyone involved in this release! Notable improvements:

WildFly Patch

As usual, a patch for WildFly is available. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 3.0.0.Alpha15

2016-2-4   release , cdi2   Martin Kouba

Weld 3.0.0.Alpha15 the next experimental Weld version has been released. See also the release details.

The CompletionStage used to bind actions to the completion of the asynchronous delivery is now using org.jboss.weld.manager.api.ExecutorServices SPI as the default asynchronous execution facility. Previously, the ForkJoinPool#commonPool() (a default executor of the underlying CompletableFuture) was used. It’s an important change because the ForkJoinPool#commonPool() is not a good fit for Java EE. See also WELD-2073.

The ExperimentalAfterBeanDiscovery receives two more methods: interceptorBuilder() and addInterceptor(). An interceptor builder allows you to create an interceptor bean without the need to create an interceptor class. This might be handy for simple use cases:

class MyExtension {
      void afterBeanDiscovery(@Observes AfterBeanDiscovery event) {
        event.addInterceptor().intercept(InterceptionType.AROUND_INVOKE, (c) -> {
                long start = System.currentTimeMillis();
                try {
                    return c.proceed();
                } finally {
                    System.out.println("Time: " + System.currentTimeMillis() - start);
                }
            }).priority(2600).addBinding(MonitoringBinding.Literal.INSTANCE);
      }
    }

See also WELD-2008.

This release also contains some enhancements and bugfixes around proxies. E.g. better support for DeltaSpike partial beans (WELD-2084), better support for Camel CDI (WELD-2089) and better support for proxies with non public classes (WELD-2091). Furthermore, we are going to drop Jetty 7,8, 9.0, 9.1 and 9.2 support in Weld 3 (WELD-2032). Also the decorator validation was improved (WELD-2085, WELD-1811, WELD-2039). Last but not least, we have performed some SPI cleanup (WELD-2077, WELD-2079).

WildFly Patch

As usual, a patch for WildFly is available. This patch not only upgrades Weld within an existing WildFly instance but also upgrades CDI API to 2.0 EDR1. This time the target platform is WildFly 10.0.0.Final. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.3.2.Final

2015-12-10   release   Martin Kouba

Weld 2.3.2.Final the last version for this year has been released! It is a bug-fixing release with 15 issues resolved. See also the release details. Thanks to everyone involved in this release!

Notable bug-fixes and enhancements

  • Weld proxies - add workaround for IBM JVM 8 (WELD-2056 and DELTASPIKE-1010)

  • Fix resource injection when using arquillian-weld-ee-embedded-1.1 (WELD-2065 and ARQ-2000)

  • All conversation contexts should be destroyed after the Servlet.service() method completes (WELD-2052)

  • Clear RequestScopedCache for remote EJB calls (WELD-2069)

  • Weld Servlet

    • Allow to perform dependency injection upon objects not having a CDI-compatible constructor (WELD-2039)

    • Add Jandex support even for WARs not extracted to the file system (WELD-2070)

  • Probe development tool is now part of the OSGi bundle (WELD-2061)