Radio example implementation
This commit is contained in:
7
Radio538/bnd.bnd
Normal file
7
Radio538/bnd.bnd
Normal file
@@ -0,0 +1,7 @@
|
||||
Bundle-Version: 1.0.0
|
||||
Private-Package: Radio538
|
||||
Bundle-Activator: Radio538.Radio538
|
||||
|
||||
-buildfeatures:
|
||||
-buildpath: \
|
||||
channelapi;version=latest
|
||||
26
Radio538/src/Radio538/Radio538.java
Normal file
26
Radio538/src/Radio538/Radio538.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package Radio538;
|
||||
|
||||
import channelapi.Channel;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
|
||||
import java.util.Dictionary;
|
||||
import java.util.Hashtable;
|
||||
|
||||
public class Radio538 implements BundleActivator {
|
||||
|
||||
private ServiceRegistration registration;
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
Dictionary<String, Object> props = new Hashtable<>();
|
||||
props.put("name", "Radio 538");
|
||||
registration = context.registerService( Channel.class, new Radio538Channel(), props);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
registration.unregister();
|
||||
}
|
||||
}
|
||||
12
Radio538/src/Radio538/Radio538Channel.java
Normal file
12
Radio538/src/Radio538/Radio538Channel.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package Radio538;
|
||||
|
||||
import channelapi.Channel;
|
||||
import channelapi.Stream;
|
||||
|
||||
public class Radio538Channel implements Channel {
|
||||
private Stream stream = new Radio538Stream();
|
||||
@Override
|
||||
public Stream getStream() {
|
||||
return stream;
|
||||
}
|
||||
}
|
||||
10
Radio538/src/Radio538/Radio538Stream.java
Normal file
10
Radio538/src/Radio538/Radio538Stream.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package Radio538;
|
||||
|
||||
import channelapi.Stream;
|
||||
|
||||
public class Radio538Stream implements Stream {
|
||||
@Override
|
||||
public String read() {
|
||||
return "Radio 538";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user