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