Skip to content

Instantly share code, notes, and snippets.

@dileeph
Created May 23, 2017 01:19
Show Gist options
  • Save dileeph/6451f0222c35481f59a0443fdf6d1321 to your computer and use it in GitHub Desktop.
Save dileeph/6451f0222c35481f59a0443fdf6d1321 to your computer and use it in GitHub Desktop.
/**
* Policy client class.
* @author Dileep Hareendran
*
*/
public class PolicyServiceClient {
private Set<PolicyService> services = new HashSet<PolicyService>();
/**
* Hook method called on activation of this service client.
* @param context BundleContext
*/
public void activate(BundleContext context){
System.out.println("activating " + context.getBundle().getSymbolicName());
for(PolicyService service: services){
System.out.println("Service" + service.getName() + " registered");
}
}
/**
* Hook method called on deactivation of this service client.
* @param context BundleContext
*/
public void deactivate(BundleContext context){
System.out.println("deactivating " + context.getBundle().getSymbolicName());
}
/**
* Called to inject a dependency service on service binding
* @param service PolicyService
*/
public void addPolicyService(PolicyService service){
services.add(service);
}
/**
* Called to unset a dependency service while unloading.
* @param service PolicyService
*/
public void removePolicyService(PolicyService service){
if(services.contains(service)){
services.remove(service);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment