Yes, cost of interceptors (@In) is a known issue, this is discussed by Dan Allen in his excellent article Speed up your Data-Driven JSF/Seam Application by Two Orders of Magnitude
For the problem you mention with SMPC, I usually just obtain the Entity manager directly, something like
In addition, many of the Seam components have static instance() methods, which do the Component.getInstance() call for you, something like
how would you know if the EntityManager instance manages a PC (@PersistenceContext) or SMPC (@In)?
Maybe i'm VERY wrong, but the @In/getInstance always will get the SMPC.
@In always injects SMPC (there's an @Unwrap getEntityManager() in ManagedPersistenceContext class).
Not sure about getInstance()...
I just tried this:
EntityManager entityManager = (EntityManager)Component.getInstance(EntityManager.class, true);
and got this:
Caused by: java.lang.IllegalArgumentException: No @Name annotation for class: javax.persistence.EntityManager at org.jboss.seam.Component.getComponentName(Component.java:1801)
plus for this:
<persistence:managed-persistence-context name="entityManager" auto-create="true" persistence-unit-jndi-name="java:/boBETSEntityManagerFactory"/>
I do not see setAutoCreate() or setName() methods in ManagedPersistenceContext class.
But I do see a clearDirty() method in ManagedPersistenceContext class but it seems that belongs in the EntityManager interface (but there's a clear() method in that API, not clearDirty()).
You have to do getInstance(
entityManager). getInstance(Class) relies on an @Name annotation on the target class to determine the component name. Component.getInstance and injection will always return the same thing (a SMPC).
name and autoCreate are availible on all seam components.
How can i inject e component on seam 3,
Component.getInstanceon seam 2 ?
I'm confuse, i don't know how get component
and how i define a componente without a components.xml