Skip to content

Instantly share code, notes, and snippets.

@tcalmant
Last active March 17, 2017 09:39
Show Gist options
  • Save tcalmant/eca99b386199d57a0546 to your computer and use it in GitHub Desktop.
Save tcalmant/eca99b386199d57a0546 to your computer and use it in GitHub Desktop.
Minimalist OSGi activator
package hello.impl;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator {
public void start(BundleContext context) throws Exception {
// TODO Auto-generated method stub
System.out.println("start");
}
public void stop(BundleContext context) throws Exception {
// TODO Auto-generated method stub
System.out.println("Stop");
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>hello</groupId>
<artifactId>hello.api</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>bundle</packaging>
<build>
<plugins>
<!-- Felix bundle plugin -->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.5.3</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>${project.name}</Bundle-Name>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>
hello.api;version="1.0.0"
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment