11 Replies Latest reply on Nov 22, 2009 4:34 PM by Gavin King

    Integrating DWR and Weld: @Named implicitly: How to get the name?

    Francisco Jose Peredo Noguez Master

      I am implementing an extension to integrate Weld and DWR.
      For DWR to integrate with Weld, I need to create a wrapper class implementing the interface org.directwebremoting.Container

      One of the methods in that interface is public Collection getBeanNames() that returns a list with the names of all the beans
      that will be remoted by DWR.

      Now, BeanManager does not have a method that returns all the beans that are annotated with a particular annotation (in this the created-by-me com.googlecode.solder.dwr.DwrBean)
      But Gavin told me that:

      You would have to write an Extension that builds the list of classes as the bean archives are being scanned, by observing ProcessAnnotatedType.

      I have done that... and I hope that it works... but I have a problem once I have the list with all the AnnotatedType<DwrBean> I need to get the name.
      Now, for named beans, Weld proportionates the @Named annotation... that would be enough for cases where the name is set explicitly: @Named("someName") class SomeName{} all I have to do
      is get the @Named object and ask for its value(), but... what to do if my bean is named implicitly: @Named class SomeName{}.

      I guess I should assume that the name in those cases is the name of the class with the first letter in lowercase...is that recommended? or should I be obtaining the name in another way?
      The thing that worries my about just changing the first letter of the class name to lowercase if @Named.value() is empty is that I do not know if Weld does some special name conflict resolution in cases like this:

      package somePackage;
      @Named class SomeName{}
      package otherPackage;
      @Named class SomeName{}

      In this cases... both classes get the someName name? or Weld detects there is a conflicts and atomatically prepends the name of the package?