Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdi-dev] Spec question about application context
  • From: Benjamin Confino <BENJAMIC@xxxxxxxxxx>
  • Date: Fri, 30 Aug 2024 10:35:47 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=uk.ibm.com; dmarc=pass action=none header.from=uk.ibm.com; dkim=pass header.d=uk.ibm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7dbomkwTHm4J4JWS1vMrov20/cFpSgm6lf1a2mVrvu4=; b=o+ag63DyUQz63lnECvRnNqU6nlA+Yh3jHCmE81oNqiLbx3elo54BmLpx6dfYJfU0OlsIfxq+K5nxOIVyN9zoP23sD+ZuSkw+1cmGD4RoBYtAF4XORdknpAQpbcyM4XwbwmFWIcnEkmYLMChe4JTxB68bLxWsyzJ3N9xHLT3pJYrUaRXuLIHfof/4r9ZGH8zJKaemTEtExjgtCB5uqEIIadpZZ7ltNYABk7Ywr0phE2RJcZ9381BpYjiTu55Sl+kQAakCMqGHsJeAiVVN5W3bKZHjoWKtHv2aEDdh96kkEOJ5C31v2zkgJ2LANP1RYJohUMp5OQusxjPzMZbuWVmi3g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=j89B6MlwpNxILr12pQljIBQxgAMPi3qUv8tJ3PXK8Ns8KFzM6DvdGjJIBH1kHinhCupfvw0AOw6rUTQYnAcoYdgNRiA1pSkxhtd0fP+14dYWdEKPwW/T4ugErmtDVzq/xmoOGPBqoAL9pUatjXxbKq4pY2MDnO25ceSuSdfP1BB4vMi9zrzVGEpvtivgwdwwu5avc5iK3iDyDH5/saVoDQkdW4YcVNbDHbbLIJy64AvAXKFB2Mhit2hzZMMWKB/1vBNVLlAUf52MSUPn5e+9c1l0bAO0GYy+s8B+1FV6Z4jp3TigvbT2wJf8qSoUljgo8bGeEJl3RiUgyqCh/eA5ZQ==
  • Delivered-to: cdi-dev@xxxxxxxxxxx
  • List-archive: <https://www.eclipse.org/mailman/private/cdi-dev/>
  • List-help: <mailto:cdi-dev-request@eclipse.org?subject=help>
  • List-subscribe: <https://www.eclipse.org/mailman/listinfo/cdi-dev>, <mailto:cdi-dev-request@eclipse.org?subject=subscribe>
  • List-unsubscribe: <https://www.eclipse.org/mailman/options/cdi-dev>, <mailto:cdi-dev-request@eclipse.org?subject=unsubscribe>
  • Msip_labels:
  • Thread-index: AQHa+lBsAp9PaXAujkuRj/osYALytrI/ZM+AgAAomeM=
  • Thread-topic: [EXTERNAL] Re: [cdi-dev] Spec question about application context

Hello Matej,

It sounds like we're all on the same page regarding the implementation and the interpretation of the spec as it currently stands. Which leaves only one final question: Do people think the spec should specify something regarding moving between threads so application and library developers can be confident all implementors will support whatever method they're using to create threads?

Regards
Benjamin

From: Matej Novotny <manovotn@xxxxxxxxxx>
Sent: 30 August 2024 08:17
To: cdi developer discussions <cdi-dev@xxxxxxxxxxx>
Cc: Benjamin Confino <BENJAMIC@xxxxxxxxxx>
Subject: [EXTERNAL] Re: [cdi-dev] Spec question about application context
 
Hello, your finds in WFLY are correct in that it also uses a mechanism to determine the caller of CDI. current() and uses a TCCL (which in are in turn based on WFLY modules). To add a little context, this happens because Weld has a structure
Hello,

your finds in WFLY are correct in that it also uses a mechanism to determine the caller of CDI.current() and uses a TCCL (which in are in turn based on WFLY modules).
To add a little context, this happens because Weld has a structure of [per archive] BMs linked between each other with certain visibility mimicking EE umbrella spec visibility rules - hence the "caller sensitivity" of CDI.current().

As for you questions, I don't think the quoted spec section explains anything in this scenario - there is very little in the spec WRT moving between threads.
Personally, I think your approach makes sense. You need some way to determine the caller and TCCL is an easy way to achieve that.

Matej

On Thu, Aug 29, 2024 at 10:17 PM Benjamin Confino via cdi-dev <cdi-dev@xxxxxxxxxxx> wrote:
Hello

I recently had a customer ask me about CDI.current() in a multithreaded environment. In our webserver we set thread context that when an application invokes CDI.current() we know which application . However, propagating that context to a new thread requires an application to use an ManagedExecutorService or a similar technique. I did a quick santiy check against wildfly and I see that https://github.com/wildfly/wildfly/blob/main/weld/subsystem/src/main/java/org/jboss/as/weld/WeldProvider.java also has logic in getCDI() find the right instance of CDI.


My customer believes this is incorrect, and they say the spec just says (they referenced CDI-2.0 section 25.3.1) which says "A Java EE container is required to provide a CDI provider that will allow access to the current container for any Java EE application or Java EE module which contains enabled beans"

Their interpretation of this is that the spec beanmanager availability only depends on if we're calling CDI.current() within a Java EE application or Java EE module.

What does everyone think? Is it acceptable to depend on ManagedExecutorService to find the right instance of CDI?

Regards
Benjamin
Unless otherwise stated above:

IBM United Kingdom Limited
Registered in England and Wales with number 741598
Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU
_______________________________________________
cdi-dev mailing list
cdi-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/cdi-dev
Unless otherwise stated above:

IBM United Kingdom Limited
Registered in England and Wales with number 741598
Registered office: PO Box 41, North Harbour, Portsmouth, Hants. PO6 3AU

Back to the top