/** * Creates an instance of CMIReferenceable with the given hint. * @param cmiReference a clue given by the Pool. Could be null. * @throws PoolException if instance cannot be created. * @return the created instance. */ 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; }
@SuppressWarnings("unchecked") @Override protected CMIReferenceable<Object> getCMIReferenceable( final CMIReference cmiReference) throws POJOInvocationHandlerException { try { return (CMIReferenceable<Object>) StubOrProxyHelper.download(clusterViewManager, cmiReference); } catch (ProtocolNotFoundException e) { logger.error("Cannot get a CMIReferenceable for " + cmiReference, e); throw new POJOInvocationHandlerException("Cannot get a CMIReferenceable for " + cmiReference, e); } catch (ObjectNotFoundException e) { logger.error("Cannot get a CMIReferenceable for " + cmiReference, e); throw new POJOInvocationHandlerException("Cannot get a CMIReferenceable for " + cmiReference, e); } catch (NamingException e) { logger.debug("No CMIReferenceable is bound for " + cmiReference, e); throw new POJOInvocationHandlerException( "No CMIReferenceable is bound for " + cmiReference, e); } }