}
private ServiceHandle getServiceHandle(Object o, List<String> watches, Entry[] entries) {
ServiceHandle handle = new ServiceHandle();
if(o instanceof Service) {
Service s = (Service)o;
try {
ServiceElement elem = ((ServiceAdmin)s.getAdmin()).getServiceElement();
OperationalStringManager opMgr = ((DeployAdmin)monitor.getAdmin()).getOperationalStringManager(elem.getOperationalStringName());
handle.setElem(elem);
handle.setOpMgr(opMgr);
for(String watch : watches) {
try {
WatchDataSource wds = s.fetch(watch);
logger.debug("WatchDataSource for watch [{}]: {}", watch, wds);
if(wds==null)
continue;
handle.addToWatchMap(watch, wds);
ThresholdValues tVals = wds.getThresholdValues();
if(tVals instanceof SLA) {
handle.addToSLAMap(watch, (SLA)tVals);
}
} catch (RemoteException e) {
logger.warn("Could not add AssociationsWatchDataReplicator to remote WatchDataSource.", e);
}
}
} catch (RemoteException e) {
handle = null;
logger.warn("Could not get ServiceElement or OperationalStringManager.", e);
} catch (OperationalStringException e) {
handle = null;
logger.error("Could not get OperationalStringManager, unable to create AssociationsWatchDataReplicator.",
e);
}
} else {
String opStringName = null;
for(Entry e : entries) {
if(e instanceof OperationalStringEntry) {
opStringName = ((OperationalStringEntry)e).name;
break;
}
}
logger.info("OperationalString for service: [{}]", opStringName);
if(opStringName!=null) {
try {
OperationalStringManager opMgr = ((DeployAdmin)monitor.getAdmin()).getOperationalStringManager(opStringName);
ServiceElement elem = opMgr.getServiceElement(o);
if(elem==null) {
logger.warn("Unable to obtain ServiceElement for service [{}], cannot create AssociationsWatchDataReplicator.",
o.toString());
return null;
}
handle.setElem(elem);
handle.setOpMgr(opMgr);
Cybernode c = null;
for(ServiceBeanInstance sbi : opMgr.getServiceBeanInstances(elem)) {
if(o.equals(sbi.getService())) {
elem.setServiceBeanConfig(sbi.getServiceBeanConfig());
Uuid uuid = sbi.getServiceBeanInstantiatorID();
for(ServiceBeanInstantiator s : monitor.getServiceBeanInstantiators()) {
if(uuid.equals(s.getInstantiatorUuid())) {
c = (Cybernode)s;
break;
}
}
}