public EJBHome getEjbHome() throws WSIFException {
Trc.entry(this);
if (fieldEjbHome == null) {
EJBAddress address = null;
try {
ExtensibilityElement portExtension =
(ExtensibilityElement) fieldPortModel.getExtensibilityElements().get(0);
if (portExtension == null) {
throw new WSIFException("missing port extension");
}
address = (EJBAddress) portExtension;
Hashtable hash = new Hashtable();
// If the initial context factory is specified in the wsdl use it
String icf = address.getInitialContextFactory();
if (icf != null) {
hash.put(InitialContext.INITIAL_CONTEXT_FACTORY, icf);
}
// If the jndi provider url is specified in the wsdl use it
String providerURL = address.getJndiProviderURL();
if (providerURL != null) {
hash.put(InitialContext.PROVIDER_URL, providerURL);
}
// Lookup from an authoritative source
hash.put(InitialContext.AUTHORITATIVE, "true");
InitialContext initContext;
initContext = new InitialContext(hash);
Class homeClass = null;
try {
if (address.getClassName() != null) {
homeClass =
Class.forName(
address.getClassName(),
true,
Thread.currentThread().getContextClassLoader());
if (!(EJBHome.class.isAssignableFrom(homeClass))) {
homeClass = null;
}
}
} catch (ClassNotFoundException cnf) {
Trc.ignoredException(cnf);
}
if (homeClass != null) {
fieldEjbHome = (EJBHome) PortableRemoteObject.narrow(initContext.lookup(address.getJndiName()),homeClass);
} else {
fieldEjbHome = (EJBHome) initContext.lookup(address.getJndiName());
}
} catch (Exception ex) {
Trc.exception(ex);
throw new WSIFException(
"Failed to lookup EJB home using JNDI name '" + address.getJndiName() + "'",
ex);
}
}
Trc.exit(fieldEjbHome);
return fieldEjbHome;