/** * Gets the type repository used to analyse java classes. * * @return the type supplied type repository, or a default implementation */ public TypeRepository getTypeRepository() { if (typeRepository == null) { typeRepository = new DefaultTypeRepository(getPackageNames(), getExclusions(), getUrlClassLoader()); } return typeRepository; }
protected Set<Class<?>> findTypesAnnotatedWith(Class<? extends Annotation> annotation) { return TypeUtils.findTypesAnnotatedWith(annotation, getTypeRepository().getAllTypes()); }
@Override public void afterFindComponents() { findSupportingTypes(componentsFound); findDependencies(); }
@Override public void beforeFindComponents() { super.beforeFindComponents(); componentFinderStrategies.add(new SpringRestControllerComponentFinderStrategy()); componentFinderStrategies.add(new SpringMvcControllerComponentFinderStrategy()); componentFinderStrategies.add(new SpringServiceComponentFinderStrategy()); componentFinderStrategies.add(new SpringComponentComponentFinderStrategy()); componentFinderStrategies.add(new SpringRepositoryComponentFinderStrategy()); for (AbstractSpringComponentFinderStrategy componentFinderStrategy : componentFinderStrategies) { componentFinderStrategy.setIncludePublicTypesOnly(includePublicTypesOnly); componentFinderStrategy.setComponentFinder(getComponentFinder()); supportingTypesStrategies.forEach(componentFinderStrategy::addSupportingTypesStrategy); componentFinderStrategy.setDuplicateComponentStrategy(getDuplicateComponentStrategy()); componentFinderStrategy.beforeFindComponents(); } }
public StructurizrAnnotationsComponentFinderStrategy() { super(new FirstImplementationOfInterfaceSupportingTypesStrategy()); }
@Override public void beforeFindComponents() { supportingTypesStrategies.forEach(sts -> sts.setTypeRepository(getTypeRepository())); }
private boolean accepts(final Class<?> clazz) { final String type = clazz.getCanonicalName(); if (type != null) { for (final String packageName : getTypeRepository().getPackages()) { if (type.startsWith(packageName)) { return true; } } } return false; }
public void setDuplicateComponentStrategy(DuplicateComponentStrategy duplicateComponentStrategy) { if (duplicateComponentStrategy != null) { this.duplicateComponentStrategy = duplicateComponentStrategy; } else { this.duplicateComponentStrategy = new ThrowExceptionDuplicateComponentStrategy(); } }
@Override protected Set<Component> doFindComponents() { return findInterfacesForImplementationClassesWithAnnotation( org.springframework.stereotype.Component.class, SPRING_COMPONENT ); }
@Override protected Set<Component> doFindComponents() { return findClassesWithAnnotation( org.springframework.ws.server.endpoint.annotation.Endpoint.class, SPRING_WEB_SERVICE_ENDPOINT, includePublicTypesOnly ); }
@Override protected Set<Component> doFindComponents() { return findClassesWithAnnotation( org.springframework.stereotype.Controller.class, SPRING_MVC_CONTROLLER, includePublicTypesOnly ); }
@Override protected Set<Component> doFindComponents() { return findInterfacesForImplementationClassesWithAnnotation( org.springframework.stereotype.Service.class, SPRING_SERVICE ); }
@Override protected Set<Component> doFindComponents() { return findClassesWithAnnotation( org.springframework.web.bind.annotation.RestController.class, SPRING_REST_CONTROLLER, includePublicTypesOnly ); }
protected TypeRepository getTypeRepository() { return componentFinder.getTypeRepository(); }
private Set<Component> findAnnotatedSpringRepositories() { return findInterfacesForImplementationClassesWithAnnotation( org.springframework.stereotype.Repository.class, SPRING_REPOSITORY); }
protected Set<Component> findClassesWithAnnotation(Class<? extends Annotation> type, String technology) { return findClassesWithAnnotation(type, technology, false); }
@Override public Set<Component> findComponents() { componentsFound.addAll(doFindComponents()); return componentsFound; }
@Test(expected = IllegalArgumentException.class) public void test_construction_ThrowsAnExceptionWhenANullRegexAsAPatternIsSupplied() { new RegexTypeMatcher((Pattern)null, "", ""); }
@Test(expected = IllegalArgumentException.class) public void test_construction_ThrowsAnExceptionWhenANullAnnotationClassIsSupplied() { new AnnotationTypeMatcher(null, "", ""); }
@Test(expected = IllegalArgumentException.class) public void test_construction_ThrowsAnExceptionWhenAnInterfaceTypeIsSupplied() { new ExtendsClassTypeMatcher(MyRepository.class, "", ""); }