[seam-dev] qualify common types

Dan Allen dan.j.allen at gmail.com
Fri Apr 2 11:10:38 EDT 2010


Seam 3 module writers,

Be sure that if you are producing a common type for internal use, such as a
javax.naming.Context, that you qualify it to your module (or purpose).
Otherwise, any other module that provides that type will conflict with your
module (AmbigousResolutionException).

Here's an example:

   @Produces
   public Context getContext() throws NamingException
   {
      return new InitialContext();
   }

Here's another:

   public @Produces @ConversationScoped EntityManager getEntityManager()
   {
      return entityManager;
   }

These should be qualified. In the first case, perhaps something like this
for the foobar module:

@Produces @org.jboss.seam.foobar.annotations.Module
public Context getContext() throws NamingException
{
   return new InitialContext();
}

If the type is common, but your module is expected to produce it, then it's
okay for it to be unqualified (@Default qualifier). For example, the
international module may be expected to produce a java.util.Locale. The
developer shouldn't use two international modules, so this is fine. I would
call this a @Default type which your module *exports*. It would be good to
provide this list in your documentation.

If you have any feedback or additional suggestions, feel free to comment.

Dan

-- 
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://www.google.com/profiles/dan.j.allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20100402/68f0fb8c/attachment-0001.html 


More information about the seam-dev mailing list