Created
May 1, 2017 18:40
-
-
Save dileeph/8c199c24546b62eafcbd1cc592ce1df2 to your computer and use it in GitHub Desktop.
osgi hello 1 based on felix tutorial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void serviceChanged(ServiceEvent event) { | |
String[] objectClass = (String[]) | |
event.getServiceReference().getProperty("objectClass"); | |
if (event.getType() == ServiceEvent.REGISTERED) | |
{ | |
System.out.println( | |
"Ex1: Service of type " + objectClass[0] + " registered."); | |
} | |
else if (event.getType() == ServiceEvent.UNREGISTERING) | |
{ | |
System.out.println( | |
"Ex1: Service of type " + objectClass[0] + " unregistered."); | |
} | |
else if (event.getType() == ServiceEvent.MODIFIED) | |
{ | |
System.out.println( | |
"Ex1: Service of type " + objectClass[0] + " modified."); | |
} | |
} | |
public void start(BundleContext context) throws Exception { | |
System.out.println("Starting to listen for service events."); | |
context.addServiceListener(this); | |
} | |
public void stop(BundleContext context) throws Exception { | |
context.removeServiceListener(this); | |
System.out.println("Stopped listening for service events."); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment