Giter Club home page Giter Club logo

cdi's Introduction

GitHub Pages

The latest news for CDI 4.x can be found in the GitHub pages

Sources in GIT

The main branch contains the work-in-progress on CDI.next specification (5.0)

Legacy Releases

Check out the cdi-spec.org for more info on CDI 2.0 and CDI 1.2

cdi's People

Contributors

antoinesd avatar arnelimburg avatar astefanutti avatar azquelt avatar bafco avatar bmscomp avatar dependabot[bot] avatar eclipse-cdi-bot avatar emily-jiang avatar gastaldi avatar graemerocher avatar gunnarmorling avatar hantsy avatar jbergmark avatar jharting avatar johnament avatar ladicek avatar lightguard avatar luksa avatar manovotn avatar mbogoevici avatar mkouba avatar mp911de avatar pmuir avatar psakar avatar starksm64 avatar struberg avatar thihup avatar tremes avatar waynebeaton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cdi's Issues

Build Compatible Extensions Proposal

TL;DR

Blog post you should read - www.cdi-spec.org/news/2020/09/15/CDI_Lite_extension/
PR with API proposal - #451
For hands-on playing with API, use this fork - https://github.com/Ladicek/quarkus-fork/tree/experiment-cdi-lite-ext

What is this

This is a proposal on how Build Compatible Extensions ( e.g. CDI Lite extensions) could look like. Various discussions in the past showed that regardless of what would CDI Lite look like, it will need some form of extensions because the existing ones are not suitable for build-time and extension are an important factor for integration of various frameworks.

This issue and the PR linked to it (#451) come with a WIP proposition that we would like to gather feedback on.

There is a blog post on CDI website that you should check out. It goes deeper into what Build Compatible Extensions Proposal is and how it works. Please do give it a read.

What it isn't

This proposal does not aim to cover what CDI Lite should/shouldn't contain and focuses solely on how could the Lite extension API look like.

How can I play with this new API

The linked PR gives you a glimpse of what the API draft looks like right now. However, that's just API - it's nice but you cannot try it out in action, right?

That's why we have also created a simple implementation for the annotation transformation part of API inside Quarkus. It uses none of Quarkus-specific APIs, just what we presented here and having tried that in Quarkus proves its viability for build-time environments (although it doesn't limit it for just that). For the sake of simplicity it right now contains a copy of the APIs inside the fork.

Intructions on how to try it out are in the blog post.

How to provide feedback

Got an idea how to improve it? What's missing or what's superfluous? We'd love to hear what you think of this API!
In order to keep it all in a readable and traceable format, please provide your feedback in form of separate GH issue on this repo with label lite-extension-api.

Rework portable extension

Rework portable extension so that they can be found at build time instead of runtime.

As a developer, I want to use cdi extension to:

  • Providing its own beans, interceptors and decorators to the container

  • Injecting dependencies into its own objects using the dependency injection service

  • Providing a context implementation for a custom scope

  • Augmenting or overriding the annotation-based metadata with metadata from some other source

Lite/Full split: define packaging/deployment/lifecycle

Lite/Full split: decide on passivation mentions in the CDI Lite spec part

Improve constructor injection

Similiar to Spring IOC, for a component managed by CDI, if there is only one constructor with parameters, it should be injected automatically without an explicit @Inject.

private final OrderRepository orders; // OrderRepository is a CDI bean

public class OrderService(OrderRepository orders){ //OrderRepository should be injected automatically here.
    this.orders = orders;
}

Similarly the methods of a component should be handled automatically.

Removal of deprecated bits for next major version

There are certain bits in the specification that have been carried over as deprecated legacy for years.
I think for future versions we can easily shake them off.

I discovered the following deprecated parts that I think we can remove:

  • @New qualifier
    • Deprecated since CDI 1.1 and replaced by @Dependent
  • Bean.isNullable() method
    • Deprecated since CDI 1.1
  • BeanManager.fireEvent() method
    • Deprecated since CDI 2.0 and replaced by BeanManager.getEvent()
  • BeanManager.createInjectionTarget(AnnotatedType) method
    • Deprecated since CDI 1.1 and replaced by BeanManager.getInjectionTargetFactory(AnnotatedType)
  • BeforeBeanDiscovery.addAnnotatedType(AnnotatedType) method
    • Deprecated since CDI 1.1 and replaced by BeforeBeanDiscovery.addAnnotatedType(AnnotatedType, String)
  • Remove the notion of a mandatory configuration switch for all container to support different understanding of missing beans.xml

Obviously, for all of the above changes might be needed in both, API and specification text.

Lite/Full split: does CDI in Java SE environment (SeContainer etc.) have to support Full?

I added a TODO "are implementations required to support Full?" into the CDI SE chapter, because I think this should be spelled out explicitly. The answer is probably yes, but we may need to debate it a little (because I think Micronaut is trying to implement some parts of the SE API, and I don't see anything particularly wrong with that, even though they won't support Full).

Could you please confirm whether you intend to implement SeContainer etc., @graemerocher?

https://github.com/eclipse-ee4j/cdi/blob/864e1b4f779e4d6d5a80f147d975a510446d4987/spec/src/main/asciidoc/javase/javase.asciidoc

Observer resolution - assignability clarification

There was a discussion on observer resolution concerns 10.3.1. Assignability of type variables, raw and parameterized types tracked in https://issues.redhat.com/browse/CDI-736, which is unclear about the if assigning a non-parameterized subclass to a parameterized superclass should work or not:

public interface QualifiedEvent<T> {
 // some methods
}

public class EventImpl implements QualifiedEvent { //NOTE - implements raw type
 // some method impls
}

observer code:

    void listenForChildEvent(@Observes QualifiedEvent<Bar> foo) {
      // stuff going on here...
    }

event type:

new EventImpl(clazz);

In this scenario, the spec is IMO unclear on what should happen in this particular case

Looking at other parts of spec, we already have this covered in, for instance, delegate injection point assignability, where it says:

A raw bean type is considered assignable to a parameterized delegate type if the raw types are identical and all type parameters of the delegate type are either unbounded type variables or java.lang.Object.

I think we should add a similar sentence to 10.3.1. Assignability of type variables, raw and parameterized types. That way the spec will behave coherently and the above observer/event assignability should not work.

Side note - for the sample above to work, you would need to change the observed types to QualifiedEvent<?>.

Split Spec doc to introduce CDI Lite

Since working group agreed to make CDI Lite a subset of CDI core, we need to organize the spec to introduce CDI Lite in it.
New organization should split the current core part in CDI Lite and CDI Full subparts.

CDI lite

In light of this discussion on allowing widely adopted by compile-time runtimes, the following use case is requried.

As a implementor of CDI spec, I would like to support the CDI parts, which can be determained at compile time so that my end users can benefit from CDI and AOT.

AFTER_SUCCESS Observers and Events fired from within EntityListeners

There currently exists an issue where if a event is fired from within an JPA EntityListener (@PostUpdate for example) the event may not be reliably observed via an @Observes(during = TransactionPhase.AFTER_SUCCESS)

The issue comes down to what state Transaction is in when the entityManager.flush is called (trigging the post update for example). If the entityManager.flush is called manually then the @PostUpdate is run while the transaction is active and things will work fine. If however, the flush is automatically called via the ending of an @Transactional method then when the @PostUpdate is run the transaction has moved past the ACTIVE status and the synchronization cannot be added to the transaction. No error is thrown and the event will silently not be observed.

Possible thoughts were having the the CDI event registered with an TransactionSynchronizationRegistry#registerInterposedSynchronization

It appears that you could do something like

  @PostUpdate
    public void postUpdate(Ticket entity) {
        try {
            TransactionSynchronizationRegistry registery = (TransactionSynchronizationRegistry) new InitialContext().lookup("java:comp/TransactionSynchronizationRegistry");
            registery.registerInterposedSynchronization(new MySyncronization());
        }
        catch (NamingException e) {
            throw new RuntimeException(e);
        }
    }
public class MySyncronization implements javax.transaction.Synchronization {

    static final Logger log = Logger.getLogger(MySyncronization.class);

    @Override
    public void beforeCompletion() {

    }

    @Override
    public void afterCompletion(int status) {
        if (status==3){
             CDI.current().getBeanManager().fireEvent(EntityEvent.updated(entity));
        }
    }
}

This appears to accomplish what we want, but obviously is not friendly to use.

The current thought is to potentially clarify in the spec that CDI events should use an Interposed Synchronization either all the time or only if a standard synchronization cannot be obtained, but that may have ramifications that I am not considering.

This jumps off from https://issues.redhat.com/browse/WELD-2444

Prepare Jakarta CDI for Jakarta EE 8 Release

Instructions

  • Update text files
  • Generate "boilerplate" specification project
  • Make a staging release
  • Generate Stand-alone TCK test results
  • Create a PR to jakartaee/specifications repository
  • Update the Jakarta EE API jar by submitting a PR to the jakartaee-api project

Details are
here

Spliting BeanManager for CDI Lite

We should create a new BM interface containing methods supported by lite only.
The current BM would be accessible by extending this lighter BM and add the missing methods for Full.

Update CONTRIBUTING.md for Specification Project's repositories

Create/Update CONTRIBUTING files

Per input from the Eclipse EMO, each Specification Project needs to ensure that a CONTRIBUTING.md or CONTRIBUTING.adoc file exists in each specification-related repository maintained by Specification Projects.
In addition, the CONTRIBUTING.md or CONTRIBUTING.adoc file needs to include the following text:

## Eclipse Development Process

This Eclipse Foundation open project is governed by the Eclipse Foundation
Development Process and operates under the terms of the Eclipse IP Policy.

The Jakarta EE Specification Committee has adopted the Jakarta EE Specification
Process (JESP) in accordance with the Eclipse Foundation Specification Process
v1.2 (EFSP) to ensure that the specification process is complied with by all
Jakarta EE specification projects.

* https://eclipse.org/projects/dev_process
* https://www.eclipse.org/org/documents/Eclipse_IP_Policy.pdf
* https://jakarta.ee/about/jesp/
* https://www.eclipse.org/legal/efsp_non_assert.php

Please do this at your earliest convenience.
Thank you!

-- EE4J PMC ([email protected])

How can getReference() legally be invoked during AfterDeploymentValidation event if contexts have not been created yet?

Section 11.5.4 says:

The container must fire an event after it has validated that there are no deployment problems and before creating contexts or processing requests [emphasis mine].

Section 11.3 indicates that it is legal to call BeanManager#getReference(Bean, Type, CreationalContext) in an AfterDeploymentValidation observer method.

In order to get contextual references, such as those returned by getReference(), you need a context.

Is this a bug in the specification? Does section 11.5.4 need to be amended in some way?

Compatibility certification request for Weld

  • [*] Organization Name ("Organization") and, if applicable, URL
    Red Hat, Inc., http://redhat.com
  • [*] Product Name, Version and download URL (if applicable)
    Weld 3.1.1.Final, https://weld.cdi-spec.org/download/
  • [*] Specification Name, Version and download URL
    Jakarta Contexts Dependency Injection 2.0
  • [*] TCK Version, digital SHA-256 fingerprint and download URL
    http://download.eclipse.org/jakartaee/cdi/2.0/cdi-tck-2.0.6-dist.zip, 75e969a7a3b3c77332154a2008309aad821a923d8684139242048a7640762808
  • [*] Public URL of TCK Results Summary
    https://github.com/jakartaredhat/weld-cdi-tck/wiki
  • [*] Java runtime used to run the implementation
    Oracle Runtime Environment java version "1.8.0_211" Java™ SE Runtime Environment (build 1.8.0_211-b12) Java HotSpot™ 64-Bit Server VM (build 25.211-b12, mixed mode)
  • [*] Summary of the information for the certification environment, operating system, cloud,
    Think pad, 18.04.1-Ubuntu
  • [*] By checking this box I acknowledge that I accept the terms of the EFTL.
  • [*] By checking this box I attest that all TCK requirements have been met, including any compatibility rules.

Weld CDI 3.0 Compatibility Certification Request

  • Organization Name ("Organization") and, if applicable, URL:

    Red Hat, https://www.redhat.com/
  • Product Name, Version and download URL (if applicable):

    Weld 4.0.0.Alpha3, https://weld.cdi-spec.org/download/
  • Specification Name, Version and download URL:

    Jakarta Contexts Dependency Injection 3.0
  • TCK Version, digital SHA-256 fingerprint and download URL:

    http://download.eclipse.org/jakartaee/cdi/3.0/cdi-tck-3.0.1-dist.zip,

    f0a3bdd81ea552ddf2c2a6cd2576f0d5ca45026665cb4a5c42606a58bf1c133d
  • Public URL of TCK Results Summary:

    https://github.com/jakartaredhat/cdi-tck/wiki/Jakarta-CDI-3.0-TCK-Results
  • Any Additional Specification Certification Requirements:

    N/A
  • Java runtime used to run the implementation:

    Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
  • Summary of the information for the certification environment, operating system, cloud, ...:

    EF CI environment Linux basic-5qhls 3.10.0-1062.el7.x86_64 #1 SMP Thu Jul 18 20:25:13 UTC 2019 x86_64 GNU/Linux
  • By checking this box I acknowledge that the Organization I represent accepts the terms of the EFTL.
  • By checking this box I attest that all TCK requirements have been met, including any compatibility rules.

Lite/Full split: decide on Portable Extensions mentions in the CDI Lite spec part

Update EFSL for Specifications and Javadoc

Per the discussions on the Spec Committee and Platform Dev mailing lists, it's been discovered that many of the Javadoc and Spec references to the EFSL need updating. Please reference the following required updates and keep them in mind as your Spec Project is updating the files for Jakarta EE 9.

Note: Some Spec Projects have already started or even completed these updates. If so, just kindly return/close this Issue. Thanks!

Required EFSL updates for Javadoc

For javadoc, the EFSL.html located in src/main/javadoc/doc-files should be modified as follows:

  • the <<url to this license>> needs to be replaced with efsl.php link[1]
  • the [title and URI of the Eclipse Foundation specification document] needs to be replaced with the Specification Name and URL (Reference [2] for an example.)
  • The javadoc footer copyright year needs to be updated to 2018, 2020 as defined in the pom.xml

Required EFSL updates for Specifications

For specification, the license-efsl.adoc located in src/main/asciidoc should be modified as follows:

  • Update copyright year to 2018, 2020 from 2019. Add link to EFSL.
  • the <<url to this license>> needs to be replaced with efsl.php link[1]
  • the [title and URI of the Eclipse Foundation specification document] needs to be replaced with the Specification Name and URL (Reference [2] for an example.)

[1] https://www.eclipse.org/legal/efsl.php
[2] https://jakarta.ee/specifications/enterprise-beans/4.0/

RequestContextController spec impossible to implement

I'm not really happy with the RequestContextController. And it appears to me that the spec is broken.

Here is the important part from the spec:

6.5.2. Activating Built In Contexts
Certain built in contexts support the ability to be activated and deactivated. This allows developers to control built-in contexts in ways that they could also manage custom built contexts.
When activating and deactivating built in contexts, it is important to realize that they can only be activated if not already active within a given thread.
6.5.2.1. Activating a Request Context
Request contexts can be managed either programmatically or via interceptor.
To programmatically manage request contexts, the container provides a built in bean that is @dependent scoped and of type RequestContextController that allows you to activate and deactivate a request context on the current thread. The object should be considered stateful, invoking the same instance on different threads may not work properly, non-portable behavior may occur.
public interface RequestContextController {
boolean activate();
void deactivate() throws ContextNotActiveException;
}
When the activate() method is called, if the request context is not already active on the current thread then it will be activated and the method returns true. Otherwise, the method returns false.
When the deactivate() method is called, if this controller started the request context then the request context is stopped. The method does nothing if this controller did not activate the context

The problem is that there are 2 ways to use that part

a.)

boolean didActivate = reqCtxCtrl.activate();
...
if (didActivate) reqCtxCrl.deactivate();

b.)

try {
  reqCtxCtrl.activate();
  ...
} finally {
  reqCtxCrl.deactivate();
}

The problematic part is nesting.
In case a) we got maybe 7 calls to activate() but only 1 to deactivate.
In case b) we got 7 calls to activate and 7 to deactivate();

There is simply no way to implement this in a clean way. A simple boolean flag does not help because of concurrency. A ThreadLocal does not help much either. If we use a ThreadLocal we potentially leak memory in case of a). If we close immediately we potentially close way too early in case b).

Temporary Observers

When bridging between synchronous and event-driven APIs, there comes a situation when a synchronous method sends a request in the form of a CDI event and then needs to wait until a responding CDI event was received (i. e. it shall not just wait for the request event to be sent but really wait for an answering event was received). After that, the synchronous method can read that responding event and provide its own return value to the caller.

Unfortunately I have not found any easy way to write code for such a situation in CDI (maybe I missed something). I could imagine passing a Future around in the CDI event payload where the orignal thread waits for and where an observer method would fulfil - but that sounds pretty complex.

What I could imagine would be something like "temporary observers", i. e. before the synchronous method sends the original request CDI event, it registeres a lambda function as a CDI event observer for the expected answer. Once that lamba event fires, it unregisters itself before it returns the result to the blocked caller. I know that programmatic global observers are aready possible as extensions, but those cannot interact with the waiting thread inside of the synchronous caller method.

Is this already possible or is it planned for the future or is there another simple solution how to make a synchronous non-static method wait for an event in such a dynamic way?

CDI on EL-API dependency

The issue in MicroProfile was reported for a potential security vulnerability. Please comment if you disagree with the security vulnerability claim.

I noticed the el-api dependency was optional in CDI 1.0, but from CDI 1.1, the EL-API dependency is mandatory. Can someone explain why? Is it possible to make the dependency optional?

Method invokers

(copied from CDI.Next doc, as there was no issue yet to track this)

Currently CDI does not have a concept of a bean method that can be executed from another bean with parameter binding.
Such a concept is used in other specs, such as JAX-RS, where resource methods are executed at runtime with the need to bind their parameters, and provide the support for interceptors and other CDI features.
The CDI spec should add API for such a feature, so other specs do not need to define a custom solution.

The following should be possible:

  • Obtain a reference to executable method with all metadata, including annotations on method and on fields
  • Execute an executable method on a bean instance
  • Obtain executable method metadata in interceptors (to analyze annotations using reflection-less approach)
  • Create a parameter binder, that would support a specific annotation on a parameter (basically a parameter qualifier)

Pseudocode:

Let’s consider the following bean:

@RequestScoped
@Path("/greet")
public class Resource {
   @GET
   String helloWorld(@HeaderParam("HEADER") String header) {
   }
}
@Qualifier
@Target(ElementType.PARAMETER)
public @interface HeaderParam {
   String value();
}

Now we could create a parameter binder:

@Singleton
@Binder(HeaderParam.class)
public class HeaderParamBinder implements ParamBinder {
   // HttpHeaders is a request scoped bean
   private final HttpHeaders headers;
   private final Converter converter;

   @Inject
   HeaderParamBinder(HttpHeaders headers, Converter converter) {
       this.headers = headers;
       this.converter = converter;
   }

   public <T> T bind(HeaderParam annotation, GenericType<T> type) {
       return converter.convert(headers.getRequestHeader(annotation.value()), type);
   }
}

And the execution of this method would be something like:

@MethodHandler(Path.class)
public class JaxRsExecutor implements ExecMethodHandler<Object, Object> {
   private final ParameterBinder binder;
   private final Container container;
  
   @Inject
   JaxRsExecutor(ArgumentBinder binder) {
       this.binder = binder;
   }

   @Override
   public void processMethod(ExecutableMethod<Object, Object> method) {
       // process registration with web server
   }
  
   private void executeMethod(ExecutableMethod<Object, Object> method) {
       // start request scope
       Object beanInstance = container.select(method.getDeclaringType()).get();
       method.invoke(beanInstance, binder.bind(method));
   }
}

Lite/Full split: decide on "Inter-module injection in CDI Full"

The "Inter-module injection in CDI Full" chapter in the specification has a TODO for deciding whether the chapter should extend rules from CDI Lite and add few more (current state, somewhat hard to read), or completely override the CDI Lite rules (would require some duplication, but might be easier to read).

https://github.com/eclipse-ee4j/cdi/blob/864e1b4f779e4d6d5a80f147d975a510446d4987/spec/src/main/asciidoc/core/injectionandresolution_full.asciidoc

Provide default wrappers for classes like AnnotatedType and AnnotatedMethod

CDI extensions allow us to add a new annotated type.

A typical use case is to programmatically add or remove annotations to/from existing types, which makes the usage of wrappers necessary. CDI does not provide default wrappers, so projects often need to recreate these. While not difficult, it's tedious and error prone.

Just like APIs like e.g. Servlet and Faces, it would be good if CDI provided a few default wrappers here.

Clarify Context#destroyBean behavior

When wanting to delete a bean instance from the HTTP session that hasn't been accessed via Contex#get in that request, destroy doesn't do anything when using Weld.

Is that intended?

I debugged and it seems to be due to the session context being lazy.

Need to break out integration tests from CDI TCK

As seen with the effort to complete the CDI updates for EE9, while CDI has a wave 3 API dependency, the TCK includes integration tests that belong in the web and full profiles. These tests should be moved into separate integration tests that can be incorporated into the platform TCKs.

Lite/Full split: decide on other mentions of Full-only concepts in the CDI Lite spec part

There's a couple of mentions of other Full concepts in the CDI Lite specification part, specifically in "Container invocations and interception" and "Built-in annotation literals". We need to decide what to do with them: move to Full, leave them where they are?

List of places:

CDI context propagation

In CDI spec, the context propagation was not addressed in the spec. The original ticket was raised:

Key: CDI-587
URL: https://issues.jboss.org/browse/CDI-587
Project: CDI Specification Issues
Issue Type: Epic
Components: Contexts
Affects Versions: 1.2.Final
Reporter: Romain Manni-Bucau

The overall idea is to ensure that it is not cause the code becomes asynchronous/reactive/... that we loose the instances or get another context.
An example is starting an AsyncContext in a servlet.
One proposal is to add a flag to ask for propagation of the context in async managed threads: @RequestScoped(inherited = true) which would reuse the same instances for these "new" threads.
Note however this issue is not only bound to servlets even if it is the easiest example.
The original thread disucssion on the list: http://cdi-development-mailing-list.1064426.n5.nabble.com/RequestScope-Life-Cycle-td5712701.html

In MicroProfile Context Propagation, some effort was made to address the context propagation and the implementation was made in Weld. However, it has a some issues, such as eclipse/microprofile-context-propagation#167

Complete steps for CDI 3.0

  • Specification Committee Mentor...
  • creates an issue in the specification project that includes the following checklist for the specification project team:

  • Specification Project Team
  • promotes api staging release promotes the specification api jars to maven central. An example release job script can be found here https://wiki.eclipse.org/MavenReleaseScript.
  • go through the merged jakarta.ee specification website page to verify all the links are valid.
  • approve the compatibility request.
  • The compatible implementation project/vendor MUST send an email to [email protected] for approval of the compatible implementation for trademark usage.
  • merge any final release branch as appropriate for the branch management for the project.

Correct Javadoc for generation with xdoclint

Javadoc generation requires Xdoclint to be turned deactivated:

mvn javadoc:javadoc -DadditionalJOption=-Xdoclint:none

We should review all Javadoc to fix issue preventing the use of Xdoclint

Add methods to BeanConfigurator for applying decorators

Currently when adding a Bean<T> using jakarta.enterprise.inject.spi.AfterBeanDiscovery.addBean() or jakarta.enterprise.inject.spi.AfterBeanDiscovery.addBean(Bean<?>) any decorators declared or programatically added for the types of the Bean<T> are not automatically applied.

Not only is this perhaps surprising, there actually is no portable way to achieve this behaviour. Someone adding a bean must resort to SPIs and implementation specific code. For instance Soteria uses the following code:

afterBeanDiscovery.addBean(
    decorator.decorateBean(authenticationMechanismBean, HttpAuthenticationMechanism.class, beanManager));

Source

Where decorator.decorateBean is an SPI, that for Weld uses code such as the following:

public class DecorableWeldBeanWrapper<T> extends RIBean<T> implements Bean<T>, PassivationCapable {

    private final Bean<T> bean;
    private final CurrentInjectionPoint currentInjectionPoint;
    private final boolean isProxyable;
    private Class<T> type;

    private List<Decorator<?>> decorators;
    private Class<T> proxyClass;
    private boolean proxyRequired;
    private boolean isPassivationCapableBean;
    private boolean isPassivationCapableDependency;

    public DecorableWeldBeanWrapper(Bean<T> bean, Class<T> type, BeanManagerImpl beanManager) {
        super(
            bean,
            new StringBeanIdentifier(BeanIdentifiers.forBuiltInBean(beanManager, type, null)),
            beanManager);

        this.bean = bean;
        this.type = type;
        this.currentInjectionPoint = beanManager.getServices().get(CurrentInjectionPoint.class);
        this.isProxyable = Proxies.isTypesProxyable(getTypes(), beanManager.getServices());
    }

    @Override
    public void initializeAfterBeanDiscovery() {
        decorators = beanManager.resolveDecorators(getTypes(), getQualifiers());

        if (!decorators.isEmpty()) {
            proxyClass = new ProxyFactory<T>(getBeanManager().getContextId(), getType(), getTypes(), this).getProxyClass();
        }
    }

    @Override
    protected void internalInitialize(BeanDeployerEnvironment environment) {
        proxyRequired = getScope() != null && isNormalScoped();
        isPassivationCapableBean = Serializable.class.isAssignableFrom(type);
        isPassivationCapableDependency = isNormalScoped() || (isDependent() && isPassivationCapableBean());
    }

    @Override
    public T create(CreationalContext<T> creationalContext) {
        T instance = bean.create(creationalContext);

        if (decorators.isEmpty()) {
            return instance;
        }

        return getOuterDelegate(this, instance, creationalContext, proxyClass, currentInjectionPoint.peek(), getBeanManager(), decorators);
    }

Source

This code is difficult to come up with, difficult to maintain and error prone. The user must also make sure the right companion SPI implementation is available on the class path.

To simplify this, I'd like to propose a method for BeanConfigurator to signal to the runtime that enabled decorators should be applied to the instance returned from the Bean.create (`Contextual.create') method, just like happens for beans which implement the bean types directly and are discovered by CDI.

For instance:

public void afterBean(final @Observes AfterBeanDiscovery afterBeanDiscovery) {
        afterBeanDiscovery
            .addBean()
            .scope(ApplicationScoped.class)
            .types(MyBean.class)
            .id("Created by " + CdiExtension.class)
            .enabledDecorators()
            .createWith(e -> new MyBeanImpl("Hi!"));
    }

Several variants could be considered, like e.g.:

  • addEnabledDecorators()
  • decorators(Decorator<?>... decorators)
  • addDecorators(Decorator<?>... decorators)

New Scope SessionCacheScoped

I would like to propose a new scope called @SessionCacheScoped with an optional cache name. The purpose of the scope is, that data is associated with a session without using the HttpSession as storage. I often associate some data that I loaded from the database with a user session and using @SessionScoped is usually fine, but in a clustered setup this becomes a problem due to session replication overhead. To avoid these issue, I would like to put the beans into a local cache instead which is associated with the session.

One might think that this kind of scope should be provided by JCache(JSR 107), but since it is not part of Jakarta EE (yet), I wanted to post it here and maybe start a discussion about the possible inclusion of the JCache API.

Lite/Full split: eliminate all TODOs from the specification

This is an umbrella issue to track the work on eliminating all TODO comments from the CDI specification Asciidoc sources, added in the initial Lite/Full split PR (#470). More sub-issues will be created and this issue will list them (and their status) to provide an overview.

  • #490 Lite/Full split: finish preface
  • #483 Lite/Full split: define packaging/deployment/lifecycle
  • #484 Lite/Full split: define new extension API
  • #485 Lite/Full split: decide on Portable Extensions mentions in the CDI Lite spec part
  • #486 Lite/Full split: decide on passivation mentions in the CDI Lite spec part
  • #489 Lite/Full split: decide on other mentions of Full-only concepts in the CDI Lite spec part
  • #487 Lite/Full split: make @singleton a bean defining annotation?
  • #488 Lite/Full split: does CDI in Java SE environment (SeContainer etc.) have to support Full?
  • #491 Lite/Full split: decide on "Inter-module injection in CDI Full"
  • #492 Lite/Full split: decide on "Unsatisfied and ambiguous dependencies"
  • #493 Lite/Full split: decide on "The EventMetadata interface"
  • #494 Lite/Full split: decide on "Defining new scope types"

Personal opinion: I have added the TODO comments instead of just Asciidoc admonitions, because that allows easy tracking of the number of remaining open items (single grep command). I don't mind putting the content of the TODO comments into admonitions (and leaving an empty TODO comment alongside), but I believe this should all be primarily present directly in the Asciidoc source, so that context is immediately obvious. Tracking in GitHub issues is, in my opinion, secondary.

Deliver cdi Specification Version update for Jakarta EE 9

Is your feature request related to a problem? Please describe.
Jakarta EE 9 is the next major release, with the main focus of moving from the javax namespace to the jakarta namespace.

Describe the solution you'd like
This issue will be used to track the progress of this work effort via the Jakarta EE 9 Project board.

Additional context
Jakarta EE Specification Process
Eclipse Project Handbook
Eclipse Release Record for Jakarta EE 9

ToDo

  • Create Eclipse Release Record in your respective Jakarta Specification Project.
    Most Component Release Records will just reference the Jakarta EE 9 Platform Release Plan. But, if your Component deviates at all from the Platform Release Plan, then a description of the changes will be required in the Release Record.
  • Initiate a ballot for your Jakarta Release Record/Plan.
    Again, if your component is only doing the required minimum as defined by the Jakarta EE 9 Platform Release Plan, then no separate ballot is required. You are already approved. But, if your component deviates from the Platform Release Plan, then you will need to initiate your own ballot as defined by the Jakarta EE Specification Process.
  • Jakarta-ize your Specification document (if applicable)
    Many of the Jakarta EE components now have the source for their Specification documents. It is strongly recommended that these Specification documents are properly updated to represent Jakarta EE instead of Java EE. Some helpful instructions are documented here.
  • javax -> jakarta Spec updates
    If your component has Specification source, then all javax package references need to be updated to use jakarta package references.
  • javax -> jakarta API updates
    Your component APIs need to move from using the javax namespace to using the jakarta namespace.
    • javax updates on dependency injection
    • javax updates on CDI
  • Release Candidate (RC) of Jakarta API in Maven Central
    A Release Candidate of your component API should be pushed to Maven Central as soon as humanly possible. This will allow other dependent components to utilize your APIs as they are updating their APIs. Multiple revisions of these Release Candidate APIs are allowed (and probably expected) during the development cycle.
  • javax -> jakarta TCK updates
    Your component TCK needs to be updated to use the jakarta namespace.
  • javax -> jakarta Compatible Implementation updates
    Your compatible implementation that will be used to demonstrate completeness of the Specification needs to be updated to use the jakarta namespace.
  • Final Jakarta API available in Staging Repo
    When ready, your final version of the API needs to be staged to get ready for the PR review and approvals.
  • Draft Specification and Apidoc PRs ready for review
    Like we did for Jakarta EE 8, draft PRs need to be created and reviewed in preparation for the final ballots.
  • Release Review Ballot started
    Each Jakarta EE component will need to initiate a separate Release Review ballot after proper reviewing has completed. To be clear, there will not be a blanket Release Review for all of Jakarta EE 9 like we did for the Plan Review. Each component needs a separate Release Review.

Make CDI to replace EJB

A frequent request for CDI is to replace EJB as CDI is becoming more and more popular and widely adopted. CDI covers many EJB functionalities with a much easier framework. However, there are some gaps to be filled. I would like to use this issue to address the gaps where CDI has no counterpart functionalities. This includes:

  • startup

  • Timer
    I think the useful feature of EJB is startup, so in CDI, we should provide this equivalent feature. As for Timer support, I think it can be supplied by other specs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.