1 Reply Latest reply on Feb 17, 2009 11:31 PM by Stuart Douglas

    Getting all components implementing a given interface

    Vassiliy Dubkin Newbie

      Hi all! I am currently implementing a very simple plugin architecture for one of our projects and looking for a possibility getting all seam components in classpath which implements a certain interface (i.e. the plugin interface). Is there an elegant way doing it with seam? I found the method
      Component.getBusinessInterfaces(arg) but it seems not solving my problem and I can't find any further documentation about that method.


      Thanks in advance!

        • 1. Re: Getting all components implementing a given interface
          Stuart Douglas Master

          This is how I do it (I really look for annotations but the principle is the same):



          @Name("customSetupInstaller")
          @Scope(ScopeType.APPLICATION)
          @Startup
          public class CustomSetupInstaller
          {
              
              @Create
              public void handleItems()
              {
               String[] names = Contexts.getApplicationContext().getNames();
               for (String i : names)
               {
                   if (i.endsWith(".component"))
                   {
                    Component c = (Component) Contexts.getApplicationContext().get(
                         i);
                    Class e = c.getBeanClass();
                    if(MyInterface.class.isAssignableFrom(e))
                          {
                              //do stuff 
                           }
          
                   }
          
               }
              }
          }