Search code examples
javaapache-karafkaraf-maven-pluginapache-karaf-feature

How to make Karaf server run code before bundles


I have file in Karaf server which is deleted after some time I don't know why. So I decide to run code to create the file before running the bundles that depends on it.

is that possible?

I have the code but I don't know where I can put it to run before bundle.

Some code to help saving my data source file before any bundles


Solution

  • For people who are struggling here is my founding solution implements BundleActivator and refrence it in pom as

    <Bundle-Activator>org.ogra.bundle1.Activator</Bundle-Activator>
    

    Refrence: https://medium.com/@udayogra/write-simple-karaf-osgi-bundles-which-interact-with-each-other-in-eclipse-in-10-minutes-46c1bed0b460