You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Gerhard Petracek <ge...@gmail.com> on 2010/03/04 20:39:24 UTC

Re: [Ext-CDI] @Transactional

hi arne,

i created a jira issue for it [1].
could you please upload your implementation.
+ a short description about the possible usages as well as restrictions (if
present).

thx & regards,
gerhard

[1] https://issues.apache.org/jira/browse/EXTCDI-4

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2010/2/20 Arne Limburg <ar...@openknowledge.de>

>  Hi,
>
>
>
> I’ve updated my code at
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> It is not really tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject scoped
> EntityManagers for every CDI-scope.
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 151 - 108 22 942
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> *Von:* Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> *Gesendet:* Montag, 15. Februar 2010 13:44
> *An:* MyFaces Development
> *Betreff:* Re: [Ext-CDI] @Transactional
>
>
>
> hi arne,
>
>
>
> thx for providing the source code.
>
> i'll have a look at it after the jsfdays.
>
>
>
> one of the goals is to provide an alternative conversation scope for cdi
> which allows to use the conversation concepts provided by orchestra.
>
> so we have to ensure that it works with every custom cdi scope.
>
> (cdi conversations would be the default scope)
>
>
>
> regards,
>
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>  2010/2/15 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
> I've prototyped some code that injects conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and added @Transactional
> support for this EntityManagers. This code needs some thinking though, e.g.
> how to handle the default-case (no unitName specified)...
>
> If you want to take a look at it, I have created a Wiki page and added my
> code as attachment:
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
> This code could be a starting point to implement Orchestra-like
> conversations (starting with CDI-Conversations)...
>
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 - 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
>
> Gesendet: Samstag, 13. Februar 2010 20:27
>
> An: MyFaces Development
> Betreff: AW: [Ext-CDI] @Transactional
>
> > I am afraid supporting multiple persistence-units in that
> > scenario is very difficult...
>
> Nope, it's really easy. I simply use Qualifiers to distinguish between
> them.
>
> @Qualifier
> public @instance Core {}
>
> @Qualifier
> public @instance Other {}
>
> ----
> @RequestScoped
> public class EMProducer {
> private @PersistenceContext(unitName="core") EntityManager emCore;
> private @PersistenceContext(unitName="other") EntityManager emOther;
>
>
> public @Produces @Core EntityManager getCoreEM() {return emCore;}
> public @Produces @Other EntityManager getOtherEM() {return emOther;}
>
>
> Injection happens with
>
> private @Inject @Core EntityManager
>
>
> Got the idea?
>
> LieGrue,
> strub
>
> --- Arne Limburg <ar...@openknowledge.de> schrieb am Sa, 13.2.2010:
>
> > Von: Arne Limburg <ar...@openknowledge.de>
> > Betreff: AW: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Samstag, 13. Februar 2010, 20:06
> > Hi Mark,
> >
> > thank you for your feedback. I was aware of the requirement
> > of CDI-containers to inject JavaEE resources in a
> > JavaEE-environment, but Gerhard and I are thinking about a
> > generic non-JavaEE-solution for EntityManager-injection. And
> > at least weld does no injection of JavaEE-resources in this
> > case. How does OpenWebBeans?
> > I am afraid supporting multiple persistence-units in that
> > scenario is very difficult...
> >
> > Nonetheless it would be nice to see your
> > multiple-database-handling TransactionInterceptor in CODI.
> >
> > Regards,
> > Arne
> >
> > --
> >
> > Arne Limburg - Enterprise Developer
> > OpenKnowledge GmbH, Oldenburg
> > Bismarckstraße 13, 26122 Oldenburg
> > Mobil: +49 (0) 151 - 108 22 942
> > Tel: +49 (0) 441 - 4082-0
> > Fax: +49 (0) 441 - 4082-111
> > arne.limburg@openknowledge.de
> > http://www.openknowledge.de
>
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> > Gesendet: Samstag, 13. Februar 2010 15:39
> > An: MyFaces Development
> > Betreff: AW: [Ext-CDI] @Transactional
> >
> > Hi!
> >
> > The JSR-299 spec defines that we have to support injection
> > of EE-Resources.
> >
> > This was more explicit in the old version of the spec, but
> > unless the wording got shortened, I still think injection of
> > @PersistenceUnit and @PersistenceContext must be supported
> > by any JSR-299 container (at least in an EE environment).
> >
> > For OpenWebBeans, you can simply use our
> > openwebbeans-resource plugin. Please note that this is
> > necessary because OWB is modular, and openwebbeans-impl (the
> > core) will have no EE dependencies at all (not even JSF,
> > JPA, etc!) This will get picked up automatically if it is
> > available in the classpath, e.g. you can simply define the
> > following maven dependency:
> >
> >         <dependency>
> >
> > <groupId>org.apache.openwebbeans</groupId>
> >
> > <artifactId>openwebbeans-resource</artifactId>
> >
> > <version>${owb.version}</version>
> >         </dependency>
> >
> > OWB supports 2 different scenarios. If you are not running
> > in a JTA aware container like e.g. OpenEJB, you will
> > automatically use a simple resource version of an SPI
> > implementation which uses
> > Persistence#createEntityManagerFactory(unitName) for
> > injecting (Thus getting an extended EM). If you use e.g.
> > OpenEJB, we are able to get the injectable resources
> > directly from there (thus getting a transactional EM).
> >
> > Once this is available, you can simply create a producer
> > method for the EntityManager:
> >
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>
> >
> > There is also an example on how to implement a
> > TransactionalInterceptor:
> >
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>
> >
> > In my company, I already implemented a
> > TransactionalInteceptor which is capable of handling
> > multiple databases at a time and also correctly handles
> > nested transactions. I hope to migrate this over to CODI in
> > the near future.
> >
> >
> > LieGrue,
> > strub
> >
> >
> > --- Arne Limburg <ar...@openknowledge.de>
> > schrieb am Sa, 13.2.2010:
> >
> > > Von: Arne Limburg <ar...@openknowledge.de>
> > > Betreff: AW: [Ext-CDI] @Transactional
> > > An: "'MyFaces Development'" <de...@myfaces.apache.org>
> > > Datum: Samstag, 13. Februar 2010, 14:42
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hi Gerhard,
> > >
> > >
> > >
> > > OK, I got what you did,
> > > basically I did the same. You are right,
> > > that was pretty straight-forward, but I had to
> > hard-code
> > > the persistence-unit
> > > name.
> > >
> > >
> > >
> > > I have two ideas to inject the
> > > persistence-unit name into the
> > > producer-method for the EntityManager:
> > >
> > >
> > >
> > > First idea: A
> > > @PersistenceUnitName qualifier-annotation to
> > > inject the name into the producer-method. Client code
> > would
> > > have somethink like
> > >
> > > public class Configuration
> > > {
> > >
> > >
> > >
> > >   @Produces
> > > @PersistenceUnitName
> > >
> > >   String
> > > getPersistenceUnitName() {
> > >
> > > …
> > >
> > > Not really nice, but the
> > > simplest solution to generify it.
> > >
> > >
> > >
> > > Second idea:
> > >
> > > The @PersistenceContext
> > > qualifier has a @Nonbind attribute
> > > persistenceUnitName which we can extract in the
> > producer
> > > method. But then we
> > > get in scoping issues. Especially when having
> > multiple
> > > persistence-units within
> > > one deployment. The second problem is: How can the
> > > @Transactional annotation
> > > know the persistence-unit-name.
> > >
> > >
> > >
> > > Any other ideas?
> > >
> > >
> > >
> > > Regards,
> > >
> > > Arne
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Arne Limburg - Enterprise
> > > Developer
> > >
> > > OpenKnowledge GmbH,
> > > Oldenburg
> > >
> > > Bismarckstraße 13, 26122
> > > Oldenburg
> > >
> > > Mobil: +49 (0) 151 - 108 22
> > > 942
> > >
> > > Tel: +49 (0) 441 -
> > > 4082-0
> > >
> > > Fax: +49 (0) 441 -
> > > 4082-111
> > >
> > > arne.limburg@openknowledge.de
> > >
> > >
> > > http://www.openknowledge.de
>
> > >
> > >
> > >
> > >
> > > Registergericht: Amtsgericht
> > > Oldenburg, HRB 4670
> > >
> > > Geschäftsführer: Lars
> > > Röwekamp, Jens Schumann
> > >
> > >
> > >
> > >
> > >
> > > Von: Gerhard Petracek
> > > [mailto:gerhard.petracek@gmail.com]
> >
> > >
> > > Gesendet: Samstag, 13. Februar 2010 14:32
> > >
> > > An: MyFaces Development
> > >
> > > Betreff: Re: [Ext-CDI] @Transactional
> > >
> > >
> > >
> > >
> > >
> > > hi arne,
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > i used the EntityManager to get
> > > an EntityTransaction.
> > >
> > >
> > >
> > >
> > >
> > > you have to use cdi to create and
> > > inject it.
> > >
> > >
> > >
> > >
> > >
> > > (i used some producer methods.)
> > >
> > >
> > >
> > >
> > >
> > > i created @PersistenceUnit which
> > > is a cdi qualifier and
> > >
> > >
> > >
> > >
> > >
> > > @Transactional which is a cdi
> > > interceptor binding.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > basically it works and it isn't
> > > hard to use.
> > >
> > >
> > >
> > >
> > >
> > > however, we have to think about an
> > > approach to provide as
> > > much as possible in a generic way.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > regards,
> > >
> > >
> > >
> > >
> > >
> > > gerhard
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > http://www.irian.at
>
> > >
> > >
> > >
> > > Your JSF powerhouse -
> > >
> > > JSF Consulting, Development and
> > >
> > > Courses in English and German
> > >
> > >
> > >
> > > Professional Support for Apache MyFaces
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hi
> > > Gerhard,
> > >
> > >
> > >
> > > Did
> > > you mean „i used
> > > UserTransaction”? If not, how do you receive your
> > > EntityTransaction?
> > >
> > >
> > >
> > > I am
> > > working on a solution to
> > > get request-scoped EntityManagers injected within a
> > > servlet-container that does
> > > not even support the web-profile (which are the
> > current
> > > jetty and the current
> > > tomcat). I am not able to get an EntityManager
> > injected via
> > > @PersistenceContext
> > > in that environment. So it would be nice if there were
> > some
> > > CDI-Extension to
> > > achieve this. The implementation would be pretty
> > > straight-forward except the
> > > configuration of the persistence-unit name and the
> > handling
> > > of different
> > > persistence-units within one CDI-deployment
> > > unit.
> > >
> > >
> > >
> > > Using
> > > JTA-Transactions vs.
> > > resource-local EntityTransactions is another issue
> > > here.
> > >
> > >
> > >
> > >
> > >
> > > Regards,
> > >
> > > Arne
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Arne
> > > Limburg - Enterprise
> > > Developer
> > >
> > > OpenKnowledge GmbH,
> > > Oldenburg
> > >
> > > Bismarckstraße
> > > 13, 26122 Oldenburg
> > >
> > > Mobil: +49 (0) 151
> > > - 108 22 942
> > >
> > > Tel: +49 (0) 441 -
> > > 4082-0
> > >
> > > Fax: +49 (0) 441 -
> > > 4082-111
> > >
> > > arne.limburg@openknowledge.de
> > >
> > >
> > > http://www.openknowledge.de
> > >
> > >
> > >
> > > Registergericht:
> > > Amtsgericht Oldenburg,
> > > HRB 4670
> > >
> > > Geschäftsführer:
> > > Lars Röwekamp, Jens
> > > Schumann
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Von: Gerhard
> > > Petracek [mailto:gerhard.petracek@gmail.com]
> > >
> > >
> > > Gesendet: Freitag, 12. Februar 2010 19:59
> > >
> > > An: MyFaces Development
> > >
> > > Betreff: Re: [Ext-CDI] @Transactional
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > hi
> > > arne,
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > yes
> > > - i used EntityTransaction in the prototype and it
> > works
> > > pretty well in a
> > > servlet container (that was the base idea).
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > regards,
> > >
> > >
> > >
> > >
> > >
> > > gerhard
> > >
> > >
> > >
> > > http://www.irian.at
>
> > >
> > >
> > >
> > > Your JSF powerhouse -
> > >
> > > JSF Consulting, Development and
> > >
> > > Courses in English and German
> > >
> > >
> > >
> > > Professional Support for Apache MyFaces
> > >
> > >
> > >
> > > 2010/2/12
> > > Arne Limburg <ar...@openknowledge.de>
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hi
> > > folks,
> > >
> > >
> > >
> > > I saw the discussion of adding an
> > > @Transactional-Annotation to your
> > > CDI extensions. I think Gerhard wrote it. I wonder if
> > it
> > > deals with JTA
> > > transactions (which indeed would be pretty
> > > straight-forward) or with
> > > EntityTransactions of an resource-local EntityManager.
> > I am
> > > working on the
> > > latter one and just would want to know if someone else
> > is
> > > working on such
> > > stuff. I think it would be great, when we could
> > archive
> > > injection of
> > > resource-local EntityManagers with transaction-support
> > to
> > > deploy it on a tomcat
> > > or jetty. What do you think?
> > >
> > >
> > >
> > > Regards,
> > >
> > > Arne
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Arne Limburg - Enterprise
> > > Developer
> > >
> > > OpenKnowledge GmbH, Oldenburg
> > >
> > > Bismarckstraße
> > > 13, 26122 Oldenburg
> > >
> > > Mobil:
> > > +49 (0) 151 - 108 22 942
> > >
> > > Tel:
> > > +49 (0) 441 - 4082-0
> > >
> > > Fax:
> > > +49 (0) 441 - 4082-111
> > >
> > > arne.limburg@openknowledge.de
> > >
> > >
> > > http://www.openknowledge.de
>
> > >
> > >
> > >
> > >
> > > Registergericht:
> > > Amtsgericht Oldenburg, HRB 4670
> > >
> > > Geschäftsführer:
> > > Lars Röwekamp, Jens Schumann
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen Massenmails.
> > http://mail.yahoo.com
> >
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
>
>

AW: [Ext-CDI] @Transactional

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi!

I think we need to further define the behavior of our injected EntityManagers and the @Transactional annotation:

1. May there be more than one EntityManager (with different persistence-units) within one scope?

2. May EntityManagers be shared between scopes?
   If yes, where are the boundaries of our EntityManagers (when are they opened and closed)?
   If no, does that mean, that EntityManagers that are injected in @Dependent beans are always different from the ones that are injected into beans with other scopes or do we want to have special behavior for @Depenent scope?

3. Does the @Transactional annotation work only for the scope of the annotated bean, within the complete Thread or for a particular persistence-unit?
   The second would mean, that a @Transactional annotation may start and commit more than one transaction. The first would mean that too, if we answer question 1 with "yes". The third would mean, that we need the unitName attribute at the @Transactional annotation, which is ugly imho.

4. Do we want to support nested transactions (a consequence of supporting @TransactionAttribute). If yes, we should define the behavior for the extended EntityManager case. This is not such trivial, because JPA does not support nested transactions. Should we open a new EntityManager instead?

5. Should we support the @PersistenceContext annotation of JPA? If yes, how can we avoid that we collide with the injection of a JavaEE server?

6. How should the default-behavior look like, when no persistence unit-name is specified? Should we implement the behavior of JavaEE (scanning various config-files...)?

Your opinions?

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 170 - 2733627
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann


-----Ursprüngliche Nachricht-----
Von: Mark Struberg [mailto:struberg@yahoo.de]
Gesendet: Donnerstag, 4. März 2010 20:47
An: MyFaces Development
Betreff: Re: [Ext-CDI] @Transactional

Hi!

Uploading the source is al always a good idea, so we can further discuss this really complicated topic.

Is this meant to work for extended EntityManagers or for transactional JTA managed ones?

Another question: does this require the EntityManager to have a certain scope? For the extended EM variant of course, for JTA managed we will most certainly use @Dependent, right?



LieGrue,
strub

--- Gerhard Petracek <ge...@gmail.com> schrieb am Do, 4.3.2010:

> Von: Gerhard Petracek <ge...@gmail.com>
> Betreff: Re: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> hi arne,
> i created a jira issue for it
> [1].could you please upload your
> implementation.+ a short description about the
> possible usages as well as restrictions (if
> present).
>
>
> thx & regards,gerhard
> [1] https://issues.apache.org/jira/browse/EXTCDI-4
>
> http://www.irian.at
>
>
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hi,
>
>
>
> I’ve updated my
> code at
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
>
>
> It is not really
> tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject
> scoped
> EntityManagers for every CDI-scope.
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg -
> Enterprise Developer
>
> OpenKnowledge GmbH,
> Oldenburg
>
> Bismarckstraße 13,
> 26122 Oldenburg
>
> Mobil: +49 (0) 151 -
> 108 22 942
>
> Tel: +49 (0) 441 -
> 4082-0
>
> Fax: +49 (0) 441 -
> 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht:
> Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer:
> Lars Röwekamp, Jens Schumann
>
>
>
>
>
> Von: Gerhard Petracek
> [mailto:gerhard.petracek@gmail.com]
>
>
> Gesendet: Montag, 15. Februar 2010 13:44
>
> An: MyFaces
> Development
>
> Betreff: Re: [Ext-CDI]
> @Transactional
>
>
>
>
>
> hi arne,
>
>
>
>
>
>
>
>
>
> thx for providing the source code.
>
>
>
>
>
> i'll have a look at it after the
> jsfdays.
>
>
>
>
>
>
>
>
>
>
>
> one of the goals is to provide an
> alternative conversation
> scope for cdi which allows to use the conversation concepts
> provided by
> orchestra.
>
>
>
>
>
> so we have to ensure that it works
> with every custom cdi
> scope.
>
>
>
>
>
> (cdi conversations would be the
> default scope)
>
>
>
>
>
>
>
>
>
>
>
> regards,
>
>
>
>
>
> gerhard
>
>
>
> http://www.irian.at
>
>
>
> Your JSF powerhouse -
>
> JSF Consulting, Development and
>
> Courses in English and German
>
>
>
> Professional Support for Apache MyFaces
>
>
>
>
>
>
>
> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
>
>
> I've prototyped some code that injects
> conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and
> added @Transactional
> support for this EntityManagers. This code needs some
> thinking though, e.g. how
> to handle the default-case (no unitName specified)...
>
>
>
> If you want to take a look at it, I have created a Wiki
> page and added my code
> as attachment:
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
>
>
> This code could be a starting point to implement
> Orchestra-like conversations
> (starting with CDI-Conversations)...
>
>
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 151 - 108 22 942
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> -----Ursprüngliche Nachricht-----
>
> Von: Mark Struberg [mailto:struberg@yahoo.de]
>
>
>
> Gesendet: Samstag, 13. Februar 2010
> 20:27
>
>
>
>
>
> An: MyFaces Development
>
> Betreff: AW: [Ext-CDI] @Transactional
>
>
>
> > I am afraid supporting multiple persistence-units in
> that
>
> > scenario is very difficult...
>
>
>
> Nope, it's really easy. I simply use Qualifiers to
> distinguish between them.
>
>
>
> @Qualifier
>
> public @instance Core {}
>
>
>
> @Qualifier
>
> public @instance Other {}
>
>
>
> ----
>
> @RequestScoped
>
> public class EMProducer {
>
> private @PersistenceContext(unitName="core")
> EntityManager emCore;
>
> private @PersistenceContext(unitName="other")
> EntityManager emOther;
>
>
>
>
>
> public @Produces @Core EntityManager getCoreEM() {return
> emCore;}
>
> public @Produces @Other EntityManager getOtherEM() {return
> emOther;}
>
>
>
>
>
> Injection happens with
>
>
>
> private @Inject @Core EntityManager
>
>
>
>
>
> Got the idea?
>
>
>
> LieGrue,
>
> strub
>
>
>
> --- Arne Limburg <ar...@openknowledge.de>
> schrieb am Sa, 13.2.2010:
>
>
>
> > Von: Arne Limburg <ar...@openknowledge.de>
>
> > Betreff: AW: [Ext-CDI] @Transactional
>
> > An: "MyFaces Development" <de...@myfaces.apache.org>
>
> > Datum: Samstag, 13. Februar 2010, 20:06
>
> > Hi Mark,
>
> >
>
> > thank you for your feedback. I was aware of the
> requirement
>
> > of CDI-containers to inject JavaEE resources in a
>
> > JavaEE-environment, but Gerhard and I are thinking
> about a
>
> > generic non-JavaEE-solution for
> EntityManager-injection. And
>
> > at least weld does no injection of JavaEE-resources in
> this
>
> > case. How does OpenWebBeans?
>
> > I am afraid supporting multiple persistence-units in
> that
>
> > scenario is very difficult...
>
> >
>
> > Nonetheless it would be nice to see your
>
> > multiple-database-handling TransactionInterceptor in
> CODI.
>
> >
>
> > Regards,
>
> > Arne
>
> >
>
> > --
>
> >
>
> > Arne Limburg - Enterprise Developer
>
> > OpenKnowledge GmbH, Oldenburg
>
> > Bismarckstraße 13, 26122 Oldenburg
>
> > Mobil: +49 (0) 151 - 108 22 942
>
> > Tel: +49 (0) 441 - 4082-0
>
> > Fax: +49 (0) 441 - 4082-111
>
> > arne.limburg@openknowledge.de
>
> > http://www.openknowledge.de
>
>
>
> >
>
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> >
>
> > -----Ursprüngliche Nachricht-----
>
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
>
> >
>
> > Gesendet: Samstag, 13. Februar 2010 15:39
>
> > An: MyFaces Development
>
> > Betreff: AW: [Ext-CDI] @Transactional
>
> >
>
> > Hi!
>
> >
>
> > The JSR-299 spec defines that we have to support
> injection
>
> > of EE-Resources.
>
> >
>
> > This was more explicit in the old version of the spec,
> but
>
> > unless the wording got shortened, I still think
> injection of
>
> > @PersistenceUnit and @PersistenceContext must be
> supported
>
> > by any JSR-299 container (at least in an EE
> environment).
>
> >
>
> > For OpenWebBeans, you can simply use our
>
> > openwebbeans-resource plugin. Please note that this
> is
>
> > necessary because OWB is modular, and
> openwebbeans-impl (the
>
> > core) will have no EE dependencies at all (not even
> JSF,
>
> > JPA, etc!) This will get picked up automatically if it
> is
>
> > available in the classpath, e.g. you can simply define
> the
>
> > following maven dependency:
>
> >
>
> >         <dependency>
>
> >
>
> >
> <groupId>org.apache.openwebbeans</groupId>
>
> >
>
> >
> <artifactId>openwebbeans-resource</artifactId>
>
> >
>
> > <version>${owb.version}</version>
>
> >         </dependency>
>
> >
>
> > OWB supports 2 different scenarios. If you are not
> running
>
> > in a JTA aware container like e.g. OpenEJB, you will
>
> > automatically use a simple resource version of an SPI
>
> > implementation which uses
>
> > Persistence#createEntityManagerFactory(unitName) for
>
> > injecting (Thus getting an extended EM). If you use
> e.g.
>
> > OpenEJB, we are able to get the injectable resources
>
> > directly from there (thus getting a transactional
> EM).
>
> >
>
> > Once this is available, you can simply create a
> producer
>
> > method for the EntityManager:
>
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>
>
>
>
>
> >
>
> > There is also an example on how to implement a
>
> > TransactionalInterceptor:
>
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>
>
>
>
>
> >
>
> > In my company, I already implemented a
>
> > TransactionalInteceptor which is capable of handling
>
> > multiple databases at a time and also correctly
> handles
>
> > nested transactions. I hope to migrate this over to
> CODI in
>
> > the near future.
>
> >
>
> >
>
> > LieGrue,
>
> > strub
>
> >
>
> >
>
> > --- Arne Limburg <ar...@openknowledge.de>
>
> > schrieb am Sa, 13.2.2010:
>
> >
>
> > > Von: Arne Limburg <ar...@openknowledge.de>
>
> > > Betreff: AW: [Ext-CDI] @Transactional
>
> > > An: "'MyFaces Development'"
> <de...@myfaces.apache.org>
>
> > > Datum: Samstag, 13. Februar 2010, 14:42
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi Gerhard,
>
> > >
>
> > >
>
> > >
>
> > > OK, I got what you did,
>
> > > basically I did the same. You are right,
>
> > > that was pretty straight-forward, but I had to
>
> > hard-code
>
> > > the persistence-unit
>
> > > name.
>
> > >
>
> > >
>
> > >
>
> > > I have two ideas to inject the
>
> > > persistence-unit name into the
>
> > > producer-method for the EntityManager:
>
> > >
>
> > >
>
> > >
>
> > > First idea: A
>
> > > @PersistenceUnitName qualifier-annotation to
>
> > > inject the name into the producer-method. Client
> code
>
> > would
>
> > > have somethink like
>
> > >
>
> > > public class Configuration
>
> > > {
>
> > >
>
> > >
>
> > >
>
> > >   @Produces
>
> > > @PersistenceUnitName
>
> > >
>
> > >   String
>
> > > getPersistenceUnitName() {
>
> > >
>
> > > …
>
> > >
>
> > > Not really nice, but the
>
> > > simplest solution to generify it.
>
> > >
>
> > >
>
> > >
>
> > > Second idea:
>
> > >
>
> > > The @PersistenceContext
>
> > > qualifier has a @Nonbind attribute
>
> > > persistenceUnitName which we can extract in the
>
> > producer
>
> > > method. But then we
>
> > > get in scoping issues. Especially when having
>
> > multiple
>
> > > persistence-units within
>
> > > one deployment. The second problem is: How can
> the
>
> > > @Transactional annotation
>
> > > know the persistence-unit-name.
>
> > >
>
> > >
>
> > >
>
> > > Any other ideas?
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH,
>
> > > Oldenburg
>
> > >
>
> > > Bismarckstraße 13, 26122
>
> > > Oldenburg
>
> > >
>
> > > Mobil: +49 (0) 151 - 108 22
>
> > > 942
>
> > >
>
> > > Tel: +49 (0) 441 -
>
> > > 4082-0
>
> > >
>
> > > Fax: +49 (0) 441 -
>
> > > 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Registergericht: Amtsgericht
>
> > > Oldenburg, HRB 4670
>
> > >
>
> > > Geschäftsführer: Lars
>
> > > Röwekamp, Jens Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Von: Gerhard Petracek
>
> > > [mailto:gerhard.petracek@gmail.com]
>
> >
>
> > >
>
> > > Gesendet: Samstag, 13. Februar 2010 14:32
>
> > >
>
> > > An: MyFaces Development
>
> > >
>
> > > Betreff: Re: [Ext-CDI] @Transactional
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > hi arne,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > i used the EntityManager to get
>
> > > an EntityTransaction.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > you have to use cdi to create and
>
> > > inject it.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > (i used some producer methods.)
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > i created @PersistenceUnit which
>
> > > is a cdi qualifier and
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > @Transactional which is a cdi
>
> > > interceptor binding.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > basically it works and it isn't
>
> > > hard to use.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > however, we have to think about an
>
> > > approach to provide as
>
> > > much as possible in a generic way.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > regards,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > gerhard
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > http://www.irian.at
>
>
>
> > >
>
> > >
>
> > >
>
> > > Your JSF powerhouse -
>
> > >
>
> > > JSF Consulting, Development and
>
> > >
>
> > > Courses in English and German
>
> > >
>
> > >
>
> > >
>
> > > Professional Support for Apache MyFaces
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi
>
> > > Gerhard,
>
> > >
>
> > >
>
> > >
>
> > > Did
>
> > > you mean „i used
>
> > > UserTransaction”? If not, how do you receive
> your
>
> > > EntityTransaction?
>
> > >
>
> > >
>
> > >
>
> > > I am
>
> > > working on a solution to
>
> > > get request-scoped EntityManagers injected within
> a
>
> > > servlet-container that does
>
> > > not even support the web-profile (which are the
>
> > current
>
> > > jetty and the current
>
> > > tomcat). I am not able to get an EntityManager
>
> > injected via
>
> > > @PersistenceContext
>
> > > in that environment. So it would be nice if there
> were
>
> > some
>
> > > CDI-Extension to
>
> > > achieve this. The implementation would be pretty
>
> > > straight-forward except the
>
> > > configuration of the persistence-unit name and
> the
>
> > handling
>
> > > of different
>
> > > persistence-units within one CDI-deployment
>
> > > unit.
>
> > >
>
> > >
>
> > >
>
> > > Using
>
> > > JTA-Transactions vs.
>
> > > resource-local EntityTransactions is another
> issue
>
> > > here.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne
>
> > > Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH,
>
> > > Oldenburg
>
> > >
>
> > > Bismarckstraße
>
> > > 13, 26122 Oldenburg
>
> > >
>
> > > Mobil: +49 (0) 151
>
> > > - 108 22 942
>
> > >
>
> > > Tel: +49 (0) 441 -
>
> > > 4082-0
>
> > >
>
> > > Fax: +49 (0) 441 -
>
> > > 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
> > >
>
> > >
>
> > >
>
> > > Registergericht:
>
> > > Amtsgericht Oldenburg,
>
> > > HRB 4670
>
> > >
>
> > > Geschäftsführer:
>
> > > Lars Röwekamp, Jens
>
> > > Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Von: Gerhard
>
> > > Petracek [mailto:gerhard.petracek@gmail.com]
>
> > >
>
> > >
>
> > > Gesendet: Freitag, 12. Februar 2010 19:59
>
> > >
>
> > > An: MyFaces Development
>
> > >
>
> > > Betreff: Re: [Ext-CDI] @Transactional
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > hi
>
> > > arne,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > yes
>
> > > - i used EntityTransaction in the prototype and
> it
>
> > works
>
> > > pretty well in a
>
> > > servlet container (that was the base idea).
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > regards,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > gerhard
>
> > >
>
> > >
>
> > >
>
> > > http://www.irian.at
>
>
>
> > >
>
> > >
>
> > >
>
> > > Your JSF powerhouse -
>
> > >
>
> > > JSF Consulting, Development and
>
> > >
>
> > > Courses in English and German
>
> > >
>
> > >
>
> > >
>
> > > Professional Support for Apache MyFaces
>
> > >
>
> > >
>
> > >
>
> > > 2010/2/12
>
> > > Arne Limburg <ar...@openknowledge.de>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi
>
> > > folks,
>
> > >
>
> > >
>
> > >
>
> > > I saw the discussion of adding an
>
> > > @Transactional-Annotation to your
>
> > > CDI extensions. I think Gerhard wrote it. I
> wonder if
>
> > it
>
> > > deals with JTA
>
> > > transactions (which indeed would be pretty
>
> > > straight-forward) or with
>
> > > EntityTransactions of an resource-local
> EntityManager.
>
> > I am
>
> > > working on the
>
> > > latter one and just would want to know if someone
> else
>
> > is
>
> > > working on such
>
> > > stuff. I think it would be great, when we could
>
> > archive
>
> > > injection of
>
> > > resource-local EntityManagers with
> transaction-support
>
> > to
>
> > > deploy it on a tomcat
>
> > > or jetty. What do you think?
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH, Oldenburg
>
> > >
>
> > > Bismarckstraße
>
> > > 13, 26122 Oldenburg
>
> > >
>
> > > Mobil:
>
> > > +49 (0) 151 - 108 22 942
>
> > >
>
> > > Tel:
>
> > > +49 (0) 441 - 4082-0
>
> > >
>
> > > Fax:
>
> > > +49 (0) 441 - 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Registergericht:
>
> > > Amtsgericht Oldenburg, HRB 4670
>
> > >
>
> > > Geschäftsführer:
>
> > > Lars Röwekamp, Jens Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> >
>
> >
>
> > __________________________________________________
>
> > Do You Yahoo!?
>
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
>
> > herausragenden Schutz gegen Massenmails.
>
> > http://mail.yahoo.com
>
> >
>
>
>
> __________________________________________________
>
> Do You Yahoo!?
>
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen
> Massenmails.
>
> http://mail.yahoo.com
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

AW: [Ext-CDI] @Transactional

Posted by Mark Struberg <st...@yahoo.de>.
will look at it.

btw, I'm available in #myfaces and #openwebbeans currently

LieGrue,
strub

--- Arne Limburg <ar...@openknowledge.de> schrieb am Fr, 5.3.2010:

> Von: Arne Limburg <ar...@openknowledge.de>
> Betreff: AW: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Freitag, 5. März, 2010 22:20 Uhr
> Hi Mark,
> 
> Your test container stuff looks good. Unfortunately I can't
> get it to work in my environment (neither from within
> eclipse nor with maven). The instanceRetrievalTest fails
> with a
> javax.enterprise.inject.ResolutionException: cannot find
> beans for class
> org.apache.webbeans.cditest.test.SessionScopedTestBean
>         at
> org.apache.webbeans.cditest.owb.CdiTestOpenWebBeansContainer.getInstance(CdiTestOpenWebBeansContainer.java:154)
>         at
> org.apache.webbeans.cditest.test.TestOwbTestContainer.testInstanceRetrieval(TestOwbTestContainer.java:37)
> ...
> I wonder if it is a classpath issue? I guess the stuff
> works on your environment. I'll take a further look into
> it.
> 
> What do the others think about adding this test support to
> CODI and implementing the CdiTestContainer for weld?
> 
> When I get this working I'll write some tests for my
> @Transactional stuff.
> 
> Regards,
> Arne
> 
> --
> 
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de

> 
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> Gesendet: Freitag, 5. März 2010 20:46
> An: MyFaces Development
> Betreff: AW: [Ext-CDI] @Transactional
> 
> Hi Arne!
> 
> Since we have OpenWebBeans-M4 officially released today, my
> test container stuff is now available [1].
> 
> It would be really fine if you could review the
> implementation and give me some feedback if you miss
> something.
> 
> I used both JUnit and testng for testing OWB projects in
> the past and most times it was enough to have a central
> class which holds one single CDI container in a static field
> and shuts it down in a finalize(). I only run
> 
> container.stopContexts();
> container.startContexts();
> 
> before each test method to wipe out contextual instances
> from the contexts. Of course, if you like to test
> CDI-Extensions and stuff, you might need to bootstrap the
> container for each test. But imo this is better handled by
> writing integration tests and using the maven-invoker-plugin
> for such cases.
> 
> Btw, if you have already worked with Weld, then you may
> eventually write the CDI test adaptor for Weld? Please ping
> me if you are interested, it's really easy to integrate.
> The OWB test provider is already part of OWB, what do you
> guys think about adding the Weld provider to CODI so we can
> test it with both OWB and Weld?
> 
> txs and LieGrue,
> strub
> 
> [1] http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/

> 
> --- Arne Limburg <ar...@openknowledge.de>
> schrieb am Do, 4.3.2010:
> 
> > Von: Arne Limburg <ar...@openknowledge.de>
> > Betreff: AW: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Donnerstag, 4. März, 2010 22:09 Uhr
> > Hi!
> >
> > I am currently working on a JUnit-Solution for CDI (I
> want
> > to have CDI-Container-Managed TestCases running with
> JUnit,
> > but this is another topic we should discuss on
> another
> > thread). So I did not so much at the
> EntityManager-front.
> > I'll write a detailed Mail about my source this
> weekend.
> >
> > For now I can say:
> > My solution is meant to work for extended
> EntityManagers
> > that are open during an arbitrary scope is active.
> >
> > If someone of you has the time, he can upload the
> sources
> > from the wiki (I have not further worked on it yet).
> As I
> > mentioned I'll write a mail about the source this
> weekend.
> >
> > Regards,
> > Arne
> >
> > --
> >
> > Arne Limburg - Enterprise Developer
> > OpenKnowledge GmbH, Oldenburg
> > Bismarckstraße 13, 26122 Oldenburg
> > Mobil: +49 (0) 170 - 2733627
> > Tel: +49 (0) 441 - 4082-0
> > Fax: +49 (0) 441 - 4082-111
> > arne.limburg@openknowledge.de
> > http://www.openknowledge.de

> 
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > -----Ursprüngliche Nachricht-----
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> > Gesendet: Donnerstag, 4. März 2010 20:47
> > An: MyFaces Development
> > Betreff: Re: [Ext-CDI] @Transactional
> >
> > Hi!
> >
> > Uploading the source is al always a good idea, so we
> can
> > further discuss this really complicated topic.
> >
> > Is this meant to work for extended EntityManagers or
> for
> > transactional JTA managed ones?
> >
> > Another question: does this require the EntityManager
> to
> > have a certain scope? For the extended EM variant of
> course,
> > for JTA managed we will most certainly use
> @Dependent,
> > right?
> >
> >
> >
> > LieGrue,
> > strub
> >
> > --- Gerhard Petracek <ge...@gmail.com>
> > schrieb am Do, 4.3.2010:
> >
> > > Von: Gerhard Petracek <ge...@gmail.com>
> > > Betreff: Re: [Ext-CDI] @Transactional
> > > An: "MyFaces Development" <de...@myfaces.apache.org>
> > > Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> > > hi arne,
> > > i created a jira issue for it
> > > [1].could you please upload your
> > > implementation.+ a short description about the
> > > possible usages as well as restrictions (if
> > > present).
> > >
> > >
> > > thx & regards,gerhard
> > > [1] https://issues.apache.org/jira/browse/EXTCDI-4

> 
> > >
> > > http://www.irian.at

> 
> > >
> > >
> > >
> > > Your JSF powerhouse -
> > > JSF Consulting, Development and
> > > Courses in English and German
> > >
> > > Professional Support for Apache MyFaces
> > >
> > >
> > >
> > > 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > Hi,
> > >
> > >
> > >
> > > I’ve updated my
> > > code at
> > >
> > > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> 
> > >
> > >
> > >
> > > It is not really
> > > tested and lacks some fallback-scenarios (i.e.
> > > null-handling, etc.), but it is a starting point
> to
> > inject
> > > scoped
> > > EntityManagers for every CDI-scope.
> > >
> > >
> > >
> > > Regards,
> > >
> > > Arne
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Arne Limburg -
> > > Enterprise Developer
> > >
> > > OpenKnowledge GmbH,
> > > Oldenburg
> > >
> > > Bismarckstraße 13,
> > > 26122 Oldenburg
> > >
> > > Mobil: +49 (0) 151 -
> > > 108 22 942
> > >
> > > Tel: +49 (0) 441 -
> > > 4082-0
> > >
> > > Fax: +49 (0) 441 -
> > > 4082-111
> > >
> > > arne.limburg@openknowledge.de
> > >
> > > http://www.openknowledge.de

> 
> > >
> > >
> > >
> > > Registergericht:
> > > Amtsgericht Oldenburg, HRB 4670
> > >
> > > Geschäftsführer:
> > > Lars Röwekamp, Jens Schumann
> > >
> > >
> > >
> > >
> > >
> > > Von: Gerhard Petracek
> > > [mailto:gerhard.petracek@gmail.com]
> > >
> > >
> > > Gesendet: Montag, 15. Februar 2010 13:44
> > >
> > > An: MyFaces
> > > Development
> > >
> > > Betreff: Re: [Ext-CDI]
> > > @Transactional
> > >
> > >
> > >
> > >
> > >
> > > hi arne,
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > thx for providing the source code.
> > >
> > >
> > >
> > >
> > >
> > > i'll have a look at it after the
> > > jsfdays.
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > one of the goals is to provide an
> > > alternative conversation
> > > scope for cdi which allows to use the
> conversation
> > concepts
> > > provided by
> > > orchestra.
> > >
> > >
> > >
> > >
> > >
> > > so we have to ensure that it works
> > > with every custom cdi
> > > scope.
> > >
> > >
> > >
> > >
> > >
> > > (cdi conversations would be the
> > > default scope)
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > regards,
> > >
> > >
> > >
> > >
> > >
> > > gerhard
> > >
> > >
> > >
> > > http://www.irian.at

> 
> > >
> > >
> > >
> > > Your JSF powerhouse -
> > >
> > > JSF Consulting, Development and
> > >
> > > Courses in English and German
> > >
> > >
> > >
> > > Professional Support for Apache MyFaces
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> > >
> > > Hi,
> > >
> > >
> > >
> > > I've prototyped some code that injects
> > > conversation-scoped EntityManagers
> > > reading the unitName from the qualifier
> annotation
> > and
> > > added @Transactional
> > > support for this EntityManagers. This code needs
> some
> > > thinking though, e.g. how
> > > to handle the default-case (no unitName
> specified)...
> > >
> > >
> > >
> > > If you want to take a look at it, I have created
> a
> > Wiki
> > > page and added my code
> > > as attachment:
> > >
> > > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> 
> > >
> > >
> > >
> > > This code could be a starting point to implement
> > > Orchestra-like conversations
> > > (starting with CDI-Conversations)...
> > >
> > >
> > >
> > >
> > >
> > > Regards,
> > >
> > > Arne
> > >
> > >
> > >
> > > --
> > >
> > >
> > >
> > > Arne Limburg - Enterprise Developer
> > >
> > > OpenKnowledge GmbH, Oldenburg
> > >
> > > Bismarckstraße 13, 26122 Oldenburg
> > >
> > > Mobil: +49 (0) 151 - 108 22 942
> > >
> > > Tel: +49 (0) 441 - 4082-0
> > >
> > > Fax: +49 (0) 441 - 4082-111
> > >
> > > arne.limburg@openknowledge.de
> > >
> > > http://www.openknowledge.de

> 
> > >
> > >
> > >
> > > Registergericht: Amtsgericht Oldenburg, HRB 4670
> > >
> > > Geschäftsführer: Lars Röwekamp, Jens Schumann
> > >
> > >
> > >
> > > -----Ursprüngliche Nachricht-----
> > >
> > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> > >
> > >
> > >
> > > Gesendet: Samstag, 13. Februar 2010
> > > 20:27
> > >
> > >
> > >
> > >
> > >
> > > An: MyFaces Development
> > >
> > > Betreff: AW: [Ext-CDI] @Transactional
> > >
> > >
> > >
> > > > I am afraid supporting multiple
> persistence-units
> > in
> > > that
> > >
> > > > scenario is very difficult...
> > >
> > >
> > >
> > > Nope, it's really easy. I simply use Qualifiers
> to
> > > distinguish between them.
> > >
> > >
> > >
> > > @Qualifier
> > >
> > > public @instance Core {}
> > >
> > >
> > >
> > > @Qualifier
> > >
> > > public @instance Other {}
> > >
> > >
> > >
> > > ----
> > >
> > > @RequestScoped
> > >
> > > public class EMProducer {
> > >
> > > private @PersistenceContext(unitName="core")
> > > EntityManager emCore;
> > >
> > > private @PersistenceContext(unitName="other")
> > > EntityManager emOther;
> > >
> > >
> > >
> > >
> > >
> > > public @Produces @Core EntityManager getCoreEM()
> > {return
> > > emCore;}
> > >
> > > public @Produces @Other EntityManager
> getOtherEM()
> > {return
> > > emOther;}
> > >
> > >
> > >
> > >
> > >
> > > Injection happens with
> > >
> > >
> > >
> > > private @Inject @Core EntityManager
> > >
> > >
> > >
> > >
> > >
> > > Got the idea?
> > >
> > >
> > >
> > > LieGrue,
> > >
> > > strub
> > >
> > >
> > >
> > > --- Arne Limburg <ar...@openknowledge.de>
> > > schrieb am Sa, 13.2.2010:
> > >
> > >
> > >
> > > > Von: Arne Limburg <ar...@openknowledge.de>
> > >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> > >
> > > > An: "MyFaces Development" <de...@myfaces.apache.org>
> > >
> > > > Datum: Samstag, 13. Februar 2010, 20:06
> > >
> > > > Hi Mark,
> > >
> > > >
> > >
> > > > thank you for your feedback. I was aware of
> the
> > > requirement
> > >
> > > > of CDI-containers to inject JavaEE resources
> in
> > a
> > >
> > > > JavaEE-environment, but Gerhard and I are
> > thinking
> > > about a
> > >
> > > > generic non-JavaEE-solution for
> > > EntityManager-injection. And
> > >
> > > > at least weld does no injection of
> > JavaEE-resources in
> > > this
> > >
> > > > case. How does OpenWebBeans?
> > >
> > > > I am afraid supporting multiple
> persistence-units
> > in
> > > that
> > >
> > > > scenario is very difficult...
> > >
> > > >
> > >
> > > > Nonetheless it would be nice to see your
> > >
> > > > multiple-database-handling
> TransactionInterceptor
> > in
> > > CODI.
> > >
> > > >
> > >
> > > > Regards,
> > >
> > > > Arne
> > >
> > > >
> > >
> > > > --
> > >
> > > >
> > >
> > > > Arne Limburg - Enterprise Developer
> > >
> > > > OpenKnowledge GmbH, Oldenburg
> > >
> > > > Bismarckstraße 13, 26122 Oldenburg
> > >
> > > > Mobil: +49 (0) 151 - 108 22 942
> > >
> > > > Tel: +49 (0) 441 - 4082-0
> > >
> > > > Fax: +49 (0) 441 - 4082-111
> > >
> > > > arne.limburg@openknowledge.de
> > >
> > > > http://www.openknowledge.de

> 
> > >
> > >
> > >
> > > >
> > >
> > > > Registergericht: Amtsgericht Oldenburg, HRB
> 4670
> > >
> > > > Geschäftsführer: Lars Röwekamp, Jens
> Schumann
> > >
> > > >
> > >
> > > > -----Ursprüngliche Nachricht-----
> > >
> > > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> > >
> > > >
> > >
> > > > Gesendet: Samstag, 13. Februar 2010 15:39
> > >
> > > > An: MyFaces Development
> > >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> > >
> > > >
> > >
> > > > Hi!
> > >
> > > >
> > >
> > > > The JSR-299 spec defines that we have to
> support
> > > injection
> > >
> > > > of EE-Resources.
> > >
> > > >
> > >
> > > > This was more explicit in the old version of
> the
> > spec,
> > > but
> > >
> > > > unless the wording got shortened, I still
> think
> > > injection of
> > >
> > > > @PersistenceUnit and @PersistenceContext
> must be
> > > supported
> > >
> > > > by any JSR-299 container (at least in an EE
> > > environment).
> > >
> > > >
> > >
> > > > For OpenWebBeans, you can simply use our
> > >
> > > > openwebbeans-resource plugin. Please note
> that
> > this
> > > is
> > >
> > > > necessary because OWB is modular, and
> > > openwebbeans-impl (the
> > >
> > > > core) will have no EE dependencies at all
> (not
> > even
> > > JSF,
> > >
> > > > JPA, etc!) This will get picked up
> automatically
> > if it
> > > is
> > >
> > > > available in the classpath, e.g. you can
> simply
> > define
> > > the
> > >
> > > > following maven dependency:
> > >
> > > >
> > >
> > > >
> >    <dependency>
> > >
> > > >
> > >
> > > >
> > >
> >
> <groupId>org.apache.openwebbeans</groupId>
> > >
> > > >
> > >
> > > >
> > >
> >
> <artifactId>openwebbeans-resource</artifactId>
> > >
> > > >
> > >
> > > >
> <version>${owb.version}</version>
> > >
> > > >
> >    </dependency>
> > >
> > > >
> > >
> > > > OWB supports 2 different scenarios. If you
> are
> > not
> > > running
> > >
> > > > in a JTA aware container like e.g. OpenEJB,
> you
> > will
> > >
> > > > automatically use a simple resource version
> of an
> > SPI
> > >
> > > > implementation which uses
> > >
> > > >
> Persistence#createEntityManagerFactory(unitName)
> > for
> > >
> > > > injecting (Thus getting an extended EM). If
> you
> > use
> > > e.g.
> > >
> > > > OpenEJB, we are able to get the injectable
> > resources
> > >
> > > > directly from there (thus getting a
> > transactional
> > > EM).
> > >
> > > >
> > >
> > > > Once this is available, you can simply
> create a
> > > producer
> > >
> > > > method for the EntityManager:
> > >
> > > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java

> 
> > >
> > >
> > >
> > >
> > >
> > > >
> > >
> > > > There is also an example on how to implement
> a
> > >
> > > > TransactionalInterceptor:
> > >
> > > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java

> 
> > >
> > >
> > >
> > >
> > >
> > > >
> > >
> > > > In my company, I already implemented a
> > >
> > > > TransactionalInteceptor which is capable of
> > handling
> > >
> > > > multiple databases at a time and also
> correctly
> > > handles
> > >
> > > > nested transactions. I hope to migrate this
> over
> > to
> > > CODI in
> > >
> > > > the near future.
> > >
> > > >
> > >
> > > >
> > >
> > > > LieGrue,
> > >
> > > > strub
> > >
> > > >
> > >
> > > >
> > >
> > > > --- Arne Limburg <ar...@openknowledge.de>
> > >
> > > > schrieb am Sa, 13.2.2010:
> > >
> > > >
> > >
> > > > > Von: Arne Limburg <ar...@openknowledge.de>
> > >
> > > > > Betreff: AW: [Ext-CDI] @Transactional
> > >
> > > > > An: "'MyFaces Development'"
> > > <de...@myfaces.apache.org>
> > >
> > > > > Datum: Samstag, 13. Februar 2010,
> 14:42
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Hi Gerhard,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > OK, I got what you did,
> > >
> > > > > basically I did the same. You are
> right,
> > >
> > > > > that was pretty straight-forward, but I
> had
> > to
> > >
> > > > hard-code
> > >
> > > > > the persistence-unit
> > >
> > > > > name.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > I have two ideas to inject the
> > >
> > > > > persistence-unit name into the
> > >
> > > > > producer-method for the EntityManager:
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > First idea: A
> > >
> > > > > @PersistenceUnitName
> qualifier-annotation
> > to
> > >
> > > > > inject the name into the
> producer-method.
> > Client
> > > code
> > >
> > > > would
> > >
> > > > > have somethink like
> > >
> > > > >
> > >
> > > > > public class Configuration
> > >
> > > > > {
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >   @Produces
> > >
> > > > > @PersistenceUnitName
> > >
> > > > >
> > >
> > > > >   String
> > >
> > > > > getPersistenceUnitName() {
> > >
> > > > >
> > >
> > > > > …
> > >
> > > > >
> > >
> > > > > Not really nice, but the
> > >
> > > > > simplest solution to generify it.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Second idea:
> > >
> > > > >
> > >
> > > > > The @PersistenceContext
> > >
> > > > > qualifier has a @Nonbind attribute
> > >
> > > > > persistenceUnitName which we can
> extract in
> > the
> > >
> > > > producer
> > >
> > > > > method. But then we
> > >
> > > > > get in scoping issues. Especially when
> > having
> > >
> > > > multiple
> > >
> > > > > persistence-units within
> > >
> > > > > one deployment. The second problem is:
> How
> > can
> > > the
> > >
> > > > > @Transactional annotation
> > >
> > > > > know the persistence-unit-name.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Any other ideas?
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Regards,
> > >
> > > > >
> > >
> > > > > Arne
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > --
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Arne Limburg - Enterprise
> > >
> > > > > Developer
> > >
> > > > >
> > >
> > > > > OpenKnowledge GmbH,
> > >
> > > > > Oldenburg
> > >
> > > > >
> > >
> > > > > Bismarckstraße 13, 26122
> > >
> > > > > Oldenburg
> > >
> > > > >
> > >
> > > > > Mobil: +49 (0) 151 - 108 22
> > >
> > > > > 942
> > >
> > > > >
> > >
> > > > > Tel: +49 (0) 441 -
> > >
> > > > > 4082-0
> > >
> > > > >
> > >
> > > > > Fax: +49 (0) 441 -
> > >
> > > > > 4082-111
> > >
> > > > >
> > >
> > > > > arne.limburg@openknowledge.de
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > http://www.openknowledge.de

> 
> > >
> > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Registergericht: Amtsgericht
> > >
> > > > > Oldenburg, HRB 4670
> > >
> > > > >
> > >
> > > > > Geschäftsführer: Lars
> > >
> > > > > Röwekamp, Jens Schumann
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Von: Gerhard Petracek
> > >
> > > > > [mailto:gerhard.petracek@gmail.com]
> > >
> > > >
> > >
> > > > >
> > >
> > > > > Gesendet: Samstag, 13. Februar 2010
> 14:32
> > >
> > > > >
> > >
> > > > > An: MyFaces Development
> > >
> > > > >
> > >
> > > > > Betreff: Re: [Ext-CDI] @Transactional
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > hi arne,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > i used the EntityManager to get
> > >
> > > > > an EntityTransaction.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > you have to use cdi to create and
> > >
> > > > > inject it.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > (i used some producer methods.)
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > i created @PersistenceUnit which
> > >
> > > > > is a cdi qualifier and
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > @Transactional which is a cdi
> > >
> > > > > interceptor binding.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > basically it works and it isn't
> > >
> > > > > hard to use.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > however, we have to think about an
> > >
> > > > > approach to provide as
> > >
> > > > > much as possible in a generic way.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > regards,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > gerhard
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > http://www.irian.at

> 
> > >
> > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Your JSF powerhouse -
> > >
> > > > >
> > >
> > > > > JSF Consulting, Development and
> > >
> > > > >
> > >
> > > > > Courses in English and German
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Professional Support for Apache
> MyFaces
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Hi
> > >
> > > > > Gerhard,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Did
> > >
> > > > > you mean „i used
> > >
> > > > > UserTransaction”? If not, how do you
> > receive
> > > your
> > >
> > > > > EntityTransaction?
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > I am
> > >
> > > > > working on a solution to
> > >
> > > > > get request-scoped EntityManagers
> injected
> > within
> > > a
> > >
> > > > > servlet-container that does
> > >
> > > > > not even support the web-profile (which
> are
> > the
> > >
> > > > current
> > >
> > > > > jetty and the current
> > >
> > > > > tomcat). I am not able to get an
> > EntityManager
> > >
> > > > injected via
> > >
> > > > > @PersistenceContext
> > >
> > > > > in that environment. So it would be
> nice if
> > there
> > > were
> > >
> > > > some
> > >
> > > > > CDI-Extension to
> > >
> > > > > achieve this. The implementation would
> be
> > pretty
> > >
> > > > > straight-forward except the
> > >
> > > > > configuration of the persistence-unit
> name
> > and
> > > the
> > >
> > > > handling
> > >
> > > > > of different
> > >
> > > > > persistence-units within one
> CDI-deployment
> > >
> > > > > unit.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Using
> > >
> > > > > JTA-Transactions vs.
> > >
> > > > > resource-local EntityTransactions is
> > another
> > > issue
> > >
> > > > > here.
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Regards,
> > >
> > > > >
> > >
> > > > > Arne
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > --
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Arne
> > >
> > > > > Limburg - Enterprise
> > >
> > > > > Developer
> > >
> > > > >
> > >
> > > > > OpenKnowledge GmbH,
> > >
> > > > > Oldenburg
> > >
> > > > >
> > >
> > > > > Bismarckstraße
> > >
> > > > > 13, 26122 Oldenburg
> > >
> > > > >
> > >
> > > > > Mobil: +49 (0) 151
> > >
> > > > > - 108 22 942
> > >
> > > > >
> > >
> > > > > Tel: +49 (0) 441 -
> > >
> > > > > 4082-0
> > >
> > > > >
> > >
> > > > > Fax: +49 (0) 441 -
> > >
> > > > > 4082-111
> > >
> > > > >
> > >
> > > > > arne.limburg@openknowledge.de
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > http://www.openknowledge.de

> 
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Registergericht:
> > >
> > > > > Amtsgericht Oldenburg,
> > >
> > > > > HRB 4670
> > >
> > > > >
> > >
> > > > > Geschäftsführer:
> > >
> > > > > Lars Röwekamp, Jens
> > >
> > > > > Schumann
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Von: Gerhard
> > >
> > > > > Petracek [mailto:gerhard.petracek@gmail.com]
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Gesendet: Freitag, 12. Februar 2010
> 19:59
> > >
> > > > >
> > >
> > > > > An: MyFaces Development
> > >
> > > > >
> > >
> > > > > Betreff: Re: [Ext-CDI] @Transactional
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > hi
> > >
> > > > > arne,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > yes
> > >
> > > > > - i used EntityTransaction in the
> prototype
> > and
> > > it
> > >
> > > > works
> > >
> > > > > pretty well in a
> > >
> > > > > servlet container (that was the base
> idea).
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > regards,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > gerhard
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > http://www.irian.at

> 
> > >
> > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Your JSF powerhouse -
> > >
> > > > >
> > >
> > > > > JSF Consulting, Development and
> > >
> > > > >
> > >
> > > > > Courses in English and German
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Professional Support for Apache
> MyFaces
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > 2010/2/12
> > >
> > > > > Arne Limburg <ar...@openknowledge.de>
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Hi
> > >
> > > > > folks,
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > I saw the discussion of adding an
> > >
> > > > > @Transactional-Annotation to your
> > >
> > > > > CDI extensions. I think Gerhard wrote
> it. I
> > > wonder if
> > >
> > > > it
> > >
> > > > > deals with JTA
> > >
> > > > > transactions (which indeed would be
> pretty
> > >
> > > > > straight-forward) or with
> > >
> > > > > EntityTransactions of an
> resource-local
> > > EntityManager.
> > >
> > > > I am
> > >
> > > > > working on the
> > >
> > > > > latter one and just would want to know
> if
> > someone
> > > else
> > >
> > > > is
> > >
> > > > > working on such
> > >
> > > > > stuff. I think it would be great, when
> we
> > could
> > >
> > > > archive
> > >
> > > > > injection of
> > >
> > > > > resource-local EntityManagers with
> > > transaction-support
> > >
> > > > to
> > >
> > > > > deploy it on a tomcat
> > >
> > > > > or jetty. What do you think?
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Regards,
> > >
> > > > >
> > >
> > > > > Arne
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > --
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Arne Limburg - Enterprise
> > >
> > > > > Developer
> > >
> > > > >
> > >
> > > > > OpenKnowledge GmbH, Oldenburg
> > >
> > > > >
> > >
> > > > > Bismarckstraße
> > >
> > > > > 13, 26122 Oldenburg
> > >
> > > > >
> > >
> > > > > Mobil:
> > >
> > > > > +49 (0) 151 - 108 22 942
> > >
> > > > >
> > >
> > > > > Tel:
> > >
> > > > > +49 (0) 441 - 4082-0
> > >
> > > > >
> > >
> > > > > Fax:
> > >
> > > > > +49 (0) 441 - 4082-111
> > >
> > > > >
> > >
> > > > > arne.limburg@openknowledge.de
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > http://www.openknowledge.de

> 
> > >
> > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > > Registergericht:
> > >
> > > > > Amtsgericht Oldenburg, HRB 4670
> > >
> > > > >
> > >
> > > > > Geschäftsführer:
> > >
> > > > > Lars Röwekamp, Jens Schumann
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > > >
> > >
> > > >
> > >
> > > >
> > >
> > > >
> > __________________________________________________
> > >
> > > > Do You Yahoo!?
> > >
> > > > Sie sind Spam leid? Yahoo! Mail verfügt
> über
> > einen
> > >
> > > > herausragenden Schutz gegen Massenmails.
> > >
> > > > http://mail.yahoo.com

> 
> > >
> > > >
> > >
> > >
> > >
> > >
> __________________________________________________
> > >
> > > Do You Yahoo!?
> > >
> > > Sie sind Spam leid? Yahoo! Mail verfügt über
> einen
> > > herausragenden Schutz gegen
> > > Massenmails.
> > >
> > > http://mail.yahoo.com

> 
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen Massenmails.
> > http://mail.yahoo.com

> 
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com

> 

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

AW: [Ext-CDI] @Transactional

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi Mark,

Your test container stuff looks good. Unfortunately I can't get it to work in my environment (neither from within eclipse nor with maven). The instanceRetrievalTest fails with a
javax.enterprise.inject.ResolutionException: cannot find beans for class org.apache.webbeans.cditest.test.SessionScopedTestBean
        at org.apache.webbeans.cditest.owb.CdiTestOpenWebBeansContainer.getInstance(CdiTestOpenWebBeansContainer.java:154)
        at org.apache.webbeans.cditest.test.TestOwbTestContainer.testInstanceRetrieval(TestOwbTestContainer.java:37)
...
I wonder if it is a classpath issue? I guess the stuff works on your environment. I'll take a further look into it.

What do the others think about adding this test support to CODI and implementing the CdiTestContainer for weld?

When I get this working I'll write some tests for my @Transactional stuff.

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 170 - 2733627
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

-----Ursprüngliche Nachricht-----
Von: Mark Struberg [mailto:struberg@yahoo.de]
Gesendet: Freitag, 5. März 2010 20:46
An: MyFaces Development
Betreff: AW: [Ext-CDI] @Transactional

Hi Arne!

Since we have OpenWebBeans-M4 officially released today, my test container stuff is now available [1].

It would be really fine if you could review the implementation and give me some feedback if you miss something.

I used both JUnit and testng for testing OWB projects in the past and most times it was enough to have a central class which holds one single CDI container in a static field and shuts it down in a finalize(). I only run

container.stopContexts();
container.startContexts();

before each test method to wipe out contextual instances from the contexts. Of course, if you like to test CDI-Extensions and stuff, you might need to bootstrap the container for each test. But imo this is better handled by writing integration tests and using the maven-invoker-plugin for such cases.

Btw, if you have already worked with Weld, then you may eventually write the CDI test adaptor for Weld? Please ping me if you are interested, it's really easy to integrate.
The OWB test provider is already part of OWB, what do you guys think about adding the Weld provider to CODI so we can test it with both OWB and Weld?

txs and LieGrue,
strub

[1] http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/

--- Arne Limburg <ar...@openknowledge.de> schrieb am Do, 4.3.2010:

> Von: Arne Limburg <ar...@openknowledge.de>
> Betreff: AW: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 22:09 Uhr
> Hi!
>
> I am currently working on a JUnit-Solution for CDI (I want
> to have CDI-Container-Managed TestCases running with JUnit,
> but this is another topic we should discuss on another
> thread). So I did not so much at the EntityManager-front.
> I'll write a detailed Mail about my source this weekend.
>
> For now I can say:
> My solution is meant to work for extended EntityManagers
> that are open during an arbitrary scope is active.
>
> If someone of you has the time, he can upload the sources
> from the wiki (I have not further worked on it yet). As I
> mentioned I'll write a mail about the source this weekend.
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de

>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> Gesendet: Donnerstag, 4. März 2010 20:47
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
> Hi!
>
> Uploading the source is al always a good idea, so we can
> further discuss this really complicated topic.
>
> Is this meant to work for extended EntityManagers or for
> transactional JTA managed ones?
>
> Another question: does this require the EntityManager to
> have a certain scope? For the extended EM variant of course,
> for JTA managed we will most certainly use @Dependent,
> right?
>
>
>
> LieGrue,
> strub
>
> --- Gerhard Petracek <ge...@gmail.com>
> schrieb am Do, 4.3.2010:
>
> > Von: Gerhard Petracek <ge...@gmail.com>
> > Betreff: Re: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> > hi arne,
> > i created a jira issue for it
> > [1].could you please upload your
> > implementation.+ a short description about the
> > possible usages as well as restrictions (if
> > present).
> >
> >
> > thx & regards,gerhard
> > [1] https://issues.apache.org/jira/browse/EXTCDI-4

> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I’ve updated my
> > code at
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > It is not really
> > tested and lacks some fallback-scenarios (i.e.
> > null-handling, etc.), but it is a starting point to
> inject
> > scoped
> > EntityManagers for every CDI-scope.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg -
> > Enterprise Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße 13,
> > 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 -
> > 108 22 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> > Von: Gerhard Petracek
> > [mailto:gerhard.petracek@gmail.com]
> >
> >
> > Gesendet: Montag, 15. Februar 2010 13:44
> >
> > An: MyFaces
> > Development
> >
> > Betreff: Re: [Ext-CDI]
> > @Transactional
> >
> >
> >
> >
> >
> > hi arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > thx for providing the source code.
> >
> >
> >
> >
> >
> > i'll have a look at it after the
> > jsfdays.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > one of the goals is to provide an
> > alternative conversation
> > scope for cdi which allows to use the conversation
> concepts
> > provided by
> > orchestra.
> >
> >
> >
> >
> >
> > so we have to ensure that it works
> > with every custom cdi
> > scope.
> >
> >
> >
> >
> >
> > (cdi conversations would be the
> > default scope)
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> >
> >
> >
> >
> > 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> >
> > Hi,
> >
> >
> >
> > I've prototyped some code that injects
> > conversation-scoped EntityManagers
> > reading the unitName from the qualifier annotation
> and
> > added @Transactional
> > support for this EntityManagers. This code needs some
> > thinking though, e.g. how
> > to handle the default-case (no unitName specified)...
> >
> >
> >
> > If you want to take a look at it, I have created a
> Wiki
> > page and added my code
> > as attachment:
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > This code could be a starting point to implement
> > Orchestra-like conversations
> > (starting with CDI-Conversations)...
> >
> >
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise Developer
> >
> > OpenKnowledge GmbH, Oldenburg
> >
> > Bismarckstraße 13, 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 - 108 22 942
> >
> > Tel: +49 (0) 441 - 4082-0
> >
> > Fax: +49 (0) 441 - 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> >
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> >
> >
> > Gesendet: Samstag, 13. Februar 2010
> > 20:27
> >
> >
> >
> >
> >
> > An: MyFaces Development
> >
> > Betreff: AW: [Ext-CDI] @Transactional
> >
> >
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> >
> >
> > Nope, it's really easy. I simply use Qualifiers to
> > distinguish between them.
> >
> >
> >
> > @Qualifier
> >
> > public @instance Core {}
> >
> >
> >
> > @Qualifier
> >
> > public @instance Other {}
> >
> >
> >
> > ----
> >
> > @RequestScoped
> >
> > public class EMProducer {
> >
> > private @PersistenceContext(unitName="core")
> > EntityManager emCore;
> >
> > private @PersistenceContext(unitName="other")
> > EntityManager emOther;
> >
> >
> >
> >
> >
> > public @Produces @Core EntityManager getCoreEM()
> {return
> > emCore;}
> >
> > public @Produces @Other EntityManager getOtherEM()
> {return
> > emOther;}
> >
> >
> >
> >
> >
> > Injection happens with
> >
> >
> >
> > private @Inject @Core EntityManager
> >
> >
> >
> >
> >
> > Got the idea?
> >
> >
> >
> > LieGrue,
> >
> > strub
> >
> >
> >
> > --- Arne Limburg <ar...@openknowledge.de>
> > schrieb am Sa, 13.2.2010:
> >
> >
> >
> > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > An: "MyFaces Development" <de...@myfaces.apache.org>
> >
> > > Datum: Samstag, 13. Februar 2010, 20:06
> >
> > > Hi Mark,
> >
> > >
> >
> > > thank you for your feedback. I was aware of the
> > requirement
> >
> > > of CDI-containers to inject JavaEE resources in
> a
> >
> > > JavaEE-environment, but Gerhard and I are
> thinking
> > about a
> >
> > > generic non-JavaEE-solution for
> > EntityManager-injection. And
> >
> > > at least weld does no injection of
> JavaEE-resources in
> > this
> >
> > > case. How does OpenWebBeans?
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> > >
> >
> > > Nonetheless it would be nice to see your
> >
> > > multiple-database-handling TransactionInterceptor
> in
> > CODI.
> >
> > >
> >
> > > Regards,
> >
> > > Arne
> >
> > >
> >
> > > --
> >
> > >
> >
> > > Arne Limburg - Enterprise Developer
> >
> > > OpenKnowledge GmbH, Oldenburg
> >
> > > Bismarckstraße 13, 26122 Oldenburg
> >
> > > Mobil: +49 (0) 151 - 108 22 942
> >
> > > Tel: +49 (0) 441 - 4082-0
> >
> > > Fax: +49 (0) 441 - 4082-111
> >
> > > arne.limburg@openknowledge.de
> >
> > > http://www.openknowledge.de

> >
> >
> >
> > >
> >
> > > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > >
> >
> > > -----Ursprüngliche Nachricht-----
> >
> > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> > >
> >
> > > Gesendet: Samstag, 13. Februar 2010 15:39
> >
> > > An: MyFaces Development
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > >
> >
> > > Hi!
> >
> > >
> >
> > > The JSR-299 spec defines that we have to support
> > injection
> >
> > > of EE-Resources.
> >
> > >
> >
> > > This was more explicit in the old version of the
> spec,
> > but
> >
> > > unless the wording got shortened, I still think
> > injection of
> >
> > > @PersistenceUnit and @PersistenceContext must be
> > supported
> >
> > > by any JSR-299 container (at least in an EE
> > environment).
> >
> > >
> >
> > > For OpenWebBeans, you can simply use our
> >
> > > openwebbeans-resource plugin. Please note that
> this
> > is
> >
> > > necessary because OWB is modular, and
> > openwebbeans-impl (the
> >
> > > core) will have no EE dependencies at all (not
> even
> > JSF,
> >
> > > JPA, etc!) This will get picked up automatically
> if it
> > is
> >
> > > available in the classpath, e.g. you can simply
> define
> > the
> >
> > > following maven dependency:
> >
> > >
> >
> > >
>    <dependency>
> >
> > >
> >
> > >
> >
> <groupId>org.apache.openwebbeans</groupId>
> >
> > >
> >
> > >
> >
> <artifactId>openwebbeans-resource</artifactId>
> >
> > >
> >
> > > <version>${owb.version}</version>
> >
> > >
>    </dependency>
> >
> > >
> >
> > > OWB supports 2 different scenarios. If you are
> not
> > running
> >
> > > in a JTA aware container like e.g. OpenEJB, you
> will
> >
> > > automatically use a simple resource version of an
> SPI
> >
> > > implementation which uses
> >
> > > Persistence#createEntityManagerFactory(unitName)
> for
> >
> > > injecting (Thus getting an extended EM). If you
> use
> > e.g.
> >
> > > OpenEJB, we are able to get the injectable
> resources
> >
> > > directly from there (thus getting a
> transactional
> > EM).
> >
> > >
> >
> > > Once this is available, you can simply create a
> > producer
> >
> > > method for the EntityManager:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java

> >
> >
> >
> >
> >
> > >
> >
> > > There is also an example on how to implement a
> >
> > > TransactionalInterceptor:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java

> >
> >
> >
> >
> >
> > >
> >
> > > In my company, I already implemented a
> >
> > > TransactionalInteceptor which is capable of
> handling
> >
> > > multiple databases at a time and also correctly
> > handles
> >
> > > nested transactions. I hope to migrate this over
> to
> > CODI in
> >
> > > the near future.
> >
> > >
> >
> > >
> >
> > > LieGrue,
> >
> > > strub
> >
> > >
> >
> > >
> >
> > > --- Arne Limburg <ar...@openknowledge.de>
> >
> > > schrieb am Sa, 13.2.2010:
> >
> > >
> >
> > > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > > An: "'MyFaces Development'"
> > <de...@myfaces.apache.org>
> >
> > > > Datum: Samstag, 13. Februar 2010, 14:42
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > OK, I got what you did,
> >
> > > > basically I did the same. You are right,
> >
> > > > that was pretty straight-forward, but I had
> to
> >
> > > hard-code
> >
> > > > the persistence-unit
> >
> > > > name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I have two ideas to inject the
> >
> > > > persistence-unit name into the
> >
> > > > producer-method for the EntityManager:
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > First idea: A
> >
> > > > @PersistenceUnitName qualifier-annotation
> to
> >
> > > > inject the name into the producer-method.
> Client
> > code
> >
> > > would
> >
> > > > have somethink like
> >
> > > >
> >
> > > > public class Configuration
> >
> > > > {
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >   @Produces
> >
> > > > @PersistenceUnitName
> >
> > > >
> >
> > > >   String
> >
> > > > getPersistenceUnitName() {
> >
> > > >
> >
> > > > …
> >
> > > >
> >
> > > > Not really nice, but the
> >
> > > > simplest solution to generify it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Second idea:
> >
> > > >
> >
> > > > The @PersistenceContext
> >
> > > > qualifier has a @Nonbind attribute
> >
> > > > persistenceUnitName which we can extract in
> the
> >
> > > producer
> >
> > > > method. But then we
> >
> > > > get in scoping issues. Especially when
> having
> >
> > > multiple
> >
> > > > persistence-units within
> >
> > > > one deployment. The second problem is: How
> can
> > the
> >
> > > > @Transactional annotation
> >
> > > > know the persistence-unit-name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Any other ideas?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße 13, 26122
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151 - 108 22
> >
> > > > 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht: Amtsgericht
> >
> > > > Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer: Lars
> >
> > > > Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard Petracek
> >
> > > > [mailto:gerhard.petracek@gmail.com]
> >
> > >
> >
> > > >
> >
> > > > Gesendet: Samstag, 13. Februar 2010 14:32
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i used the EntityManager to get
> >
> > > > an EntityTransaction.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > you have to use cdi to create and
> >
> > > > inject it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > (i used some producer methods.)
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i created @PersistenceUnit which
> >
> > > > is a cdi qualifier and
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > @Transactional which is a cdi
> >
> > > > interceptor binding.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > basically it works and it isn't
> >
> > > > hard to use.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > however, we have to think about an
> >
> > > > approach to provide as
> >
> > > > much as possible in a generic way.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Did
> >
> > > > you mean „i used
> >
> > > > UserTransaction”? If not, how do you
> receive
> > your
> >
> > > > EntityTransaction?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I am
> >
> > > > working on a solution to
> >
> > > > get request-scoped EntityManagers injected
> within
> > a
> >
> > > > servlet-container that does
> >
> > > > not even support the web-profile (which are
> the
> >
> > > current
> >
> > > > jetty and the current
> >
> > > > tomcat). I am not able to get an
> EntityManager
> >
> > > injected via
> >
> > > > @PersistenceContext
> >
> > > > in that environment. So it would be nice if
> there
> > were
> >
> > > some
> >
> > > > CDI-Extension to
> >
> > > > achieve this. The implementation would be
> pretty
> >
> > > > straight-forward except the
> >
> > > > configuration of the persistence-unit name
> and
> > the
> >
> > > handling
> >
> > > > of different
> >
> > > > persistence-units within one CDI-deployment
> >
> > > > unit.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Using
> >
> > > > JTA-Transactions vs.
> >
> > > > resource-local EntityTransactions is
> another
> > issue
> >
> > > > here.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne
> >
> > > > Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151
> >
> > > > - 108 22 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg,
> >
> > > > HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens
> >
> > > > Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard
> >
> > > > Petracek [mailto:gerhard.petracek@gmail.com]
> >
> > > >
> >
> > > >
> >
> > > > Gesendet: Freitag, 12. Februar 2010 19:59
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi
> >
> > > > arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > yes
> >
> > > > - i used EntityTransaction in the prototype
> and
> > it
> >
> > > works
> >
> > > > pretty well in a
> >
> > > > servlet container (that was the base idea).
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/12
> >
> > > > Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > folks,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I saw the discussion of adding an
> >
> > > > @Transactional-Annotation to your
> >
> > > > CDI extensions. I think Gerhard wrote it. I
> > wonder if
> >
> > > it
> >
> > > > deals with JTA
> >
> > > > transactions (which indeed would be pretty
> >
> > > > straight-forward) or with
> >
> > > > EntityTransactions of an resource-local
> > EntityManager.
> >
> > > I am
> >
> > > > working on the
> >
> > > > latter one and just would want to know if
> someone
> > else
> >
> > > is
> >
> > > > working on such
> >
> > > > stuff. I think it would be great, when we
> could
> >
> > > archive
> >
> > > > injection of
> >
> > > > resource-local EntityManagers with
> > transaction-support
> >
> > > to
> >
> > > > deploy it on a tomcat
> >
> > > > or jetty. What do you think?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH, Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil:
> >
> > > > +49 (0) 151 - 108 22 942
> >
> > > >
> >
> > > > Tel:
> >
> > > > +49 (0) 441 - 4082-0
> >
> > > >
> >
> > > > Fax:
> >
> > > > +49 (0) 441 - 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > >
> >
> > >
> >
> > >
> __________________________________________________
> >
> > > Do You Yahoo!?
> >
> > > Sie sind Spam leid? Yahoo! Mail verfügt über
> einen
> >
> > > herausragenden Schutz gegen Massenmails.
> >
> > > http://mail.yahoo.com

> >
> > >
> >
> >
> >
> > __________________________________________________
> >
> > Do You Yahoo!?
> >
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen
> > Massenmails.
> >
> > http://mail.yahoo.com

> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com

>

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

Re: [Ext-CDI] @Transactional

Posted by Gerhard Petracek <ge...@gmail.com>.
hi arne,

before you start an upload, you have to confirm "Grant license to ASF for
inclusion in ASF works".
-> in the end you are the only one who is allowed to upload & confirm it.

regards,
gerhard

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces


2010/3/4 Arne Limburg <ar...@openknowledge.de>

> Hi!
>
> I am currently working on a JUnit-Solution for CDI (I want to have
> CDI-Container-Managed TestCases running with JUnit, but this is another
> topic we should discuss on another thread). So I did not so much at the
> EntityManager-front. I'll write a detailed Mail about my source this
> weekend.
>
> For now I can say:
> My solution is meant to work for extended EntityManagers that are open
> during an arbitrary scope is active.
>
> If someone of you has the time, he can upload the sources from the wiki (I
> have not further worked on it yet). As I mentioned I'll write a mail about
> the source this weekend.
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> Gesendet: Donnerstag, 4. März 2010 20:47
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
> Hi!
>
> Uploading the source is al always a good idea, so we can further discuss
> this really complicated topic.
>
> Is this meant to work for extended EntityManagers or for transactional JTA
> managed ones?
>
> Another question: does this require the EntityManager to have a certain
> scope? For the extended EM variant of course, for JTA managed we will most
> certainly use @Dependent, right?
>
>
>
> LieGrue,
> strub
>
> --- Gerhard Petracek <ge...@gmail.com> schrieb am Do, 4.3.2010:
>
> > Von: Gerhard Petracek <ge...@gmail.com>
> > Betreff: Re: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> > hi arne,
> > i created a jira issue for it
> > [1].could you please upload your
> > implementation.+ a short description about the
> > possible usages as well as restrictions (if
> > present).
> >
> >
> > thx & regards,gerhard
> > [1] https://issues.apache.org/jira/browse/EXTCDI-4
> >
> > http://www.irian.at
> >
> >
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I’ve updated my
> > code at
> >
> >
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> >
> >
> >
> > It is not really
> > tested and lacks some fallback-scenarios (i.e.
> > null-handling, etc.), but it is a starting point to inject
> > scoped
> > EntityManagers for every CDI-scope.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg -
> > Enterprise Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße 13,
> > 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 -
> > 108 22 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de
> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> > Von: Gerhard Petracek
> > [mailto:gerhard.petracek@gmail.com]
> >
> >
> > Gesendet: Montag, 15. Februar 2010 13:44
> >
> > An: MyFaces
> > Development
> >
> > Betreff: Re: [Ext-CDI]
> > @Transactional
> >
> >
> >
> >
> >
> > hi arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > thx for providing the source code.
> >
> >
> >
> >
> >
> > i'll have a look at it after the
> > jsfdays.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > one of the goals is to provide an
> > alternative conversation
> > scope for cdi which allows to use the conversation concepts
> > provided by
> > orchestra.
> >
> >
> >
> >
> >
> > so we have to ensure that it works
> > with every custom cdi
> > scope.
> >
> >
> >
> >
> >
> > (cdi conversations would be the
> > default scope)
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> > http://www.irian.at
> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> >
> >
> >
> >
> > 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> >
> > Hi,
> >
> >
> >
> > I've prototyped some code that injects
> > conversation-scoped EntityManagers
> > reading the unitName from the qualifier annotation and
> > added @Transactional
> > support for this EntityManagers. This code needs some
> > thinking though, e.g. how
> > to handle the default-case (no unitName specified)...
> >
> >
> >
> > If you want to take a look at it, I have created a Wiki
> > page and added my code
> > as attachment:
> >
> >
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> >
> >
> >
> > This code could be a starting point to implement
> > Orchestra-like conversations
> > (starting with CDI-Conversations)...
> >
> >
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise Developer
> >
> > OpenKnowledge GmbH, Oldenburg
> >
> > Bismarckstraße 13, 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 - 108 22 942
> >
> > Tel: +49 (0) 441 - 4082-0
> >
> > Fax: +49 (0) 441 - 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de
> >
> >
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> >
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> >
> >
> > Gesendet: Samstag, 13. Februar 2010
> > 20:27
> >
> >
> >
> >
> >
> > An: MyFaces Development
> >
> > Betreff: AW: [Ext-CDI] @Transactional
> >
> >
> >
> > > I am afraid supporting multiple persistence-units in
> > that
> >
> > > scenario is very difficult...
> >
> >
> >
> > Nope, it's really easy. I simply use Qualifiers to
> > distinguish between them.
> >
> >
> >
> > @Qualifier
> >
> > public @instance Core {}
> >
> >
> >
> > @Qualifier
> >
> > public @instance Other {}
> >
> >
> >
> > ----
> >
> > @RequestScoped
> >
> > public class EMProducer {
> >
> > private @PersistenceContext(unitName="core")
> > EntityManager emCore;
> >
> > private @PersistenceContext(unitName="other")
> > EntityManager emOther;
> >
> >
> >
> >
> >
> > public @Produces @Core EntityManager getCoreEM() {return
> > emCore;}
> >
> > public @Produces @Other EntityManager getOtherEM() {return
> > emOther;}
> >
> >
> >
> >
> >
> > Injection happens with
> >
> >
> >
> > private @Inject @Core EntityManager
> >
> >
> >
> >
> >
> > Got the idea?
> >
> >
> >
> > LieGrue,
> >
> > strub
> >
> >
> >
> > --- Arne Limburg <ar...@openknowledge.de>
> > schrieb am Sa, 13.2.2010:
> >
> >
> >
> > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > An: "MyFaces Development" <de...@myfaces.apache.org>
> >
> > > Datum: Samstag, 13. Februar 2010, 20:06
> >
> > > Hi Mark,
> >
> > >
> >
> > > thank you for your feedback. I was aware of the
> > requirement
> >
> > > of CDI-containers to inject JavaEE resources in a
> >
> > > JavaEE-environment, but Gerhard and I are thinking
> > about a
> >
> > > generic non-JavaEE-solution for
> > EntityManager-injection. And
> >
> > > at least weld does no injection of JavaEE-resources in
> > this
> >
> > > case. How does OpenWebBeans?
> >
> > > I am afraid supporting multiple persistence-units in
> > that
> >
> > > scenario is very difficult...
> >
> > >
> >
> > > Nonetheless it would be nice to see your
> >
> > > multiple-database-handling TransactionInterceptor in
> > CODI.
> >
> > >
> >
> > > Regards,
> >
> > > Arne
> >
> > >
> >
> > > --
> >
> > >
> >
> > > Arne Limburg - Enterprise Developer
> >
> > > OpenKnowledge GmbH, Oldenburg
> >
> > > Bismarckstraße 13, 26122 Oldenburg
> >
> > > Mobil: +49 (0) 151 - 108 22 942
> >
> > > Tel: +49 (0) 441 - 4082-0
> >
> > > Fax: +49 (0) 441 - 4082-111
> >
> > > arne.limburg@openknowledge.de
> >
> > > http://www.openknowledge.de
> >
> >
> >
> > >
> >
> > > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > >
> >
> > > -----Ursprüngliche Nachricht-----
> >
> > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> > >
> >
> > > Gesendet: Samstag, 13. Februar 2010 15:39
> >
> > > An: MyFaces Development
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > >
> >
> > > Hi!
> >
> > >
> >
> > > The JSR-299 spec defines that we have to support
> > injection
> >
> > > of EE-Resources.
> >
> > >
> >
> > > This was more explicit in the old version of the spec,
> > but
> >
> > > unless the wording got shortened, I still think
> > injection of
> >
> > > @PersistenceUnit and @PersistenceContext must be
> > supported
> >
> > > by any JSR-299 container (at least in an EE
> > environment).
> >
> > >
> >
> > > For OpenWebBeans, you can simply use our
> >
> > > openwebbeans-resource plugin. Please note that this
> > is
> >
> > > necessary because OWB is modular, and
> > openwebbeans-impl (the
> >
> > > core) will have no EE dependencies at all (not even
> > JSF,
> >
> > > JPA, etc!) This will get picked up automatically if it
> > is
> >
> > > available in the classpath, e.g. you can simply define
> > the
> >
> > > following maven dependency:
> >
> > >
> >
> > >         <dependency>
> >
> > >
> >
> > >
> > <groupId>org.apache.openwebbeans</groupId>
> >
> > >
> >
> > >
> > <artifactId>openwebbeans-resource</artifactId>
> >
> > >
> >
> > > <version>${owb.version}</version>
> >
> > >         </dependency>
> >
> > >
> >
> > > OWB supports 2 different scenarios. If you are not
> > running
> >
> > > in a JTA aware container like e.g. OpenEJB, you will
> >
> > > automatically use a simple resource version of an SPI
> >
> > > implementation which uses
> >
> > > Persistence#createEntityManagerFactory(unitName) for
> >
> > > injecting (Thus getting an extended EM). If you use
> > e.g.
> >
> > > OpenEJB, we are able to get the injectable resources
> >
> > > directly from there (thus getting a transactional
> > EM).
> >
> > >
> >
> > > Once this is available, you can simply create a
> > producer
> >
> > > method for the EntityManager:
> >
> > >
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
> >
> >
> >
> >
> >
> > >
> >
> > > There is also an example on how to implement a
> >
> > > TransactionalInterceptor:
> >
> > >
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
> >
> >
> >
> >
> >
> > >
> >
> > > In my company, I already implemented a
> >
> > > TransactionalInteceptor which is capable of handling
> >
> > > multiple databases at a time and also correctly
> > handles
> >
> > > nested transactions. I hope to migrate this over to
> > CODI in
> >
> > > the near future.
> >
> > >
> >
> > >
> >
> > > LieGrue,
> >
> > > strub
> >
> > >
> >
> > >
> >
> > > --- Arne Limburg <ar...@openknowledge.de>
> >
> > > schrieb am Sa, 13.2.2010:
> >
> > >
> >
> > > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > > An: "'MyFaces Development'"
> > <de...@myfaces.apache.org>
> >
> > > > Datum: Samstag, 13. Februar 2010, 14:42
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > OK, I got what you did,
> >
> > > > basically I did the same. You are right,
> >
> > > > that was pretty straight-forward, but I had to
> >
> > > hard-code
> >
> > > > the persistence-unit
> >
> > > > name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I have two ideas to inject the
> >
> > > > persistence-unit name into the
> >
> > > > producer-method for the EntityManager:
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > First idea: A
> >
> > > > @PersistenceUnitName qualifier-annotation to
> >
> > > > inject the name into the producer-method. Client
> > code
> >
> > > would
> >
> > > > have somethink like
> >
> > > >
> >
> > > > public class Configuration
> >
> > > > {
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >   @Produces
> >
> > > > @PersistenceUnitName
> >
> > > >
> >
> > > >   String
> >
> > > > getPersistenceUnitName() {
> >
> > > >
> >
> > > > …
> >
> > > >
> >
> > > > Not really nice, but the
> >
> > > > simplest solution to generify it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Second idea:
> >
> > > >
> >
> > > > The @PersistenceContext
> >
> > > > qualifier has a @Nonbind attribute
> >
> > > > persistenceUnitName which we can extract in the
> >
> > > producer
> >
> > > > method. But then we
> >
> > > > get in scoping issues. Especially when having
> >
> > > multiple
> >
> > > > persistence-units within
> >
> > > > one deployment. The second problem is: How can
> > the
> >
> > > > @Transactional annotation
> >
> > > > know the persistence-unit-name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Any other ideas?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße 13, 26122
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151 - 108 22
> >
> > > > 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de
> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht: Amtsgericht
> >
> > > > Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer: Lars
> >
> > > > Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard Petracek
> >
> > > > [mailto:gerhard.petracek@gmail.com]
> >
> > >
> >
> > > >
> >
> > > > Gesendet: Samstag, 13. Februar 2010 14:32
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i used the EntityManager to get
> >
> > > > an EntityTransaction.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > you have to use cdi to create and
> >
> > > > inject it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > (i used some producer methods.)
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i created @PersistenceUnit which
> >
> > > > is a cdi qualifier and
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > @Transactional which is a cdi
> >
> > > > interceptor binding.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > basically it works and it isn't
> >
> > > > hard to use.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > however, we have to think about an
> >
> > > > approach to provide as
> >
> > > > much as possible in a generic way.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at
> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Did
> >
> > > > you mean „i used
> >
> > > > UserTransaction”? If not, how do you receive
> > your
> >
> > > > EntityTransaction?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I am
> >
> > > > working on a solution to
> >
> > > > get request-scoped EntityManagers injected within
> > a
> >
> > > > servlet-container that does
> >
> > > > not even support the web-profile (which are the
> >
> > > current
> >
> > > > jetty and the current
> >
> > > > tomcat). I am not able to get an EntityManager
> >
> > > injected via
> >
> > > > @PersistenceContext
> >
> > > > in that environment. So it would be nice if there
> > were
> >
> > > some
> >
> > > > CDI-Extension to
> >
> > > > achieve this. The implementation would be pretty
> >
> > > > straight-forward except the
> >
> > > > configuration of the persistence-unit name and
> > the
> >
> > > handling
> >
> > > > of different
> >
> > > > persistence-units within one CDI-deployment
> >
> > > > unit.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Using
> >
> > > > JTA-Transactions vs.
> >
> > > > resource-local EntityTransactions is another
> > issue
> >
> > > > here.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne
> >
> > > > Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151
> >
> > > > - 108 22 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg,
> >
> > > > HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens
> >
> > > > Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard
> >
> > > > Petracek [mailto:gerhard.petracek@gmail.com]
> >
> > > >
> >
> > > >
> >
> > > > Gesendet: Freitag, 12. Februar 2010 19:59
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi
> >
> > > > arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > yes
> >
> > > > - i used EntityTransaction in the prototype and
> > it
> >
> > > works
> >
> > > > pretty well in a
> >
> > > > servlet container (that was the base idea).
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at
> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/12
> >
> > > > Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > folks,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I saw the discussion of adding an
> >
> > > > @Transactional-Annotation to your
> >
> > > > CDI extensions. I think Gerhard wrote it. I
> > wonder if
> >
> > > it
> >
> > > > deals with JTA
> >
> > > > transactions (which indeed would be pretty
> >
> > > > straight-forward) or with
> >
> > > > EntityTransactions of an resource-local
> > EntityManager.
> >
> > > I am
> >
> > > > working on the
> >
> > > > latter one and just would want to know if someone
> > else
> >
> > > is
> >
> > > > working on such
> >
> > > > stuff. I think it would be great, when we could
> >
> > > archive
> >
> > > > injection of
> >
> > > > resource-local EntityManagers with
> > transaction-support
> >
> > > to
> >
> > > > deploy it on a tomcat
> >
> > > > or jetty. What do you think?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH, Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil:
> >
> > > > +49 (0) 151 - 108 22 942
> >
> > > >
> >
> > > > Tel:
> >
> > > > +49 (0) 441 - 4082-0
> >
> > > >
> >
> > > > Fax:
> >
> > > > +49 (0) 441 - 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de
> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > >
> >
> > >
> >
> > > __________________________________________________
> >
> > > Do You Yahoo!?
> >
> > > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> >
> > > herausragenden Schutz gegen Massenmails.
> >
> > > http://mail.yahoo.com
> >
> > >
> >
> >
> >
> > __________________________________________________
> >
> > Do You Yahoo!?
> >
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen
> > Massenmails.
> >
> > http://mail.yahoo.com
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>

AW: [Ext-CDI] @Transactional

Posted by Mark Struberg <st...@yahoo.de>.
Hi Arne!

Since we have OpenWebBeans-M4 officially released today, my test container stuff is now available [1].

It would be really fine if you could review the implementation and give me some feedback if you miss something. 

I used both JUnit and testng for testing OWB projects in the past and most times it was enough to have a central class which holds one single CDI container in a static field and shuts it down in a finalize(). I only run 

container.stopContexts();
container.startContexts();

before each test method to wipe out contextual instances from the contexts. Of course, if you like to test CDI-Extensions and stuff, you might need to bootstrap the container for each test. But imo this is better handled by writing integration tests and using the maven-invoker-plugin for such cases.

Btw, if you have already worked with Weld, then you may eventually write the CDI test adaptor for Weld? Please ping me if you are interested, it's really easy to integrate.
The OWB test provider is already part of OWB, what do you guys think about adding the Weld provider to CODI so we can test it with both OWB and Weld?

txs and LieGrue,
strub

[1] http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-test/

--- Arne Limburg <ar...@openknowledge.de> schrieb am Do, 4.3.2010:

> Von: Arne Limburg <ar...@openknowledge.de>
> Betreff: AW: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 22:09 Uhr
> Hi!
> 
> I am currently working on a JUnit-Solution for CDI (I want
> to have CDI-Container-Managed TestCases running with JUnit,
> but this is another topic we should discuss on another
> thread). So I did not so much at the EntityManager-front.
> I'll write a detailed Mail about my source this weekend.
> 
> For now I can say:
> My solution is meant to work for extended EntityManagers
> that are open during an arbitrary scope is active.
> 
> If someone of you has the time, he can upload the sources
> from the wiki (I have not further worked on it yet). As I
> mentioned I'll write a mail about the source this weekend.
> 
> Regards,
> Arne
> 
> --
> 
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de

> 
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> Gesendet: Donnerstag, 4. März 2010 20:47
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
> 
> Hi!
> 
> Uploading the source is al always a good idea, so we can
> further discuss this really complicated topic.
> 
> Is this meant to work for extended EntityManagers or for
> transactional JTA managed ones?
> 
> Another question: does this require the EntityManager to
> have a certain scope? For the extended EM variant of course,
> for JTA managed we will most certainly use @Dependent,
> right?
> 
> 
> 
> LieGrue,
> strub
> 
> --- Gerhard Petracek <ge...@gmail.com>
> schrieb am Do, 4.3.2010:
> 
> > Von: Gerhard Petracek <ge...@gmail.com>
> > Betreff: Re: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> > hi arne,
> > i created a jira issue for it
> > [1].could you please upload your
> > implementation.+ a short description about the
> > possible usages as well as restrictions (if
> > present).
> >
> >
> > thx & regards,gerhard
> > [1] https://issues.apache.org/jira/browse/EXTCDI-4

> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I’ve updated my
> > code at
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > It is not really
> > tested and lacks some fallback-scenarios (i.e.
> > null-handling, etc.), but it is a starting point to
> inject
> > scoped
> > EntityManagers for every CDI-scope.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg -
> > Enterprise Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße 13,
> > 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 -
> > 108 22 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> > Von: Gerhard Petracek
> > [mailto:gerhard.petracek@gmail.com]
> >
> >
> > Gesendet: Montag, 15. Februar 2010 13:44
> >
> > An: MyFaces
> > Development
> >
> > Betreff: Re: [Ext-CDI]
> > @Transactional
> >
> >
> >
> >
> >
> > hi arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > thx for providing the source code.
> >
> >
> >
> >
> >
> > i'll have a look at it after the
> > jsfdays.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > one of the goals is to provide an
> > alternative conversation
> > scope for cdi which allows to use the conversation
> concepts
> > provided by
> > orchestra.
> >
> >
> >
> >
> >
> > so we have to ensure that it works
> > with every custom cdi
> > scope.
> >
> >
> >
> >
> >
> > (cdi conversations would be the
> > default scope)
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> >
> >
> >
> >
> > 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> >
> > Hi,
> >
> >
> >
> > I've prototyped some code that injects
> > conversation-scoped EntityManagers
> > reading the unitName from the qualifier annotation
> and
> > added @Transactional
> > support for this EntityManagers. This code needs some
> > thinking though, e.g. how
> > to handle the default-case (no unitName specified)...
> >
> >
> >
> > If you want to take a look at it, I have created a
> Wiki
> > page and added my code
> > as attachment:
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > This code could be a starting point to implement
> > Orchestra-like conversations
> > (starting with CDI-Conversations)...
> >
> >
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise Developer
> >
> > OpenKnowledge GmbH, Oldenburg
> >
> > Bismarckstraße 13, 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 - 108 22 942
> >
> > Tel: +49 (0) 441 - 4082-0
> >
> > Fax: +49 (0) 441 - 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> >
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> >
> >
> > Gesendet: Samstag, 13. Februar 2010
> > 20:27
> >
> >
> >
> >
> >
> > An: MyFaces Development
> >
> > Betreff: AW: [Ext-CDI] @Transactional
> >
> >
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> >
> >
> > Nope, it's really easy. I simply use Qualifiers to
> > distinguish between them.
> >
> >
> >
> > @Qualifier
> >
> > public @instance Core {}
> >
> >
> >
> > @Qualifier
> >
> > public @instance Other {}
> >
> >
> >
> > ----
> >
> > @RequestScoped
> >
> > public class EMProducer {
> >
> > private @PersistenceContext(unitName="core")
> > EntityManager emCore;
> >
> > private @PersistenceContext(unitName="other")
> > EntityManager emOther;
> >
> >
> >
> >
> >
> > public @Produces @Core EntityManager getCoreEM()
> {return
> > emCore;}
> >
> > public @Produces @Other EntityManager getOtherEM()
> {return
> > emOther;}
> >
> >
> >
> >
> >
> > Injection happens with
> >
> >
> >
> > private @Inject @Core EntityManager
> >
> >
> >
> >
> >
> > Got the idea?
> >
> >
> >
> > LieGrue,
> >
> > strub
> >
> >
> >
> > --- Arne Limburg <ar...@openknowledge.de>
> > schrieb am Sa, 13.2.2010:
> >
> >
> >
> > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > An: "MyFaces Development" <de...@myfaces.apache.org>
> >
> > > Datum: Samstag, 13. Februar 2010, 20:06
> >
> > > Hi Mark,
> >
> > >
> >
> > > thank you for your feedback. I was aware of the
> > requirement
> >
> > > of CDI-containers to inject JavaEE resources in
> a
> >
> > > JavaEE-environment, but Gerhard and I are
> thinking
> > about a
> >
> > > generic non-JavaEE-solution for
> > EntityManager-injection. And
> >
> > > at least weld does no injection of
> JavaEE-resources in
> > this
> >
> > > case. How does OpenWebBeans?
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> > >
> >
> > > Nonetheless it would be nice to see your
> >
> > > multiple-database-handling TransactionInterceptor
> in
> > CODI.
> >
> > >
> >
> > > Regards,
> >
> > > Arne
> >
> > >
> >
> > > --
> >
> > >
> >
> > > Arne Limburg - Enterprise Developer
> >
> > > OpenKnowledge GmbH, Oldenburg
> >
> > > Bismarckstraße 13, 26122 Oldenburg
> >
> > > Mobil: +49 (0) 151 - 108 22 942
> >
> > > Tel: +49 (0) 441 - 4082-0
> >
> > > Fax: +49 (0) 441 - 4082-111
> >
> > > arne.limburg@openknowledge.de
> >
> > > http://www.openknowledge.de

> >
> >
> >
> > >
> >
> > > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > >
> >
> > > -----Ursprüngliche Nachricht-----
> >
> > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> > >
> >
> > > Gesendet: Samstag, 13. Februar 2010 15:39
> >
> > > An: MyFaces Development
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > >
> >
> > > Hi!
> >
> > >
> >
> > > The JSR-299 spec defines that we have to support
> > injection
> >
> > > of EE-Resources.
> >
> > >
> >
> > > This was more explicit in the old version of the
> spec,
> > but
> >
> > > unless the wording got shortened, I still think
> > injection of
> >
> > > @PersistenceUnit and @PersistenceContext must be
> > supported
> >
> > > by any JSR-299 container (at least in an EE
> > environment).
> >
> > >
> >
> > > For OpenWebBeans, you can simply use our
> >
> > > openwebbeans-resource plugin. Please note that
> this
> > is
> >
> > > necessary because OWB is modular, and
> > openwebbeans-impl (the
> >
> > > core) will have no EE dependencies at all (not
> even
> > JSF,
> >
> > > JPA, etc!) This will get picked up automatically
> if it
> > is
> >
> > > available in the classpath, e.g. you can simply
> define
> > the
> >
> > > following maven dependency:
> >
> > >
> >
> > >     
>    <dependency>
> >
> > >
> >
> > >
> >
> <groupId>org.apache.openwebbeans</groupId>
> >
> > >
> >
> > >
> >
> <artifactId>openwebbeans-resource</artifactId>
> >
> > >
> >
> > > <version>${owb.version}</version>
> >
> > >     
>    </dependency>
> >
> > >
> >
> > > OWB supports 2 different scenarios. If you are
> not
> > running
> >
> > > in a JTA aware container like e.g. OpenEJB, you
> will
> >
> > > automatically use a simple resource version of an
> SPI
> >
> > > implementation which uses
> >
> > > Persistence#createEntityManagerFactory(unitName)
> for
> >
> > > injecting (Thus getting an extended EM). If you
> use
> > e.g.
> >
> > > OpenEJB, we are able to get the injectable
> resources
> >
> > > directly from there (thus getting a
> transactional
> > EM).
> >
> > >
> >
> > > Once this is available, you can simply create a
> > producer
> >
> > > method for the EntityManager:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java

> >
> >
> >
> >
> >
> > >
> >
> > > There is also an example on how to implement a
> >
> > > TransactionalInterceptor:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java

> >
> >
> >
> >
> >
> > >
> >
> > > In my company, I already implemented a
> >
> > > TransactionalInteceptor which is capable of
> handling
> >
> > > multiple databases at a time and also correctly
> > handles
> >
> > > nested transactions. I hope to migrate this over
> to
> > CODI in
> >
> > > the near future.
> >
> > >
> >
> > >
> >
> > > LieGrue,
> >
> > > strub
> >
> > >
> >
> > >
> >
> > > --- Arne Limburg <ar...@openknowledge.de>
> >
> > > schrieb am Sa, 13.2.2010:
> >
> > >
> >
> > > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > > An: "'MyFaces Development'"
> > <de...@myfaces.apache.org>
> >
> > > > Datum: Samstag, 13. Februar 2010, 14:42
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > OK, I got what you did,
> >
> > > > basically I did the same. You are right,
> >
> > > > that was pretty straight-forward, but I had
> to
> >
> > > hard-code
> >
> > > > the persistence-unit
> >
> > > > name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I have two ideas to inject the
> >
> > > > persistence-unit name into the
> >
> > > > producer-method for the EntityManager:
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > First idea: A
> >
> > > > @PersistenceUnitName qualifier-annotation
> to
> >
> > > > inject the name into the producer-method.
> Client
> > code
> >
> > > would
> >
> > > > have somethink like
> >
> > > >
> >
> > > > public class Configuration
> >
> > > > {
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >   @Produces
> >
> > > > @PersistenceUnitName
> >
> > > >
> >
> > > >   String
> >
> > > > getPersistenceUnitName() {
> >
> > > >
> >
> > > > …
> >
> > > >
> >
> > > > Not really nice, but the
> >
> > > > simplest solution to generify it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Second idea:
> >
> > > >
> >
> > > > The @PersistenceContext
> >
> > > > qualifier has a @Nonbind attribute
> >
> > > > persistenceUnitName which we can extract in
> the
> >
> > > producer
> >
> > > > method. But then we
> >
> > > > get in scoping issues. Especially when
> having
> >
> > > multiple
> >
> > > > persistence-units within
> >
> > > > one deployment. The second problem is: How
> can
> > the
> >
> > > > @Transactional annotation
> >
> > > > know the persistence-unit-name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Any other ideas?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße 13, 26122
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151 - 108 22
> >
> > > > 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht: Amtsgericht
> >
> > > > Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer: Lars
> >
> > > > Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard Petracek
> >
> > > > [mailto:gerhard.petracek@gmail.com]
> >
> > >
> >
> > > >
> >
> > > > Gesendet: Samstag, 13. Februar 2010 14:32
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i used the EntityManager to get
> >
> > > > an EntityTransaction.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > you have to use cdi to create and
> >
> > > > inject it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > (i used some producer methods.)
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i created @PersistenceUnit which
> >
> > > > is a cdi qualifier and
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > @Transactional which is a cdi
> >
> > > > interceptor binding.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > basically it works and it isn't
> >
> > > > hard to use.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > however, we have to think about an
> >
> > > > approach to provide as
> >
> > > > much as possible in a generic way.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Did
> >
> > > > you mean „i used
> >
> > > > UserTransaction”? If not, how do you
> receive
> > your
> >
> > > > EntityTransaction?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I am
> >
> > > > working on a solution to
> >
> > > > get request-scoped EntityManagers injected
> within
> > a
> >
> > > > servlet-container that does
> >
> > > > not even support the web-profile (which are
> the
> >
> > > current
> >
> > > > jetty and the current
> >
> > > > tomcat). I am not able to get an
> EntityManager
> >
> > > injected via
> >
> > > > @PersistenceContext
> >
> > > > in that environment. So it would be nice if
> there
> > were
> >
> > > some
> >
> > > > CDI-Extension to
> >
> > > > achieve this. The implementation would be
> pretty
> >
> > > > straight-forward except the
> >
> > > > configuration of the persistence-unit name
> and
> > the
> >
> > > handling
> >
> > > > of different
> >
> > > > persistence-units within one CDI-deployment
> >
> > > > unit.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Using
> >
> > > > JTA-Transactions vs.
> >
> > > > resource-local EntityTransactions is
> another
> > issue
> >
> > > > here.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne
> >
> > > > Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151
> >
> > > > - 108 22 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg,
> >
> > > > HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens
> >
> > > > Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard
> >
> > > > Petracek [mailto:gerhard.petracek@gmail.com]
> >
> > > >
> >
> > > >
> >
> > > > Gesendet: Freitag, 12. Februar 2010 19:59
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi
> >
> > > > arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > yes
> >
> > > > - i used EntityTransaction in the prototype
> and
> > it
> >
> > > works
> >
> > > > pretty well in a
> >
> > > > servlet container (that was the base idea).
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/12
> >
> > > > Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > folks,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I saw the discussion of adding an
> >
> > > > @Transactional-Annotation to your
> >
> > > > CDI extensions. I think Gerhard wrote it. I
> > wonder if
> >
> > > it
> >
> > > > deals with JTA
> >
> > > > transactions (which indeed would be pretty
> >
> > > > straight-forward) or with
> >
> > > > EntityTransactions of an resource-local
> > EntityManager.
> >
> > > I am
> >
> > > > working on the
> >
> > > > latter one and just would want to know if
> someone
> > else
> >
> > > is
> >
> > > > working on such
> >
> > > > stuff. I think it would be great, when we
> could
> >
> > > archive
> >
> > > > injection of
> >
> > > > resource-local EntityManagers with
> > transaction-support
> >
> > > to
> >
> > > > deploy it on a tomcat
> >
> > > > or jetty. What do you think?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH, Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil:
> >
> > > > +49 (0) 151 - 108 22 942
> >
> > > >
> >
> > > > Tel:
> >
> > > > +49 (0) 441 - 4082-0
> >
> > > >
> >
> > > > Fax:
> >
> > > > +49 (0) 441 - 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > >
> >
> > >
> >
> > >
> __________________________________________________
> >
> > > Do You Yahoo!?
> >
> > > Sie sind Spam leid? Yahoo! Mail verfügt über
> einen
> >
> > > herausragenden Schutz gegen Massenmails.
> >
> > > http://mail.yahoo.com

> >
> > >
> >
> >
> >
> > __________________________________________________
> >
> > Do You Yahoo!?
> >
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen
> > Massenmails.
> >
> > http://mail.yahoo.com

> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com

> 

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

AW: [Ext-CDI] @Transactional

Posted by Mark Struberg <st...@yahoo.de>.
Hi Arne!

Glad to know you are also thinking about such things :)

The bad news: there is already such a thing ;)
https://issues.apache.org/jira/browse/OWB-316

I only cannot check that in because we currently shipping M4. After that (early next week) I'll commit it. 

The idea is that we provide an easy interface for 
.) starting the container
.) stopping the container
.) start and stop the following scopes: singleton, application, session, conversation, request and pluggable own ones.
.) a convenience function to clean all contextual instances (for @BeforeMethod)

I already have such a container running in my company (in a real project) but I'm currently running with a patched version of OWB.

The testcontainer will be an implementation agnostic API (no OWB dependencies) + we will also provide a SPI implementation for OWB of course. The SPI implementation for running Weld may be part of CODI.

LieGrue,
strub

--- Arne Limburg <ar...@openknowledge.de> schrieb am Do, 4.3.2010:

> Von: Arne Limburg <ar...@openknowledge.de>
> Betreff: AW: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 22:09 Uhr
> Hi!
> 
> I am currently working on a JUnit-Solution for CDI (I want
> to have CDI-Container-Managed TestCases running with JUnit,
> but this is another topic we should discuss on another
> thread). So I did not so much at the EntityManager-front.
> I'll write a detailed Mail about my source this weekend.
> 
> For now I can say:
> My solution is meant to work for extended EntityManagers
> that are open during an arbitrary scope is active.
> 
> If someone of you has the time, he can upload the sources
> from the wiki (I have not further worked on it yet). As I
> mentioned I'll write a mail about the source this weekend.
> 
> Regards,
> Arne
> 
> --
> 
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de

> 
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> Gesendet: Donnerstag, 4. März 2010 20:47
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
> 
> Hi!
> 
> Uploading the source is al always a good idea, so we can
> further discuss this really complicated topic.
> 
> Is this meant to work for extended EntityManagers or for
> transactional JTA managed ones?
> 
> Another question: does this require the EntityManager to
> have a certain scope? For the extended EM variant of course,
> for JTA managed we will most certainly use @Dependent,
> right?
> 
> 
> 
> LieGrue,
> strub
> 
> --- Gerhard Petracek <ge...@gmail.com>
> schrieb am Do, 4.3.2010:
> 
> > Von: Gerhard Petracek <ge...@gmail.com>
> > Betreff: Re: [Ext-CDI] @Transactional
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> > Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> > hi arne,
> > i created a jira issue for it
> > [1].could you please upload your
> > implementation.+ a short description about the
> > possible usages as well as restrictions (if
> > present).
> >
> >
> > thx & regards,gerhard
> > [1] https://issues.apache.org/jira/browse/EXTCDI-4

> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> > JSF Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> >
> >
> > I’ve updated my
> > code at
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > It is not really
> > tested and lacks some fallback-scenarios (i.e.
> > null-handling, etc.), but it is a starting point to
> inject
> > scoped
> > EntityManagers for every CDI-scope.
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg -
> > Enterprise Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße 13,
> > 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 -
> > 108 22 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> > Von: Gerhard Petracek
> > [mailto:gerhard.petracek@gmail.com]
> >
> >
> > Gesendet: Montag, 15. Februar 2010 13:44
> >
> > An: MyFaces
> > Development
> >
> > Betreff: Re: [Ext-CDI]
> > @Transactional
> >
> >
> >
> >
> >
> > hi arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > thx for providing the source code.
> >
> >
> >
> >
> >
> > i'll have a look at it after the
> > jsfdays.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > one of the goals is to provide an
> > alternative conversation
> > scope for cdi which allows to use the conversation
> concepts
> > provided by
> > orchestra.
> >
> >
> >
> >
> >
> > so we have to ensure that it works
> > with every custom cdi
> > scope.
> >
> >
> >
> >
> >
> > (cdi conversations would be the
> > default scope)
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> >
> >
> >
> >
> > 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> >
> > Hi,
> >
> >
> >
> > I've prototyped some code that injects
> > conversation-scoped EntityManagers
> > reading the unitName from the qualifier annotation
> and
> > added @Transactional
> > support for this EntityManagers. This code needs some
> > thinking though, e.g. how
> > to handle the default-case (no unitName specified)...
> >
> >
> >
> > If you want to take a look at it, I have created a
> Wiki
> > page and added my code
> > as attachment:
> >
> > http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

> >
> >
> >
> > This code could be a starting point to implement
> > Orchestra-like conversations
> > (starting with CDI-Conversations)...
> >
> >
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise Developer
> >
> > OpenKnowledge GmbH, Oldenburg
> >
> > Bismarckstraße 13, 26122 Oldenburg
> >
> > Mobil: +49 (0) 151 - 108 22 942
> >
> > Tel: +49 (0) 441 - 4082-0
> >
> > Fax: +49 (0) 441 - 4082-111
> >
> > arne.limburg@openknowledge.de
> >
> > http://www.openknowledge.de

> >
> >
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> >
> >
> > -----Ursprüngliche Nachricht-----
> >
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> >
> >
> > Gesendet: Samstag, 13. Februar 2010
> > 20:27
> >
> >
> >
> >
> >
> > An: MyFaces Development
> >
> > Betreff: AW: [Ext-CDI] @Transactional
> >
> >
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> >
> >
> > Nope, it's really easy. I simply use Qualifiers to
> > distinguish between them.
> >
> >
> >
> > @Qualifier
> >
> > public @instance Core {}
> >
> >
> >
> > @Qualifier
> >
> > public @instance Other {}
> >
> >
> >
> > ----
> >
> > @RequestScoped
> >
> > public class EMProducer {
> >
> > private @PersistenceContext(unitName="core")
> > EntityManager emCore;
> >
> > private @PersistenceContext(unitName="other")
> > EntityManager emOther;
> >
> >
> >
> >
> >
> > public @Produces @Core EntityManager getCoreEM()
> {return
> > emCore;}
> >
> > public @Produces @Other EntityManager getOtherEM()
> {return
> > emOther;}
> >
> >
> >
> >
> >
> > Injection happens with
> >
> >
> >
> > private @Inject @Core EntityManager
> >
> >
> >
> >
> >
> > Got the idea?
> >
> >
> >
> > LieGrue,
> >
> > strub
> >
> >
> >
> > --- Arne Limburg <ar...@openknowledge.de>
> > schrieb am Sa, 13.2.2010:
> >
> >
> >
> > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > An: "MyFaces Development" <de...@myfaces.apache.org>
> >
> > > Datum: Samstag, 13. Februar 2010, 20:06
> >
> > > Hi Mark,
> >
> > >
> >
> > > thank you for your feedback. I was aware of the
> > requirement
> >
> > > of CDI-containers to inject JavaEE resources in
> a
> >
> > > JavaEE-environment, but Gerhard and I are
> thinking
> > about a
> >
> > > generic non-JavaEE-solution for
> > EntityManager-injection. And
> >
> > > at least weld does no injection of
> JavaEE-resources in
> > this
> >
> > > case. How does OpenWebBeans?
> >
> > > I am afraid supporting multiple persistence-units
> in
> > that
> >
> > > scenario is very difficult...
> >
> > >
> >
> > > Nonetheless it would be nice to see your
> >
> > > multiple-database-handling TransactionInterceptor
> in
> > CODI.
> >
> > >
> >
> > > Regards,
> >
> > > Arne
> >
> > >
> >
> > > --
> >
> > >
> >
> > > Arne Limburg - Enterprise Developer
> >
> > > OpenKnowledge GmbH, Oldenburg
> >
> > > Bismarckstraße 13, 26122 Oldenburg
> >
> > > Mobil: +49 (0) 151 - 108 22 942
> >
> > > Tel: +49 (0) 441 - 4082-0
> >
> > > Fax: +49 (0) 441 - 4082-111
> >
> > > arne.limburg@openknowledge.de
> >
> > > http://www.openknowledge.de

> >
> >
> >
> > >
> >
> > > Registergericht: Amtsgericht Oldenburg, HRB 4670
> >
> > > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > >
> >
> > > -----Ursprüngliche Nachricht-----
> >
> > > Von: Mark Struberg [mailto:struberg@yahoo.de]
> >
> > >
> >
> > > Gesendet: Samstag, 13. Februar 2010 15:39
> >
> > > An: MyFaces Development
> >
> > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > >
> >
> > > Hi!
> >
> > >
> >
> > > The JSR-299 spec defines that we have to support
> > injection
> >
> > > of EE-Resources.
> >
> > >
> >
> > > This was more explicit in the old version of the
> spec,
> > but
> >
> > > unless the wording got shortened, I still think
> > injection of
> >
> > > @PersistenceUnit and @PersistenceContext must be
> > supported
> >
> > > by any JSR-299 container (at least in an EE
> > environment).
> >
> > >
> >
> > > For OpenWebBeans, you can simply use our
> >
> > > openwebbeans-resource plugin. Please note that
> this
> > is
> >
> > > necessary because OWB is modular, and
> > openwebbeans-impl (the
> >
> > > core) will have no EE dependencies at all (not
> even
> > JSF,
> >
> > > JPA, etc!) This will get picked up automatically
> if it
> > is
> >
> > > available in the classpath, e.g. you can simply
> define
> > the
> >
> > > following maven dependency:
> >
> > >
> >
> > >     
>    <dependency>
> >
> > >
> >
> > >
> >
> <groupId>org.apache.openwebbeans</groupId>
> >
> > >
> >
> > >
> >
> <artifactId>openwebbeans-resource</artifactId>
> >
> > >
> >
> > > <version>${owb.version}</version>
> >
> > >     
>    </dependency>
> >
> > >
> >
> > > OWB supports 2 different scenarios. If you are
> not
> > running
> >
> > > in a JTA aware container like e.g. OpenEJB, you
> will
> >
> > > automatically use a simple resource version of an
> SPI
> >
> > > implementation which uses
> >
> > > Persistence#createEntityManagerFactory(unitName)
> for
> >
> > > injecting (Thus getting an extended EM). If you
> use
> > e.g.
> >
> > > OpenEJB, we are able to get the injectable
> resources
> >
> > > directly from there (thus getting a
> transactional
> > EM).
> >
> > >
> >
> > > Once this is available, you can simply create a
> > producer
> >
> > > method for the EntityManager:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java

> >
> >
> >
> >
> >
> > >
> >
> > > There is also an example on how to implement a
> >
> > > TransactionalInterceptor:
> >
> > > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java

> >
> >
> >
> >
> >
> > >
> >
> > > In my company, I already implemented a
> >
> > > TransactionalInteceptor which is capable of
> handling
> >
> > > multiple databases at a time and also correctly
> > handles
> >
> > > nested transactions. I hope to migrate this over
> to
> > CODI in
> >
> > > the near future.
> >
> > >
> >
> > >
> >
> > > LieGrue,
> >
> > > strub
> >
> > >
> >
> > >
> >
> > > --- Arne Limburg <ar...@openknowledge.de>
> >
> > > schrieb am Sa, 13.2.2010:
> >
> > >
> >
> > > > Von: Arne Limburg <ar...@openknowledge.de>
> >
> > > > Betreff: AW: [Ext-CDI] @Transactional
> >
> > > > An: "'MyFaces Development'"
> > <de...@myfaces.apache.org>
> >
> > > > Datum: Samstag, 13. Februar 2010, 14:42
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > OK, I got what you did,
> >
> > > > basically I did the same. You are right,
> >
> > > > that was pretty straight-forward, but I had
> to
> >
> > > hard-code
> >
> > > > the persistence-unit
> >
> > > > name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I have two ideas to inject the
> >
> > > > persistence-unit name into the
> >
> > > > producer-method for the EntityManager:
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > First idea: A
> >
> > > > @PersistenceUnitName qualifier-annotation
> to
> >
> > > > inject the name into the producer-method.
> Client
> > code
> >
> > > would
> >
> > > > have somethink like
> >
> > > >
> >
> > > > public class Configuration
> >
> > > > {
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >   @Produces
> >
> > > > @PersistenceUnitName
> >
> > > >
> >
> > > >   String
> >
> > > > getPersistenceUnitName() {
> >
> > > >
> >
> > > > …
> >
> > > >
> >
> > > > Not really nice, but the
> >
> > > > simplest solution to generify it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Second idea:
> >
> > > >
> >
> > > > The @PersistenceContext
> >
> > > > qualifier has a @Nonbind attribute
> >
> > > > persistenceUnitName which we can extract in
> the
> >
> > > producer
> >
> > > > method. But then we
> >
> > > > get in scoping issues. Especially when
> having
> >
> > > multiple
> >
> > > > persistence-units within
> >
> > > > one deployment. The second problem is: How
> can
> > the
> >
> > > > @Transactional annotation
> >
> > > > know the persistence-unit-name.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Any other ideas?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße 13, 26122
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151 - 108 22
> >
> > > > 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht: Amtsgericht
> >
> > > > Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer: Lars
> >
> > > > Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard Petracek
> >
> > > > [mailto:gerhard.petracek@gmail.com]
> >
> > >
> >
> > > >
> >
> > > > Gesendet: Samstag, 13. Februar 2010 14:32
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i used the EntityManager to get
> >
> > > > an EntityTransaction.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > you have to use cdi to create and
> >
> > > > inject it.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > (i used some producer methods.)
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > i created @PersistenceUnit which
> >
> > > > is a cdi qualifier and
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > @Transactional which is a cdi
> >
> > > > interceptor binding.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > basically it works and it isn't
> >
> > > > hard to use.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > however, we have to think about an
> >
> > > > approach to provide as
> >
> > > > much as possible in a generic way.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > Gerhard,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Did
> >
> > > > you mean „i used
> >
> > > > UserTransaction”? If not, how do you
> receive
> > your
> >
> > > > EntityTransaction?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I am
> >
> > > > working on a solution to
> >
> > > > get request-scoped EntityManagers injected
> within
> > a
> >
> > > > servlet-container that does
> >
> > > > not even support the web-profile (which are
> the
> >
> > > current
> >
> > > > jetty and the current
> >
> > > > tomcat). I am not able to get an
> EntityManager
> >
> > > injected via
> >
> > > > @PersistenceContext
> >
> > > > in that environment. So it would be nice if
> there
> > were
> >
> > > some
> >
> > > > CDI-Extension to
> >
> > > > achieve this. The implementation would be
> pretty
> >
> > > > straight-forward except the
> >
> > > > configuration of the persistence-unit name
> and
> > the
> >
> > > handling
> >
> > > > of different
> >
> > > > persistence-units within one CDI-deployment
> >
> > > > unit.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Using
> >
> > > > JTA-Transactions vs.
> >
> > > > resource-local EntityTransactions is
> another
> > issue
> >
> > > > here.
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne
> >
> > > > Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH,
> >
> > > > Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil: +49 (0) 151
> >
> > > > - 108 22 942
> >
> > > >
> >
> > > > Tel: +49 (0) 441 -
> >
> > > > 4082-0
> >
> > > >
> >
> > > > Fax: +49 (0) 441 -
> >
> > > > 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg,
> >
> > > > HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens
> >
> > > > Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Von: Gerhard
> >
> > > > Petracek [mailto:gerhard.petracek@gmail.com]
> >
> > > >
> >
> > > >
> >
> > > > Gesendet: Freitag, 12. Februar 2010 19:59
> >
> > > >
> >
> > > > An: MyFaces Development
> >
> > > >
> >
> > > > Betreff: Re: [Ext-CDI] @Transactional
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > hi
> >
> > > > arne,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > yes
> >
> > > > - i used EntityTransaction in the prototype
> and
> > it
> >
> > > works
> >
> > > > pretty well in a
> >
> > > > servlet container (that was the base idea).
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > regards,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > gerhard
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > http://www.irian.at

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Your JSF powerhouse -
> >
> > > >
> >
> > > > JSF Consulting, Development and
> >
> > > >
> >
> > > > Courses in English and German
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Professional Support for Apache MyFaces
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > 2010/2/12
> >
> > > > Arne Limburg <ar...@openknowledge.de>
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Hi
> >
> > > > folks,
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > I saw the discussion of adding an
> >
> > > > @Transactional-Annotation to your
> >
> > > > CDI extensions. I think Gerhard wrote it. I
> > wonder if
> >
> > > it
> >
> > > > deals with JTA
> >
> > > > transactions (which indeed would be pretty
> >
> > > > straight-forward) or with
> >
> > > > EntityTransactions of an resource-local
> > EntityManager.
> >
> > > I am
> >
> > > > working on the
> >
> > > > latter one and just would want to know if
> someone
> > else
> >
> > > is
> >
> > > > working on such
> >
> > > > stuff. I think it would be great, when we
> could
> >
> > > archive
> >
> > > > injection of
> >
> > > > resource-local EntityManagers with
> > transaction-support
> >
> > > to
> >
> > > > deploy it on a tomcat
> >
> > > > or jetty. What do you think?
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Regards,
> >
> > > >
> >
> > > > Arne
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > --
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Arne Limburg - Enterprise
> >
> > > > Developer
> >
> > > >
> >
> > > > OpenKnowledge GmbH, Oldenburg
> >
> > > >
> >
> > > > Bismarckstraße
> >
> > > > 13, 26122 Oldenburg
> >
> > > >
> >
> > > > Mobil:
> >
> > > > +49 (0) 151 - 108 22 942
> >
> > > >
> >
> > > > Tel:
> >
> > > > +49 (0) 441 - 4082-0
> >
> > > >
> >
> > > > Fax:
> >
> > > > +49 (0) 441 - 4082-111
> >
> > > >
> >
> > > > arne.limburg@openknowledge.de
> >
> > > >
> >
> > > >
> >
> > > > http://www.openknowledge.de

> >
> >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > > Registergericht:
> >
> > > > Amtsgericht Oldenburg, HRB 4670
> >
> > > >
> >
> > > > Geschäftsführer:
> >
> > > > Lars Röwekamp, Jens Schumann
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > > >
> >
> > >
> >
> > >
> >
> > >
> __________________________________________________
> >
> > > Do You Yahoo!?
> >
> > > Sie sind Spam leid? Yahoo! Mail verfügt über
> einen
> >
> > > herausragenden Schutz gegen Massenmails.
> >
> > > http://mail.yahoo.com

> >
> > >
> >
> >
> >
> > __________________________________________________
> >
> > Do You Yahoo!?
> >
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> > herausragenden Schutz gegen
> > Massenmails.
> >
> > http://mail.yahoo.com

> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> 
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com

> 

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

AW: [Ext-CDI] @Transactional

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi!

I am currently working on a JUnit-Solution for CDI (I want to have CDI-Container-Managed TestCases running with JUnit, but this is another topic we should discuss on another thread). So I did not so much at the EntityManager-front. I'll write a detailed Mail about my source this weekend.

For now I can say:
My solution is meant to work for extended EntityManagers that are open during an arbitrary scope is active.

If someone of you has the time, he can upload the sources from the wiki (I have not further worked on it yet). As I mentioned I'll write a mail about the source this weekend.

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 170 - 2733627
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

-----Ursprüngliche Nachricht-----
Von: Mark Struberg [mailto:struberg@yahoo.de]
Gesendet: Donnerstag, 4. März 2010 20:47
An: MyFaces Development
Betreff: Re: [Ext-CDI] @Transactional

Hi!

Uploading the source is al always a good idea, so we can further discuss this really complicated topic.

Is this meant to work for extended EntityManagers or for transactional JTA managed ones?

Another question: does this require the EntityManager to have a certain scope? For the extended EM variant of course, for JTA managed we will most certainly use @Dependent, right?



LieGrue,
strub

--- Gerhard Petracek <ge...@gmail.com> schrieb am Do, 4.3.2010:

> Von: Gerhard Petracek <ge...@gmail.com>
> Betreff: Re: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> hi arne,
> i created a jira issue for it
> [1].could you please upload your
> implementation.+ a short description about the
> possible usages as well as restrictions (if
> present).
>
>
> thx & regards,gerhard
> [1] https://issues.apache.org/jira/browse/EXTCDI-4
>
> http://www.irian.at
>
>
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
>
>
> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hi,
>
>
>
> I’ve updated my
> code at
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
>
>
> It is not really
> tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject
> scoped
> EntityManagers for every CDI-scope.
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg -
> Enterprise Developer
>
> OpenKnowledge GmbH,
> Oldenburg
>
> Bismarckstraße 13,
> 26122 Oldenburg
>
> Mobil: +49 (0) 151 -
> 108 22 942
>
> Tel: +49 (0) 441 -
> 4082-0
>
> Fax: +49 (0) 441 -
> 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht:
> Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer:
> Lars Röwekamp, Jens Schumann
>
>
>
>
>
> Von: Gerhard Petracek
> [mailto:gerhard.petracek@gmail.com]
>
>
> Gesendet: Montag, 15. Februar 2010 13:44
>
> An: MyFaces
> Development
>
> Betreff: Re: [Ext-CDI]
> @Transactional
>
>
>
>
>
> hi arne,
>
>
>
>
>
>
>
>
>
> thx for providing the source code.
>
>
>
>
>
> i'll have a look at it after the
> jsfdays.
>
>
>
>
>
>
>
>
>
>
>
> one of the goals is to provide an
> alternative conversation
> scope for cdi which allows to use the conversation concepts
> provided by
> orchestra.
>
>
>
>
>
> so we have to ensure that it works
> with every custom cdi
> scope.
>
>
>
>
>
> (cdi conversations would be the
> default scope)
>
>
>
>
>
>
>
>
>
>
>
> regards,
>
>
>
>
>
> gerhard
>
>
>
> http://www.irian.at
>
>
>
> Your JSF powerhouse -
>
> JSF Consulting, Development and
>
> Courses in English and German
>
>
>
> Professional Support for Apache MyFaces
>
>
>
>
>
>
>
> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
>
>
> I've prototyped some code that injects
> conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and
> added @Transactional
> support for this EntityManagers. This code needs some
> thinking though, e.g. how
> to handle the default-case (no unitName specified)...
>
>
>
> If you want to take a look at it, I have created a Wiki
> page and added my code
> as attachment:
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
>
>
> This code could be a starting point to implement
> Orchestra-like conversations
> (starting with CDI-Conversations)...
>
>
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 151 - 108 22 942
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> -----Ursprüngliche Nachricht-----
>
> Von: Mark Struberg [mailto:struberg@yahoo.de]
>
>
>
> Gesendet: Samstag, 13. Februar 2010
> 20:27
>
>
>
>
>
> An: MyFaces Development
>
> Betreff: AW: [Ext-CDI] @Transactional
>
>
>
> > I am afraid supporting multiple persistence-units in
> that
>
> > scenario is very difficult...
>
>
>
> Nope, it's really easy. I simply use Qualifiers to
> distinguish between them.
>
>
>
> @Qualifier
>
> public @instance Core {}
>
>
>
> @Qualifier
>
> public @instance Other {}
>
>
>
> ----
>
> @RequestScoped
>
> public class EMProducer {
>
> private @PersistenceContext(unitName="core")
> EntityManager emCore;
>
> private @PersistenceContext(unitName="other")
> EntityManager emOther;
>
>
>
>
>
> public @Produces @Core EntityManager getCoreEM() {return
> emCore;}
>
> public @Produces @Other EntityManager getOtherEM() {return
> emOther;}
>
>
>
>
>
> Injection happens with
>
>
>
> private @Inject @Core EntityManager
>
>
>
>
>
> Got the idea?
>
>
>
> LieGrue,
>
> strub
>
>
>
> --- Arne Limburg <ar...@openknowledge.de>
> schrieb am Sa, 13.2.2010:
>
>
>
> > Von: Arne Limburg <ar...@openknowledge.de>
>
> > Betreff: AW: [Ext-CDI] @Transactional
>
> > An: "MyFaces Development" <de...@myfaces.apache.org>
>
> > Datum: Samstag, 13. Februar 2010, 20:06
>
> > Hi Mark,
>
> >
>
> > thank you for your feedback. I was aware of the
> requirement
>
> > of CDI-containers to inject JavaEE resources in a
>
> > JavaEE-environment, but Gerhard and I are thinking
> about a
>
> > generic non-JavaEE-solution for
> EntityManager-injection. And
>
> > at least weld does no injection of JavaEE-resources in
> this
>
> > case. How does OpenWebBeans?
>
> > I am afraid supporting multiple persistence-units in
> that
>
> > scenario is very difficult...
>
> >
>
> > Nonetheless it would be nice to see your
>
> > multiple-database-handling TransactionInterceptor in
> CODI.
>
> >
>
> > Regards,
>
> > Arne
>
> >
>
> > --
>
> >
>
> > Arne Limburg - Enterprise Developer
>
> > OpenKnowledge GmbH, Oldenburg
>
> > Bismarckstraße 13, 26122 Oldenburg
>
> > Mobil: +49 (0) 151 - 108 22 942
>
> > Tel: +49 (0) 441 - 4082-0
>
> > Fax: +49 (0) 441 - 4082-111
>
> > arne.limburg@openknowledge.de
>
> > http://www.openknowledge.de
>
>
>
> >
>
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> >
>
> > -----Ursprüngliche Nachricht-----
>
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
>
> >
>
> > Gesendet: Samstag, 13. Februar 2010 15:39
>
> > An: MyFaces Development
>
> > Betreff: AW: [Ext-CDI] @Transactional
>
> >
>
> > Hi!
>
> >
>
> > The JSR-299 spec defines that we have to support
> injection
>
> > of EE-Resources.
>
> >
>
> > This was more explicit in the old version of the spec,
> but
>
> > unless the wording got shortened, I still think
> injection of
>
> > @PersistenceUnit and @PersistenceContext must be
> supported
>
> > by any JSR-299 container (at least in an EE
> environment).
>
> >
>
> > For OpenWebBeans, you can simply use our
>
> > openwebbeans-resource plugin. Please note that this
> is
>
> > necessary because OWB is modular, and
> openwebbeans-impl (the
>
> > core) will have no EE dependencies at all (not even
> JSF,
>
> > JPA, etc!) This will get picked up automatically if it
> is
>
> > available in the classpath, e.g. you can simply define
> the
>
> > following maven dependency:
>
> >
>
> >         <dependency>
>
> >
>
> >
> <groupId>org.apache.openwebbeans</groupId>
>
> >
>
> >
> <artifactId>openwebbeans-resource</artifactId>
>
> >
>
> > <version>${owb.version}</version>
>
> >         </dependency>
>
> >
>
> > OWB supports 2 different scenarios. If you are not
> running
>
> > in a JTA aware container like e.g. OpenEJB, you will
>
> > automatically use a simple resource version of an SPI
>
> > implementation which uses
>
> > Persistence#createEntityManagerFactory(unitName) for
>
> > injecting (Thus getting an extended EM). If you use
> e.g.
>
> > OpenEJB, we are able to get the injectable resources
>
> > directly from there (thus getting a transactional
> EM).
>
> >
>
> > Once this is available, you can simply create a
> producer
>
> > method for the EntityManager:
>
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>
>
>
>
>
> >
>
> > There is also an example on how to implement a
>
> > TransactionalInterceptor:
>
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>
>
>
>
>
> >
>
> > In my company, I already implemented a
>
> > TransactionalInteceptor which is capable of handling
>
> > multiple databases at a time and also correctly
> handles
>
> > nested transactions. I hope to migrate this over to
> CODI in
>
> > the near future.
>
> >
>
> >
>
> > LieGrue,
>
> > strub
>
> >
>
> >
>
> > --- Arne Limburg <ar...@openknowledge.de>
>
> > schrieb am Sa, 13.2.2010:
>
> >
>
> > > Von: Arne Limburg <ar...@openknowledge.de>
>
> > > Betreff: AW: [Ext-CDI] @Transactional
>
> > > An: "'MyFaces Development'"
> <de...@myfaces.apache.org>
>
> > > Datum: Samstag, 13. Februar 2010, 14:42
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi Gerhard,
>
> > >
>
> > >
>
> > >
>
> > > OK, I got what you did,
>
> > > basically I did the same. You are right,
>
> > > that was pretty straight-forward, but I had to
>
> > hard-code
>
> > > the persistence-unit
>
> > > name.
>
> > >
>
> > >
>
> > >
>
> > > I have two ideas to inject the
>
> > > persistence-unit name into the
>
> > > producer-method for the EntityManager:
>
> > >
>
> > >
>
> > >
>
> > > First idea: A
>
> > > @PersistenceUnitName qualifier-annotation to
>
> > > inject the name into the producer-method. Client
> code
>
> > would
>
> > > have somethink like
>
> > >
>
> > > public class Configuration
>
> > > {
>
> > >
>
> > >
>
> > >
>
> > >   @Produces
>
> > > @PersistenceUnitName
>
> > >
>
> > >   String
>
> > > getPersistenceUnitName() {
>
> > >
>
> > > …
>
> > >
>
> > > Not really nice, but the
>
> > > simplest solution to generify it.
>
> > >
>
> > >
>
> > >
>
> > > Second idea:
>
> > >
>
> > > The @PersistenceContext
>
> > > qualifier has a @Nonbind attribute
>
> > > persistenceUnitName which we can extract in the
>
> > producer
>
> > > method. But then we
>
> > > get in scoping issues. Especially when having
>
> > multiple
>
> > > persistence-units within
>
> > > one deployment. The second problem is: How can
> the
>
> > > @Transactional annotation
>
> > > know the persistence-unit-name.
>
> > >
>
> > >
>
> > >
>
> > > Any other ideas?
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH,
>
> > > Oldenburg
>
> > >
>
> > > Bismarckstraße 13, 26122
>
> > > Oldenburg
>
> > >
>
> > > Mobil: +49 (0) 151 - 108 22
>
> > > 942
>
> > >
>
> > > Tel: +49 (0) 441 -
>
> > > 4082-0
>
> > >
>
> > > Fax: +49 (0) 441 -
>
> > > 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Registergericht: Amtsgericht
>
> > > Oldenburg, HRB 4670
>
> > >
>
> > > Geschäftsführer: Lars
>
> > > Röwekamp, Jens Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Von: Gerhard Petracek
>
> > > [mailto:gerhard.petracek@gmail.com]
>
> >
>
> > >
>
> > > Gesendet: Samstag, 13. Februar 2010 14:32
>
> > >
>
> > > An: MyFaces Development
>
> > >
>
> > > Betreff: Re: [Ext-CDI] @Transactional
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > hi arne,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > i used the EntityManager to get
>
> > > an EntityTransaction.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > you have to use cdi to create and
>
> > > inject it.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > (i used some producer methods.)
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > i created @PersistenceUnit which
>
> > > is a cdi qualifier and
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > @Transactional which is a cdi
>
> > > interceptor binding.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > basically it works and it isn't
>
> > > hard to use.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > however, we have to think about an
>
> > > approach to provide as
>
> > > much as possible in a generic way.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > regards,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > gerhard
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > http://www.irian.at
>
>
>
> > >
>
> > >
>
> > >
>
> > > Your JSF powerhouse -
>
> > >
>
> > > JSF Consulting, Development and
>
> > >
>
> > > Courses in English and German
>
> > >
>
> > >
>
> > >
>
> > > Professional Support for Apache MyFaces
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi
>
> > > Gerhard,
>
> > >
>
> > >
>
> > >
>
> > > Did
>
> > > you mean „i used
>
> > > UserTransaction”? If not, how do you receive
> your
>
> > > EntityTransaction?
>
> > >
>
> > >
>
> > >
>
> > > I am
>
> > > working on a solution to
>
> > > get request-scoped EntityManagers injected within
> a
>
> > > servlet-container that does
>
> > > not even support the web-profile (which are the
>
> > current
>
> > > jetty and the current
>
> > > tomcat). I am not able to get an EntityManager
>
> > injected via
>
> > > @PersistenceContext
>
> > > in that environment. So it would be nice if there
> were
>
> > some
>
> > > CDI-Extension to
>
> > > achieve this. The implementation would be pretty
>
> > > straight-forward except the
>
> > > configuration of the persistence-unit name and
> the
>
> > handling
>
> > > of different
>
> > > persistence-units within one CDI-deployment
>
> > > unit.
>
> > >
>
> > >
>
> > >
>
> > > Using
>
> > > JTA-Transactions vs.
>
> > > resource-local EntityTransactions is another
> issue
>
> > > here.
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne
>
> > > Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH,
>
> > > Oldenburg
>
> > >
>
> > > Bismarckstraße
>
> > > 13, 26122 Oldenburg
>
> > >
>
> > > Mobil: +49 (0) 151
>
> > > - 108 22 942
>
> > >
>
> > > Tel: +49 (0) 441 -
>
> > > 4082-0
>
> > >
>
> > > Fax: +49 (0) 441 -
>
> > > 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
> > >
>
> > >
>
> > >
>
> > > Registergericht:
>
> > > Amtsgericht Oldenburg,
>
> > > HRB 4670
>
> > >
>
> > > Geschäftsführer:
>
> > > Lars Röwekamp, Jens
>
> > > Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Von: Gerhard
>
> > > Petracek [mailto:gerhard.petracek@gmail.com]
>
> > >
>
> > >
>
> > > Gesendet: Freitag, 12. Februar 2010 19:59
>
> > >
>
> > > An: MyFaces Development
>
> > >
>
> > > Betreff: Re: [Ext-CDI] @Transactional
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > hi
>
> > > arne,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > yes
>
> > > - i used EntityTransaction in the prototype and
> it
>
> > works
>
> > > pretty well in a
>
> > > servlet container (that was the base idea).
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > regards,
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > gerhard
>
> > >
>
> > >
>
> > >
>
> > > http://www.irian.at
>
>
>
> > >
>
> > >
>
> > >
>
> > > Your JSF powerhouse -
>
> > >
>
> > > JSF Consulting, Development and
>
> > >
>
> > > Courses in English and German
>
> > >
>
> > >
>
> > >
>
> > > Professional Support for Apache MyFaces
>
> > >
>
> > >
>
> > >
>
> > > 2010/2/12
>
> > > Arne Limburg <ar...@openknowledge.de>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Hi
>
> > > folks,
>
> > >
>
> > >
>
> > >
>
> > > I saw the discussion of adding an
>
> > > @Transactional-Annotation to your
>
> > > CDI extensions. I think Gerhard wrote it. I
> wonder if
>
> > it
>
> > > deals with JTA
>
> > > transactions (which indeed would be pretty
>
> > > straight-forward) or with
>
> > > EntityTransactions of an resource-local
> EntityManager.
>
> > I am
>
> > > working on the
>
> > > latter one and just would want to know if someone
> else
>
> > is
>
> > > working on such
>
> > > stuff. I think it would be great, when we could
>
> > archive
>
> > > injection of
>
> > > resource-local EntityManagers with
> transaction-support
>
> > to
>
> > > deploy it on a tomcat
>
> > > or jetty. What do you think?
>
> > >
>
> > >
>
> > >
>
> > > Regards,
>
> > >
>
> > > Arne
>
> > >
>
> > >
>
> > >
>
> > > --
>
> > >
>
> > >
>
> > >
>
> > > Arne Limburg - Enterprise
>
> > > Developer
>
> > >
>
> > > OpenKnowledge GmbH, Oldenburg
>
> > >
>
> > > Bismarckstraße
>
> > > 13, 26122 Oldenburg
>
> > >
>
> > > Mobil:
>
> > > +49 (0) 151 - 108 22 942
>
> > >
>
> > > Tel:
>
> > > +49 (0) 441 - 4082-0
>
> > >
>
> > > Fax:
>
> > > +49 (0) 441 - 4082-111
>
> > >
>
> > > arne.limburg@openknowledge.de
>
> > >
>
> > >
>
> > > http://www.openknowledge.de
>
>
>
> > >
>
> > >
>
> > >
>
> > >
>
> > > Registergericht:
>
> > > Amtsgericht Oldenburg, HRB 4670
>
> > >
>
> > > Geschäftsführer:
>
> > > Lars Röwekamp, Jens Schumann
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> > >
>
> >
>
> >
>
> > __________________________________________________
>
> > Do You Yahoo!?
>
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
>
> > herausragenden Schutz gegen Massenmails.
>
> > http://mail.yahoo.com
>
> >
>
>
>
> __________________________________________________
>
> Do You Yahoo!?
>
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen
> Massenmails.
>
> http://mail.yahoo.com
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com

Re: [Ext-CDI] @Transactional

Posted by Mark Struberg <st...@yahoo.de>.
I will also give it a try later today.

LieGrue,
strub

--- Matthias Wessendorf <ma...@apache.org> schrieb am Di, 16.3.2010:

> Von: Matthias Wessendorf <ma...@apache.org>
> Betreff: Re: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Dienstag, 16. März, 2010 14:32 Uhr
> On Tue, Mar 16, 2010 at 1:18 AM, Arne
> Limburg
> <ar...@openknowledge.de>
> wrote:
> > Hi Matthias,
> >
> > I used Weld to test it and it does not complain
> anything ;-)
> 
> I was guessing that ;-)
> 
> > I wonder why it is a problem to have the
> EntityManagerProducer @ApplicationScoped. The returned
> EntityManagers are @Dependent scoped. I'll take a look at
> what the spec says about this. I need to do some rework to
> make the EntityManagerProducer @Dependent scoped. The state
> must be moved to another bean that is @ApplicationScoped.
> That bean then can be injected into the
> EntityManagerProducer.
> >
> 
> I think I will do some OWB debugging (and double checking
> the spec)
> 2nite, regarding the error that we see.
> 
> > Regards,
> > Arne
> >
> > --
> >
> > Arne Limburg - Enterprise Developer
> > OpenKnowledge GmbH, Oldenburg
> > Bismarckstraße 13, 26122 Oldenburg
> > Mobil: +49 (0) 170 - 2733627
> > Tel: +49 (0) 441 - 4082-0
> > Fax: +49 (0) 441 - 4082-111
> > arne.limburg@openknowledge.de
> > http://www.openknowledge.de
> >
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> >
> > -----Ursprüngliche Nachricht-----
> > Von: mwessendorf@gmail.com
> [mailto:mwessendorf@gmail.com]
> Im Auftrag von Matthias Wessendorf
> > Gesendet: Dienstag, 16. März 2010 05:44
> > An: MyFaces Development
> > Betreff: Re: [Ext-CDI] @Transactional
> >
> > HEllo Arne,
> >
> > what version of OWB did you use?
> > Or did you use Weld?
> >
> > on deployment I get the following error (2times):
> > SEVERE:
> >
> org.apache.webbeans.exception.WebBeansConfigurationException:
> Bean
> > Name:null,WebBeans Type:MANAGED,API
> >
> Types:[java.lang.Object,org.apache.myfaces.codi.EntityManagerProducer],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]scope
> > can not define other scope except @Dependent to inject
> InjectionPoint
> >        at
> org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1001)
> >        at
> org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:346)
> >        at
> org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:301)
> >        at
> org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:154)
> >        at
> org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:120)
> >        at
> org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:75)
> >        at
> org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:66)
> >        at
> org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
> >        at
> org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
> >        at
> org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
> >        at
> org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
> >        at
> org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
> >        at
> org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
> >        at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> >        at
> org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
> >        at
> org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
> >        at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> >        at
> org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
> >        at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> >        at
> org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
> >        at
> org.mortbay.jetty.Server.doStart(Server.java:224)
> >        at
> org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
> >        at
> org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
> >        at
> org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
> >        at
> org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
> >        at
> org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
> >        at
> org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
> >
> >
> >
> > yes, the message is not easy to read, but it is
> basically complaining, that the
> > EntityManagerProducer is not having @Dependent scope
> (since it has
> > @ApplicationScoped).
> >
> > Good night,
> > Matthias
> >
> > On Fri, Mar 5, 2010 at 3:30 PM, Arne Limburg
> > <ar...@openknowledge.de>
> wrote:
> >> Hi,
> >>
> >>
> >>
> >> I have attached my source to EXTCDI-4.
> >>
> >> This is how you could use it, how it works and the
> limitations it has:
> >>
> >>
> >>
> >> First you have to qualify your EntityManager
> injection point with the
> >> provided @PersistenceContext annotation. Then you
> can use the @Transactional
> >> annotation.
> >>
> >> You will get the same (extended) EntityManager for
> all beans in the same
> >> scope and different EntityManagers for beans from
> other scopes.
> >>
> >>
> >>
> >> The EntityManagerProducer then checks whether an
> entity manager for that
> >> persistence unit and scope exists, creates one if
> not, and returns the
> >> entity manager.
> >>
> >>
> >>
> >> In the current implementation you have to specify
> the unitName of your
> >> persistence unit both at the @PersistenceContext
> annotation and the
> >> @Transactional annotation. This is very ugly, we
> should define a sensible
> >> default behavior here. The advantage is that you
> can have injected multiple
> >> persistence units within one scope.
> >>
> >>
> >>
> >> Other potential problems:
> >>
> >> I don't know if the detection of the current scope
> works correctly when an
> >> EntityManager is injected in a bean with
> @Dependent scope or when a
> >> @Transactional annotation is used on a bean with
> @Dependent scope
> >>
> >> I don't know if the closing of the EntityManager
> works correct (i.e. if the
> >> scope is still active when the EntityManager gets
> destroyed). Or could we
> >> simply close the EntityManager, if it is open
> assuming that all beans in
> >> that scope will be destroyed at the same time?
> >>
> >>
> >>
> >> What do you think?
> >>
> >>
> >>
> >> Regards,
> >>
> >> Arne
> >>
> >>
> >>
> >> --
> >>
> >>
> >>
> >> Arne Limburg - Enterprise Developer
> >>
> >> OpenKnowledge GmbH, Oldenburg
> >>
> >> Bismarckstraße 13, 26122 Oldenburg
> >>
> >> Mobil: +49 (0) 170 - 2733627
> >>
> >> Tel: +49 (0) 441 - 4082-0
> >>
> >> Fax: +49 (0) 441 - 4082-111
> >>
> >> arne.limburg@openknowledge.de
> >>
> >> http://www.openknowledge.de
> >>
> >>
> >>
> >> Registergericht: Amtsgericht Oldenburg, HRB 4670
> >>
> >> Geschäftsführer: Lars Röwekamp, Jens Schumann
> >>
> >>
> >>
> >> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> >> Gesendet: Donnerstag, 4. März 2010 20:39
> >> An: MyFaces Development
> >> Betreff: Re: [Ext-CDI] @Transactional
> >>
> >>
> >>
> >> hi arne,
> >>
> >>
> >>
> >> i created a jira issue for it [1].
> >>
> >> could you please upload your implementation.
> >>
> >> + a short description about the possible usages as
> well as restrictions (if
> >> present).
> >>
> >>
> >>
> >> thx & regards,
> >>
> >> gerhard
> >>
> >>
> >>
> >> [1] https://issues.apache.org/jira/browse/EXTCDI-4
> >>
> >> http://www.irian.at
> >>
> >> Your JSF powerhouse -
> >> JSF Consulting, Development and
> >> Courses in English and German
> >>
> >> Professional Support for Apache MyFaces
> >>
> >> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> >>
> >> Hi,
> >>
> >>
> >>
> >> I've updated my code at
> >>
> >> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> >>
> >> It is not really tested and lacks some
> fallback-scenarios (i.e.
> >> null-handling, etc.), but it is a starting point
> to inject scoped
> >> EntityManagers for every CDI-scope.
> >>
> >>
> >>
> >> Regards,
> >>
> >> Arne
> >>
> >>
> >>
> >> --
> >>
> >>
> >>
> >> Arne Limburg - Enterprise Developer
> >>
> >> OpenKnowledge GmbH, Oldenburg
> >>
> >> Bismarckstraße 13, 26122 Oldenburg
> >>
> >> Mobil: +49 (0) 151 - 108 22 942
> >>
> >> Tel: +49 (0) 441 - 4082-0
> >>
> >> Fax: +49 (0) 441 - 4082-111
> >>
> >> arne.limburg@openknowledge.de
> >>
> >> http://www.openknowledge.de
> >>
> >>
> >>
> >> Registergericht: Amtsgericht Oldenburg, HRB 4670
> >>
> >> Geschäftsführer: Lars Röwekamp, Jens Schumann
> >>
> >>
> >>
> >> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> >>
> >> Gesendet: Montag, 15. Februar 2010 13:44
> >>
> >> An: MyFaces Development
> >> Betreff: Re: [Ext-CDI] @Transactional
> >>
> >>
> >>
> >> hi arne,
> >>
> >>
> >>
> >> thx for providing the source code.
> >>
> >> i'll have a look at it after the jsfdays.
> >>
> >>
> >>
> >> one of the goals is to provide an alternative
> conversation scope for cdi
> >> which allows to use the conversation concepts
> provided by orchestra.
> >>
> >> so we have to ensure that it works with every
> custom cdi scope.
> >>
> >> (cdi conversations would be the default scope)
> >>
> >>
> >>
> >> regards,
> >>
> >> gerhard
> >>
> >> http://www.irian.at
> >>
> >> Your JSF powerhouse -
> >> JSF Consulting, Development and
> >> Courses in English and German
> >>
> >> Professional Support for Apache MyFaces
> >>
> >> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> >>
> >> Hi,
> >>
> >> I've prototyped some code that injects
> conversation-scoped EntityManagers
> >> reading the unitName from the qualifier annotation
> and added @Transactional
> >> support for this EntityManagers. This code needs
> some thinking though, e.g.
> >> how to handle the default-case (no unitName
> specified)...
> >>
> >> If you want to take a look at it, I have created a
> Wiki page and added my
> >> code as attachment:
> >> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> >>
> >> This code could be a starting point to implement
> Orchestra-like
> >> conversations (starting with
> CDI-Conversations)...
> >>
> >> Regards,
> >> Arne
> >>
> >> --
> >>
> >> Arne Limburg - Enterprise Developer
> >> OpenKnowledge GmbH, Oldenburg
> >> Bismarckstraße 13, 26122 Oldenburg
> >> Mobil: +49 (0) 151 - 108 22 942
> >> Tel: +49 (0) 441 - 4082-0
> >> Fax: +49 (0) 441 - 4082-111
> >> arne.limburg@openknowledge.de
> >> http://www.openknowledge.de
> >>
> >> Registergericht: Amtsgericht Oldenburg, HRB 4670
> >> Geschäftsführer: Lars Röwekamp, Jens Schumann
> >>
> >> -----Ursprüngliche Nachricht-----
> >> Von: Mark Struberg [mailto:struberg@yahoo.de]
> >>
> >> Gesendet: Samstag, 13. Februar 2010 20:27
> >>
> >> An: MyFaces Development
> >> Betreff: AW: [Ext-CDI] @Transactional
> >>
> >>> I am afraid supporting multiple
> persistence-units in that
> >>> scenario is very difficult...
> >>
> >> Nope, it's really easy. I simply use Qualifiers to
> distinguish between them.
> >>
> >> @Qualifier
> >> public @instance Core {}
> >>
> >> @Qualifier
> >> public @instance Other {}
> >>
> >> ----
> >> @RequestScoped
> >> public class EMProducer {
> >> private @PersistenceContext(unitName="core")
> EntityManager emCore;
> >> private @PersistenceContext(unitName="other")
> EntityManager emOther;
> >>
> >>
> >> public @Produces @Core EntityManager getCoreEM()
> {return emCore;}
> >> public @Produces @Other EntityManager getOtherEM()
> {return emOther;}
> >>
> >>
> >> Injection happens with
> >>
> >> private @Inject @Core EntityManager
> >>
> >>
> >> Got the idea?
> >>
> >> LieGrue,
> >> strub
> >>
> >> --- Arne Limburg <ar...@openknowledge.de>
> schrieb am Sa, 13.2.2010:
> >>
> >>> Von: Arne Limburg <ar...@openknowledge.de>
> >>> Betreff: AW: [Ext-CDI] @Transactional
> >>> An: "MyFaces Development" <de...@myfaces.apache.org>
> >>> Datum: Samstag, 13. Februar 2010, 20:06
> >>> Hi Mark,
> >>>
> >>> thank you for your feedback. I was aware of
> the requirement
> >>> of CDI-containers to inject JavaEE resources
> in a
> >>> JavaEE-environment, but Gerhard and I are
> thinking about a
> >>> generic non-JavaEE-solution for
> EntityManager-injection. And
> >>> at least weld does no injection of
> JavaEE-resources in this
> >>> case. How does OpenWebBeans?
> >>> I am afraid supporting multiple
> persistence-units in that
> >>> scenario is very difficult...
> >>>
> >>> Nonetheless it would be nice to see your
> >>> multiple-database-handling
> TransactionInterceptor in CODI.
> >>>
> >>> Regards,
> >>> Arne
> >>>
> >>> --
> >>>
> >>> Arne Limburg - Enterprise Developer
> >>> OpenKnowledge GmbH, Oldenburg
> >>> Bismarckstraße 13, 26122 Oldenburg
> >>> Mobil: +49 (0) 151 - 108 22 942
> >>> Tel: +49 (0) 441 - 4082-0
> >>> Fax: +49 (0) 441 - 4082-111
> >>> arne.limburg@openknowledge.de
> >>> http://www.openknowledge.de
> >>
> >>>
> >>> Registergericht: Amtsgericht Oldenburg, HRB
> 4670
> >>> Geschäftsführer: Lars Röwekamp, Jens
> Schumann
> >>>
> >>> -----Ursprüngliche Nachricht-----
> >>> Von: Mark Struberg [mailto:struberg@yahoo.de]
> >>>
> >>> Gesendet: Samstag, 13. Februar 2010 15:39
> >>> An: MyFaces Development
> >>> Betreff: AW: [Ext-CDI] @Transactional
> >>>
> >>> Hi!
> >>>
> >>> The JSR-299 spec defines that we have to
> support injection
> >>> of EE-Resources.
> >>>
> >>> This was more explicit in the old version of
> the spec, but
> >>> unless the wording got shortened, I still
> think injection of
> >>> @PersistenceUnit and @PersistenceContext must
> be supported
> >>> by any JSR-299 container (at least in an EE
> environment).
> >>>
> >>> For OpenWebBeans, you can simply use our
> >>> openwebbeans-resource plugin. Please note that
> this is
> >>> necessary because OWB is modular, and
> openwebbeans-impl (the
> >>> core) will have no EE dependencies at all (not
> even JSF,
> >>> JPA, etc!) This will get picked up
> automatically if it is
> >>> available in the classpath, e.g. you can
> simply define the
> >>> following maven dependency:
> >>>
> >>>         <dependency>
> >>>
> >>>
> <groupId>org.apache.openwebbeans</groupId>
> >>>
> >>>
> <artifactId>openwebbeans-resource</artifactId>
> >>>
> >>> <version>${owb.version}</version>
> >>>         </dependency>
> >>>
> >>> OWB supports 2 different scenarios. If you are
> not running
> >>> in a JTA aware container like e.g. OpenEJB,
> you will
> >>> automatically use a simple resource version of
> an SPI
> >>> implementation which uses
> >>>
> Persistence#createEntityManagerFactory(unitName) for
> >>> injecting (Thus getting an extended EM). If
> you use e.g.
> >>> OpenEJB, we are able to get the injectable
> resources
> >>> directly from there (thus getting a
> transactional EM).
> >>>
> >>> Once this is available, you can simply create
> a producer
> >>> method for the EntityManager:
> >>>
> >>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
> >>
> >>>
> >>> There is also an example on how to implement
> a
> >>> TransactionalInterceptor:
> >>>
> >>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
> >>
> >>>
> >>> In my company, I already implemented a
> >>> TransactionalInteceptor which is capable of
> handling
> >>> multiple databases at a time and also
> correctly handles
> >>> nested transactions. I hope to migrate this
> over to CODI in
> >>> the near future.
> >>>
> >>>
> >>> LieGrue,
> >>> strub
> >>>
> >>>
> >>> --- Arne Limburg <ar...@openknowledge.de>
> >>> schrieb am Sa, 13.2.2010:
> >>>
> >>> > Von: Arne Limburg <ar...@openknowledge.de>
> >>> > Betreff: AW: [Ext-CDI] @Transactional
> >>> > An: "'MyFaces Development'" <de...@myfaces.apache.org>
> >>> > Datum: Samstag, 13. Februar 2010, 14:42
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Hi Gerhard,
> >>> >
> >>> >
> >>> >
> >>> > OK, I got what you did,
> >>> > basically I did the same. You are right,
> >>> > that was pretty straight-forward, but I
> had to
> >>> hard-code
> >>> > the persistence-unit
> >>> > name.
> >>> >
> >>> >
> >>> >
> >>> > I have two ideas to inject the
> >>> > persistence-unit name into the
> >>> > producer-method for the EntityManager:
> >>> >
> >>> >
> >>> >
> >>> > First idea: A
> >>> > @PersistenceUnitName qualifier-annotation
> to
> >>> > inject the name into the producer-method.
> Client code
> >>> would
> >>> > have somethink like
> >>> >
> >>> > public class Configuration
> >>> > {
> >>> >
> >>> >
> >>> >
> >>> >   @Produces
> >>> > @PersistenceUnitName
> >>> >
> >>> >   String
> >>> > getPersistenceUnitName() {
> >>> >
> >>> > ...
> >>> >
> >>> > Not really nice, but the
> >>> > simplest solution to generify it.
> >>> >
> >>> >
> >>> >
> >>> > Second idea:
> >>> >
> >>> > The @PersistenceContext
> >>> > qualifier has a @Nonbind attribute
> >>> > persistenceUnitName which we can extract
> in the
> >>> producer
> >>> > method. But then we
> >>> > get in scoping issues. Especially when
> having
> >>> multiple
> >>> > persistence-units within
> >>> > one deployment. The second problem is:
> How can the
> >>> > @Transactional annotation
> >>> > know the persistence-unit-name.
> >>> >
> >>> >
> >>> >
> >>> > Any other ideas?
> >>> >
> >>> >
> >>> >
> >>> > Regards,
> >>> >
> >>> > Arne
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> >
> >>> >
> >>> >
> >>> > Arne Limburg - Enterprise
> >>> > Developer
> >>> >
> >>> > OpenKnowledge GmbH,
> >>> > Oldenburg
> >>> >
> >>> > Bismarckstraße 13, 26122
> >>> > Oldenburg
> >>> >
> >>> > Mobil: +49 (0) 151 - 108 22
> >>> > 942
> >>> >
> >>> > Tel: +49 (0) 441 -
> >>> > 4082-0
> >>> >
> >>> > Fax: +49 (0) 441 -
> >>> > 4082-111
> >>> >
> >>> > arne.limburg@openknowledge.de
> >>> >
> >>> >
> >>> > http://www.openknowledge.de
> >>
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Registergericht: Amtsgericht
> >>> > Oldenburg, HRB 4670
> >>> >
> >>> > Geschäftsführer: Lars
> >>> > Röwekamp, Jens Schumann
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Von: Gerhard Petracek
> >>> > [mailto:gerhard.petracek@gmail.com]
> >>>
> >>> >
> >>> > Gesendet: Samstag, 13. Februar 2010
> 14:32
> >>> >
> >>> > An: MyFaces Development
> >>> >
> >>> > Betreff: Re: [Ext-CDI] @Transactional
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > hi arne,
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > i used the EntityManager to get
> >>> > an EntityTransaction.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > you have to use cdi to create and
> >>> > inject it.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > (i used some producer methods.)
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > i created @PersistenceUnit which
> >>> > is a cdi qualifier and
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > @Transactional which is a cdi
> >>> > interceptor binding.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > basically it works and it isn't
> >>> > hard to use.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > however, we have to think about an
> >>> > approach to provide as
> >>> > much as possible in a generic way.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > regards,
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > gerhard
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > http://www.irian.at
> >>
> >>> >
> >>> >
> >>> >
> >>> > Your JSF powerhouse -
> >>> >
> >>> > JSF Consulting, Development and
> >>> >
> >>> > Courses in English and German
> >>> >
> >>> >
> >>> >
> >>> > Professional Support for Apache MyFaces
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Hi
> >>> > Gerhard,
> >>> >
> >>> >
> >>> >
> >>> > Did
> >>> > you mean "i used
> >>> > UserTransaction"? If not, how do you
> receive your
> >>> > EntityTransaction?
> >>> >
> >>> >
> >>> >
> >>> > I am
> >>> > working on a solution to
> >>> > get request-scoped EntityManagers
> injected within a
> >>> > servlet-container that does
> >>> > not even support the web-profile (which
> are the
> >>> current
> >>> > jetty and the current
> >>> > tomcat). I am not able to get an
> EntityManager
> >>> injected via
> >>> > @PersistenceContext
> >>> > in that environment. So it would be nice
> if there were
> >>> some
> >>> > CDI-Extension to
> >>> > achieve this. The implementation would be
> pretty
> >>> > straight-forward except the
> >>> > configuration of the persistence-unit
> name and the
> >>> handling
> >>> > of different
> >>> > persistence-units within one
> CDI-deployment
> >>> > unit.
> >>> >
> >>> >
> >>> >
> >>> > Using
> >>> > JTA-Transactions vs.
> >>> > resource-local EntityTransactions is
> another issue
> >>> > here.
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Regards,
> >>> >
> >>> > Arne
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> >
> >>> >
> >>> >
> >>> > Arne
> >>> > Limburg - Enterprise
> >>> > Developer
> >>> >
> >>> > OpenKnowledge GmbH,
> >>> > Oldenburg
> >>> >
> >>> > Bismarckstraße
> >>> > 13, 26122 Oldenburg
> >>> >
> >>> > Mobil: +49 (0) 151
> >>> > - 108 22 942
> >>> >
> >>> > Tel: +49 (0) 441 -
> >>> > 4082-0
> >>> >
> >>> > Fax: +49 (0) 441 -
> >>> > 4082-111
> >>> >
> >>> > arne.limburg@openknowledge.de
> >>> >
> >>> >
> >>> > http://www.openknowledge.de
> >>> >
> >>> >
> >>> >
> >>> > Registergericht:
> >>> > Amtsgericht Oldenburg,
> >>> > HRB 4670
> >>> >
> >>> > Geschäftsführer:
> >>> > Lars Röwekamp, Jens
> >>> > Schumann
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Von: Gerhard
> >>> > Petracek [mailto:gerhard.petracek@gmail.com]
> >>> >
> >>> >
> >>> > Gesendet: Freitag, 12. Februar 2010
> 19:59
> >>> >
> >>> > An: MyFaces Development
> >>> >
> >>> > Betreff: Re: [Ext-CDI] @Transactional
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > hi
> >>> > arne,
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > yes
> >>> > - i used EntityTransaction in the
> prototype and it
> >>> works
> >>> > pretty well in a
> >>> > servlet container (that was the base
> idea).
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > regards,
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > gerhard
> >>> >
> >>> >
> >>> >
> >>> > http://www.irian.at
> >>
> >>> >
> >>> >
> >>> >
> >>> > Your JSF powerhouse -
> >>> >
> >>> > JSF Consulting, Development and
> >>> >
> >>> > Courses in English and German
> >>> >
> >>> >
> >>> >
> >>> > Professional Support for Apache MyFaces
> >>> >
> >>> >
> >>> >
> >>> > 2010/2/12
> >>> > Arne Limburg <ar...@openknowledge.de>
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Hi
> >>> > folks,
> >>> >
> >>> >
> >>> >
> >>> > I saw the discussion of adding an
> >>> > @Transactional-Annotation to your
> >>> > CDI extensions. I think Gerhard wrote it.
> I wonder if
> >>> it
> >>> > deals with JTA
> >>> > transactions (which indeed would be
> pretty
> >>> > straight-forward) or with
> >>> > EntityTransactions of an resource-local
> EntityManager.
> >>> I am
> >>> > working on the
> >>> > latter one and just would want to know if
> someone else
> >>> is
> >>> > working on such
> >>> > stuff. I think it would be great, when we
> could
> >>> archive
> >>> > injection of
> >>> > resource-local EntityManagers with
> transaction-support
> >>> to
> >>> > deploy it on a tomcat
> >>> > or jetty. What do you think?
> >>> >
> >>> >
> >>> >
> >>> > Regards,
> >>> >
> >>> > Arne
> >>> >
> >>> >
> >>> >
> >>> > --
> >>> >
> >>> >
> >>> >
> >>> > Arne Limburg - Enterprise
> >>> > Developer
> >>> >
> >>> > OpenKnowledge GmbH, Oldenburg
> >>> >
> >>> > Bismarckstraße
> >>> > 13, 26122 Oldenburg
> >>> >
> >>> > Mobil:
> >>> > +49 (0) 151 - 108 22 942
> >>> >
> >>> > Tel:
> >>> > +49 (0) 441 - 4082-0
> >>> >
> >>> > Fax:
> >>> > +49 (0) 441 - 4082-111
> >>> >
> >>> > arne.limburg@openknowledge.de
> >>> >
> >>> >
> >>> > http://www.openknowledge.de
> >>
> >>> >
> >>> >
> >>> >
> >>> >
> >>> > Registergericht:
> >>> > Amtsgericht Oldenburg, HRB 4670
> >>> >
> >>> > Geschäftsführer:
> >>> > Lars Röwekamp, Jens Schumann
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >
> >>>
> >>>
> >>>
> __________________________________________________
> >>> Do You Yahoo!?
> >>> Sie sind Spam leid? Yahoo! Mail verfügt über
> einen
> >>> herausragenden Schutz gegen Massenmails.
> >>> http://mail.yahoo.com
> >>>
> >>
> >>
> __________________________________________________
> >> Do You Yahoo!?
> >> Sie sind Spam leid? Yahoo! Mail verfügt über
> einen herausragenden Schutz
> >> gegen Massenmails.
> >> http://mail.yahoo.com
> >>
> >>
> >>
> >>
> >
> >
> >
> > --
> > Matthias Wessendorf
> >
> > blog: http://matthiaswessendorf.wordpress.com/
> > sessions: http://www.slideshare.net/mwessendorf
> > twitter: http://twitter.com/mwessendorf
> >
> 
> 
> 
> -- 
> Matthias Wessendorf
> 
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
> 

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com 

Re: [Ext-CDI] @Transactional

Posted by Matthias Wessendorf <ma...@apache.org>.
On Tue, Mar 16, 2010 at 1:18 AM, Arne Limburg
<ar...@openknowledge.de> wrote:
> Hi Matthias,
>
> I used Weld to test it and it does not complain anything ;-)

I was guessing that ;-)

> I wonder why it is a problem to have the EntityManagerProducer @ApplicationScoped. The returned EntityManagers are @Dependent scoped. I'll take a look at what the spec says about this. I need to do some rework to make the EntityManagerProducer @Dependent scoped. The state must be moved to another bean that is @ApplicationScoped. That bean then can be injected into the EntityManagerProducer.
>

I think I will do some OWB debugging (and double checking the spec)
2nite, regarding the error that we see.

> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 170 - 2733627
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im Auftrag von Matthias Wessendorf
> Gesendet: Dienstag, 16. März 2010 05:44
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
> HEllo Arne,
>
> what version of OWB did you use?
> Or did you use Weld?
>
> on deployment I get the following error (2times):
> SEVERE:
> org.apache.webbeans.exception.WebBeansConfigurationException: Bean
> Name:null,WebBeans Type:MANAGED,API
> Types:[java.lang.Object,org.apache.myfaces.codi.EntityManagerProducer],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]scope
> can not define other scope except @Dependent to inject InjectionPoint
>        at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1001)
>        at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:346)
>        at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:301)
>        at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:154)
>        at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:120)
>        at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:75)
>        at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:66)
>        at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
>        at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
>        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
>        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
>        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
>        at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
>        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
>        at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
>        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
>        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
>        at org.mortbay.jetty.Server.doStart(Server.java:224)
>        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
>        at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
>        at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
>        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
>        at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
>        at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)
>
>
>
> yes, the message is not easy to read, but it is basically complaining, that the
> EntityManagerProducer is not having @Dependent scope (since it has
> @ApplicationScoped).
>
> Good night,
> Matthias
>
> On Fri, Mar 5, 2010 at 3:30 PM, Arne Limburg
> <ar...@openknowledge.de> wrote:
>> Hi,
>>
>>
>>
>> I have attached my source to EXTCDI-4.
>>
>> This is how you could use it, how it works and the limitations it has:
>>
>>
>>
>> First you have to qualify your EntityManager injection point with the
>> provided @PersistenceContext annotation. Then you can use the @Transactional
>> annotation.
>>
>> You will get the same (extended) EntityManager for all beans in the same
>> scope and different EntityManagers for beans from other scopes.
>>
>>
>>
>> The EntityManagerProducer then checks whether an entity manager for that
>> persistence unit and scope exists, creates one if not, and returns the
>> entity manager.
>>
>>
>>
>> In the current implementation you have to specify the unitName of your
>> persistence unit both at the @PersistenceContext annotation and the
>> @Transactional annotation. This is very ugly, we should define a sensible
>> default behavior here. The advantage is that you can have injected multiple
>> persistence units within one scope.
>>
>>
>>
>> Other potential problems:
>>
>> I don't know if the detection of the current scope works correctly when an
>> EntityManager is injected in a bean with @Dependent scope or when a
>> @Transactional annotation is used on a bean with @Dependent scope
>>
>> I don't know if the closing of the EntityManager works correct (i.e. if the
>> scope is still active when the EntityManager gets destroyed). Or could we
>> simply close the EntityManager, if it is open assuming that all beans in
>> that scope will be destroyed at the same time?
>>
>>
>>
>> What do you think?
>>
>>
>>
>> Regards,
>>
>> Arne
>>
>>
>>
>> --
>>
>>
>>
>> Arne Limburg - Enterprise Developer
>>
>> OpenKnowledge GmbH, Oldenburg
>>
>> Bismarckstraße 13, 26122 Oldenburg
>>
>> Mobil: +49 (0) 170 - 2733627
>>
>> Tel: +49 (0) 441 - 4082-0
>>
>> Fax: +49 (0) 441 - 4082-111
>>
>> arne.limburg@openknowledge.de
>>
>> http://www.openknowledge.de
>>
>>
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>>
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>>
>>
>> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
>> Gesendet: Donnerstag, 4. März 2010 20:39
>> An: MyFaces Development
>> Betreff: Re: [Ext-CDI] @Transactional
>>
>>
>>
>> hi arne,
>>
>>
>>
>> i created a jira issue for it [1].
>>
>> could you please upload your implementation.
>>
>> + a short description about the possible usages as well as restrictions (if
>> present).
>>
>>
>>
>> thx & regards,
>>
>> gerhard
>>
>>
>>
>> [1] https://issues.apache.org/jira/browse/EXTCDI-4
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
>>
>> Hi,
>>
>>
>>
>> I've updated my code at
>>
>> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>>
>> It is not really tested and lacks some fallback-scenarios (i.e.
>> null-handling, etc.), but it is a starting point to inject scoped
>> EntityManagers for every CDI-scope.
>>
>>
>>
>> Regards,
>>
>> Arne
>>
>>
>>
>> --
>>
>>
>>
>> Arne Limburg - Enterprise Developer
>>
>> OpenKnowledge GmbH, Oldenburg
>>
>> Bismarckstraße 13, 26122 Oldenburg
>>
>> Mobil: +49 (0) 151 - 108 22 942
>>
>> Tel: +49 (0) 441 - 4082-0
>>
>> Fax: +49 (0) 441 - 4082-111
>>
>> arne.limburg@openknowledge.de
>>
>> http://www.openknowledge.de
>>
>>
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>>
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>>
>>
>> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
>>
>> Gesendet: Montag, 15. Februar 2010 13:44
>>
>> An: MyFaces Development
>> Betreff: Re: [Ext-CDI] @Transactional
>>
>>
>>
>> hi arne,
>>
>>
>>
>> thx for providing the source code.
>>
>> i'll have a look at it after the jsfdays.
>>
>>
>>
>> one of the goals is to provide an alternative conversation scope for cdi
>> which allows to use the conversation concepts provided by orchestra.
>>
>> so we have to ensure that it works with every custom cdi scope.
>>
>> (cdi conversations would be the default scope)
>>
>>
>>
>> regards,
>>
>> gerhard
>>
>> http://www.irian.at
>>
>> Your JSF powerhouse -
>> JSF Consulting, Development and
>> Courses in English and German
>>
>> Professional Support for Apache MyFaces
>>
>> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
>>
>> Hi,
>>
>> I've prototyped some code that injects conversation-scoped EntityManagers
>> reading the unitName from the qualifier annotation and added @Transactional
>> support for this EntityManagers. This code needs some thinking though, e.g.
>> how to handle the default-case (no unitName specified)...
>>
>> If you want to take a look at it, I have created a Wiki page and added my
>> code as attachment:
>> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>>
>> This code could be a starting point to implement Orchestra-like
>> conversations (starting with CDI-Conversations)...
>>
>> Regards,
>> Arne
>>
>> --
>>
>> Arne Limburg - Enterprise Developer
>> OpenKnowledge GmbH, Oldenburg
>> Bismarckstraße 13, 26122 Oldenburg
>> Mobil: +49 (0) 151 - 108 22 942
>> Tel: +49 (0) 441 - 4082-0
>> Fax: +49 (0) 441 - 4082-111
>> arne.limburg@openknowledge.de
>> http://www.openknowledge.de
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Mark Struberg [mailto:struberg@yahoo.de]
>>
>> Gesendet: Samstag, 13. Februar 2010 20:27
>>
>> An: MyFaces Development
>> Betreff: AW: [Ext-CDI] @Transactional
>>
>>> I am afraid supporting multiple persistence-units in that
>>> scenario is very difficult...
>>
>> Nope, it's really easy. I simply use Qualifiers to distinguish between them.
>>
>> @Qualifier
>> public @instance Core {}
>>
>> @Qualifier
>> public @instance Other {}
>>
>> ----
>> @RequestScoped
>> public class EMProducer {
>> private @PersistenceContext(unitName="core") EntityManager emCore;
>> private @PersistenceContext(unitName="other") EntityManager emOther;
>>
>>
>> public @Produces @Core EntityManager getCoreEM() {return emCore;}
>> public @Produces @Other EntityManager getOtherEM() {return emOther;}
>>
>>
>> Injection happens with
>>
>> private @Inject @Core EntityManager
>>
>>
>> Got the idea?
>>
>> LieGrue,
>> strub
>>
>> --- Arne Limburg <ar...@openknowledge.de> schrieb am Sa, 13.2.2010:
>>
>>> Von: Arne Limburg <ar...@openknowledge.de>
>>> Betreff: AW: [Ext-CDI] @Transactional
>>> An: "MyFaces Development" <de...@myfaces.apache.org>
>>> Datum: Samstag, 13. Februar 2010, 20:06
>>> Hi Mark,
>>>
>>> thank you for your feedback. I was aware of the requirement
>>> of CDI-containers to inject JavaEE resources in a
>>> JavaEE-environment, but Gerhard and I are thinking about a
>>> generic non-JavaEE-solution for EntityManager-injection. And
>>> at least weld does no injection of JavaEE-resources in this
>>> case. How does OpenWebBeans?
>>> I am afraid supporting multiple persistence-units in that
>>> scenario is very difficult...
>>>
>>> Nonetheless it would be nice to see your
>>> multiple-database-handling TransactionInterceptor in CODI.
>>>
>>> Regards,
>>> Arne
>>>
>>> --
>>>
>>> Arne Limburg - Enterprise Developer
>>> OpenKnowledge GmbH, Oldenburg
>>> Bismarckstraße 13, 26122 Oldenburg
>>> Mobil: +49 (0) 151 - 108 22 942
>>> Tel: +49 (0) 441 - 4082-0
>>> Fax: +49 (0) 441 - 4082-111
>>> arne.limburg@openknowledge.de
>>> http://www.openknowledge.de
>>
>>>
>>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>>
>>> -----Ursprüngliche Nachricht-----
>>> Von: Mark Struberg [mailto:struberg@yahoo.de]
>>>
>>> Gesendet: Samstag, 13. Februar 2010 15:39
>>> An: MyFaces Development
>>> Betreff: AW: [Ext-CDI] @Transactional
>>>
>>> Hi!
>>>
>>> The JSR-299 spec defines that we have to support injection
>>> of EE-Resources.
>>>
>>> This was more explicit in the old version of the spec, but
>>> unless the wording got shortened, I still think injection of
>>> @PersistenceUnit and @PersistenceContext must be supported
>>> by any JSR-299 container (at least in an EE environment).
>>>
>>> For OpenWebBeans, you can simply use our
>>> openwebbeans-resource plugin. Please note that this is
>>> necessary because OWB is modular, and openwebbeans-impl (the
>>> core) will have no EE dependencies at all (not even JSF,
>>> JPA, etc!) This will get picked up automatically if it is
>>> available in the classpath, e.g. you can simply define the
>>> following maven dependency:
>>>
>>>         <dependency>
>>>
>>> <groupId>org.apache.openwebbeans</groupId>
>>>
>>> <artifactId>openwebbeans-resource</artifactId>
>>>
>>> <version>${owb.version}</version>
>>>         </dependency>
>>>
>>> OWB supports 2 different scenarios. If you are not running
>>> in a JTA aware container like e.g. OpenEJB, you will
>>> automatically use a simple resource version of an SPI
>>> implementation which uses
>>> Persistence#createEntityManagerFactory(unitName) for
>>> injecting (Thus getting an extended EM). If you use e.g.
>>> OpenEJB, we are able to get the injectable resources
>>> directly from there (thus getting a transactional EM).
>>>
>>> Once this is available, you can simply create a producer
>>> method for the EntityManager:
>>>
>>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>>
>>>
>>> There is also an example on how to implement a
>>> TransactionalInterceptor:
>>>
>>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>>
>>>
>>> In my company, I already implemented a
>>> TransactionalInteceptor which is capable of handling
>>> multiple databases at a time and also correctly handles
>>> nested transactions. I hope to migrate this over to CODI in
>>> the near future.
>>>
>>>
>>> LieGrue,
>>> strub
>>>
>>>
>>> --- Arne Limburg <ar...@openknowledge.de>
>>> schrieb am Sa, 13.2.2010:
>>>
>>> > Von: Arne Limburg <ar...@openknowledge.de>
>>> > Betreff: AW: [Ext-CDI] @Transactional
>>> > An: "'MyFaces Development'" <de...@myfaces.apache.org>
>>> > Datum: Samstag, 13. Februar 2010, 14:42
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Hi Gerhard,
>>> >
>>> >
>>> >
>>> > OK, I got what you did,
>>> > basically I did the same. You are right,
>>> > that was pretty straight-forward, but I had to
>>> hard-code
>>> > the persistence-unit
>>> > name.
>>> >
>>> >
>>> >
>>> > I have two ideas to inject the
>>> > persistence-unit name into the
>>> > producer-method for the EntityManager:
>>> >
>>> >
>>> >
>>> > First idea: A
>>> > @PersistenceUnitName qualifier-annotation to
>>> > inject the name into the producer-method. Client code
>>> would
>>> > have somethink like
>>> >
>>> > public class Configuration
>>> > {
>>> >
>>> >
>>> >
>>> >   @Produces
>>> > @PersistenceUnitName
>>> >
>>> >   String
>>> > getPersistenceUnitName() {
>>> >
>>> > ...
>>> >
>>> > Not really nice, but the
>>> > simplest solution to generify it.
>>> >
>>> >
>>> >
>>> > Second idea:
>>> >
>>> > The @PersistenceContext
>>> > qualifier has a @Nonbind attribute
>>> > persistenceUnitName which we can extract in the
>>> producer
>>> > method. But then we
>>> > get in scoping issues. Especially when having
>>> multiple
>>> > persistence-units within
>>> > one deployment. The second problem is: How can the
>>> > @Transactional annotation
>>> > know the persistence-unit-name.
>>> >
>>> >
>>> >
>>> > Any other ideas?
>>> >
>>> >
>>> >
>>> > Regards,
>>> >
>>> > Arne
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> >
>>> >
>>> > Arne Limburg - Enterprise
>>> > Developer
>>> >
>>> > OpenKnowledge GmbH,
>>> > Oldenburg
>>> >
>>> > Bismarckstraße 13, 26122
>>> > Oldenburg
>>> >
>>> > Mobil: +49 (0) 151 - 108 22
>>> > 942
>>> >
>>> > Tel: +49 (0) 441 -
>>> > 4082-0
>>> >
>>> > Fax: +49 (0) 441 -
>>> > 4082-111
>>> >
>>> > arne.limburg@openknowledge.de
>>> >
>>> >
>>> > http://www.openknowledge.de
>>
>>> >
>>> >
>>> >
>>> >
>>> > Registergericht: Amtsgericht
>>> > Oldenburg, HRB 4670
>>> >
>>> > Geschäftsführer: Lars
>>> > Röwekamp, Jens Schumann
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Von: Gerhard Petracek
>>> > [mailto:gerhard.petracek@gmail.com]
>>>
>>> >
>>> > Gesendet: Samstag, 13. Februar 2010 14:32
>>> >
>>> > An: MyFaces Development
>>> >
>>> > Betreff: Re: [Ext-CDI] @Transactional
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > hi arne,
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > i used the EntityManager to get
>>> > an EntityTransaction.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > you have to use cdi to create and
>>> > inject it.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > (i used some producer methods.)
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > i created @PersistenceUnit which
>>> > is a cdi qualifier and
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > @Transactional which is a cdi
>>> > interceptor binding.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > basically it works and it isn't
>>> > hard to use.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > however, we have to think about an
>>> > approach to provide as
>>> > much as possible in a generic way.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > regards,
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > gerhard
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > http://www.irian.at
>>
>>> >
>>> >
>>> >
>>> > Your JSF powerhouse -
>>> >
>>> > JSF Consulting, Development and
>>> >
>>> > Courses in English and German
>>> >
>>> >
>>> >
>>> > Professional Support for Apache MyFaces
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Hi
>>> > Gerhard,
>>> >
>>> >
>>> >
>>> > Did
>>> > you mean "i used
>>> > UserTransaction"? If not, how do you receive your
>>> > EntityTransaction?
>>> >
>>> >
>>> >
>>> > I am
>>> > working on a solution to
>>> > get request-scoped EntityManagers injected within a
>>> > servlet-container that does
>>> > not even support the web-profile (which are the
>>> current
>>> > jetty and the current
>>> > tomcat). I am not able to get an EntityManager
>>> injected via
>>> > @PersistenceContext
>>> > in that environment. So it would be nice if there were
>>> some
>>> > CDI-Extension to
>>> > achieve this. The implementation would be pretty
>>> > straight-forward except the
>>> > configuration of the persistence-unit name and the
>>> handling
>>> > of different
>>> > persistence-units within one CDI-deployment
>>> > unit.
>>> >
>>> >
>>> >
>>> > Using
>>> > JTA-Transactions vs.
>>> > resource-local EntityTransactions is another issue
>>> > here.
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Regards,
>>> >
>>> > Arne
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> >
>>> >
>>> > Arne
>>> > Limburg - Enterprise
>>> > Developer
>>> >
>>> > OpenKnowledge GmbH,
>>> > Oldenburg
>>> >
>>> > Bismarckstraße
>>> > 13, 26122 Oldenburg
>>> >
>>> > Mobil: +49 (0) 151
>>> > - 108 22 942
>>> >
>>> > Tel: +49 (0) 441 -
>>> > 4082-0
>>> >
>>> > Fax: +49 (0) 441 -
>>> > 4082-111
>>> >
>>> > arne.limburg@openknowledge.de
>>> >
>>> >
>>> > http://www.openknowledge.de
>>> >
>>> >
>>> >
>>> > Registergericht:
>>> > Amtsgericht Oldenburg,
>>> > HRB 4670
>>> >
>>> > Geschäftsführer:
>>> > Lars Röwekamp, Jens
>>> > Schumann
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Von: Gerhard
>>> > Petracek [mailto:gerhard.petracek@gmail.com]
>>> >
>>> >
>>> > Gesendet: Freitag, 12. Februar 2010 19:59
>>> >
>>> > An: MyFaces Development
>>> >
>>> > Betreff: Re: [Ext-CDI] @Transactional
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > hi
>>> > arne,
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > yes
>>> > - i used EntityTransaction in the prototype and it
>>> works
>>> > pretty well in a
>>> > servlet container (that was the base idea).
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > regards,
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > gerhard
>>> >
>>> >
>>> >
>>> > http://www.irian.at
>>
>>> >
>>> >
>>> >
>>> > Your JSF powerhouse -
>>> >
>>> > JSF Consulting, Development and
>>> >
>>> > Courses in English and German
>>> >
>>> >
>>> >
>>> > Professional Support for Apache MyFaces
>>> >
>>> >
>>> >
>>> > 2010/2/12
>>> > Arne Limburg <ar...@openknowledge.de>
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> > Hi
>>> > folks,
>>> >
>>> >
>>> >
>>> > I saw the discussion of adding an
>>> > @Transactional-Annotation to your
>>> > CDI extensions. I think Gerhard wrote it. I wonder if
>>> it
>>> > deals with JTA
>>> > transactions (which indeed would be pretty
>>> > straight-forward) or with
>>> > EntityTransactions of an resource-local EntityManager.
>>> I am
>>> > working on the
>>> > latter one and just would want to know if someone else
>>> is
>>> > working on such
>>> > stuff. I think it would be great, when we could
>>> archive
>>> > injection of
>>> > resource-local EntityManagers with transaction-support
>>> to
>>> > deploy it on a tomcat
>>> > or jetty. What do you think?
>>> >
>>> >
>>> >
>>> > Regards,
>>> >
>>> > Arne
>>> >
>>> >
>>> >
>>> > --
>>> >
>>> >
>>> >
>>> > Arne Limburg - Enterprise
>>> > Developer
>>> >
>>> > OpenKnowledge GmbH, Oldenburg
>>> >
>>> > Bismarckstraße
>>> > 13, 26122 Oldenburg
>>> >
>>> > Mobil:
>>> > +49 (0) 151 - 108 22 942
>>> >
>>> > Tel:
>>> > +49 (0) 441 - 4082-0
>>> >
>>> > Fax:
>>> > +49 (0) 441 - 4082-111
>>> >
>>> > arne.limburg@openknowledge.de
>>> >
>>> >
>>> > http://www.openknowledge.de
>>
>>> >
>>> >
>>> >
>>> >
>>> > Registergericht:
>>> > Amtsgericht Oldenburg, HRB 4670
>>> >
>>> > Geschäftsführer:
>>> > Lars Röwekamp, Jens Schumann
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>> >
>>>
>>>
>>> __________________________________________________
>>> Do You Yahoo!?
>>> Sie sind Spam leid? Yahoo! Mail verfügt über einen
>>> herausragenden Schutz gegen Massenmails.
>>> http://mail.yahoo.com
>>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
>> gegen Massenmails.
>> http://mail.yahoo.com
>>
>>
>>
>>
>
>
>
> --
> Matthias Wessendorf
>
> blog: http://matthiaswessendorf.wordpress.com/
> sessions: http://www.slideshare.net/mwessendorf
> twitter: http://twitter.com/mwessendorf
>



-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

AW: [Ext-CDI] @Transactional

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi Matthias,

I used Weld to test it and it does not complain anything ;-)
I wonder why it is a problem to have the EntityManagerProducer @ApplicationScoped. The returned EntityManagers are @Dependent scoped. I'll take a look at what the spec says about this. I need to do some rework to make the EntityManagerProducer @Dependent scoped. The state must be moved to another bean that is @ApplicationScoped. That bean then can be injected into the EntityManagerProducer.

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 170 - 2733627
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

-----Ursprüngliche Nachricht-----
Von: mwessendorf@gmail.com [mailto:mwessendorf@gmail.com] Im Auftrag von Matthias Wessendorf
Gesendet: Dienstag, 16. März 2010 05:44
An: MyFaces Development
Betreff: Re: [Ext-CDI] @Transactional

HEllo Arne,

what version of OWB did you use?
Or did you use Weld?

on deployment I get the following error (2times):
SEVERE:
org.apache.webbeans.exception.WebBeansConfigurationException: Bean
Name:null,WebBeans Type:MANAGED,API
Types:[java.lang.Object,org.apache.myfaces.codi.EntityManagerProducer],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]scope
can not define other scope except @Dependent to inject InjectionPoint
        at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1001)
        at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:346)
        at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:301)
        at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:154)
        at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:120)
        at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:75)
        at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:66)
        at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
        at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
        at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
        at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
        at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
        at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
        at org.mortbay.jetty.Server.doStart(Server.java:224)
        at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
        at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
        at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
        at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
        at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)



yes, the message is not easy to read, but it is basically complaining, that the
EntityManagerProducer is not having @Dependent scope (since it has
@ApplicationScoped).

Good night,
Matthias

On Fri, Mar 5, 2010 at 3:30 PM, Arne Limburg
<ar...@openknowledge.de> wrote:
> Hi,
>
>
>
> I have attached my source to EXTCDI-4.
>
> This is how you could use it, how it works and the limitations it has:
>
>
>
> First you have to qualify your EntityManager injection point with the
> provided @PersistenceContext annotation. Then you can use the @Transactional
> annotation.
>
> You will get the same (extended) EntityManager for all beans in the same
> scope and different EntityManagers for beans from other scopes.
>
>
>
> The EntityManagerProducer then checks whether an entity manager for that
> persistence unit and scope exists, creates one if not, and returns the
> entity manager.
>
>
>
> In the current implementation you have to specify the unitName of your
> persistence unit both at the @PersistenceContext annotation and the
> @Transactional annotation. This is very ugly, we should define a sensible
> default behavior here. The advantage is that you can have injected multiple
> persistence units within one scope.
>
>
>
> Other potential problems:
>
> I don't know if the detection of the current scope works correctly when an
> EntityManager is injected in a bean with @Dependent scope or when a
> @Transactional annotation is used on a bean with @Dependent scope
>
> I don't know if the closing of the EntityManager works correct (i.e. if the
> scope is still active when the EntityManager gets destroyed). Or could we
> simply close the EntityManager, if it is open assuming that all beans in
> that scope will be destroyed at the same time?
>
>
>
> What do you think?
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 170 - 2733627
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> Gesendet: Donnerstag, 4. März 2010 20:39
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
>
>
> hi arne,
>
>
>
> i created a jira issue for it [1].
>
> could you please upload your implementation.
>
> + a short description about the possible usages as well as restrictions (if
> present).
>
>
>
> thx & regards,
>
> gerhard
>
>
>
> [1] https://issues.apache.org/jira/browse/EXTCDI-4
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
>
>
> I've updated my code at
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
> It is not really tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject scoped
> EntityManagers for every CDI-scope.
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 151 - 108 22 942
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
>
> Gesendet: Montag, 15. Februar 2010 13:44
>
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
>
>
> hi arne,
>
>
>
> thx for providing the source code.
>
> i'll have a look at it after the jsfdays.
>
>
>
> one of the goals is to provide an alternative conversation scope for cdi
> which allows to use the conversation concepts provided by orchestra.
>
> so we have to ensure that it works with every custom cdi scope.
>
> (cdi conversations would be the default scope)
>
>
>
> regards,
>
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
> I've prototyped some code that injects conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and added @Transactional
> support for this EntityManagers. This code needs some thinking though, e.g.
> how to handle the default-case (no unitName specified)...
>
> If you want to take a look at it, I have created a Wiki page and added my
> code as attachment:
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
> This code could be a starting point to implement Orchestra-like
> conversations (starting with CDI-Conversations)...
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 - 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
>
> Gesendet: Samstag, 13. Februar 2010 20:27
>
> An: MyFaces Development
> Betreff: AW: [Ext-CDI] @Transactional
>
>> I am afraid supporting multiple persistence-units in that
>> scenario is very difficult...
>
> Nope, it's really easy. I simply use Qualifiers to distinguish between them.
>
> @Qualifier
> public @instance Core {}
>
> @Qualifier
> public @instance Other {}
>
> ----
> @RequestScoped
> public class EMProducer {
> private @PersistenceContext(unitName="core") EntityManager emCore;
> private @PersistenceContext(unitName="other") EntityManager emOther;
>
>
> public @Produces @Core EntityManager getCoreEM() {return emCore;}
> public @Produces @Other EntityManager getOtherEM() {return emOther;}
>
>
> Injection happens with
>
> private @Inject @Core EntityManager
>
>
> Got the idea?
>
> LieGrue,
> strub
>
> --- Arne Limburg <ar...@openknowledge.de> schrieb am Sa, 13.2.2010:
>
>> Von: Arne Limburg <ar...@openknowledge.de>
>> Betreff: AW: [Ext-CDI] @Transactional
>> An: "MyFaces Development" <de...@myfaces.apache.org>
>> Datum: Samstag, 13. Februar 2010, 20:06
>> Hi Mark,
>>
>> thank you for your feedback. I was aware of the requirement
>> of CDI-containers to inject JavaEE resources in a
>> JavaEE-environment, but Gerhard and I are thinking about a
>> generic non-JavaEE-solution for EntityManager-injection. And
>> at least weld does no injection of JavaEE-resources in this
>> case. How does OpenWebBeans?
>> I am afraid supporting multiple persistence-units in that
>> scenario is very difficult...
>>
>> Nonetheless it would be nice to see your
>> multiple-database-handling TransactionInterceptor in CODI.
>>
>> Regards,
>> Arne
>>
>> --
>>
>> Arne Limburg - Enterprise Developer
>> OpenKnowledge GmbH, Oldenburg
>> Bismarckstraße 13, 26122 Oldenburg
>> Mobil: +49 (0) 151 - 108 22 942
>> Tel: +49 (0) 441 - 4082-0
>> Fax: +49 (0) 441 - 4082-111
>> arne.limburg@openknowledge.de
>> http://www.openknowledge.de
>
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Mark Struberg [mailto:struberg@yahoo.de]
>>
>> Gesendet: Samstag, 13. Februar 2010 15:39
>> An: MyFaces Development
>> Betreff: AW: [Ext-CDI] @Transactional
>>
>> Hi!
>>
>> The JSR-299 spec defines that we have to support injection
>> of EE-Resources.
>>
>> This was more explicit in the old version of the spec, but
>> unless the wording got shortened, I still think injection of
>> @PersistenceUnit and @PersistenceContext must be supported
>> by any JSR-299 container (at least in an EE environment).
>>
>> For OpenWebBeans, you can simply use our
>> openwebbeans-resource plugin. Please note that this is
>> necessary because OWB is modular, and openwebbeans-impl (the
>> core) will have no EE dependencies at all (not even JSF,
>> JPA, etc!) This will get picked up automatically if it is
>> available in the classpath, e.g. you can simply define the
>> following maven dependency:
>>
>>         <dependency>
>>
>> <groupId>org.apache.openwebbeans</groupId>
>>
>> <artifactId>openwebbeans-resource</artifactId>
>>
>> <version>${owb.version}</version>
>>         </dependency>
>>
>> OWB supports 2 different scenarios. If you are not running
>> in a JTA aware container like e.g. OpenEJB, you will
>> automatically use a simple resource version of an SPI
>> implementation which uses
>> Persistence#createEntityManagerFactory(unitName) for
>> injecting (Thus getting an extended EM). If you use e.g.
>> OpenEJB, we are able to get the injectable resources
>> directly from there (thus getting a transactional EM).
>>
>> Once this is available, you can simply create a producer
>> method for the EntityManager:
>>
>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>
>>
>> There is also an example on how to implement a
>> TransactionalInterceptor:
>>
>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>
>>
>> In my company, I already implemented a
>> TransactionalInteceptor which is capable of handling
>> multiple databases at a time and also correctly handles
>> nested transactions. I hope to migrate this over to CODI in
>> the near future.
>>
>>
>> LieGrue,
>> strub
>>
>>
>> --- Arne Limburg <ar...@openknowledge.de>
>> schrieb am Sa, 13.2.2010:
>>
>> > Von: Arne Limburg <ar...@openknowledge.de>
>> > Betreff: AW: [Ext-CDI] @Transactional
>> > An: "'MyFaces Development'" <de...@myfaces.apache.org>
>> > Datum: Samstag, 13. Februar 2010, 14:42
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi Gerhard,
>> >
>> >
>> >
>> > OK, I got what you did,
>> > basically I did the same. You are right,
>> > that was pretty straight-forward, but I had to
>> hard-code
>> > the persistence-unit
>> > name.
>> >
>> >
>> >
>> > I have two ideas to inject the
>> > persistence-unit name into the
>> > producer-method for the EntityManager:
>> >
>> >
>> >
>> > First idea: A
>> > @PersistenceUnitName qualifier-annotation to
>> > inject the name into the producer-method. Client code
>> would
>> > have somethink like
>> >
>> > public class Configuration
>> > {
>> >
>> >
>> >
>> >   @Produces
>> > @PersistenceUnitName
>> >
>> >   String
>> > getPersistenceUnitName() {
>> >
>> > ...
>> >
>> > Not really nice, but the
>> > simplest solution to generify it.
>> >
>> >
>> >
>> > Second idea:
>> >
>> > The @PersistenceContext
>> > qualifier has a @Nonbind attribute
>> > persistenceUnitName which we can extract in the
>> producer
>> > method. But then we
>> > get in scoping issues. Especially when having
>> multiple
>> > persistence-units within
>> > one deployment. The second problem is: How can the
>> > @Transactional annotation
>> > know the persistence-unit-name.
>> >
>> >
>> >
>> > Any other ideas?
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH,
>> > Oldenburg
>> >
>> > Bismarckstraße 13, 26122
>> > Oldenburg
>> >
>> > Mobil: +49 (0) 151 - 108 22
>> > 942
>> >
>> > Tel: +49 (0) 441 -
>> > 4082-0
>> >
>> > Fax: +49 (0) 441 -
>> > 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>
>> >
>> >
>> >
>> >
>> > Registergericht: Amtsgericht
>> > Oldenburg, HRB 4670
>> >
>> > Geschäftsführer: Lars
>> > Röwekamp, Jens Schumann
>> >
>> >
>> >
>> >
>> >
>> > Von: Gerhard Petracek
>> > [mailto:gerhard.petracek@gmail.com]
>>
>> >
>> > Gesendet: Samstag, 13. Februar 2010 14:32
>> >
>> > An: MyFaces Development
>> >
>> > Betreff: Re: [Ext-CDI] @Transactional
>> >
>> >
>> >
>> >
>> >
>> > hi arne,
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > i used the EntityManager to get
>> > an EntityTransaction.
>> >
>> >
>> >
>> >
>> >
>> > you have to use cdi to create and
>> > inject it.
>> >
>> >
>> >
>> >
>> >
>> > (i used some producer methods.)
>> >
>> >
>> >
>> >
>> >
>> > i created @PersistenceUnit which
>> > is a cdi qualifier and
>> >
>> >
>> >
>> >
>> >
>> > @Transactional which is a cdi
>> > interceptor binding.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > basically it works and it isn't
>> > hard to use.
>> >
>> >
>> >
>> >
>> >
>> > however, we have to think about an
>> > approach to provide as
>> > much as possible in a generic way.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > regards,
>> >
>> >
>> >
>> >
>> >
>> > gerhard
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > http://www.irian.at
>
>> >
>> >
>> >
>> > Your JSF powerhouse -
>> >
>> > JSF Consulting, Development and
>> >
>> > Courses in English and German
>> >
>> >
>> >
>> > Professional Support for Apache MyFaces
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi
>> > Gerhard,
>> >
>> >
>> >
>> > Did
>> > you mean "i used
>> > UserTransaction"? If not, how do you receive your
>> > EntityTransaction?
>> >
>> >
>> >
>> > I am
>> > working on a solution to
>> > get request-scoped EntityManagers injected within a
>> > servlet-container that does
>> > not even support the web-profile (which are the
>> current
>> > jetty and the current
>> > tomcat). I am not able to get an EntityManager
>> injected via
>> > @PersistenceContext
>> > in that environment. So it would be nice if there were
>> some
>> > CDI-Extension to
>> > achieve this. The implementation would be pretty
>> > straight-forward except the
>> > configuration of the persistence-unit name and the
>> handling
>> > of different
>> > persistence-units within one CDI-deployment
>> > unit.
>> >
>> >
>> >
>> > Using
>> > JTA-Transactions vs.
>> > resource-local EntityTransactions is another issue
>> > here.
>> >
>> >
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne
>> > Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH,
>> > Oldenburg
>> >
>> > Bismarckstraße
>> > 13, 26122 Oldenburg
>> >
>> > Mobil: +49 (0) 151
>> > - 108 22 942
>> >
>> > Tel: +49 (0) 441 -
>> > 4082-0
>> >
>> > Fax: +49 (0) 441 -
>> > 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>> >
>> >
>> >
>> > Registergericht:
>> > Amtsgericht Oldenburg,
>> > HRB 4670
>> >
>> > Geschäftsführer:
>> > Lars Röwekamp, Jens
>> > Schumann
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Von: Gerhard
>> > Petracek [mailto:gerhard.petracek@gmail.com]
>> >
>> >
>> > Gesendet: Freitag, 12. Februar 2010 19:59
>> >
>> > An: MyFaces Development
>> >
>> > Betreff: Re: [Ext-CDI] @Transactional
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > hi
>> > arne,
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > yes
>> > - i used EntityTransaction in the prototype and it
>> works
>> > pretty well in a
>> > servlet container (that was the base idea).
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > regards,
>> >
>> >
>> >
>> >
>> >
>> > gerhard
>> >
>> >
>> >
>> > http://www.irian.at
>
>> >
>> >
>> >
>> > Your JSF powerhouse -
>> >
>> > JSF Consulting, Development and
>> >
>> > Courses in English and German
>> >
>> >
>> >
>> > Professional Support for Apache MyFaces
>> >
>> >
>> >
>> > 2010/2/12
>> > Arne Limburg <ar...@openknowledge.de>
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi
>> > folks,
>> >
>> >
>> >
>> > I saw the discussion of adding an
>> > @Transactional-Annotation to your
>> > CDI extensions. I think Gerhard wrote it. I wonder if
>> it
>> > deals with JTA
>> > transactions (which indeed would be pretty
>> > straight-forward) or with
>> > EntityTransactions of an resource-local EntityManager.
>> I am
>> > working on the
>> > latter one and just would want to know if someone else
>> is
>> > working on such
>> > stuff. I think it would be great, when we could
>> archive
>> > injection of
>> > resource-local EntityManagers with transaction-support
>> to
>> > deploy it on a tomcat
>> > or jetty. What do you think?
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH, Oldenburg
>> >
>> > Bismarckstraße
>> > 13, 26122 Oldenburg
>> >
>> > Mobil:
>> > +49 (0) 151 - 108 22 942
>> >
>> > Tel:
>> > +49 (0) 441 - 4082-0
>> >
>> > Fax:
>> > +49 (0) 441 - 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>
>> >
>> >
>> >
>> >
>> > Registergericht:
>> > Amtsgericht Oldenburg, HRB 4670
>> >
>> > Geschäftsführer:
>> > Lars Röwekamp, Jens Schumann
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Sie sind Spam leid? Yahoo! Mail verfügt über einen
>> herausragenden Schutz gegen Massenmails.
>> http://mail.yahoo.com
>>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
>
>
>



--
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

Re: [Ext-CDI] @Transactional

Posted by Matthias Wessendorf <ma...@apache.org>.
HEllo Arne,

what version of OWB did you use?
Or did you use Weld?

on deployment I get the following error (2times):
SEVERE:
org.apache.webbeans.exception.WebBeansConfigurationException: Bean
Name:null,WebBeans Type:MANAGED,API
Types:[java.lang.Object,org.apache.myfaces.codi.EntityManagerProducer],Qualifiers:[javax.enterprise.inject.Any,javax.enterprise.inject.Default]scope
can not define other scope except @Dependent to inject InjectionPoint
	at org.apache.webbeans.container.BeanManagerImpl.validate(BeanManagerImpl.java:1001)
	at org.apache.webbeans.config.BeansDeployer.validate(BeansDeployer.java:346)
	at org.apache.webbeans.config.BeansDeployer.validateInjectionPoints(BeansDeployer.java:301)
	at org.apache.webbeans.config.BeansDeployer.deploy(BeansDeployer.java:154)
	at org.apache.webbeans.lifecycle.AbstractLifeCycle.startApplication(AbstractLifeCycle.java:120)
	at org.apache.webbeans.web.lifecycle.WebContainerLifecycle.startApplication(WebContainerLifecycle.java:75)
	at org.apache.webbeans.servlet.WebBeansConfigurationListener.contextInitialized(WebBeansConfigurationListener.java:66)
	at org.mortbay.jetty.handler.ContextHandler.startContext(ContextHandler.java:548)
	at org.mortbay.jetty.servlet.Context.startContext(Context.java:136)
	at org.mortbay.jetty.webapp.WebAppContext.startContext(WebAppContext.java:1239)
	at org.mortbay.jetty.handler.ContextHandler.doStart(ContextHandler.java:517)
	at org.mortbay.jetty.webapp.WebAppContext.doStart(WebAppContext.java:466)
	at org.mortbay.jetty.plugin.Jetty6PluginWebAppContext.doStart(Jetty6PluginWebAppContext.java:124)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
	at org.mortbay.jetty.handler.ContextHandlerCollection.doStart(ContextHandlerCollection.java:156)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at org.mortbay.jetty.handler.HandlerCollection.doStart(HandlerCollection.java:152)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at org.mortbay.jetty.handler.HandlerWrapper.doStart(HandlerWrapper.java:130)
	at org.mortbay.jetty.Server.doStart(Server.java:224)
	at org.mortbay.component.AbstractLifeCycle.start(AbstractLifeCycle.java:50)
	at org.mortbay.jetty.plugin.Jetty6PluginServer.start(Jetty6PluginServer.java:132)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:441)
	at org.mortbay.jetty.plugin.AbstractJettyMojo.execute(AbstractJettyMojo.java:383)
	at org.mortbay.jetty.plugin.AbstractJettyRunMojo.execute(AbstractJettyRunMojo.java:210)
	at org.mortbay.jetty.plugin.Jetty6RunMojo.execute(Jetty6RunMojo.java:184)



yes, the message is not easy to read, but it is basically complaining, that the
EntityManagerProducer is not having @Dependent scope (since it has
@ApplicationScoped).

Good night,
Matthias

On Fri, Mar 5, 2010 at 3:30 PM, Arne Limburg
<ar...@openknowledge.de> wrote:
> Hi,
>
>
>
> I have attached my source to EXTCDI-4.
>
> This is how you could use it, how it works and the limitations it has:
>
>
>
> First you have to qualify your EntityManager injection point with the
> provided @PersistenceContext annotation. Then you can use the @Transactional
> annotation.
>
> You will get the same (extended) EntityManager for all beans in the same
> scope and different EntityManagers for beans from other scopes.
>
>
>
> The EntityManagerProducer then checks whether an entity manager for that
> persistence unit and scope exists, creates one if not, and returns the
> entity manager.
>
>
>
> In the current implementation you have to specify the unitName of your
> persistence unit both at the @PersistenceContext annotation and the
> @Transactional annotation. This is very ugly, we should define a sensible
> default behavior here. The advantage is that you can have injected multiple
> persistence units within one scope.
>
>
>
> Other potential problems:
>
> I don’t know if the detection of the current scope works correctly when an
> EntityManager is injected in a bean with @Dependent scope or when a
> @Transactional annotation is used on a bean with @Dependent scope
>
> I don’t know if the closing of the EntityManager works correct (i.e. if the
> scope is still active when the EntityManager gets destroyed). Or could we
> simply close the EntityManager, if it is open assuming that all beans in
> that scope will be destroyed at the same time?
>
>
>
> What do you think?
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 170 - 2733627
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
> Gesendet: Donnerstag, 4. März 2010 20:39
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
>
>
> hi arne,
>
>
>
> i created a jira issue for it [1].
>
> could you please upload your implementation.
>
> + a short description about the possible usages as well as restrictions (if
> present).
>
>
>
> thx & regards,
>
> gerhard
>
>
>
> [1] https://issues.apache.org/jira/browse/EXTCDI-4
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
>
>
> I’ve updated my code at
>
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
> It is not really tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject scoped
> EntityManagers for every CDI-scope.
>
>
>
> Regards,
>
> Arne
>
>
>
> --
>
>
>
> Arne Limburg - Enterprise Developer
>
> OpenKnowledge GmbH, Oldenburg
>
> Bismarckstraße 13, 26122 Oldenburg
>
> Mobil: +49 (0) 151 - 108 22 942
>
> Tel: +49 (0) 441 - 4082-0
>
> Fax: +49 (0) 441 - 4082-111
>
> arne.limburg@openknowledge.de
>
> http://www.openknowledge.de
>
>
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
>
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
>
>
> Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
>
> Gesendet: Montag, 15. Februar 2010 13:44
>
> An: MyFaces Development
> Betreff: Re: [Ext-CDI] @Transactional
>
>
>
> hi arne,
>
>
>
> thx for providing the source code.
>
> i'll have a look at it after the jsfdays.
>
>
>
> one of the goals is to provide an alternative conversation scope for cdi
> which allows to use the conversation concepts provided by orchestra.
>
> so we have to ensure that it works with every custom cdi scope.
>
> (cdi conversations would be the default scope)
>
>
>
> regards,
>
> gerhard
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>
> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
>
> Hi,
>
> I've prototyped some code that injects conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and added @Transactional
> support for this EntityManagers. This code needs some thinking though, e.g.
> how to handle the default-case (no unitName specified)...
>
> If you want to take a look at it, I have created a Wiki page and added my
> code as attachment:
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
>
> This code could be a starting point to implement Orchestra-like
> conversations (starting with CDI-Conversations)...
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 - 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de
> http://www.openknowledge.de
>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de]
>
> Gesendet: Samstag, 13. Februar 2010 20:27
>
> An: MyFaces Development
> Betreff: AW: [Ext-CDI] @Transactional
>
>> I am afraid supporting multiple persistence-units in that
>> scenario is very difficult...
>
> Nope, it's really easy. I simply use Qualifiers to distinguish between them.
>
> @Qualifier
> public @instance Core {}
>
> @Qualifier
> public @instance Other {}
>
> ----
> @RequestScoped
> public class EMProducer {
> private @PersistenceContext(unitName="core") EntityManager emCore;
> private @PersistenceContext(unitName="other") EntityManager emOther;
>
>
> public @Produces @Core EntityManager getCoreEM() {return emCore;}
> public @Produces @Other EntityManager getOtherEM() {return emOther;}
>
>
> Injection happens with
>
> private @Inject @Core EntityManager
>
>
> Got the idea?
>
> LieGrue,
> strub
>
> --- Arne Limburg <ar...@openknowledge.de> schrieb am Sa, 13.2.2010:
>
>> Von: Arne Limburg <ar...@openknowledge.de>
>> Betreff: AW: [Ext-CDI] @Transactional
>> An: "MyFaces Development" <de...@myfaces.apache.org>
>> Datum: Samstag, 13. Februar 2010, 20:06
>> Hi Mark,
>>
>> thank you for your feedback. I was aware of the requirement
>> of CDI-containers to inject JavaEE resources in a
>> JavaEE-environment, but Gerhard and I are thinking about a
>> generic non-JavaEE-solution for EntityManager-injection. And
>> at least weld does no injection of JavaEE-resources in this
>> case. How does OpenWebBeans?
>> I am afraid supporting multiple persistence-units in that
>> scenario is very difficult...
>>
>> Nonetheless it would be nice to see your
>> multiple-database-handling TransactionInterceptor in CODI.
>>
>> Regards,
>> Arne
>>
>> --
>>
>> Arne Limburg - Enterprise Developer
>> OpenKnowledge GmbH, Oldenburg
>> Bismarckstraße 13, 26122 Oldenburg
>> Mobil: +49 (0) 151 - 108 22 942
>> Tel: +49 (0) 441 - 4082-0
>> Fax: +49 (0) 441 - 4082-111
>> arne.limburg@openknowledge.de
>> http://www.openknowledge.de
>
>>
>> Registergericht: Amtsgericht Oldenburg, HRB 4670
>> Geschäftsführer: Lars Röwekamp, Jens Schumann
>>
>> -----Ursprüngliche Nachricht-----
>> Von: Mark Struberg [mailto:struberg@yahoo.de]
>>
>> Gesendet: Samstag, 13. Februar 2010 15:39
>> An: MyFaces Development
>> Betreff: AW: [Ext-CDI] @Transactional
>>
>> Hi!
>>
>> The JSR-299 spec defines that we have to support injection
>> of EE-Resources.
>>
>> This was more explicit in the old version of the spec, but
>> unless the wording got shortened, I still think injection of
>> @PersistenceUnit and @PersistenceContext must be supported
>> by any JSR-299 container (at least in an EE environment).
>>
>> For OpenWebBeans, you can simply use our
>> openwebbeans-resource plugin. Please note that this is
>> necessary because OWB is modular, and openwebbeans-impl (the
>> core) will have no EE dependencies at all (not even JSF,
>> JPA, etc!) This will get picked up automatically if it is
>> available in the classpath, e.g. you can simply define the
>> following maven dependency:
>>
>>         <dependency>
>>
>> <groupId>org.apache.openwebbeans</groupId>
>>
>> <artifactId>openwebbeans-resource</artifactId>
>>
>> <version>${owb.version}</version>
>>         </dependency>
>>
>> OWB supports 2 different scenarios. If you are not running
>> in a JTA aware container like e.g. OpenEJB, you will
>> automatically use a simple resource version of an SPI
>> implementation which uses
>> Persistence#createEntityManagerFactory(unitName) for
>> injecting (Thus getting an extended EM). If you use e.g.
>> OpenEJB, we are able to get the injectable resources
>> directly from there (thus getting a transactional EM).
>>
>> Once this is available, you can simply create a producer
>> method for the EntityManager:
>>
>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
>
>>
>> There is also an example on how to implement a
>> TransactionalInterceptor:
>>
>> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
>
>>
>> In my company, I already implemented a
>> TransactionalInteceptor which is capable of handling
>> multiple databases at a time and also correctly handles
>> nested transactions. I hope to migrate this over to CODI in
>> the near future.
>>
>>
>> LieGrue,
>> strub
>>
>>
>> --- Arne Limburg <ar...@openknowledge.de>
>> schrieb am Sa, 13.2.2010:
>>
>> > Von: Arne Limburg <ar...@openknowledge.de>
>> > Betreff: AW: [Ext-CDI] @Transactional
>> > An: "'MyFaces Development'" <de...@myfaces.apache.org>
>> > Datum: Samstag, 13. Februar 2010, 14:42
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi Gerhard,
>> >
>> >
>> >
>> > OK, I got what you did,
>> > basically I did the same. You are right,
>> > that was pretty straight-forward, but I had to
>> hard-code
>> > the persistence-unit
>> > name.
>> >
>> >
>> >
>> > I have two ideas to inject the
>> > persistence-unit name into the
>> > producer-method for the EntityManager:
>> >
>> >
>> >
>> > First idea: A
>> > @PersistenceUnitName qualifier-annotation to
>> > inject the name into the producer-method. Client code
>> would
>> > have somethink like
>> >
>> > public class Configuration
>> > {
>> >
>> >
>> >
>> >   @Produces
>> > @PersistenceUnitName
>> >
>> >   String
>> > getPersistenceUnitName() {
>> >
>> > …
>> >
>> > Not really nice, but the
>> > simplest solution to generify it.
>> >
>> >
>> >
>> > Second idea:
>> >
>> > The @PersistenceContext
>> > qualifier has a @Nonbind attribute
>> > persistenceUnitName which we can extract in the
>> producer
>> > method. But then we
>> > get in scoping issues. Especially when having
>> multiple
>> > persistence-units within
>> > one deployment. The second problem is: How can the
>> > @Transactional annotation
>> > know the persistence-unit-name.
>> >
>> >
>> >
>> > Any other ideas?
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH,
>> > Oldenburg
>> >
>> > Bismarckstraße 13, 26122
>> > Oldenburg
>> >
>> > Mobil: +49 (0) 151 - 108 22
>> > 942
>> >
>> > Tel: +49 (0) 441 -
>> > 4082-0
>> >
>> > Fax: +49 (0) 441 -
>> > 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>
>> >
>> >
>> >
>> >
>> > Registergericht: Amtsgericht
>> > Oldenburg, HRB 4670
>> >
>> > Geschäftsführer: Lars
>> > Röwekamp, Jens Schumann
>> >
>> >
>> >
>> >
>> >
>> > Von: Gerhard Petracek
>> > [mailto:gerhard.petracek@gmail.com]
>>
>> >
>> > Gesendet: Samstag, 13. Februar 2010 14:32
>> >
>> > An: MyFaces Development
>> >
>> > Betreff: Re: [Ext-CDI] @Transactional
>> >
>> >
>> >
>> >
>> >
>> > hi arne,
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > i used the EntityManager to get
>> > an EntityTransaction.
>> >
>> >
>> >
>> >
>> >
>> > you have to use cdi to create and
>> > inject it.
>> >
>> >
>> >
>> >
>> >
>> > (i used some producer methods.)
>> >
>> >
>> >
>> >
>> >
>> > i created @PersistenceUnit which
>> > is a cdi qualifier and
>> >
>> >
>> >
>> >
>> >
>> > @Transactional which is a cdi
>> > interceptor binding.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > basically it works and it isn't
>> > hard to use.
>> >
>> >
>> >
>> >
>> >
>> > however, we have to think about an
>> > approach to provide as
>> > much as possible in a generic way.
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > regards,
>> >
>> >
>> >
>> >
>> >
>> > gerhard
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > http://www.irian.at
>
>> >
>> >
>> >
>> > Your JSF powerhouse -
>> >
>> > JSF Consulting, Development and
>> >
>> > Courses in English and German
>> >
>> >
>> >
>> > Professional Support for Apache MyFaces
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi
>> > Gerhard,
>> >
>> >
>> >
>> > Did
>> > you mean „i used
>> > UserTransaction”? If not, how do you receive your
>> > EntityTransaction?
>> >
>> >
>> >
>> > I am
>> > working on a solution to
>> > get request-scoped EntityManagers injected within a
>> > servlet-container that does
>> > not even support the web-profile (which are the
>> current
>> > jetty and the current
>> > tomcat). I am not able to get an EntityManager
>> injected via
>> > @PersistenceContext
>> > in that environment. So it would be nice if there were
>> some
>> > CDI-Extension to
>> > achieve this. The implementation would be pretty
>> > straight-forward except the
>> > configuration of the persistence-unit name and the
>> handling
>> > of different
>> > persistence-units within one CDI-deployment
>> > unit.
>> >
>> >
>> >
>> > Using
>> > JTA-Transactions vs.
>> > resource-local EntityTransactions is another issue
>> > here.
>> >
>> >
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne
>> > Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH,
>> > Oldenburg
>> >
>> > Bismarckstraße
>> > 13, 26122 Oldenburg
>> >
>> > Mobil: +49 (0) 151
>> > - 108 22 942
>> >
>> > Tel: +49 (0) 441 -
>> > 4082-0
>> >
>> > Fax: +49 (0) 441 -
>> > 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>> >
>> >
>> >
>> > Registergericht:
>> > Amtsgericht Oldenburg,
>> > HRB 4670
>> >
>> > Geschäftsführer:
>> > Lars Röwekamp, Jens
>> > Schumann
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > Von: Gerhard
>> > Petracek [mailto:gerhard.petracek@gmail.com]
>> >
>> >
>> > Gesendet: Freitag, 12. Februar 2010 19:59
>> >
>> > An: MyFaces Development
>> >
>> > Betreff: Re: [Ext-CDI] @Transactional
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > hi
>> > arne,
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > yes
>> > - i used EntityTransaction in the prototype and it
>> works
>> > pretty well in a
>> > servlet container (that was the base idea).
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> > regards,
>> >
>> >
>> >
>> >
>> >
>> > gerhard
>> >
>> >
>> >
>> > http://www.irian.at
>
>> >
>> >
>> >
>> > Your JSF powerhouse -
>> >
>> > JSF Consulting, Development and
>> >
>> > Courses in English and German
>> >
>> >
>> >
>> > Professional Support for Apache MyFaces
>> >
>> >
>> >
>> > 2010/2/12
>> > Arne Limburg <ar...@openknowledge.de>
>> >
>> >
>> >
>> >
>> >
>> >
>> > Hi
>> > folks,
>> >
>> >
>> >
>> > I saw the discussion of adding an
>> > @Transactional-Annotation to your
>> > CDI extensions. I think Gerhard wrote it. I wonder if
>> it
>> > deals with JTA
>> > transactions (which indeed would be pretty
>> > straight-forward) or with
>> > EntityTransactions of an resource-local EntityManager.
>> I am
>> > working on the
>> > latter one and just would want to know if someone else
>> is
>> > working on such
>> > stuff. I think it would be great, when we could
>> archive
>> > injection of
>> > resource-local EntityManagers with transaction-support
>> to
>> > deploy it on a tomcat
>> > or jetty. What do you think?
>> >
>> >
>> >
>> > Regards,
>> >
>> > Arne
>> >
>> >
>> >
>> > --
>> >
>> >
>> >
>> > Arne Limburg - Enterprise
>> > Developer
>> >
>> > OpenKnowledge GmbH, Oldenburg
>> >
>> > Bismarckstraße
>> > 13, 26122 Oldenburg
>> >
>> > Mobil:
>> > +49 (0) 151 - 108 22 942
>> >
>> > Tel:
>> > +49 (0) 441 - 4082-0
>> >
>> > Fax:
>> > +49 (0) 441 - 4082-111
>> >
>> > arne.limburg@openknowledge.de
>> >
>> >
>> > http://www.openknowledge.de
>
>> >
>> >
>> >
>> >
>> > Registergericht:
>> > Amtsgericht Oldenburg, HRB 4670
>> >
>> > Geschäftsführer:
>> > Lars Röwekamp, Jens Schumann
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>> __________________________________________________
>> Do You Yahoo!?
>> Sie sind Spam leid? Yahoo! Mail verfügt über einen
>> herausragenden Schutz gegen Massenmails.
>> http://mail.yahoo.com
>>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz
> gegen Massenmails.
> http://mail.yahoo.com
>
>
>
>



-- 
Matthias Wessendorf

blog: http://matthiaswessendorf.wordpress.com/
sessions: http://www.slideshare.net/mwessendorf
twitter: http://twitter.com/mwessendorf

AW: [Ext-CDI] @Transactional

Posted by Arne Limburg <ar...@openknowledge.de>.
Hi,

I have attached my source to EXTCDI-4.
This is how you could use it, how it works and the limitations it has:

First you have to qualify your EntityManager injection point with the provided @PersistenceContext annotation. Then you can use the @Transactional annotation.
You will get the same (extended) EntityManager for all beans in the same scope and different EntityManagers for beans from other scopes.

The EntityManagerProducer then checks whether an entity manager for that persistence unit and scope exists, creates one if not, and returns the entity manager.

In the current implementation you have to specify the unitName of your persistence unit both at the @PersistenceContext annotation and the @Transactional annotation. This is very ugly, we should define a sensible default behavior here. The advantage is that you can have injected multiple persistence units within one scope.

Other potential problems:
I don't know if the detection of the current scope works correctly when an EntityManager is injected in a bean with @Dependent scope or when a @Transactional annotation is used on a bean with @Dependent scope
I don't know if the closing of the EntityManager works correct (i.e. if the scope is still active when the EntityManager gets destroyed). Or could we simply close the EntityManager, if it is open assuming that all beans in that scope will be destroyed at the same time?

What do you think?

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 170 - 2733627
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de<ma...@openknowledge.de>
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com]
Gesendet: Donnerstag, 4. März 2010 20:39
An: MyFaces Development
Betreff: Re: [Ext-CDI] @Transactional

hi arne,

i created a jira issue for it [1].
could you please upload your implementation.
+ a short description about the possible usages as well as restrictions (if present).

thx & regards,
gerhard

[1] https://issues.apache.org/jira/browse/EXTCDI-4

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

2010/2/20 Arne Limburg <ar...@openknowledge.de>>
Hi,

I've updated my code at
http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
It is not really tested and lacks some fallback-scenarios (i.e. null-handling, etc.), but it is a starting point to inject scoped EntityManagers for every CDI-scope.

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 151 - 108 22 942
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de<ma...@openknowledge.de>
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

Von: Gerhard Petracek [mailto:gerhard.petracek@gmail.com<ma...@gmail.com>]
Gesendet: Montag, 15. Februar 2010 13:44
An: MyFaces Development
Betreff: Re: [Ext-CDI] @Transactional

hi arne,

thx for providing the source code.
i'll have a look at it after the jsfdays.

one of the goals is to provide an alternative conversation scope for cdi which allows to use the conversation concepts provided by orchestra.
so we have to ensure that it works with every custom cdi scope.
(cdi conversations would be the default scope)

regards,
gerhard

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces
2010/2/15 Arne Limburg <ar...@openknowledge.de>>
Hi,

I've prototyped some code that injects conversation-scoped EntityManagers reading the unitName from the qualifier annotation and added @Transactional support for this EntityManagers. This code needs some thinking though, e.g. how to handle the default-case (no unitName specified)...

If you want to take a look at it, I have created a Wiki page and added my code as attachment:
http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional

This code could be a starting point to implement Orchestra-like conversations (starting with CDI-Conversations)...

Regards,
Arne

--

Arne Limburg - Enterprise Developer
OpenKnowledge GmbH, Oldenburg
Bismarckstraße 13, 26122 Oldenburg
Mobil: +49 (0) 151 - 108 22 942
Tel: +49 (0) 441 - 4082-0
Fax: +49 (0) 441 - 4082-111
arne.limburg@openknowledge.de<ma...@openknowledge.de>
http://www.openknowledge.de

Registergericht: Amtsgericht Oldenburg, HRB 4670
Geschäftsführer: Lars Röwekamp, Jens Schumann

-----Ursprüngliche Nachricht-----
Von: Mark Struberg [mailto:struberg@yahoo.de<ma...@yahoo.de>]
Gesendet: Samstag, 13. Februar 2010 20:27
An: MyFaces Development
Betreff: AW: [Ext-CDI] @Transactional

> I am afraid supporting multiple persistence-units in that
> scenario is very difficult...

Nope, it's really easy. I simply use Qualifiers to distinguish between them.

@Qualifier
public @instance Core {}

@Qualifier
public @instance Other {}

----
@RequestScoped
public class EMProducer {
private @PersistenceContext(unitName="core") EntityManager emCore;
private @PersistenceContext(unitName="other") EntityManager emOther;


public @Produces @Core EntityManager getCoreEM() {return emCore;}
public @Produces @Other EntityManager getOtherEM() {return emOther;}


Injection happens with

private @Inject @Core EntityManager


Got the idea?

LieGrue,
strub

--- Arne Limburg <ar...@openknowledge.de>> schrieb am Sa, 13.2.2010:

> Von: Arne Limburg <ar...@openknowledge.de>>
> Betreff: AW: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>>
> Datum: Samstag, 13. Februar 2010, 20:06
> Hi Mark,
>
> thank you for your feedback. I was aware of the requirement
> of CDI-containers to inject JavaEE resources in a
> JavaEE-environment, but Gerhard and I are thinking about a
> generic non-JavaEE-solution for EntityManager-injection. And
> at least weld does no injection of JavaEE-resources in this
> case. How does OpenWebBeans?
> I am afraid supporting multiple persistence-units in that
> scenario is very difficult...
>
> Nonetheless it would be nice to see your
> multiple-database-handling TransactionInterceptor in CODI.
>
> Regards,
> Arne
>
> --
>
> Arne Limburg - Enterprise Developer
> OpenKnowledge GmbH, Oldenburg
> Bismarckstraße 13, 26122 Oldenburg
> Mobil: +49 (0) 151 - 108 22 942
> Tel: +49 (0) 441 - 4082-0
> Fax: +49 (0) 441 - 4082-111
> arne.limburg@openknowledge.de<ma...@openknowledge.de>
> http://www.openknowledge.de

>
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> Geschäftsführer: Lars Röwekamp, Jens Schumann
>
> -----Ursprüngliche Nachricht-----
> Von: Mark Struberg [mailto:struberg@yahoo.de<ma...@yahoo.de>]
>
> Gesendet: Samstag, 13. Februar 2010 15:39
> An: MyFaces Development
> Betreff: AW: [Ext-CDI] @Transactional
>
> Hi!
>
> The JSR-299 spec defines that we have to support injection
> of EE-Resources.
>
> This was more explicit in the old version of the spec, but
> unless the wording got shortened, I still think injection of
> @PersistenceUnit and @PersistenceContext must be supported
> by any JSR-299 container (at least in an EE environment).
>
> For OpenWebBeans, you can simply use our
> openwebbeans-resource plugin. Please note that this is
> necessary because OWB is modular, and openwebbeans-impl (the
> core) will have no EE dependencies at all (not even JSF,
> JPA, etc!) This will get picked up automatically if it is
> available in the classpath, e.g. you can simply define the
> following maven dependency:
>
>         <dependency>
>
> <groupId>org.apache.openwebbeans</groupId>
>
> <artifactId>openwebbeans-resource</artifactId>
>
> <version>${owb.version}</version>
>         </dependency>
>
> OWB supports 2 different scenarios. If you are not running
> in a JTA aware container like e.g. OpenEJB, you will
> automatically use a simple resource version of an SPI
> implementation which uses
> Persistence#createEntityManagerFactory(unitName) for
> injecting (Thus getting an extended EM). If you use e.g.
> OpenEJB, we are able to get the injectable resources
> directly from there (thus getting a transactional EM).
>
> Once this is available, you can simply create a producer
> method for the EntityManager:
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java

>
> There is also an example on how to implement a
> TransactionalInterceptor:
> https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java

>
> In my company, I already implemented a
> TransactionalInteceptor which is capable of handling
> multiple databases at a time and also correctly handles
> nested transactions. I hope to migrate this over to CODI in
> the near future.
>
>
> LieGrue,
> strub
>
>
> --- Arne Limburg <ar...@openknowledge.de>>
> schrieb am Sa, 13.2.2010:
>
> > Von: Arne Limburg <ar...@openknowledge.de>>
> > Betreff: AW: [Ext-CDI] @Transactional
> > An: "'MyFaces Development'" <de...@myfaces.apache.org>>
> > Datum: Samstag, 13. Februar 2010, 14:42
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > Hi Gerhard,
> >
> >
> >
> > OK, I got what you did,
> > basically I did the same. You are right,
> > that was pretty straight-forward, but I had to
> hard-code
> > the persistence-unit
> > name.
> >
> >
> >
> > I have two ideas to inject the
> > persistence-unit name into the
> > producer-method for the EntityManager:
> >
> >
> >
> > First idea: A
> > @PersistenceUnitName qualifier-annotation to
> > inject the name into the producer-method. Client code
> would
> > have somethink like
> >
> > public class Configuration
> > {
> >
> >
> >
> >   @Produces
> > @PersistenceUnitName
> >
> >   String
> > getPersistenceUnitName() {
> >
> > ...
> >
> > Not really nice, but the
> > simplest solution to generify it.
> >
> >
> >
> > Second idea:
> >
> > The @PersistenceContext
> > qualifier has a @Nonbind attribute
> > persistenceUnitName which we can extract in the
> producer
> > method. But then we
> > get in scoping issues. Especially when having
> multiple
> > persistence-units within
> > one deployment. The second problem is: How can the
> > @Transactional annotation
> > know the persistence-unit-name.
> >
> >
> >
> > Any other ideas?
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise
> > Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße 13, 26122
> > Oldenburg
> >
> > Mobil: +49 (0) 151 - 108 22
> > 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de<ma...@openknowledge.de>
> >
> >
> > http://www.openknowledge.de

> >
> >
> >
> >
> > Registergericht: Amtsgericht
> > Oldenburg, HRB 4670
> >
> > Geschäftsführer: Lars
> > Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> > Von: Gerhard Petracek
> > [mailto:gerhard.petracek@gmail.com<ma...@gmail.com>]
>
> >
> > Gesendet: Samstag, 13. Februar 2010 14:32
> >
> > An: MyFaces Development
> >
> > Betreff: Re: [Ext-CDI] @Transactional
> >
> >
> >
> >
> >
> > hi arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > i used the EntityManager to get
> > an EntityTransaction.
> >
> >
> >
> >
> >
> > you have to use cdi to create and
> > inject it.
> >
> >
> >
> >
> >
> > (i used some producer methods.)
> >
> >
> >
> >
> >
> > i created @PersistenceUnit which
> > is a cdi qualifier and
> >
> >
> >
> >
> >
> > @Transactional which is a cdi
> > interceptor binding.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > basically it works and it isn't
> > hard to use.
> >
> >
> >
> >
> >
> > however, we have to think about an
> > approach to provide as
> > much as possible in a generic way.
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> >
> >
> >
> >
> > 2010/2/13 Arne Limburg <ar...@openknowledge.de>>
> >
> >
> >
> >
> >
> >
> > Hi
> > Gerhard,
> >
> >
> >
> > Did
> > you mean "i used
> > UserTransaction"? If not, how do you receive your
> > EntityTransaction?
> >
> >
> >
> > I am
> > working on a solution to
> > get request-scoped EntityManagers injected within a
> > servlet-container that does
> > not even support the web-profile (which are the
> current
> > jetty and the current
> > tomcat). I am not able to get an EntityManager
> injected via
> > @PersistenceContext
> > in that environment. So it would be nice if there were
> some
> > CDI-Extension to
> > achieve this. The implementation would be pretty
> > straight-forward except the
> > configuration of the persistence-unit name and the
> handling
> > of different
> > persistence-units within one CDI-deployment
> > unit.
> >
> >
> >
> > Using
> > JTA-Transactions vs.
> > resource-local EntityTransactions is another issue
> > here.
> >
> >
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne
> > Limburg - Enterprise
> > Developer
> >
> > OpenKnowledge GmbH,
> > Oldenburg
> >
> > Bismarckstraße
> > 13, 26122 Oldenburg
> >
> > Mobil: +49 (0) 151
> > - 108 22 942
> >
> > Tel: +49 (0) 441 -
> > 4082-0
> >
> > Fax: +49 (0) 441 -
> > 4082-111
> >
> > arne.limburg@openknowledge.de<ma...@openknowledge.de>
> >
> >
> > http://www.openknowledge.de
> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg,
> > HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens
> > Schumann
> >
> >
> >
> >
> >
> >
> >
> > Von: Gerhard
> > Petracek [mailto:gerhard.petracek@gmail.com<ma...@gmail.com>]
> >
> >
> > Gesendet: Freitag, 12. Februar 2010 19:59
> >
> > An: MyFaces Development
> >
> > Betreff: Re: [Ext-CDI] @Transactional
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > hi
> > arne,
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > yes
> > - i used EntityTransaction in the prototype and it
> works
> > pretty well in a
> > servlet container (that was the base idea).
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > regards,
> >
> >
> >
> >
> >
> > gerhard
> >
> >
> >
> > http://www.irian.at

> >
> >
> >
> > Your JSF powerhouse -
> >
> > JSF Consulting, Development and
> >
> > Courses in English and German
> >
> >
> >
> > Professional Support for Apache MyFaces
> >
> >
> >
> > 2010/2/12
> > Arne Limburg <ar...@openknowledge.de>>
> >
> >
> >
> >
> >
> >
> > Hi
> > folks,
> >
> >
> >
> > I saw the discussion of adding an
> > @Transactional-Annotation to your
> > CDI extensions. I think Gerhard wrote it. I wonder if
> it
> > deals with JTA
> > transactions (which indeed would be pretty
> > straight-forward) or with
> > EntityTransactions of an resource-local EntityManager.
> I am
> > working on the
> > latter one and just would want to know if someone else
> is
> > working on such
> > stuff. I think it would be great, when we could
> archive
> > injection of
> > resource-local EntityManagers with transaction-support
> to
> > deploy it on a tomcat
> > or jetty. What do you think?
> >
> >
> >
> > Regards,
> >
> > Arne
> >
> >
> >
> > --
> >
> >
> >
> > Arne Limburg - Enterprise
> > Developer
> >
> > OpenKnowledge GmbH, Oldenburg
> >
> > Bismarckstraße
> > 13, 26122 Oldenburg
> >
> > Mobil:
> > +49 (0) 151 - 108 22 942
> >
> > Tel:
> > +49 (0) 441 - 4082-0
> >
> > Fax:
> > +49 (0) 441 - 4082-111
> >
> > arne.limburg@openknowledge.de<ma...@openknowledge.de>
> >
> >
> > http://www.openknowledge.de

> >
> >
> >
> >
> > Registergericht:
> > Amtsgericht Oldenburg, HRB 4670
> >
> > Geschäftsführer:
> > Lars Röwekamp, Jens Schumann
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
>
> __________________________________________________
> Do You Yahoo!?
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen Massenmails.
> http://mail.yahoo.com
>

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails.
http://mail.yahoo.com



Re: [Ext-CDI] @Transactional

Posted by Mark Struberg <st...@yahoo.de>.
Hi!

Uploading the source is al always a good idea, so we can further discuss this really complicated topic. 

Is this meant to work for extended EntityManagers or for transactional JTA managed ones?

Another question: does this require the EntityManager to have a certain scope? For the extended EM variant of course, for JTA managed we will most certainly use @Dependent, right?



LieGrue,
strub

--- Gerhard Petracek <ge...@gmail.com> schrieb am Do, 4.3.2010:

> Von: Gerhard Petracek <ge...@gmail.com>
> Betreff: Re: [Ext-CDI] @Transactional
> An: "MyFaces Development" <de...@myfaces.apache.org>
> Datum: Donnerstag, 4. März, 2010 20:39 Uhr
> hi arne,
> i created a jira issue for it
> [1].could you please upload your
> implementation.+ a short description about the
> possible usages as well as restrictions (if
> present).
> 
> 
> thx & regards,gerhard
> [1] https://issues.apache.org/jira/browse/EXTCDI-4
> 
> http://www.irian.at
> 
> 
> 
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
> 
> Professional Support for Apache MyFaces
> 
> 
> 
> 2010/2/20 Arne Limburg <ar...@openknowledge.de>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> Hi,
> 
>  
> 
> I’ve updated my
> code at 
> 
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> 
> 
> 
> It is not really
> tested and lacks some fallback-scenarios (i.e.
> null-handling, etc.), but it is a starting point to inject
> scoped
> EntityManagers for every CDI-scope.
> 
>  
> 
> Regards,
> 
> Arne
> 
>  
> 
> --
> 
>  
> 
> Arne Limburg -
> Enterprise Developer
> 
> OpenKnowledge GmbH,
> Oldenburg
> 
> Bismarckstraße 13,
> 26122 Oldenburg
> 
> Mobil: +49 (0) 151 -
> 108 22 942
> 
> Tel: +49 (0) 441 -
> 4082-0
> 
> Fax: +49 (0) 441 -
> 4082-111
> 
> arne.limburg@openknowledge.de
> 
> http://www.openknowledge.de
> 
>  
> 
> Registergericht:
> Amtsgericht Oldenburg, HRB 4670
> 
> Geschäftsführer:
> Lars Röwekamp, Jens Schumann
> 
>  
> 
> 
> 
> Von: Gerhard Petracek
> [mailto:gerhard.petracek@gmail.com]
> 
> 
> Gesendet: Montag, 15. Februar 2010 13:44
> 
> An: MyFaces
> Development
> 
> Betreff: Re: [Ext-CDI]
> @Transactional
> 
> 
> 
>  
> 
> hi arne,
> 
> 
> 
>  
> 
> 
> 
> 
> 
> thx for providing the source code.
> 
> 
> 
> 
> 
> i'll have a look at it after the
> jsfdays.
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> one of the goals is to provide an
> alternative conversation
> scope for cdi which allows to use the conversation concepts
> provided by
> orchestra.
> 
> 
> 
> 
> 
> so we have to ensure that it works
> with every custom cdi
> scope.
> 
> 
> 
> 
> 
> (cdi conversations would be the
> default scope)
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> regards,
> 
> 
> 
> 
> 
> gerhard
> 
> 
> 
> http://www.irian.at
> 
> 
> 
> Your JSF powerhouse -
> 
> JSF Consulting, Development and
> 
> Courses in English and German
> 
> 
> 
> Professional Support for Apache MyFaces
> 
> 
> 
> 
> 
> 
> 
> 2010/2/15 Arne Limburg <ar...@openknowledge.de>
> 
> Hi,
> 
> 
> 
> I've prototyped some code that injects
> conversation-scoped EntityManagers
> reading the unitName from the qualifier annotation and
> added @Transactional
> support for this EntityManagers. This code needs some
> thinking though, e.g. how
> to handle the default-case (no unitName specified)...
> 
> 
> 
> If you want to take a look at it, I have created a Wiki
> page and added my code
> as attachment:
> 
> http://wiki.apache.org/myfaces/Extensions/CDI/DevDoc/Drafts/Transactional
> 
> 
> 
> This code could be a starting point to implement
> Orchestra-like conversations
> (starting with CDI-Conversations)...
> 
> 
> 
> 
> 
> Regards,
> 
> Arne
> 
> 
> 
> --
> 
> 
> 
> Arne Limburg - Enterprise Developer
> 
> OpenKnowledge GmbH, Oldenburg
> 
> Bismarckstraße 13, 26122 Oldenburg
> 
> Mobil: +49 (0) 151 - 108 22 942
> 
> Tel: +49 (0) 441 - 4082-0
> 
> Fax: +49 (0) 441 - 4082-111
> 
> arne.limburg@openknowledge.de
> 
> http://www.openknowledge.de
> 
> 
> 
> Registergericht: Amtsgericht Oldenburg, HRB 4670
> 
> Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> 
> 
> -----Ursprüngliche Nachricht-----
> 
> Von: Mark Struberg [mailto:struberg@yahoo.de]
> 
> 
> 
> Gesendet: Samstag, 13. Februar 2010
> 20:27
> 
> 
> 
> 
> 
> An: MyFaces Development
> 
> Betreff: AW: [Ext-CDI] @Transactional
> 
> 
> 
> > I am afraid supporting multiple persistence-units in
> that
> 
> > scenario is very difficult...
> 
> 
> 
> Nope, it's really easy. I simply use Qualifiers to
> distinguish between them.
> 
> 
> 
> @Qualifier
> 
> public @instance Core {}
> 
> 
> 
> @Qualifier
> 
> public @instance Other {}
> 
> 
> 
> ----
> 
> @RequestScoped
> 
> public class EMProducer {
> 
> private @PersistenceContext(unitName="core")
> EntityManager emCore;
> 
> private @PersistenceContext(unitName="other")
> EntityManager emOther;
> 
> 
> 
> 
> 
> public @Produces @Core EntityManager getCoreEM() {return
> emCore;}
> 
> public @Produces @Other EntityManager getOtherEM() {return
> emOther;}
> 
> 
> 
> 
> 
> Injection happens with
> 
> 
> 
> private @Inject @Core EntityManager
> 
> 
> 
> 
> 
> Got the idea?
> 
> 
> 
> LieGrue,
> 
> strub
> 
> 
> 
> --- Arne Limburg <ar...@openknowledge.de>
> schrieb am Sa, 13.2.2010:
> 
> 
> 
> > Von: Arne Limburg <ar...@openknowledge.de>
> 
> > Betreff: AW: [Ext-CDI] @Transactional
> 
> > An: "MyFaces Development" <de...@myfaces.apache.org>
> 
> > Datum: Samstag, 13. Februar 2010, 20:06
> 
> > Hi Mark,
> 
> >
> 
> > thank you for your feedback. I was aware of the
> requirement
> 
> > of CDI-containers to inject JavaEE resources in a
> 
> > JavaEE-environment, but Gerhard and I are thinking
> about a
> 
> > generic non-JavaEE-solution for
> EntityManager-injection. And
> 
> > at least weld does no injection of JavaEE-resources in
> this
> 
> > case. How does OpenWebBeans?
> 
> > I am afraid supporting multiple persistence-units in
> that
> 
> > scenario is very difficult...
> 
> >
> 
> > Nonetheless it would be nice to see your
> 
> > multiple-database-handling TransactionInterceptor in
> CODI.
> 
> >
> 
> > Regards,
> 
> > Arne
> 
> >
> 
> > --
> 
> >
> 
> > Arne Limburg - Enterprise Developer
> 
> > OpenKnowledge GmbH, Oldenburg
> 
> > Bismarckstraße 13, 26122 Oldenburg
> 
> > Mobil: +49 (0) 151 - 108 22 942
> 
> > Tel: +49 (0) 441 - 4082-0
> 
> > Fax: +49 (0) 441 - 4082-111
> 
> > arne.limburg@openknowledge.de
> 
> > http://www.openknowledge.de
> 
> 
> 
> >
> 
> > Registergericht: Amtsgericht Oldenburg, HRB 4670
> 
> > Geschäftsführer: Lars Röwekamp, Jens Schumann
> 
> >
> 
> > -----Ursprüngliche Nachricht-----
> 
> > Von: Mark Struberg [mailto:struberg@yahoo.de]
> 
> >
> 
> > Gesendet: Samstag, 13. Februar 2010 15:39
> 
> > An: MyFaces Development
> 
> > Betreff: AW: [Ext-CDI] @Transactional
> 
> >
> 
> > Hi!
> 
> >
> 
> > The JSR-299 spec defines that we have to support
> injection
> 
> > of EE-Resources.
> 
> >
> 
> > This was more explicit in the old version of the spec,
> but
> 
> > unless the wording got shortened, I still think
> injection of
> 
> > @PersistenceUnit and @PersistenceContext must be
> supported
> 
> > by any JSR-299 container (at least in an EE
> environment).
> 
> >
> 
> > For OpenWebBeans, you can simply use our
> 
> > openwebbeans-resource plugin. Please note that this
> is
> 
> > necessary because OWB is modular, and
> openwebbeans-impl (the
> 
> > core) will have no EE dependencies at all (not even
> JSF,
> 
> > JPA, etc!) This will get picked up automatically if it
> is
> 
> > available in the classpath, e.g. you can simply define
> the
> 
> > following maven dependency:
> 
> >
> 
> >         <dependency>
> 
> >                
> 
> >
> <groupId>org.apache.openwebbeans</groupId>
> 
> >                
> 
> >
> <artifactId>openwebbeans-resource</artifactId>
> 
> >                
> 
> > <version>${owb.version}</version>
> 
> >         </dependency>
> 
> >
> 
> > OWB supports 2 different scenarios. If you are not
> running
> 
> > in a JTA aware container like e.g. OpenEJB, you will
> 
> > automatically use a simple resource version of an SPI
> 
> > implementation which uses
> 
> > Persistence#createEntityManagerFactory(unitName) for
> 
> > injecting (Thus getting an extended EM). If you use
> e.g.
> 
> > OpenEJB, we are able to get the injectable resources
> 
> > directly from there (thus getting a transactional
> EM).
> 
> >
> 
> > Once this is available, you can simply create a
> producer
> 
> > method for the EntityManager:
> 
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/util/EntityManagerUtil.java
> 
> 
> 
> 
> 
> >
> 
> > There is also an example on how to implement a
> 
> > TransactionalInterceptor:
> 
> > https://svn.apache.org/repos/asf/openwebbeans/trunk/samples/reservation/src/main/java/org/apache/webbeans/reservation/intercept/TransactionalInterceptor.java
> 
> 
> 
> 
> 
> >
> 
> > In my company, I already implemented a
> 
> > TransactionalInteceptor which is capable of handling
> 
> > multiple databases at a time and also correctly
> handles
> 
> > nested transactions. I hope to migrate this over to
> CODI in
> 
> > the near future.
> 
> >
> 
> >
> 
> > LieGrue,
> 
> > strub
> 
> >
> 
> >
> 
> > --- Arne Limburg <ar...@openknowledge.de>
> 
> > schrieb am Sa, 13.2.2010:
> 
> >
> 
> > > Von: Arne Limburg <ar...@openknowledge.de>
> 
> > > Betreff: AW: [Ext-CDI] @Transactional
> 
> > > An: "'MyFaces Development'"
> <de...@myfaces.apache.org>
> 
> > > Datum: Samstag, 13. Februar 2010, 14:42
> 
> > >
> 
> > >
> 
> > >
> 
> > > 
> 
> > > 
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > 
> 
> > >
> 
> > >
> 
> > >
> 
> > > Hi Gerhard,
> 
> > >
> 
> > >   
> 
> > >
> 
> > > OK, I got what you did,
> 
> > > basically I did the same. You are right,
> 
> > > that was pretty straight-forward, but I had to
> 
> > hard-code
> 
> > > the persistence-unit
> 
> > > name.
> 
> > >
> 
> > >   
> 
> > >
> 
> > > I have two ideas to inject the
> 
> > > persistence-unit name into the
> 
> > > producer-method for the EntityManager:
> 
> > >
> 
> > >   
> 
> > >
> 
> > > First idea: A
> 
> > > @PersistenceUnitName qualifier-annotation to
> 
> > > inject the name into the producer-method. Client
> code
> 
> > would
> 
> > > have somethink like
> 
> > >
> 
> > > public class Configuration
> 
> > > {
> 
> > >
> 
> > >   
> 
> > >
> 
> > >   @Produces
> 
> > > @PersistenceUnitName
> 
> > >
> 
> > >   String
> 
> > > getPersistenceUnitName() {
> 
> > >
> 
> > > …
> 
> > >
> 
> > > Not really nice, but the
> 
> > > simplest solution to generify it.
> 
> > >
> 
> > >   
> 
> > >
> 
> > > Second idea:
> 
> > >
> 
> > > The @PersistenceContext
> 
> > > qualifier has a @Nonbind attribute
> 
> > > persistenceUnitName which we can extract in the
> 
> > producer
> 
> > > method. But then we
> 
> > > get in scoping issues. Especially when having
> 
> > multiple
> 
> > > persistence-units within
> 
> > > one deployment. The second problem is: How can
> the
> 
> > > @Transactional annotation
> 
> > > know the persistence-unit-name.
> 
> > >
> 
> > >   
> 
> > >
> 
> > > Any other ideas?
> 
> > >
> 
> > >   
> 
> > >
> 
> > > Regards,
> 
> > >
> 
> > > Arne
> 
> > >
> 
> > >   
> 
> > >
> 
> > > --
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Arne Limburg - Enterprise
> 
> > > Developer
> 
> > >
> 
> > > OpenKnowledge GmbH,
> 
> > > Oldenburg
> 
> > >
> 
> > > Bismarckstraße 13, 26122
> 
> > > Oldenburg
> 
> > >
> 
> > > Mobil: +49 (0) 151 - 108 22
> 
> > > 942
> 
> > >
> 
> > > Tel: +49 (0) 441 -
> 
> > > 4082-0
> 
> > >
> 
> > > Fax: +49 (0) 441 -
> 
> > > 4082-111
> 
> > >
> 
> > > arne.limburg@openknowledge.de
> 
> > >
> 
> > >
> 
> > > http://www.openknowledge.de
> 
> 
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > > Registergericht: Amtsgericht
> 
> > > Oldenburg, HRB 4670
> 
> > >
> 
> > > Geschäftsführer: Lars
> 
> > > Röwekamp, Jens Schumann
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > > Von: Gerhard Petracek
> 
> > > [mailto:gerhard.petracek@gmail.com]
> 
> >
> 
> > >
> 
> > > Gesendet: Samstag, 13. Februar 2010 14:32
> 
> > >
> 
> > > An: MyFaces Development
> 
> > >
> 
> > > Betreff: Re: [Ext-CDI] @Transactional
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > > hi arne,
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > i used the EntityManager to get
> 
> > > an EntityTransaction.
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > you have to use cdi to create and
> 
> > > inject it.
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > (i used some producer methods.)
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > i created @PersistenceUnit which
> 
> > > is a cdi qualifier and
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > @Transactional which is a cdi
> 
> > > interceptor binding.
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > basically it works and it isn't
> 
> > > hard to use.
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > however, we have to think about an
> 
> > > approach to provide as
> 
> > > much as possible in a generic way.
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > regards,
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > gerhard
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > http://www.irian.at
> 
> 
> 
> > >
> 
> > >
> 
> > >
> 
> > > Your JSF powerhouse -
> 
> > >
> 
> > > JSF Consulting, Development and
> 
> > >
> 
> > > Courses in English and German
> 
> > >
> 
> > >
> 
> > >
> 
> > > Professional Support for Apache MyFaces
> 
> > >
> 
> > >
> 
> > >
> 
> > > 
> 
> > >
> 
> > >
> 
> > >
> 
> > > 2010/2/13 Arne Limburg <ar...@openknowledge.de>
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > Hi
> 
> > > Gerhard,
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Did
> 
> > > you mean „i used
> 
> > > UserTransaction”? If not, how do you receive
> your
> 
> > > EntityTransaction?
> 
> > >
> 
> > >  
> 
> > >
> 
> > > I am
> 
> > > working on a solution to
> 
> > > get request-scoped EntityManagers injected within
> a
> 
> > > servlet-container that does
> 
> > > not even support the web-profile (which are the
> 
> > current
> 
> > > jetty and the current
> 
> > > tomcat). I am not able to get an EntityManager
> 
> > injected via
> 
> > > @PersistenceContext
> 
> > > in that environment. So it would be nice if there
> were
> 
> > some
> 
> > > CDI-Extension to
> 
> > > achieve this. The implementation would be pretty
> 
> > > straight-forward except the
> 
> > > configuration of the persistence-unit name and
> the
> 
> > handling
> 
> > > of different
> 
> > > persistence-units within one CDI-deployment
> 
> > > unit.
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Using
> 
> > > JTA-Transactions vs.
> 
> > > resource-local EntityTransactions is another
> issue
> 
> > > here.
> 
> > >
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Regards,
> 
> > >
> 
> > > Arne
> 
> > >
> 
> > >  
> 
> > >
> 
> > > --
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Arne
> 
> > > Limburg - Enterprise
> 
> > > Developer
> 
> > >
> 
> > > OpenKnowledge GmbH,
> 
> > > Oldenburg
> 
> > >
> 
> > > Bismarckstraße
> 
> > > 13, 26122 Oldenburg
> 
> > >
> 
> > > Mobil: +49 (0) 151
> 
> > > - 108 22 942
> 
> > >
> 
> > > Tel: +49 (0) 441 -
> 
> > > 4082-0
> 
> > >
> 
> > > Fax: +49 (0) 441 -
> 
> > > 4082-111
> 
> > >
> 
> > > arne.limburg@openknowledge.de
> 
> > >
> 
> > >
> 
> > > http://www.openknowledge.de
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Registergericht:
> 
> > > Amtsgericht Oldenburg,
> 
> > > HRB 4670
> 
> > >
> 
> > > Geschäftsführer:
> 
> > > Lars Röwekamp, Jens
> 
> > > Schumann
> 
> > >
> 
> > >  
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > Von: Gerhard
> 
> > > Petracek [mailto:gerhard.petracek@gmail.com]
> 
> > >
> 
> > >
> 
> > > Gesendet: Freitag, 12. Februar 2010 19:59
> 
> > >
> 
> > > An: MyFaces Development
> 
> > >
> 
> > > Betreff: Re: [Ext-CDI] @Transactional
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > > hi
> 
> > > arne,
> 
> > >
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > yes
> 
> > > - i used EntityTransaction in the prototype and
> it
> 
> > works
> 
> > > pretty well in a
> 
> > > servlet container (that was the base idea).
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > regards,
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > gerhard
> 
> > >
> 
> > >
> 
> > >
> 
> > > http://www.irian.at
> 
> 
> 
> > >
> 
> > >
> 
> > >
> 
> > > Your JSF powerhouse -
> 
> > >
> 
> > > JSF Consulting, Development and
> 
> > >
> 
> > > Courses in English and German
> 
> > >
> 
> > >
> 
> > >
> 
> > > Professional Support for Apache MyFaces
> 
> > >
> 
> > >
> 
> > >
> 
> > > 2010/2/12
> 
> > > Arne Limburg <ar...@openknowledge.de>
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > Hi
> 
> > > folks,
> 
> > >
> 
> > >  
> 
> > >
> 
> > > I saw the discussion of adding an
> 
> > > @Transactional-Annotation to your
> 
> > > CDI extensions. I think Gerhard wrote it. I
> wonder if
> 
> > it
> 
> > > deals with JTA
> 
> > > transactions (which indeed would be pretty
> 
> > > straight-forward) or with
> 
> > > EntityTransactions of an resource-local
> EntityManager.
> 
> > I am
> 
> > > working on the
> 
> > > latter one and just would want to know if someone
> else
> 
> > is
> 
> > > working on such
> 
> > > stuff. I think it would be great, when we could
> 
> > archive
> 
> > > injection of
> 
> > > resource-local EntityManagers with
> transaction-support
> 
> > to
> 
> > > deploy it on a tomcat
> 
> > > or jetty. What do you think?
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Regards,
> 
> > >
> 
> > > Arne
> 
> > >
> 
> > >  
> 
> > >
> 
> > > --
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Arne Limburg - Enterprise
> 
> > > Developer
> 
> > >
> 
> > > OpenKnowledge GmbH, Oldenburg
> 
> > >
> 
> > > Bismarckstraße
> 
> > > 13, 26122 Oldenburg
> 
> > >
> 
> > > Mobil:
> 
> > > +49 (0) 151 - 108 22 942
> 
> > >
> 
> > > Tel:
> 
> > > +49 (0) 441 - 4082-0
> 
> > >
> 
> > > Fax:
> 
> > > +49 (0) 441 - 4082-111
> 
> > >
> 
> > > arne.limburg@openknowledge.de
> 
> > >
> 
> > >
> 
> > > http://www.openknowledge.de
> 
> 
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > > Registergericht:
> 
> > > Amtsgericht Oldenburg, HRB 4670
> 
> > >
> 
> > > Geschäftsführer:
> 
> > > Lars Röwekamp, Jens Schumann
> 
> > >
> 
> > >  
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >  
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >   
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > >
> 
> > > 
> 
> > >
> 
> > >
> 
> > >
> 
> >
> 
> >
> 
> > __________________________________________________
> 
> > Do You Yahoo!?
> 
> > Sie sind Spam leid? Yahoo! Mail verfügt über einen
> 
> > herausragenden Schutz gegen Massenmails.
> 
> > http://mail.yahoo.com
> 
> >
> 
> 
> 
> __________________________________________________
> 
> Do You Yahoo!?
> 
> Sie sind Spam leid? Yahoo! Mail verfügt über einen
> herausragenden Schutz gegen
> Massenmails.
> 
> http://mail.yahoo.com
> 
> 
> 
> 
> 
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 

__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen Massenmails. 
http://mail.yahoo.com