String className = resource.getServer().getImplementationClass();
Class clazz;
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException exception) {
throw new ServiceException("Failed to load class " + className);
}
if (!ServerConnector.class.isAssignableFrom(clazz)) {
throw new ServiceException(
"Class " + className
+ " does not implement ServerConnector");
}
try {
SchemeType scheme = connector.getScheme();
Constructor ctor = clazz.getConstructor(new Class[]{
SchemeType.class, Configuration.class,
Authenticator.class, ServerConnectionFactory.class,
AdminConnectionManager.class, NameService.class,
ThreadPoolFactory.class});
server = (ServerConnector) ctor.newInstance(new Object[]{
scheme, _config, _authenticator, _factory, _manager, _names,
_threads});
} catch (NoSuchMethodException ignore) {
// fall back to the default constructor
try {
server = (ServerConnector) clazz.newInstance();
} catch (Exception exception) {
throw new ServiceException(exception.getMessage(), exception);
}
} catch (Exception exception) {
throw new ServiceException(exception.getMessage(), exception);
}
_log.debug("Created an instance of " + className
+ " as a server interface");