How to find out org.springframework version used by UPM

I’m guessing that the reason that the tutorial references the osgi framework is for the DisposableBean and InitializingBean pieces.

You can skip those though and just use the LifecycleAware interface from SAL (much nicer :slight_smile: ). Just do a dependency on sal api in your pom:

 <dependency>
            <groupId>com.atlassian.sal</groupId>
            <artifactId>sal-api</artifactId>
            <version>3.0.0</version>
            <scope>provided</scope>
        </dependency>

Then in your code:


public class MyEventListener  implements LifecycleAware
{
    private final EventPublisher eventPublisher;

    public WittifiedSchedulerStartup( final EventPublisher eventPublisher)
    {
        this.eventPublisher = eventPublisher;
    }

    
    @Override
    public void onStart()
    {
        eventPublisher.register(this);

    }

    @Override
    public void onStop()
	{
        eventPublisher.unregister(this);
    }



    @EventListener
    public void someEventFunction(MyEvent event)
    {
// do stuff ....
    }

}

2 Likes