URL url = new URL(_jndiName);
jndiConn = url.openConnection();
_homeInstance = jndiConn.getContent();
}
catch (MalformedURLException mue) {
throw new ControlException(_jndiName + " is not a valid JNDI URL", mue);
}
catch (IOException ioe) {
throw new ControlException("Error during JNDI lookup from " + _jndiName, ioe);
}
}
else {
try {
javax.naming.Context ctx = getInitialContext();
_homeInstance = ctx.lookup(_jndiName);
}
catch (Exception ne) {
throw new ControlException("Error during JNDI lookup from " + _jndiName, ne);
}
}
if (!_homeInterface.isAssignableFrom(_homeInstance.getClass())) {
throw new ControlException("JNDI lookup of " + _jndiName + " failed to return an instance of " + _homeInterface);
}
}
}