Skip to content

Instantly share code, notes, and snippets.

@dileeph
Created May 22, 2017 20:43
Show Gist options
  • Save dileeph/61e13152fe458efc83d993d3ad4b5355 to your computer and use it in GitHub Desktop.
Save dileeph/61e13152fe458efc83d993d3ad4b5355 to your computer and use it in GitHub Desktop.
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 " + policyService.getName() +" got bound at " + i);
}else if(policyService.verifyPolicy("abab")){
System.out.println("Insurer B " + policyService.getName() +" got bound at " + i);
}else{
System.out.println("There was another service provider" + policyService.getName());
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment