Hello world
This commit is contained in:
7
MyFirstBundle/bnd.bnd
Normal file
7
MyFirstBundle/bnd.bnd
Normal file
@@ -0,0 +1,7 @@
|
||||
Bundle-Version: 1.0.0
|
||||
Private-Package: MyFirstBundle
|
||||
|
||||
-buildfeatures:
|
||||
-buildpath:
|
||||
|
||||
Bundle-Activator: MyFirstBundle.Activator
|
||||
28
MyFirstBundle/src/MyFirstBundle/Activator.java
Normal file
28
MyFirstBundle/src/MyFirstBundle/Activator.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package MyFirstBundle;
|
||||
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
|
||||
public class Activator implements BundleActivator {
|
||||
private Thread thread;
|
||||
|
||||
@Override
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
thread = new Thread(() -> {
|
||||
try {
|
||||
while (true) {
|
||||
System.out.println("Hello!");
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("MyFirstBundle stopped");
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
thread.interrupt();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user