2 Replies Latest reply on Mar 24, 2009 9:09 AM by nimo22

    static instance Set?

    nimo22

      I want to have a static Object in my Application Scope managed by Seam:


      Is this right?:



      public static Set<MyObject> instance() { return (Set<MyObject>) Component.getInstance(MyObject.class, ScopeType.APPLICATION);}



      Is this the same as this:



      private static Set<MyObject> myStaticInstance =  new HashSet<MyObject>();
      // getter/setter



        • 1. Re: static instance Set?
          norman

          I don't understand what you are asking, but your static method is similar to the getInstance() idiom you see on many internal Seam components.  However, we wouldn't normally include the scope on the call to Component.getInstance().

          • 2. Re: static instance Set?
            nimo22

            Hello,


            I did not realized that a typical Servlet Listener has no access to Seams @In,@Out-attributes - So in my case, I cannot use Component.findInstance.. I use the latter one, now it works within a listener.