5 Replies Latest reply on Dec 16, 2009 8:17 PM by njiang

    Simple SE that uses an external library (using OSGi)

    ireilly

      I'm trying to create a proof of concept using the ESB v4 that simply takes a message posted to HTTP and persists some data.

       

      I've got all the FUSE stuff working fine, whereas the message is traveling from the endpoint to the SE's pojo.

       

      What I'm having trouble wrapping my head around is how to implement more advanced functionality in the pojo, in particular, using Hibernate to persist data.  The whole OSGi thing is throwing me for a loop. 

       

      Actually, my confusion doesn't necessarily lie with Hibernate, but with any external dependency that I want to use.  In particular, how do I deploy the SE bundle with the external dependencies?  Do I have to OSGi-enable every library and then manually install each one in the container? 

       

      I realize there are already many common libraries that have already been bundled for OSGi but do I still have to download each one and install manually?

       

      How do I integrate this in my development environment?  I'm using maven (and eclipse).  I've found repositories with the common bundles (notably, springsource) and I've added necessary bundles as dependencies, but I'm not sure what that does for me over regular jars.  Is there a way to automate this whole thing using maven?  I guess I'm having trouble seeing the big picture.

       

      I'm sure these questions have been answered before and this may not be the right forum (my apologies).  But, I figured there were probably people who have dealt with these issues and could point me in the right directory.  Perhaps I need to read an OSGi tutorial?

       

      Thanks much,

       

      -IR

        • 1. Re: Simple SE that uses an external library (using OSGi)
          martinmurphy

          One approach may be to use the JNDI integration. Although I haven't tried this myself.

          Another approach would be just to deploy this as a camel bundle and avoid the JBI classloading issues and instead just import the OSGi packages directly into your bundle.

          • 2. Re: Simple SE that uses an external library (using OSGi)
            ireilly

            Thanks for the response. 

             

            I'm not sure what you mean by "camel bundle".  Is there some where you can point me to learn more about this?  Is there a sample that uses this strategy?

            • 3. Re: Simple SE that uses an external library (using OSGi)
              martinmurphy

              Have a look at the camel-osgi demo, you can see the route defined in Spring:

              examples\camel-osgi\src\main\resources\META-INF\spring\beans.xml

              You could route from the jetty endpoint to your bean and achieve the same thing as you do in the JBI world.

              There's some really good getting started videos here on the site.

               

              Edited by: martinmurphy on Dec 15, 2009 4:06 PM

              • 4. Re: Simple SE that uses an external library (using OSGi)
                ireilly

                I think you may misunderstand what I'm asking.  My problem has to do with packaging and deployment - I just don't get the whole OSGi thing.

                 

                I actually have seen the video page before and in fact, I based my prototype on the ESB Getting Started video.  The problem is, my SE isn't just a simple POJO that takes in and outputs internally defined classes.  I want it to do a lot more, in particular, use Hibernate to persist data.

                 

                How do I bundle that up?  I've done some more looking into the maven felix plugin.  I see that I can declare packages that get exported into the final bundle.  So, do I sit there and try to list all the Hibernate packages, all the packages it depends on, and the packages those packages depend on, etc. eventually ending up with a 20 meg+ bundle that gets deployed to the ESB?  I'm actually not so much worried about the size as I am about having to figure out and list all the dependent packages in the maven-felix plugin.

                 

                Is there some easier way to do this that I am missing?

                • 5. Re: Simple SE that uses an external library (using OSGi)
                  njiang

                  I'm sorry you are trying to get the benefit from OSGi (ServiceMix4) but still using Old JBI (ServiceMix3) package.

                  You can use camel as bundle to route out the Request from JBI layer and leverage Camel-JPA to do the persistence work for your.

                  Here is an example which is coming with Apache Camel 2.2-SNAPSHOT I just managed to deploy it into ServiceMix(Karaf) recently,  you can take a look at the instruction in JIRA and try it in coming up Fuse ESB 4.1.