Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dileeph/a43635b6d1d607b736e7f85b3e043885 to your computer and use it in GitHub Desktop.
Save dileeph/a43635b6d1d607b736e7f85b3e043885 to your computer and use it in GitHub Desktop.
osgi client activator
public void start(BundleContext context) throws Exception {
System.out.println("start simple policy client");
ServiceReference[] serviceReferences = context.getServiceReferences(PolicyService.class.getName(), "(Insurer=*)");
if(serviceReferences != null && serviceReferences.length > 0){
for(int i =0; i < serviceReferences.length; i++){
PolicyService policyService = (PolicyService)context.getService(serviceReferences[i]);
System.out.println("Trying to find the services");
if(policyService.verifyPolicy("1212")){
System.out.println("Insurer A got bound at " + i);
}else if(policyService.verifyPolicy("abab")){
System.out.println("Insurer B got bound at " + i);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment