public CMIReferenceable<?> create(final CMIReference cmiReference) throws PoolException {
CMIReferenceable<?> stubOrProxy;
try {
stubOrProxy = StubOrProxyHelper.download(clusterViewManager, cmiReference);
} catch (ProtocolNotFoundException e) {
LOGGER.error("Cannot get a CMIReferenceable for " + cmiReference, e);
throw new PoolException("Cannot get a CMIReferenceable for " + cmiReference, e);
} catch (ObjectNotFoundException e) {
LOGGER.error("Cannot get a CMIReferenceable for " + cmiReference, e);
throw new PoolException("Cannot get a CMIReferenceable for " + cmiReference, e);
} catch (NamingException e) {
LOGGER.debug("No CMIReferenceable is bound for " + cmiReference, e);
throw new NamingPoolException(
"No CMIReferenceable is bound for " + cmiReference, e);
}
if (expectedType != null && !expectedType.isAssignableFrom(stubOrProxy.getReferencedObject().getClass())) {
LOGGER.error("Unexpected type! Required: {0} - Found: {1}",
expectedType.getName(), stubOrProxy.getReferencedObject().getClass().getName());
throw new PoolException("Unexpected type! Required: " + expectedType.getName() + " - Found: "
+ stubOrProxy.getReferencedObject().getClass().getName());
}
LOGGER.debug("Adding a new stub/proxy for {0}: {1}", cmiReference, stubOrProxy);
return stubOrProxy;
}