@Test public void testLoadExternalClassShouldReturnTheClassWhenAlreadyInApplicationContexg() throws ClassNotFoundException { TemplateGenerator generator = new DummyGenerator(); given(beanRegistryService.getBean(SIMPLE_CLASS_NAME, TemplateGenerator.class)).willReturn(generator); TemplateGenerator actual = underTest.loadExternalClass(CLASS, PATH, TemplateGenerator.class); assertEquals(actual, generator); }
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; }
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; } }
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; }  }
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; }  T loadExternalClass(final String externalClassName, final String classPath, final Class<T> interfaceToCast); }
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; }  T loadExternalClass(final String externalClassName, final String classPath, final Class<T> interfaceToCast);  }