@Test public void testLoadExternalClassShouldBeRegisteredToApplicationContext() throws ClassNotFoundException { given(beanRegistryService.getBean(SIMPLE_CLASS_NAME, TemplateGenerator.class)).willThrow(new NoSuchBeanDefinitionException("")); given(classFactory.getClassToLoad(CLASS)).willReturn(Object.class); ignoreInterfaceTypeValidation(); underTest.loadExternalClass(SIMPLE_CLASS_NAME, PATH, TemplateGenerator.class); verify(beanRegistryService).register(eq(SIMPLE_CLASS_NAME), any(Object.class)); verify(classNameMapper).get(SIMPLE_CLASS_NAME); }
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);  }