I have a use case where I want to create dynamically (=programmatically) a Stateless Session Bean (EJB3) instead of declaratively creating a Stateless bean through annotation (@Stateless).
Is there a way of telling the EJB container / CDI that my programme wants to:
create a java instance;
dynamically register the instance as a Stateless EJB (including any meta information such as transactional context (which method should run in which transaction context and under which TxType (Required, Supports, ...)) and
registering it also in the naming context (JNDI / EJB name)?
So, in a nutshell:
I have custom code acting as a "Stateless SB" producer/provider and it should be able to let the container know that it wants to register a new instance (class) as a Stateless SB with all expected EJB's behaviours (Tx interceptors etc etc).
So what I am really saying:
My code knows how to implement a specific logic(by code) which needs to be dynamically encapsulated in an instance which belongs to SOME class that is NOT declaratively annotated with the @Stateless annotation and will be dynamically (runtime) decorated in such a way to behave like a Stateless session bean.
Another way to approach this, IMO:
To define all EJB specific meta information in the interface which would be implemented by a bean, but EJB3 spec does NOT allow you to declare @Stateless on interface level. @Stateless should be declared on implementation level (bean).
Mind you: it is precisely this STATELESS ANNOTATED bean implementation which does NOT exist in my case. So there is no way for the container to scan the code, to find and to register a class as a stateless bean.
Any ideas?