* @see org.rioproject.servicebean.ServiceBeanContext#getDiscoveryManagement()
*/
public DiscoveryManagement getDiscoveryManagement() throws IOException {
if(serviceDiscoMgmt == null) {
logger.trace("Create DiscoveryManagement for {}/{}", sElem.getOperationalStringName(), sElem.getName());
DiscoveryManagementPool discoPool = DiscoveryManagementPool.getInstance();
String locatorString = System.getProperty(Constants.LOCATOR_PROPERTY_NAME);
List<LookupLocator> locators = new ArrayList<LookupLocator>();
if(sElem.getServiceBeanConfig().getLocators()!=null)
locators.addAll(
Arrays.asList(sElem.getServiceBeanConfig().getLocators()));
if(locatorString!=null) {
LookupLocator[] systemLocators = JiniClient.parseLocators(locatorString);
if(locators.isEmpty()) {
locators.addAll(Arrays.asList(systemLocators));
} else {
List<LookupLocator> toAdd = new ArrayList<LookupLocator>();
for(LookupLocator lookLoc : systemLocators) {
boolean add = true;
for(LookupLocator ll : locators) {
if(ll.equals(lookLoc)) {
add = false;
break;
}
}
if(add)
toAdd.add(lookLoc);
}
for(LookupLocator ll : toAdd)
locators.add(ll);
}
}
LookupLocator[] locatorsToUse = locators.isEmpty()?null:
locators.toArray(new LookupLocator[locators.size()]);
if(sElem.getDiscoveryManagementPooling()) {
serviceDiscoMgmt = discoPool.getDiscoveryManager(getOperationalStringName(),
sElem.getServiceBeanConfig().getGroups(),
locatorsToUse);
} else {
Configuration discoConfig = null;
try {
discoConfig = getConfiguration();
} catch(ConfigurationException e) {
logger.trace("Getting Configuration while creating DiscoveryManagement", e);
}
serviceDiscoMgmt = discoPool.getDiscoveryManager(serviceBeanManager.getServiceID().toString(),
sElem.getServiceBeanConfig().getGroups(),
locatorsToUse,
null,
discoConfig);
}