Seam SVN: r13812 - modules/resteasy/trunk/impl.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-10-07 11:23:09 -0400 (Thu, 07 Oct 2010)
New Revision: 13812
Modified:
modules/resteasy/trunk/impl/
Log:
updated svn:ignore
Property changes on: modules/resteasy/trunk/impl
___________________________________________________________________
Name: svn:ignore
- .classpath
.project
target
temp-testng-customsuite.xml
test-output
.settings
+ .classpath
.project
target
temp-testng-customsuite.xml
test-output
.settings
transaction.log
14 years, 3 months
Seam SVN: r13811 - modules/resteasy/trunk.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-10-07 09:52:58 -0400 (Thu, 07 Oct 2010)
New Revision: 13811
Modified:
modules/resteasy/trunk/pom.xml
Log:
weld-extensions version
Modified: modules/resteasy/trunk/pom.xml
===================================================================
--- modules/resteasy/trunk/pom.xml 2010-10-07 11:49:54 UTC (rev 13810)
+++ modules/resteasy/trunk/pom.xml 2010-10-07 13:52:58 UTC (rev 13811)
@@ -20,7 +20,7 @@
<arquillian.version>1.0.0.Alpha3</arquillian.version>
<jbossas.version>6.0.0.20100911-M5</jbossas.version>
<jboss.server.manager.version>1.0.3.GA</jboss.server.manager.version>
- <weld.extensions.version>1.0.3.GA</weld.extensions.version>
+ <weld.extensions.version>1.0.0-SNAPSHOT</weld.extensions.version>
</properties>
<url>http://www.seamframework.org</url>
14 years, 3 months
Seam SVN: r13810 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 07:49:54 -0400 (Thu, 07 Oct 2010)
New Revision: 13810
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
Log:
minor logging change
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-10-07 11:19:19 UTC (rev 13809)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-10-07 11:49:54 UTC (rev 13810)
@@ -154,8 +154,8 @@
{
modifiedType.removeFromField(field.getJavaMember(), Produces.class);
}
- registerManagedPersistenceContext(qualifiers, scope, field.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), field);
- log.info("Configuring Seam Managed Persistence Context from producer field " + field.getDeclaringType().getJavaClass().getName() + "." + field.getJavaMember().getName() + " with qualifiers " + qualifiers);
+ registerManagedPersistenceContext(qualifiers, scope, field.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), field, event.getAnnotatedType().getJavaClass());
+ log.info("Configuring Seam Managed Persistence Context from producer field " + event.getAnnotatedType().getJavaClass().getName() + "." + field.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
// now look for producer methods that produce an EntityManagerFactory.
// This allows the user to manually configure an EntityManagerFactory
@@ -195,8 +195,8 @@
// we need to change the scope to application scoped
modifiedType.removeFromMethod(method.getJavaMember(), scope);
modifiedType.addToMethod(method.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
- registerManagedPersistenceContext(qualifiers, scope, method.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), method);
- log.info("Configuring Seam Managed Persistence Context from producer method " + method.getDeclaringType().getJavaClass().getName() + "." + method.getJavaMember().getName() + " with qualifiers " + qualifiers);
+ registerManagedPersistenceContext(qualifiers, scope, method.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), method, event.getAnnotatedType().getJavaClass());
+ log.info("Configuring Seam Managed Persistence Context from producer method " + event.getAnnotatedType().getJavaClass().getName() + "." + method.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
}
@@ -233,7 +233,7 @@
return builder.create();
}
- private void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, boolean alternative, BeanManager manager, ClassLoader loader, AnnotatedMember<?> member)
+ private void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, boolean alternative, BeanManager manager, ClassLoader loader, AnnotatedMember<?> member, Class<?> declaringClass)
{
// we need to add all additional interfaces from our
// SeamPersistenceProvider to the bean as at this stage we have no way of
@@ -258,7 +258,7 @@
builder.getTypes().add(Object.class);
builder.beanLifecycle(lifecycle);
builder.alternative(alternative);
- builder.toString("Seam Managed Persistence Context with qualifiers [" + qualifiers + "] with configured by [" + member + "]");
+ builder.toString("Seam Managed Persistence Context with qualifiers [" + qualifiers + "] with configured by [" + member + "] on class [" + declaringClass + "]");
beans.add(builder.create());
}
14 years, 3 months
Seam SVN: r13809 - in modules/resteasy/trunk: examples/tasks and 1 other directory.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-10-07 07:19:19 -0400 (Thu, 07 Oct 2010)
New Revision: 13809
Modified:
modules/resteasy/trunk/examples/tasks/pom.xml
modules/resteasy/trunk/pom.xml
Log:
weld-extensions version
Modified: modules/resteasy/trunk/examples/tasks/pom.xml
===================================================================
--- modules/resteasy/trunk/examples/tasks/pom.xml 2010-10-07 10:57:09 UTC (rev 13808)
+++ modules/resteasy/trunk/examples/tasks/pom.xml 2010-10-07 11:19:19 UTC (rev 13809)
@@ -90,7 +90,6 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
- <version>1.0.0-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>javax.transaction</groupId>
Modified: modules/resteasy/trunk/pom.xml
===================================================================
--- modules/resteasy/trunk/pom.xml 2010-10-07 10:57:09 UTC (rev 13808)
+++ modules/resteasy/trunk/pom.xml 2010-10-07 11:19:19 UTC (rev 13809)
@@ -18,8 +18,9 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
<arquillian.version>1.0.0.Alpha3</arquillian.version>
- <jbossas.version>6.0.0.20100721-M4</jbossas.version>
+ <jbossas.version>6.0.0.20100911-M5</jbossas.version>
<jboss.server.manager.version>1.0.3.GA</jboss.server.manager.version>
+ <weld.extensions.version>1.0.3.GA</weld.extensions.version>
</properties>
<url>http://www.seamframework.org</url>
@@ -49,6 +50,11 @@
<scope>import</scope>
<type>pom</type>
</dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>${weld.extensions.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
14 years, 3 months
Seam SVN: r13808 - modules/persistence/trunk/docs/src/main/docbook/en-US.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 06:57:09 -0400 (Thu, 07 Oct 2010)
New Revision: 13808
Modified:
modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml
modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml
Log:
update seam-persistence documentation
Modified: modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml
===================================================================
--- modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml 2010-10-07 10:29:36 UTC (rev 13807)
+++ modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml 2010-10-07 10:57:09 UTC (rev 13808)
@@ -6,6 +6,6 @@
<toc/>
<title>Seam Persistence</title>
- <xi:include href="persistence-introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+ <xi:include href="persistence-general.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
</book>
\ No newline at end of file
Modified: modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml
===================================================================
--- modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml 2010-10-07 10:29:36 UTC (rev 13807)
+++ modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml 2010-10-07 10:57:09 UTC (rev 13808)
@@ -4,48 +4,287 @@
<chapter id="persistence">
<title>Seam Persistence Reference</title>
- <section>
- <title>The Seam Managed Persistence Context</title>
- <para>
- The seam managed persistence context is an EntityManager that has its lifecycle managed by Seam. You configure one as follows:
- </para>
+ <para>
+ Seam provides extensive support for the two most popular persistence
+ architectures for Java: Hibernate3, and the Java Persistence API
+ introduced with EJB 3.0. Seam's unique state-management architecture
+ allows the most sophisticated ORM integration of any web application
+ framework.
+ </para>
- <programlisting role="java">
-@SeamManaged
+ <section>
+ <title>Introduction</title>
+
+ <para>
+ Seam grew out of the frustration of the Hibernate team with the
+ statelessness typical of the previous generation of Java application
+ architectures. The state management architecture of Seam was originally
+ designed to solve problems relating to persistence — in particular
+ problems associated with <emphasis>optimistic transaction processing</emphasis>.
+ Scalable online applications always use optimistic transactions. An atomic
+ (database/JTA) level transaction should not span a user interaction unless
+ the application is designed to support only a very small number of concurrent
+ clients. But almost all interesting work involves first displaying data
+ to a user, and then, slightly later, updating the same data. So Hibernate was
+ designed to support the idea of a persistence context which spanned an
+ optimistic transaction.
+ </para>
+
+ <para>
+ Unfortunately, the so-called "stateless" architectures that preceded Seam and
+ EJB 3.0 had no construct for representing an optimistic transaction. So, instead,
+ these architectures provided persistence contexts scoped to the atomic
+ transaction. Of course, this resulted in many problems for users, and is the
+ cause of the number one user complaint about Hibernate: the dreaded
+ <literal>LazyInitializationException</literal>. What we need is a construct
+ for representing an optimistic transaction in the application tier.
+ </para>
+
+ <para>
+ EJB 3.0 recognizes this problem, and introduces the idea of a stateful
+ component (a stateful session bean) with an <emphasis>extended persistence
+ context</emphasis> scoped to the lifetime of the component. This is a
+ partial solution to the problem (and is a useful construct in and of
+ itself) however there are two problems:
+ </para>
+
+ <itemizedlist>
+ <listitem>
+ <para>
+ The lifecycle of the stateful session bean must be managed manually
+ via code in the web tier (it turns out that this is a subtle problem
+ and much more difficult in practice than it sounds).
+ </para>
+ </listitem>
+ <listitem>
+ <para>
+ Propagation of the persistence context between stateful components
+ in the same optimistic transaction is possible, but tricky.
+ </para>
+ </listitem>
+ </itemizedlist>
+
+ <para>
+ Seam solves the first problem by providing conversations, and stateful
+ session bean components scoped to the conversation. (Most conversations
+ actually represent optimistic transactions in the data layer.) This is
+ sufficient for many simple applications (such as the Seam booking
+ demo) where persistence context propagation is not needed. For more
+ complex applications, with many loosly-interacting components in each
+ conversation, propagation of the persistence context across components
+ becomes an important issue. So Seam extends the persistence context
+ management model of EJB 3.0, to provide conversation-scoped extended
+ persistence contexts.
+ </para>
+
+ </section>
+
+ <section id="persistence.seam-managed-persistence-contexts">
+ <title>Seam-managed persistence contexts</title>
+
+ <para>
+ If you're using Seam outside of a Java EE 5 environment, you can't rely upon the
+ container to manage the persistence context lifecycle for you. Even if you are
+ in an EE 5 environment, you might have a complex application with many loosely
+ coupled components that collaborate together in the scope of a single conversation,
+ and in this case you might find that propagation of the persistence context between
+ component is tricky and error-prone.
+ </para>
+
+ <para>
+ In either case, you'll need to use a <emphasis>managed persistence context</emphasis>
+ (for JPA) or a <emphasis>managed session</emphasis> (for Hibernate) in your components.
+ A Seam-managed persistence context is just a built-in Seam component that manages an
+ instance of <literal>EntityManager</literal> or <literal>Session</literal> in the
+ conversation (or any other) context. You can inject it with <literal>@In</literal>.
+ </para>
+
+ <section>
+ <title>Using a Seam-managed persistence context with JPA</title>
+
+ <programlisting role="java">@SeamManaged
@Produces
@PersistenceUnit
@ConversationScoped
EntityManagerFactory producerField;
- </programlisting>
- <para>
- This is just an ordinary resource producer field as defined by the CDI specification, however the presence of the <literal>@SeamManaged</literal>
- annotation tells seam to create a seam managed persistence context from this <literal>EntityManagerFactory</literal>. This managed
- persistence context can be injected normally, and has the same scope and qualifiers that are specified on the resource producer field.
- </para>
- <note>
- <para>
- The more eagle eyed among you may have noticed that the resource producer field appears to be conversation scoped, which the CDI
- specification does not require containers to support. This is in fact not the case, as the @ConversationScoped annotation is removed
- by the seam persistence portable extension. It only specifies the scope of the created SMPC, not the EntityManagerFactory.
- </para>
- </note>
- <programlisting role="java">
-@Inject
-EntityManager smpc;
- </programlisting>
- <para>
- The seam managed persistence context provides the following features:
- </para>
- <itemizedlist>
- <listitem>Automatic enrollment in the active transaction</listitem>
- <listitem>The ability to use EL in JPA queries</listitem>
- </itemizedlist>
- </section>
- <section>
- <title>Seam Transactions</title>
- <para>Seam provides a lightweight UserTransaction wrapper called SeamTransaction.</para>
- <para>Seam also provides a transaction intercepter. In EE environments the normal <literal>@TransactionAttribute</literal> annotation
- can be used to demarcate transaction boundaries on managed beans, not just EJB's.</para>
-
- </section>
+ </programlisting>
+ <para>
+ This is just an ordinary resource producer field as defined by the CDI specification, however the presence of the <literal>@SeamManaged</literal>
+ annotation tells seam to create a seam managed persistence context from this <literal>EntityManagerFactory</literal>. This managed
+ persistence context can be injected normally, and has the same scope and qualifiers that are specified on the resource producer field.
+ </para>
+ <para>
+ This will work even in a SE environment where <code>@PersistenceUnit</code> injection is not normally supported. This is because
+ the seam persistence extensions will bootstrap the <code>EntityManagerFactory</code> for you.
+ </para>
+ <note>
+ <para>
+ The more eagle eyed among you may have noticed that the resource producer field appears to be conversation scoped, which the CDI
+ specification does not require containers to support. This is in fact not the case, as the @ConversationScoped annotation is removed
+ by the seam persistence portable extension. It only specifies the scope of the created SMPC, not the EntityManagerFactory.
+ </para>
+ </note>
+ <para>
+ Now we can have our <literal>EntityManager</literal> injected using:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[@Inject EntityManager entityManager;]]></programlisting>
+
+ <warning>
+ <para>
+ If you are using EJB3 and mark your class or method
+ <literal>@TransactionAttribute(REQUIRES_NEW)</literal> then the
+ transaction and persistence context shouldn't be propagated to method
+ calls on this object. However as the Seam-managed persistence
+ context is propagated to any component within the conversation, it
+ will be propagated to methods marked <literal>REQUIRES_NEW</literal>.
+ Therefore, if you mark a method <literal>REQUIRES_NEW</literal> then
+ you should access the entity manager using @PersistenceContext.
+ </para>
+ </warning>
+
+ </section>
+
+ <section>
+ <title>Seam-managed persistence contexts and atomic conversations</title>
+ <para>
+ Persistence contexts scoped to the conversation allows you to program optimistic
+ transactions that span multiple requests to the server without the need to use the
+ <literal>merge()</literal> operation , without the need to re-load
+ data at the beginning of each request, and without the need to wrestle with the
+ <literal>LazyInitializationException</literal> or
+ <literal>NonUniqueObjectException</literal>.
+ </para>
+
+ <para>
+ As with any optimistic transaction management, transaction isolation and consistency
+ can be achieved via use of optimistic locking. Fortunately, both Hibernate and EJB
+ 3.0 make it very easy to use optimistic locking, by providing the
+ <literal>@Version</literal> annotation.
+ </para>
+
+ <para>
+ By default, the persistence context is flushed (synchronized with the database)
+ at the end of each transaction. This is sometimes the desired behavior. But very
+ often, we would prefer that all changes are held in memory and only written to
+ the database when the conversation ends successfully. This allows for truly
+ atomic conversations. As the result of a truly stupid and shortsighted decision
+ by certain non-JBoss, non-Sun and non-Sybase members of the EJB 3.0 expert group,
+ there is currently no simple, usable and portable way to implement atomic
+ conversations using EJB 3.0 persistence. However, Hibernate provides this feature
+ as a vendor extension to the <literal>FlushModeType</literal>s defined by the
+ specification, and it is our expectation that other vendors will soon provide
+ a similar extension.
+ </para>
+
+ <para>
+ Seam lets you specify <literal>FlushModeType.MANUAL</literal> when beginning a
+ conversation. Currently, this works only when Hibernate is the underlying
+ persistence provider, but we plan to support other equivalent vendor extensions.
+ </para>
+
+ <para>
+ TODO: The next section needs to be updated to seam 3.
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[@In EntityManager em; //a Seam-managed persistence context
+
+ @Begin(flushMode=MANUAL)
+ public void beginClaimWizard() {
+ claim = em.find(Claim.class, claimId);
+ }]]></programlisting>
+
+ <para>
+ Now, the <literal>claim</literal> object remains managed by the persistence context
+ for the rest of the conversation. We can make changes to the claim:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[public void addPartyToClaim() {
+ Party party = ....;
+ claim.addParty(party);
+ }]]></programlisting>
+
+ <para>
+ But these changes will not be flushed to the database until we explicitly force
+ the flush to occur:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[@End
+ public void commitClaim() {
+ em.flush();
+ }]]></programlisting>
+
+ <para>
+ Of course, you could set the <literal>flushMode</literal> to <literal>MANUAL</literal>
+ from pages.xml, for example in a navigation rule:
+ </para>
+
+ <programlisting role="XML"><![CDATA[<begin-conversation flush-mode="MANUAL" />]]></programlisting>
+
+ <para>
+ You can set any Seam Managed Persistence Context to use manual flush
+ mode:
+ </para>
+
+ <programlisting><![CDATA[<components xmlns="http://jboss.com/products/seam/components"
+ xmlns:core="http://jboss.com/products/seam/core">
+ <core:manager conversation-timeout="120000" default-flush-mode="manual" />
+ </components>]]></programlisting>
+
+ </section>
+
+
+ <section>
+ <title>Using EL in EJB-QL/HQL</title>
+ <para>
+ Seam proxies the <literal>EntityManager</literal> or <literal>Session</literal>
+ object whenever you use a Seam-managed persistence context or inject a container
+ managed persistence context using <literal>@PersistenceContext</literal>. This
+ lets you use EL expressions in your query strings, safely and efficiently. For
+ example, this:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[User user = em.createQuery("from User where username=#{user.username}")
+ .getSingleResult();]]></programlisting>
+
+ <para>is equivalent to:</para>
+
+ <programlisting role="JAVA"><![CDATA[User user = em.createQuery("from User where username=:username")
+ .setParameter("username", user.getUsername())
+ .getSingleResult();]]></programlisting>
+
+ <para>
+ Of course, you should never, ever write it like this:
+ </para>
+
+ <programlisting role="JAVA"><![CDATA[User user = em.createQuery("from User where username=" + user.getUsername()) //BAD!
+ .getSingleResult();]]></programlisting>
+
+ <para>
+ (It is inefficient and vulnerable to SQL injection attacks.)
+ </para>
+
+ </section>
+
+ <section>
+ <title>Setting up the EntityManager</title>
+
+ <para>
+ Sometimes you may want to perform some additional setup on the <code>EntityManager</code> after
+ it has been created. For example, if you are using Hibernate you may want to set a filter. Seam
+ persistence fires a <code>SeamManagedPersistenceContextCreated</code> event when a Seam managed
+ persistence context is created. You can observe this event and perform any setup you require in
+ an observer method. For example:
+ </para>
+
+ <programlisting role="JAVA">public void setupEntityManager(@Observes SeamManagedPersistenceContextCreated event) {
+ Session session = (Session)event.getEntityManager().getDelegate();
+ session.enableFilter("myfilter");
+}
+ </programlisting>
+
+ </section>
+
+ </section>
+
</chapter>
14 years, 3 months
Seam SVN: r13807 - modules/resteasy/trunk/examples/tasks.
by seam-commits@lists.jboss.org
Author: jharting
Date: 2010-10-07 06:29:36 -0400 (Thu, 07 Oct 2010)
New Revision: 13807
Modified:
modules/resteasy/trunk/examples/tasks/pom.xml
Log:
remove firefox path from functional test setup
Modified: modules/resteasy/trunk/examples/tasks/pom.xml
===================================================================
--- modules/resteasy/trunk/examples/tasks/pom.xml 2010-10-07 09:17:23 UTC (rev 13806)
+++ modules/resteasy/trunk/examples/tasks/pom.xml 2010-10-07 10:29:36 UTC (rev 13807)
@@ -20,7 +20,7 @@
<selenium.java.client.version>1.0.1</selenium.java.client.version>
<richfaces.selenium.version>1.5.1.Final</richfaces.selenium.version>
<ftest.version.discriminator />
- <selenium.browser>*firefoxproxy /usr/lib64/firefox-3.5/firefox</selenium.browser>
+ <selenium.browser>*firefoxproxy</selenium.browser>
<selenium.browser.url>http://localhost:8080</selenium.browser.url>
<selenium.server.port>14444</selenium.server.port>
<selenium.server.host>localhost</selenium.server.host>
14 years, 3 months
Seam SVN: r13806 - in modules/persistence/trunk: docs and 4 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 05:17:23 -0400 (Thu, 07 Oct 2010)
New Revision: 13806
Added:
modules/persistence/trunk/docs/
modules/persistence/trunk/docs/pom.xml
modules/persistence/trunk/docs/src/
modules/persistence/trunk/docs/src/main/
modules/persistence/trunk/docs/src/main/docbook/
modules/persistence/trunk/docs/src/main/docbook/en-US/
modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml
modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml
Log:
Add docs folder
Property changes on: modules/persistence/trunk/docs
___________________________________________________________________
Name: svn:ignore
+ target
.project
.classpath
.settings
Added: modules/persistence/trunk/docs/pom.xml
===================================================================
--- modules/persistence/trunk/docs/pom.xml (rev 0)
+++ modules/persistence/trunk/docs/pom.xml 2010-10-07 09:17:23 UTC (rev 13806)
@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-parent</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.jboss.seam.persistence</groupId>
+ <artifactId>seam-persistence-reference-guide</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ <packaging>jdocbook</packaging>
+ <name>Seam Persistence Reference Guide</name>
+
+ <properties>
+ <pdf.name>persistence-reference.pdf</pdf.name>
+ <weld.docbook.version>1.1.1-Beta5</weld.docbook.version>
+ </properties>
+
+ <build>
+ <defaultGoal>process-classes</defaultGoal>
+ <plugins>
+
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ </plugin>
+
+ <!-- Attach docs as a war so dist can retrieve them -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-zip</id>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.outputDirectory}/${project.artifactId}-${project.version}.war</file>
+ <type>war</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>distribution</id>
+ <activation>
+ <property>
+ <name>release</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-assembly-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/seam/modules/xml/trunk/docs</connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/seam/modules/xml/trunk/docs</developerConnection>
+ <url>http://fisheye.jboss.org/browse/seam/modules/xml/docs</url>
+ </scm>
+</project>
Added: modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml
===================================================================
--- modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml (rev 0)
+++ modules/persistence/trunk/docs/src/main/docbook/en-US/master.xml 2010-10-07 09:17:23 UTC (rev 13806)
@@ -0,0 +1,11 @@
+<?xml version='1.0' encoding="utf-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.35//EN"
+ "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [ ]>
+<book lang="en">
+
+ <toc/>
+
+ <title>Seam Persistence</title>
+ <xi:include href="persistence-introduction.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
\ No newline at end of file
Added: modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml
===================================================================
--- modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml (rev 0)
+++ modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml 2010-10-07 09:17:23 UTC (rev 13806)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+
+<chapter id="persistence">
+ <title>Seam Persistence Reference</title>
+
+ <section>
+ <title>The Seam Managed Persistence Context</title>
+ <para>
+ The seam managed persistence context is an EntityManager that has its lifecycle managed by Seam. You configure one as follows:
+ </para>
+
+ <programlisting role="java">
+@SeamManaged
+@Produces
+@PersistenceUnit
+@ConversationScoped
+EntityManagerFactory producerField;
+ </programlisting>
+ <para>
+ This is just an ordinary resource producer field as defined by the CDI specification, however the presence of the <literal>@SeamManaged</literal>
+ annotation tells seam to create a seam managed persistence context from this <literal>EntityManagerFactory</literal>. This managed
+ persistence context can be injected normally, and has the same scope and qualifiers that are specified on the resource producer field.
+ </para>
+ <note>
+ <para>
+ The more eagle eyed among you may have noticed that the resource producer field appears to be conversation scoped, which the CDI
+ specification does not require containers to support. This is in fact not the case, as the @ConversationScoped annotation is removed
+ by the seam persistence portable extension. It only specifies the scope of the created SMPC, not the EntityManagerFactory.
+ </para>
+ </note>
+ <programlisting role="java">
+@Inject
+EntityManager smpc;
+ </programlisting>
+ <para>
+ The seam managed persistence context provides the following features:
+ </para>
+ <itemizedlist>
+ <listitem>Automatic enrollment in the active transaction</listitem>
+ <listitem>The ability to use EL in JPA queries</listitem>
+ </itemizedlist>
+ </section>
+ <section>
+ <title>Seam Transactions</title>
+ <para>Seam provides a lightweight UserTransaction wrapper called SeamTransaction.</para>
+ <para>Seam also provides a transaction intercepter. In EE environments the normal <literal>@TransactionAttribute</literal> annotation
+ can be used to demarcate transaction boundaries on managed beans, not just EJB's.</para>
+
+ </section>
+</chapter>
Property changes on: modules/persistence/trunk/docs/src/main/docbook/en-US/persistence-general.xml
___________________________________________________________________
Name: svn:executable
+ *
14 years, 3 months
Seam SVN: r13805 - in modules/persistence/trunk: api/src/main/java/org/jboss/seam/persistence/transaction and 2 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 05:13:56 -0400 (Thu, 07 Oct 2010)
New Revision: 13805
Modified:
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManaged.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/DefaultTransaction.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/DefaultTransactionLiteral.java
modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/TransactionScopedLiteral.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
Log:
minor javadoc updates
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManaged.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManaged.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManaged.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -43,16 +43,15 @@
* @SomeQualifier
* EntityManagerFactory emf;
* </pre>
- *
- * will create a conversation scoped seam managed persistence context that is
+ * <p/>
+ * Will create a conversation scoped seam managed persistence context that is
* conversation scoped with the qualifier @SomeQualifier.
- *
+ * <p/>
* This field still produces the EntityManagerFactory with qualifier
+ * @SomeQualifier, however the scope for the producer field is changed to
+ * {@link Dependent}, as the specification does not allow resource producer
+ * fields to have a scope other than Dependent
*
- * @SomeQualifier, however the scope for the producer field is changed to
- * {@link Dependent}, as the specification does not allow
- * resource producer fields to have a scope other than Dependent
- *
* @author Stuart Douglas
*
*/
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/SeamManagedPersistenceContextCreated.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -22,11 +22,22 @@
package org.jboss.seam.persistence;
import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+
/**
- * event that is fired when the SMPC is created. This allows you to configure
- * the SMPC before it is used, e.g. by enabling hibernate filters
+ * Event that is fired when the SMPC is created. This allows you to configure
+ * the SMPC before it is used, e.g. by enabling Hibernate filters.
+ * <p/>
+ * NOTE: If you are using {@link EntityTransaction} you must not attempt to
+ * access the current {@link SeamTransaction} from observers for this event, as
+ * an infinite loop will result.
+ * <p/>
+ * NOTE: The entityManger property is the unproxied EntityManager, not the seam
+ * proxy.
*
+ *
* @author Stuart Douglas <stuart(a)baileyroberts.com.au>
*
*/
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/DefaultTransaction.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/DefaultTransaction.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/DefaultTransaction.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -13,9 +13,9 @@
* Qualifier that is used to denote the SeamTransaction implementation that is
* used by the transaction interceptor and other seam transaction services.
*
- * A qualifier is nessesary to prevent the seam provided {@link UserTransaction}
+ * A qualifier is necessary to prevent the seam provided {@link UserTransaction}
* wrapper {@link SeamTransaction} from conflicting with the container provided
- * builtin UserTransaction
+ * built-in UserTransaction
*
* @author Stuart Douglas
*
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/SeamApplicationException.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -13,9 +13,9 @@
* Seam Annotation for identifying an Exception class as an Application
* Exception, which does not cause a transaction rollback.
*
- * This will NOT control the behaviour of EJB container managed transactions. To
+ * This will NOT control the behavior of EJB container managed transactions. To
* avoid confusion, it is recommended that this annotation is only used outside
- * an EE environment when @{link {@link ApplicationException} is not availible.
+ * an EE environment when @{link {@link ApplicationException} is not available.
*
*/
@Target(ElementType.TYPE)
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/Transactional.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -31,10 +31,10 @@
* Demarcates transaction boundaries
*
* Note that is you are using seam managed transactions seam will automatically
- * manage your transactions for you, rendering this unnessesary
+ * manage your transactions for you, rendering this unnecessary
*
- * Note that this annotation is not actually an interceptor binding. It is
- * replaced by an interceptor binding at runtime by a portable extension in the
+ * Note that this annotation is not actually an intercepter binding. It is
+ * replaced by an intercepter binding at runtime by a portable extension in the
* ProcessAnnotatedType phase
*
*
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/DefaultTransactionLiteral.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/DefaultTransactionLiteral.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/DefaultTransactionLiteral.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -1,5 +1,23 @@
-/**
- *
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.seam.persistence.transaction.literal;
Modified: modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/TransactionScopedLiteral.java
===================================================================
--- modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/TransactionScopedLiteral.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/api/src/main/java/org/jboss/seam/persistence/transaction/literal/TransactionScopedLiteral.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -1,5 +1,23 @@
-/**
- *
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.seam.persistence.transaction.literal;
@@ -13,6 +31,6 @@
{
}
- TransactionScopedLiteral INSTANCE = new TransactionScopedLiteral();
+ public static TransactionScopedLiteral INSTANCE = new TransactionScopedLiteral();
}
\ No newline at end of file
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-10-07 08:45:26 UTC (rev 13804)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextBeanLifecycle.java 2010-10-07 09:13:56 UTC (rev 13805)
@@ -123,7 +123,7 @@
EntityManager proxy = (EntityManager) proxyConstructor.newInstance(handler);
arg0.push(proxy);
getPersistenceProvider(entityManager).setFlushMode(proxy, getFlushMode());
- manager.fireEvent(new SeamManagedPersistenceContextCreated(proxy), qualifiers);
+ manager.fireEvent(new SeamManagedPersistenceContextCreated(entityManager), qualifiers);
return proxy;
}
14 years, 3 months
Seam SVN: r13804 - modules/persistence/trunk/tests-jetty.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 04:45:26 -0400 (Thu, 07 Oct 2010)
New Revision: 13804
Modified:
modules/persistence/trunk/tests-jetty/pom.xml
Log:
minor
Modified: modules/persistence/trunk/tests-jetty/pom.xml
===================================================================
--- modules/persistence/trunk/tests-jetty/pom.xml 2010-10-07 08:44:35 UTC (rev 13803)
+++ modules/persistence/trunk/tests-jetty/pom.xml 2010-10-07 08:45:26 UTC (rev 13804)
@@ -12,7 +12,7 @@
<artifactId>seam-persistence-tests-jetty</artifactId>
<packaging>jar</packaging>
<version>3.0.0-SNAPSHOT</version>
- <name>Seam Persistence Weld SE Tests</name>
+ <name>Seam Persistence Jetty Tests</name>
<prerequisites>
<maven>3.0</maven>
14 years, 3 months
Seam SVN: r13803 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-10-07 04:44:35 -0400 (Thu, 07 Oct 2010)
New Revision: 13803
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
Log:
minor clean up of SE support
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-10-07 08:28:16 UTC (rev 13802)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-10-07 08:44:35 UTC (rev 13803)
@@ -24,13 +24,11 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Resource;
-import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
@@ -45,7 +43,6 @@
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.ProcessAnnotatedType;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -55,6 +52,7 @@
import org.jboss.seam.persistence.util.EnvironmentUtils;
import org.jboss.weld.extensions.bean.BeanBuilder;
import org.jboss.weld.extensions.bean.Beans;
+import org.jboss.weld.extensions.bean.ContextualLifecycle;
import org.jboss.weld.extensions.literal.AnyLiteral;
import org.jboss.weld.extensions.literal.ApplicationScopedLiteral;
import org.jboss.weld.extensions.literal.DefaultLiteral;
@@ -64,8 +62,8 @@
import org.slf4j.LoggerFactory;
/**
- * Extension the wraps producer methods/fields that produce an entity manager to
- * turn them into Seam Managed Persistence Contexts.
+ * Extension the wraps producer methods/fields that produce an entity manager
+ * factory to turn them into Seam Managed Persistence Contexts.
*
*
* @author Stuart Douglas
@@ -105,23 +103,23 @@
{
AnnotatedTypeBuilder<T> modifiedType = null;
boolean bootstrapped = false;
- for (AnnotatedField<? super T> f : event.getAnnotatedType().getFields())
+ for (AnnotatedField<? super T> field : event.getAnnotatedType().getFields())
{
- if (f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class) && !EnvironmentUtils.isEEEnvironment())
+ if (field.isAnnotationPresent(PersistenceUnit.class) && field.isAnnotationPresent(Produces.class) && !EnvironmentUtils.isEEEnvironment())
{
bootstrapped = true;
- final String unitName = f.getAnnotation(PersistenceUnit.class).unitName();
- final Set<Annotation> qualifiers = Beans.getQualifiers(manager, f.getAnnotations());
+ final String unitName = field.getAnnotation(PersistenceUnit.class).unitName();
+ final Set<Annotation> qualifiers = Beans.getQualifiers(manager, field.getAnnotations());
if (qualifiers.isEmpty())
{
qualifiers.add(DefaultLiteral.INSTANCE);
}
qualifiers.add(AnyLiteral.INSTANCE);
- beans.add(createEMFBean(unitName, qualifiers, event.getAnnotatedType()));
+ beans.add(createEMFBean(unitName, qualifiers, event.getAnnotatedType(), manager));
}
// look for a seam managed persistence unit declaration on EE resource
// producer fields
- if (f.isAnnotationPresent(SeamManaged.class) && (f.isAnnotationPresent(PersistenceUnit.class) || f.isAnnotationPresent(Resource.class)) && f.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(f.getJavaMember().getType()))
+ if (field.isAnnotationPresent(SeamManaged.class) && (field.isAnnotationPresent(PersistenceUnit.class) || field.isAnnotationPresent(Resource.class)) && field.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(field.getJavaMember().getType()))
{
if (modifiedType == null)
{
@@ -130,15 +128,15 @@
Set<Annotation> qualifiers = new HashSet<Annotation>();
Class<? extends Annotation> scope = Dependent.class;
// get the qualifier and scope for the new bean
- for (Annotation a : f.getAnnotations())
+ for (Annotation annotation : field.getAnnotations())
{
- if (manager.isQualifier(a.annotationType()))
+ if (manager.isQualifier(annotation.annotationType()))
{
- qualifiers.add(a);
+ qualifiers.add(annotation);
}
- else if (manager.isScope(a.annotationType()))
+ else if (manager.isScope(annotation.annotationType()))
{
- scope = a.annotationType();
+ scope = annotation.annotationType();
}
}
if (qualifiers.isEmpty())
@@ -150,14 +148,14 @@
// on producer fields
if (scope != Dependent.class)
{
- modifiedType.removeFromField(f.getJavaMember(), scope);
+ modifiedType.removeFromField(field.getJavaMember(), scope);
}
if (bootstrapped)
{
- modifiedType.removeFromField(f.getJavaMember(), Produces.class);
+ modifiedType.removeFromField(field.getJavaMember(), Produces.class);
}
- registerManagedPersistenceContext(qualifiers, scope, f.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), f);
- log.info("Configuring Seam Managed Persistence Context from producer field " + f.getDeclaringType().getJavaClass().getName() + "." + f.getJavaMember().getName() + " with qualifiers " + qualifiers);
+ registerManagedPersistenceContext(qualifiers, scope, field.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), field);
+ log.info("Configuring Seam Managed Persistence Context from producer field " + field.getDeclaringType().getJavaClass().getName() + "." + field.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
// now look for producer methods that produce an EntityManagerFactory.
// This allows the user to manually configure an EntityManagerFactory
@@ -167,9 +165,9 @@
// method. This looks for both EMF's and SessionFactories
// The producer method has its scope changes to application scoped
// this allows for programatic config of the SMPC
- for (AnnotatedMethod<? super T> m : event.getAnnotatedType().getMethods())
+ for (AnnotatedMethod<? super T> method : event.getAnnotatedType().getMethods())
{
- if (m.isAnnotationPresent(SeamManaged.class) && m.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(m.getJavaMember().getReturnType()))
+ if (method.isAnnotationPresent(SeamManaged.class) && method.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(method.getJavaMember().getReturnType()))
{
if (modifiedType == null)
{
@@ -178,15 +176,15 @@
Set<Annotation> qualifiers = new HashSet<Annotation>();
Class<? extends Annotation> scope = Dependent.class;
// get the qualifier and scope for the new bean
- for (Annotation a : m.getAnnotations())
+ for (Annotation annotation : method.getAnnotations())
{
- if (manager.isQualifier(a.annotationType()))
+ if (manager.isQualifier(annotation.annotationType()))
{
- qualifiers.add(a);
+ qualifiers.add(annotation);
}
- else if (manager.isScope(a.annotationType()))
+ else if (manager.isScope(annotation.annotationType()))
{
- scope = a.annotationType();
+ scope = annotation.annotationType();
}
}
if (qualifiers.isEmpty())
@@ -195,10 +193,10 @@
}
qualifiers.add(AnyLiteral.INSTANCE);
// we need to change the scope to application scoped
- modifiedType.removeFromMethod(m.getJavaMember(), scope);
- modifiedType.addToMethod(m.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
- registerManagedPersistenceContext(qualifiers, scope, m.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), m);
- log.info("Configuring Seam Managed Persistence Context from producer method " + m.getDeclaringType().getJavaClass().getName() + "." + m.getJavaMember().getName() + " with qualifiers " + qualifiers);
+ modifiedType.removeFromMethod(method.getJavaMember(), scope);
+ modifiedType.addToMethod(method.getJavaMember(), ApplicationScopedLiteral.INSTANCE);
+ registerManagedPersistenceContext(qualifiers, scope, method.isAnnotationPresent(Alternative.class), manager, event.getAnnotatedType().getJavaClass().getClassLoader(), method);
+ log.info("Configuring Seam Managed Persistence Context from producer method " + method.getDeclaringType().getJavaClass().getName() + "." + method.getJavaMember().getName() + " with qualifiers " + qualifiers);
}
}
@@ -208,70 +206,31 @@
}
}
- private Bean<?> createEMFBean(final String unitName, final Set<Annotation> qualifiers, final AnnotatedType<?> type)
+ /**
+ * Creates an EntityManagerFactory bean in a SE environment
+ */
+ private Bean<?> createEMFBean(final String unitName, final Set<Annotation> qualifiers, final AnnotatedType<?> type, final BeanManager beanManager)
{
- return new Bean<EntityManagerFactory>()
+ BeanBuilder<EntityManagerFactory> builder = new BeanBuilder<EntityManagerFactory>(beanManager);
+ Set<Type> types = new HashSet<Type>();
+ types.add(EntityManagerFactory.class);
+ types.add(Object.class);
+ builder.beanClass(type.getJavaClass()).qualifiers(qualifiers).types(types);
+ builder.beanLifecycle(new ContextualLifecycle<EntityManagerFactory>()
{
- public Set<Type> getTypes()
- {
- Set<Type> types = new HashSet<Type>();
- types.add(Object.class);
- types.add(EntityManagerFactory.class);
- return types;
- }
- public Class<? extends Annotation> getScope()
+ public void destroy(Bean<EntityManagerFactory> bean, EntityManagerFactory instance, CreationalContext<EntityManagerFactory> creationalContext)
{
- return ApplicationScoped.class;
+ instance.close();
+ creationalContext.release();
}
- public EntityManagerFactory create(CreationalContext<EntityManagerFactory> ctx)
+ public EntityManagerFactory create(Bean<EntityManagerFactory> bean, CreationalContext<EntityManagerFactory> creationalContext)
{
return Persistence.createEntityManagerFactory(unitName);
}
-
- public void destroy(EntityManagerFactory emf, CreationalContext<EntityManagerFactory> ctx)
- {
- emf.close();
- ctx.release();
- }
-
- public Class<?> getBeanClass()
- {
- return type.getJavaClass();
- }
-
- public Set<InjectionPoint> getInjectionPoints()
- {
- return Collections.emptySet();
- }
-
- public String getName()
- {
- return null;
- }
-
- public Set<Annotation> getQualifiers()
- {
- return qualifiers;
- }
-
- public Set<Class<? extends Annotation>> getStereotypes()
- {
- return Collections.emptySet();
-
- }
-
- public boolean isAlternative()
- {
- return false;
- }
-
- public boolean isNullable()
- {
- return false;
- }
- };
+ });
+ return builder.create();
}
private void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, boolean alternative, BeanManager manager, ClassLoader loader, AnnotatedMember<?> member)
14 years, 3 months