Radio example implementation
This commit is contained in:
7
speaker/bnd.bnd
Normal file
7
speaker/bnd.bnd
Normal file
@@ -0,0 +1,7 @@
|
||||
Bundle-Version: 1.0.0
|
||||
Private-Package: speaker
|
||||
Bundle-Activator: speaker.Speaker
|
||||
|
||||
-buildfeatures:
|
||||
-buildpath: \
|
||||
outputapi;version=latest
|
||||
25
speaker/src/speaker/Speaker.java
Normal file
25
speaker/src/speaker/Speaker.java
Normal 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();
|
||||
}
|
||||
}
|
||||
10
speaker/src/speaker/SpeakerOutput.java
Normal file
10
speaker/src/speaker/SpeakerOutput.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user