scope = annotation.annotationType();
}
}
if (qualifiers.isEmpty())
{
qualifiers.add(new DefaultLiteral());
}
qualifiers.add(AnyLiteral.INSTANCE);
// we need to remove the scope, they are not nessesarily supported
// on producer fields
if (scope != Dependent.class)
{
modifiedType.removeFromField(field.getJavaMember(), scope);
}
if (bootstrapped)
{
modifiedType.removeFromField(field.getJavaMember(), Produces.class);
}
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
// and return it from a producer method
}
// now look for SMPC's that are configured programatically via a producer
// 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> method : event.getAnnotatedType().getMethods())
{
if (method.isAnnotationPresent(ExtensionManaged.class) && method.isAnnotationPresent(Produces.class) && EntityManagerFactory.class.isAssignableFrom(method.getJavaMember().getReturnType()))
{
if (modifiedType == null)
{
modifiedType = new AnnotatedTypeBuilder().readFromType(event.getAnnotatedType());
}
Set<Annotation> qualifiers = new HashSet<Annotation>();
Class<? extends Annotation> scope = Dependent.class;
// get the qualifier and scope for the new bean
for (Annotation annotation : method.getAnnotations())
{
if (manager.isQualifier(annotation.annotationType()))
{
qualifiers.add(annotation);
}
else if (manager.isScope(annotation.annotationType()))
{
scope = annotation.annotationType();
}
}
if (qualifiers.isEmpty())
{
qualifiers.add(new DefaultLiteral());
}
qualifiers.add(AnyLiteral.INSTANCE);
// we need to change the scope to application scoped
modifiedType.removeFromMethod(method.getJavaMember(), scope);
modifiedType.addToMethod(method.getJavaMember(), ApplicationScopedLiteral.INSTANCE);