use of org.moduliths.model.Modules in project moduliths by moduliths.
the class Documenter method addComponentsToView.
private void addComponentsToView(Supplier<Stream<Module>> modules, ComponentView view, Options options, Consumer<ComponentView> afterCleanup) {
Styles styles = view.getViewSet().getConfiguration().getStyles();
Map<Module, Component> components = getComponents(options);
//
modules.get().distinct().filter(//
options.getExclusions().negate()).map(//
it -> applyBackgroundColor(it, components, options, styles)).filter(//
options.getComponentFilter()).forEach(view::add);
// view.getViewSet().getConfiguration().getStyles().findElementStyle(element).getBackground()
// Remove filtered dependency types
//
DependencyType.allBut(options.getDependencyTypes()).map(//
Object::toString).forEach(it -> view.removeRelationshipsWithTag(it));
afterCleanup.accept(view);
// Filter outgoing relationships of target-only modules
//
modules.get().filter(options.getTargetOnly()).forEach(module -> {
Component component = components.get(module);
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).filter(//
it -> it.getSource().equals(component)).forEach(it -> view.remove(it));
});
// … as well as all elements left without a relationship
if (options.hideElementsWithoutRelationships()) {
view.removeElementsWithNoRelationships();
}
afterCleanup.accept(view);
// Remove default relationships if more qualified ones exist
//
view.getRelationships().stream().map(//
RelationshipView::getRelationship).collect(//
Collectors.groupingBy(Connection::of)).values().stream().forEach(it -> potentiallyRemoveDefaultRelationship(view, it));
}
use of org.moduliths.model.Modules in project moduliths by moduliths.
the class Documenter method addDependencies.
private void addDependencies(Module module, Component component, Options options) {
DEPENDENCY_DESCRIPTIONS.entrySet().stream().forEach(entry -> {
//
module.getDependencies(modules, entry.getKey()).stream().map(//
it -> getComponents(options).get(it)).forEach(it -> {
Relationship relationship = component.uses(it, entry.getValue());
relationship.addTags(entry.getKey().toString());
});
});
//
module.getBootstrapDependencies(modules).forEach(it -> {
Relationship relationship = component.uses(getComponents(options).get(it), "uses");
relationship.addTags(DependencyType.USES_COMPONENT.toString());
});
}
use of org.moduliths.model.Modules in project moduliths by moduliths.
the class ModuleTracingBeanPostProcessor method postProcessAfterInitialization.
/*
* (non-Javadoc)
* @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object, java.lang.String)
*/
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
Class<?> type = getBeanUserClass(bean, beanName);
if (!runtime.isApplicationClass(type) || !type.isInstance(bean)) {
return bean;
}
Modules modules = getModules();
return modules.getModuleByType(type.getName()).map(DefaultObservedModule::new).map(it -> {
ObservedModuleType moduleType = it.getObservedModuleType(type, modules);
return //
moduleType != null ? //
addAdvisor(bean, getOrBuildAdvisor(it, moduleType)) : bean;
}).orElse(bean);
}
use of org.moduliths.model.Modules in project moduliths by moduliths.
the class FieldInjectedIntegrationTest method rejectsFieldInjection.
// #52
@Test
void rejectsFieldInjection() {
Modules modules = execution.getModules();
//
assertThat(execution.getModule().detectDependencies(modules)).hasMessageContaining(//
"field injection").hasMessageContaining(// offending field
"WithFieldInjection.a");
}
Aggregations