class ExternalJarClassInitializer {

    public <T> T loadExternalClass(final String packageName, final String jarFolderPath, final Class<T> interfaceToCast) {
        String beanName = createBeanName(packageName, interfaceToCast);
        T result;
        try {
            result = beanRegistryService.getBean(beanName, interfaceToCast);
            logger.info(GOT_BEAN_TEMPLATE, beanName, result.getClass().getName(), interfaceToCast);
        } catch (BeansException e) {
            logger.debug(String.format("Finding bean with name '%s' of type '%s' failed", beanName, interfaceToCast), e);
            result = initializeFromJars(packageName, jarFolderPath, interfaceToCast);
            beanRegistryService.register(beanName, result);
        }

        return result;
    }

}