public class ApplicationRouterLoader
{
@SuppressWarnings("unchecked")
public static SipApplicationRouter loadApplicationRouter()
{
SipApplicationRouterProvider provider = null;
String providerClass = System.getProperty(SipApplicationRouterProvider.class.getName());
try
{
if (providerClass != null)
{
Class clazz = Loader.loadClass(Server.class, providerClass);
provider = (SipApplicationRouterProvider) clazz.newInstance();
}
}
catch (Exception e)
{
throw new IllegalStateException("Could not load SipApplicationRouterProvider class: " + providerClass, e);
}
if (provider == null)
{
Iterator it = Service.providers(SipApplicationRouterProvider.class);
if (it.hasNext())
provider = (SipApplicationRouterProvider) it.next();
}
if (provider != null)
return provider.getSipApplicationRouter();
else
throw new IllegalStateException("Could not find any application router provider");
}