/** * Returns a policy to access to the object with the given name. * @param objectName a name of object * @return a policy to access to the object with the given name * @throws PolicyFactoryException if the policy cannot be constructed * @throws ObjectNotFoundException if none object has the given name */ @SuppressWarnings("unchecked") public IPolicy<T> getPolicy(final String objectName) throws PolicyFactoryException, ObjectNotFoundException { Class<? extends IPolicy<T>> policyClass; try { policyClass = (Class<? extends IPolicy<T>>) clusterViewManager.getPolicyClass(objectName); } catch (ClusterViewManagerException e) { LOGGER.error("Error while finding the policy class", e); throw new PolicyFactoryException("Error while finding the policy class", e); } Map<String, Object> properties = clusterViewManager.getPropertiesForPolicy(objectName); Class<? extends IStrategy<T>> strategyClass; try { strategyClass = (Class<? extends IStrategy<T>>) clusterViewManager.getStrategyClass(objectName); } catch (ClusterViewManagerException e) { LOGGER.error("Error while finding the strategy class", e); throw new PolicyFactoryException("Error while finding the strategy class", e); } return getPolicy(policyClass, strategyClass, properties); }