ServerConfig config = configManager.getServerConfig(aDestination.getServerId());
if (config == null) {
// no such server, try default config?
}
Class<? extends ServerInstance> instanceClass = getInstanceClass(config);
ServerInstance instance;
try {
instance = instanceClass.newInstance();
} catch (Exception e) {
throw new ConfigurationException("Failed to create server instance. " + e.getMessage(), e);
}
instance.setDestination(aDestination);
return instance;
}