}
}
if (!started_) {
logger.log(Level.WARNING, "endpointfactory.unavailable");
throw new UnavailableException(
"EndpointFactory is currently not available");
}
MessageEndpoint endpoint = null;
try {
ResourceHandle resourceHandle = allocator_.createResource(xaResource);
MessageBeanListener listener =
messageBeanPM_.createMessageBeanListener(resourceHandle);
//Use the MDB's application classloader to load the
//message listener class. If it is generic listener
//class, it is expected to be packaged with the MDB application
//or in the system classpath.
String moduleID = getDescriptor().getApplication().getModuleID();
Class endpointClass = null;
ClassLoader loader = null;
try {
BundleDescriptor moduleDesc =
getDescriptor().getEjbBundleDescriptor();
loader = moduleDesc.getClassLoader();
} catch (Exception e) {
logger.log(Level.WARNING, "endpointfactory.loader_not_found", e);
}
if (loader == null) {
loader = Thread.currentThread().getContextClassLoader();
}
endpointClass = loader.loadClass(MESSAGE_ENDPOINT);
String msgListenerType = getDescriptor().getMessageListenerType();
if (msgListenerType == null || "".equals(msgListenerType))
msgListenerType = "javax.jms.MessageListener";
Class listenerClass = loader.loadClass(msgListenerType);
MessageEndpointInvocationHandler handler =
new MessageEndpointInvocationHandler(listener, messageBeanPM_);
endpoint = (MessageEndpoint) Proxy.newProxyInstance
(loader, new Class[]{endpointClass, listenerClass}, handler);
} catch (Exception ex) {
throw (UnavailableException)
(new UnavailableException()).initCause(ex);
}
return endpoint;
}