3 Replies Latest reply on Aug 20, 2008 4:51 AM by tokc

    esb 4.0 preview - BundleActivator vs. beans.xml

    tokc

      Hello,

       

      Gert thanks for your answers so far. I think I'll keep you busy with my questions for a while.

       

      I've tried to do some simple stuff with osgi bundles (which are new to me). I followed apache felix tutorial (http://felix.apache.org/site/apache-felix-osgi-tutorial.html).

       

      I've tried to deploy first bundle, register it (using BundleActivator or beans.xml) and then deploy second bundle, which would discover the first one (using context.getServiceReference(...)). But I've failed on this.

       

      It looks like the first bundle is deployed correctly (from what I can see in logs). It loooks the same if I use BundleActivator (context.registerService(...)) or beans.xml (<osgi:service ... />).

       

      But than I deploy second bundle, and it has a piece of code like this:

      public void start(BundleContext context) throws Exception {

      ServiceReference ref = context.getServiceReference(

                     MyInterface.class.getName());

              if (ref == null ) {

                  System.out.println("nothing found");

                  System.out.println("nothing found");

                  System.out.println("nothing found");

                  System.out.println("nothing found");

                  System.out.println("nothing found");

                  System.out.println("nothing found");

              } else {

                      System.out.println("ref: " + ref);

              } and "nothing found" is printed

       

      Is what I'm trying to do impossible in ESB 4.0 ? Or maybe the idea is ok, but I do some mistakes ?

       

      best regards

      Tomek Kaczanowski

        • 1. Re: esb 4.0 preview - BundleActivator vs. beans.xml
          tokc

          hello,

           

          could someone please answer this question ? It's a simple one - all I ask is to tell me, if it's possible in Fuse ESB 4.0 preview to:

          1. deploy an osgi bundle (using BundleActivator or beans.xml)

          2. deploy another osgi bundle and discover the bundle deployed in point 1 using context.getServiceReference(...) or context.getServiceReferences(...)

           

          is it possible ?

           

          will appreciate your help

          Tomek Kaczanowski

          • 2. Re: esb 4.0 preview - BundleActivator vs. beans.xml
            gertv

            Tomek,

             

            Your scenario should definitely work.  We use this all the time in ServiceMix 4 (both the registerContext() and Spring DM <osgi:service /> approach).  ServiceMix 4's Kernel is just an OSGi runtime, so there's no magic there.

             

            If you look at the ServiceMix 4 log files, you'll see services being registered all the time.  Do you see the same thing happening for your service too?

             

            Regards,

             

            Gert

             

             

            P.S. Sorry for the communication lag -- vacation and holidays...

            • 3. Re: esb 4.0 preview - BundleActivator vs. beans.xml
              tokc

              Hello Gert, thx for you answer.

               

              I probably tried to do too many things at once - now I've simplified my examples a little bit and everything works fine. No problem with discovering services no matter if they are deployed with registerService() or <osgi:service /> approach. It works.

               

              thx

              Tomek Kaczanowski