return ht;
}
public static long getBundleId(String symbolicName, AgentContext ac) throws BundleNotAvailableException{
if(symbolicName==null) throw new IllegalArgumentException("Symbolic name cannot be null");
String [] s=symbolicName.split(";");
if(s==null||s.length==0) throw new BundleNotAvailableException("Could not find bundle identified by "+symbolicName);
Bundle[] bundles=ac.getBundleContext().getBundles();
long id=-1;
Vector candidates=new Vector();
for(int i=0;i<bundles.length;i++) {
//First find all bundles with symbolicName
String name=bundles[i].getSymbolicName();
if(name==null) continue;
if (s[0].equals(name)){
candidates.add(new Long(bundles[i].getBundleId()));
}
}
//now search the one that matches the version
for(int i=0; i< candidates.size();i++){
long cId=((Long)candidates.elementAt(i)).longValue();
Bundle c=ac.getBundleContext().getBundle(cId);
String version=(String)c.getHeaders().get(Constants.BUNDLE_VERSION);
if(s.length==1){//no version available
ac.debug("no version available for "+symbolicName);
if(candidates.size()>1) throw new BundleNotAvailableException("could not distinguish among multiple candidates");
if(candidates.size()==1) {
id=cId;
break;
}
}
if (version.equals(s[1])) id=cId;
}
if(id==-1) throw new BundleNotAvailableException("No " + symbolicName+ "installed");
return id;
}