class ExternalClassInitializer {

    public <T> T loadExternalClass(final String externalClassName, final String classPath, final Class<T> interfaceToCast) {
        String simpleName = getSimpleName(externalClassName);
        T result;
        try {
            result = findBean(interfaceToCast, simpleName);
        } catch (BeansException ex) {
            LOGGER.debug(String.format("Finding class with name '%s' of type '%s' as a bean failed", simpleName, interfaceToCast), ex);
            String fullClassName = classNameMapper.get(externalClassName);
            result = initializeBean(fullClassName, classPath, interfaceToCast, simpleName);
        }
        return result;
    }

}