Results 1 to 4 of 4

Thread: How i get applicationContext in my bundle?

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    12

    Default How i get applicationContext in my bundle?

    I have two bundles. In first bundle i declare sevice:

    <osgi:service id="applicationManagerOsgi" ref="applicationManager"
    interface="com.icl.ios.dispcore.architecture.Appli cationManager"/>

    <bean id="applicationManager"
    class="com.icl.ios.dispcore.architecture.Applicati onManagerImpl"/>

    In second bundle i get reference on this service:

    <osgi:reference id="applicationManager"
    interface="com.icl.ios.dispcore.architecture.Appli cationManager"/>

    I need using this service in second bundle in code. How i get this service? In simple spring it's simple:

    applicationContext.getBean("applicationManager");

  2. #2
    Join Date
    Oct 2008
    Posts
    12

    Default

    Can I use BeanFactoryAware in Spring DM + OSGI to get BeanFactory and then to get beans?

  3. #3
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    For beans running inside an application context, just use the BeanFactory/ApplicationContextAware interfaces. For objects in other bundles, look for the ApplicationContext as an OSGi service - any Spring DM app is (by default) exported as an OSGi service.
    Of course, it's even easier to inject the application context as a simple service inside your other bundle, assuming that other bundle uses Spring DM as well.
    However, normally you don't need to do this since it's considerably easier to just export the beans as services rather then the appCtx themselves.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #4
    Join Date
    Oct 2008
    Posts
    12

    Default

    Thanks for explanation! It's worked!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •