Radio example implementation

This commit is contained in:
2021-09-28 15:35:56 +02:00
parent 9cdbb84076
commit 2ad5deac3e
26 changed files with 318 additions and 0 deletions

7
speaker/bnd.bnd Normal file
View File

@@ -0,0 +1,7 @@
Bundle-Version: 1.0.0
Private-Package: speaker
Bundle-Activator: speaker.Speaker
-buildfeatures:
-buildpath: \
outputapi;version=latest

View File

@@ -0,0 +1,25 @@
package speaker;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import outputapi.Output;
import java.util.Dictionary;
import java.util.Hashtable;
public class Speaker implements BundleActivator {
private ServiceRegistration registration;
@Override
public void start(BundleContext context) throws Exception {
Dictionary<String, Object> props = new Hashtable<>();
props.put("type", "Speaker");
registration = context.registerService( Output.class, new SpeakerOutput(), props);
}
@Override
public void stop(BundleContext context) throws Exception {
registration.unregister();
}
}

View File

@@ -0,0 +1,10 @@
package speaker;
import outputapi.Output;
public class SpeakerOutput implements Output {
@Override
public void write(String sound) {
System.out.println(sound);
}
}