News - tagged as "release"

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

  • 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)


Weld 3.0.0.Alpha14

2015-12-4   release , cdi2   Martin Kouba

Weld 3.0.0.Alpha14 the penultimate Weld version for this year has been released into the wild. It reflects some of the most recent changes in the CDI 2.0 specification, mostly related to asynchronous events. Moreover, this release also contains quite a lot of enhancements and bugfixes. See also the release details.

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.CR4. If you’re not familiar with patching WildFly, check Markus’s tutorial.


Weld 2.3.1.Final arrives...

2015-10-27   release   Martin Kouba

Weld 2.3.1.Final has been released! The delivery: a few killed bugs, couple of Weld SE enhancements and several Weld Probe improvements.

Notable bug-fixes and enhancements:

  • Private producer, disposer and observer methods should be intercepted (WELD-2043)

  • Specializing bean - remove @Default qualifier unless explicitly declared (WELD-2046)

  • Weld SE

    • Fix the development mode enablement

    • Allow to pass a ResourceLoader to be used for scanning (WELD-2044)

    • Allow to skip the registration of a shutdown hook (WELD-2051)

  • Weld Probe now supports monitoring of container lifecycle events during bootstrap (see also supported configuration properties)


Weld 2.3.0.Final released!

2015-9-18   release   Martin Kouba

Weld 2.3.0.Final has been just released! From now on, 2.3 is the current stable version of Weld and 2.2 is not actively developed anymore - i.e. no new features are added, only bugs will be fixed. Weld 2.3 will remain a CDI 1.2 implementation. We are incrementing the minor version due to several new features added. Weld 2.3 is also included in WildFly 10 application server.

Notable features and changes:

  • Java 6 support was dropped - Java 7 is the minimal requirement for building and running Weld 2.3

  • Weld 2.3 comes with a special mode for application development, the Probe development tool allows to inspect application CDI components at runtime

  • Weld SE Bootstrap API was enhanced in many ways - new features are mostly backported from Weld 3 development branch

  • Weld Servlet now supports Undertow web server

  • Revised delivery of @Initialized/@Destroyed events for @ApplicationScoped in an EAR (see also WELD-1821)

Weld 2.2.16.SP1

In addition, Weld 2.2.16.SP1 has been also released. It’s a bugfix release for 2.2 branch.


Weld 3.0.0.Alpha12 - CDI 2.0 EDR1 Reference Implementation!

2015-8-5   release , cdi2   Martin Kouba

Weld 3.0.0.Alpha12 has been released. Compared to previous alpha releases this is an important milestone - it’s a reference implementation of CDI 2.0 Early Draft (EDR1). You can read more about CDI 2.0 EDR1 on the official blog: CDI 2.0 Early Draft Review 1 released.

Bootstrapping a CDI container in Java SE

Starting a CDI container is now really that easy:

public static void main(String... args) {
        try(CDI<Object> cdi = CDI.getCDIProvider().initialize()) {
            ComputingService service = cdi.select(ComputingService.class).get();
            service.compute();
        }
    }

javax.enterprise.inject.spi.CDI now implements AutoCloseable and can therefore be used in a try-with-resources block.

Note that the specification of the bean discovery process in Java SE is not finished yet. Therefore, bean archives which don’t contain a beans.xml file are not supported. The main reason is that we don’t want to implement a feature which is being discussed and will likely undergo some important changes. Nevertheless, the feature will be implemented in one of the next alpha versions.

Weld SE bootstrap API

How does it compare to Weld SE bootstrap API? Weld has provided support for the Java SE environment for a long time. Recently, the org.jboss.weld.environment.se.Weld class was turned into a powerful builder which allows to configure the Weld container before it is initialized.

Typical usage of the Weld SE API looks like this:

try (WeldContainer container = new Weld().initialize()) {
        ComputingService service = container.select(ComputingService.class).get();
        service.compute();
    }

This looks very similar to CDI SE, right? However, there are several advanced feratures available:

  • automatic scanning can be disabled, classes or packages can be selected explicitly

    • WeldContainer container = new Weld().disableDiscovery().beanClasses(Foo.class, Bar.class).alternatives(Bar.class).interceptors(FooInterceptor.class).initialize();

  • WeldContainer allows to fire events easily

    • container.event().select(Bar.class).fire(new Bar());

  • Weld-specific configuration options can be specified using the builder

  • it is possible to start multiple independent Weld instances (specification does not require this)

See also Weld 3.0.0.Alpha8 announcement for more information.

Asynchronous Events

An experimental support of asynchronous events is implemented in Weld since 3.0.0.Alpha3. However, in this release the API was aligned with CDI 2.0 EDR1:

class OrderProcessor {
    
        @Inject Event<Order> orderEvent;
    
        public void process(Order order) {
            orderEvent.fireAsync(order).thenAccept((o)->System.out.println("Asynchronous processing finished: " + o.getId()));
        }
    
        public void processingOrder(@Observes Order event) {
            // This observer is notified synchronously, before the fireAsync() method returns
        }
    
        public void asyncProcessingOrder(@ObservesAsync Order event) {
            // This observer is notified asynchronously, in a different thread
        }
    }

There are few important things to notice:

  • the event was triggered with fireAsync()

  • the asynchronous observer is defined by @ObservesAsync

  • synchronous observers defined by @Observes are also notified!

To sum it up:

Event method @Observes notified @ObservesAsync notified

fire()

yes, in the same thread

no

fireAsync()

yes, in the same thread

yes, in a different thread

Observers SPI Changes

javax.enterprise.inject.spi.ObserverMethod now extends javax.enterprise.inject.spi.Prioritized and overrides the ObserverMethod.getPriority() method which is used to determine the notification order in which the event observer methods are invoked. Prioritized interface is currently only used for observers. However, the Weld team is working on a prototype where Prioritized can be used to globally select/enable custom alternative beans, interceptors and decorators, see also WELD-2000.

Furthermore, ObserverMethod.isAsync() method was added to determine whether an observer method is asynchronous or not.

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.Alpha6. If you’re not familiar with patching WildFly, check Markus’s tutorial.