Announcement Announcement Module
Collapse

Spring Dynamic Modules forum decommissioned in favor of Eclipse Gemini Blueprint

With the official first release of Eclipse Gemini Blueprint shipped, the migration of the Spring Dynamic Modules code base to the Eclipse Foundation, as part of the Gemini project, has been completed.

As such, this forum has been decommissioned in favour of the Eclipse Gemini forums.
See more
See less
OSGI Service + init-method + exception Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • OSGI Service + init-method + exception

    I have a question on better way to avoid a bundle to start when starting services throw an exception.

    I have a bean and a service declare as :
    Code:
    	<bean id="vaultService" class="com.sample.confiance.vault.impl.VaultServiceImpl">
    		<property name="halService" ref="halService"/>
    	</bean>
          
            <osgi:service id="VaultOsgiService" ref="vaultService"
                 interface="com.sample.confiance.vault.VaultService"
                 init-method="start"/>
    When in OSGI a BundleActivator.start() method throw an exception, the bundle refuse to start and come back to resolved state.
    If my vaultService.start method throw an exception, bundle start anyway, ans my service is in an inconsistant state. Is there a way, my bundle don't start if start method throw an exception ?

    Thanks for your reply

  • #2
    Hi,

    the Spring DM/Blueprint extender cannot prevent a bundle from starting by throwing an exception in the BundleListener's bundleChanged method. That means, you might want to look for another way to guarantee a consistent state of your services whatsoever.

    Greetings,
    André

    Comment


    • #3
      Yes, you could attach OsgiBundleApplicationContextListener in you bundle activator, which gets an event about your context state.

      Or you could implement BundleContextAware interface in your bean and when you got an exception, just stop your bundle.

      Comment

      Working...
      X