Class interfaceClass = null;
ClassLoader ejbClassLoader = null;
ClassLoader currentThreadContextClassLoader = null;
try {
if ("".equals(serviceName)) {
throw new ResourceAdapterInternalException(
"A WSDL service QName must be specified as the value of the EJB JNDI name key: "
+ jndiName);
} else {
serviceQName = serviceQNameFromString(serviceName);
serviceQNameFromString(serviceName);
// Get ejbObject
ejb = getEJBObject(jndiName);
ejbClassLoader = ejb.getClass().getClassLoader();
//NOTE we can use the ejbClassLoader to load WSDL
currentThreadContextClassLoader = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(ejbClassLoader);
Thread.currentThread().setContextClassLoader(currentThreadContextClassLoader);
nameSpace = serviceQName.getNamespaceURI();
packageName = PackageUtils.parsePackageName(nameSpace, null);
// Get interface of ejbObject
interfaceName = jndiName.substring(0, jndiName.length() - 4);
interfaceName = packageName + "." + interfaceName;
interfaceClass = Class.forName(interfaceName);
// NOTE We can check the annoation to descide which kind of frontend we will use
// Almostly we just need to use the jax-ws frontend
// If we have wsdl , then wsdl first,
// else code first
servant = publishServantWithoutWSDL(ejb, jndiName, nameSpace, interfaceClass);
}
} catch (Exception e) {
throw new ResourceAdapterInternalException(e.getMessage());
}
synchronized (servantsCache) {
if (servant != null) {
servantsCache.add(servant);
}