Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed Old Dev UI: Arc #34971

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions extensions/arc/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-context-propagation-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-console-spi</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-vertx-http-dev-ui-spi</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.quarkus.arc.deployment.devui;

import io.quarkus.arc.deployment.devconsole.DevBeanInfos;
import io.quarkus.builder.item.SimpleBuildItem;

public final class ArcBeanInfoBuildItem extends SimpleBuildItem {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.arc.deployment.devconsole;
package io.quarkus.arc.deployment.devui;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -10,15 +10,8 @@
import java.util.Set;
import java.util.stream.Collectors;

import io.quarkus.arc.deployment.AdditionalBeanBuildItem;
import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem;
import io.quarkus.arc.deployment.ArcConfig;
import io.quarkus.arc.deployment.BeanDefiningAnnotationBuildItem;
import io.quarkus.arc.deployment.CompletedApplicationClassPredicateBuildItem;
import io.quarkus.arc.deployment.CustomScopeAnnotationsBuildItem;
import io.quarkus.arc.deployment.ValidationPhaseBuildItem;
import io.quarkus.arc.deployment.devconsole.DependencyGraph.Link;
import io.quarkus.arc.deployment.devui.ArcBeanInfoBuildItem;
import io.quarkus.arc.processor.BeanDeploymentValidator;
import io.quarkus.arc.processor.BeanDeploymentValidator.ValidationContext;
import io.quarkus.arc.processor.BeanInfo;
Expand All @@ -28,53 +21,16 @@
import io.quarkus.arc.processor.InjectionPointInfo;
import io.quarkus.arc.processor.InterceptorInfo;
import io.quarkus.arc.processor.ObserverInfo;
import io.quarkus.arc.runtime.ArcContainerSupplier;
import io.quarkus.arc.runtime.ArcRecorder;
import io.quarkus.arc.runtime.BeanLookupSupplier;
import io.quarkus.arc.runtime.devconsole.InvocationsMonitor;
import io.quarkus.arc.runtime.devmode.EventsMonitor;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.dev.console.DevConsoleManager;
import io.quarkus.devconsole.spi.DevConsoleRouteBuildItem;
import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem;
import io.quarkus.devconsole.spi.DevConsoleTemplateInfoBuildItem;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

public class ArcDevConsoleProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
@Record(ExecutionTime.STATIC_INIT)
public DevConsoleRuntimeTemplateInfoBuildItem exposeArcContainer(ArcRecorder recorder,
CurateOutcomeBuildItem curateOutcomeBuildItem) {
return new DevConsoleRuntimeTemplateInfoBuildItem("arcContainer",
new ArcContainerSupplier(), this.getClass(), curateOutcomeBuildItem);
}

@BuildStep(onlyIf = IsDevelopment.class)
void monitor(ArcConfig config, BuildProducer<DevConsoleRuntimeTemplateInfoBuildItem> runtimeInfos,
BuildProducer<AdditionalBeanBuildItem> beans, BuildProducer<AnnotationsTransformerBuildItem> annotationTransformers,
CustomScopeAnnotationsBuildItem customScopes,
List<BeanDefiningAnnotationBuildItem> beanDefiningAnnotations, CurateOutcomeBuildItem curateOutcomeBuildItem) {
if (!config.devMode.monitoringEnabled) {
return;
}
runtimeInfos.produce(
new DevConsoleRuntimeTemplateInfoBuildItem("eventsMonitor",
new BeanLookupSupplier(EventsMonitor.class), this.getClass(), curateOutcomeBuildItem));
runtimeInfos.produce(new DevConsoleRuntimeTemplateInfoBuildItem("invocationsMonitor",
new BeanLookupSupplier(InvocationsMonitor.class), this.getClass(), curateOutcomeBuildItem));
}
public class ArcDevModeApiProcessor {

@BuildStep(onlyIf = IsDevelopment.class)
public void collectBeanInfo(ValidationPhaseBuildItem validationPhaseBuildItem,
CompletedApplicationClassPredicateBuildItem predicate, BuildProducer<DevConsoleTemplateInfoBuildItem> templates,
BuildProducer<DevConsoleRouteBuildItem> routes,
CompletedApplicationClassPredicateBuildItem predicate,
BuildProducer<ArcBeanInfoBuildItem> arcBeanInfoProducer) {
BeanDeploymentValidator.ValidationContext validationContext = validationPhaseBuildItem.getContext();
DevBeanInfos beanInfos = new DevBeanInfos();
Expand Down Expand Up @@ -137,60 +93,13 @@ public void collectBeanInfo(ValidationPhaseBuildItem validationPhaseBuildItem,
.collect(Collectors.toList()));
}
// Set the global that could be used at runtime when generating the json payload for /q/arc/beans
DevConsoleManager.setGlobal(BEAN_DEPENDENCIES, beanDependenciesMap);
DevConsoleManager.setGlobal(DevBeanInfos.BEAN_DEPENDENCIES, beanDependenciesMap);

beanInfos.sort();
templates.produce(new DevConsoleTemplateInfoBuildItem("devBeanInfos", beanInfos));

arcBeanInfoProducer.produce(new ArcBeanInfoBuildItem(beanInfos));

routes.produce(new DevConsoleRouteBuildItem("toggleBeanDescription", "POST", new Handler<RoutingContext>() {
@Override
public void handle(RoutingContext context) {
Object val = DevConsoleManager.getGlobal(BEAN_DESCRIPTION);
if (val != null && val.equals("simple")) {
val = "full";
} else {
val = "simple";
}
DevConsoleManager.setGlobal(BEAN_DESCRIPTION, val);
context.response()
.putHeader("location", "beanDependencyGraph?beanId=" + context.request().getParam("beanId"))
.setStatusCode(302).end();
}
}));

routes.produce(new DevConsoleRouteBuildItem("setMaxDependencyLevel", "POST", new Handler<RoutingContext>() {
@Override
public void handle(RoutingContext context) {
context.request().setExpectMultipart(true);
context.request().endHandler(new Handler<Void>() {
@Override
public void handle(Void ignore) {
Integer val = null;
try {
val = Integer.parseInt(context.request().getFormAttribute("maxDepLevel"));
} catch (NumberFormatException ignored) {
}
if (val != null) {
DevConsoleManager.setGlobal(MAX_DEPENDENCY_LEVEL, val);
}
context.response()
.putHeader("location", "beanDependencyGraph?beanId=" + context.request().getParam("beanId"))
.setStatusCode(302).end();
}
});

}
}));
}

static final String BEAN_DESCRIPTION = "io.quarkus.arc.beanDescription";
static final String MAX_DEPENDENCY_LEVEL = "io.quarkus.arc.maxDependencyLevel";
public static final String BEAN_DEPENDENCIES = "io.quarkus.arc.beanDependencies";

static final int DEFAULT_MAX_DEPENDENCY_LEVEL = 10;

DependencyGraph buildDependencyGraph(BeanInfo bean, ValidationContext validationContext, BeanResolver resolver,
DevBeanInfos devBeanInfos, List<InjectionPointInfo> allInjectionPoints,
Map<BeanInfo, List<BeanInfo>> declaringToProducers,
Expand All @@ -203,7 +112,7 @@ DependencyGraph buildDependencyGraph(BeanInfo bean, ValidationContext validation
return new DependencyGraph(nodes, links);
}

void addNodesDependencies(int level, BeanInfo root, Set<DevBeanInfo> nodes, Set<Link> links, BeanInfo bean,
private void addNodesDependencies(int level, BeanInfo root, Set<DevBeanInfo> nodes, Set<Link> links, BeanInfo bean,
DevBeanInfos devBeanInfos) {
if (nodes.add(devBeanInfos.getBean(bean.getIdentifier()))) {
if (bean.isProducerField() || bean.isProducerMethod()) {
Expand All @@ -221,7 +130,7 @@ void addNodesDependencies(int level, BeanInfo root, Set<DevBeanInfo> nodes, Set<
}
}

void addNodesDependents(int level, BeanInfo root, Set<DevBeanInfo> nodes, Set<Link> links, BeanInfo bean,
private void addNodesDependents(int level, BeanInfo root, Set<DevBeanInfo> nodes, Set<Link> links, BeanInfo bean,
List<InjectionPointInfo> injectionPoints, Map<BeanInfo, List<BeanInfo>> declaringToProducers, BeanResolver resolver,
DevBeanInfos devBeanInfos, Map<BeanInfo, List<InjectionPointInfo>> directDependents) {
List<InjectionPointInfo> direct = directDependents.get(bean);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
import io.quarkus.arc.deployment.ArcConfig;
import io.quarkus.arc.deployment.BeanDefiningAnnotationBuildItem;
import io.quarkus.arc.deployment.CustomScopeAnnotationsBuildItem;
import io.quarkus.arc.deployment.devconsole.DevBeanInfo;
import io.quarkus.arc.deployment.devconsole.DevBeanInfos;
import io.quarkus.arc.deployment.devconsole.DevDecoratorInfo;
import io.quarkus.arc.deployment.devconsole.DevInterceptorInfo;
import io.quarkus.arc.deployment.devconsole.DevObserverInfo;
import io.quarkus.arc.processor.AnnotationsTransformer;
import io.quarkus.arc.runtime.devconsole.InvocationInterceptor;
import io.quarkus.arc.runtime.devconsole.InvocationTree;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package io.quarkus.arc.deployment.devui;

import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;

public class DependencyGraph {

public final Set<DevBeanInfo> nodes;
public final Set<Link> links;
public final int maxLevel;

public DependencyGraph(Set<DevBeanInfo> nodes, Set<Link> links) {
this.nodes = nodes;
this.links = links;
this.maxLevel = links.stream().mapToInt(l -> l.level).max().orElse(0);
}

DependencyGraph forLevel(int level) {
return filterLinks(link -> link.level <= level);
}

DependencyGraph filterLinks(Predicate<Link> predicate) {
// Filter out links first
Set<Link> newLinks = new HashSet<>();
Set<DevBeanInfo> newNodes = new HashSet<>();
Set<String> usedIds = new HashSet<>();
for (Link link : links) {
if (predicate.test(link)) {
newLinks.add(link);
usedIds.add(link.source);
usedIds.add(link.target);
}
}
// Now keep only nodes for which a link exists...
for (DevBeanInfo node : nodes) {
if (usedIds.contains(node.getId())) {
newNodes.add(node);
}
}
return new DependencyGraph(newNodes, newLinks);
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.arc.deployment.devconsole;
package io.quarkus.arc.deployment.devui;

import java.util.ArrayList;
import java.util.HashSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.arc.deployment.devconsole;
package io.quarkus.arc.deployment.devui;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -63,12 +63,12 @@ public Map<String, DependencyGraph> getDependencyGraphs() {
}

public String getBeanDescription() {
return DevConsoleManager.getGlobal(ArcDevConsoleProcessor.BEAN_DESCRIPTION);
return DevConsoleManager.getGlobal(BEAN_DESCRIPTION);
}

public int getMaxDependencyLevel() {
Integer val = DevConsoleManager.getGlobal(ArcDevConsoleProcessor.MAX_DEPENDENCY_LEVEL);
return val != null ? val : ArcDevConsoleProcessor.DEFAULT_MAX_DEPENDENCY_LEVEL;
Integer val = DevConsoleManager.getGlobal(MAX_DEPENDENCY_LEVEL);
return val != null ? val : DEFAULT_MAX_DEPENDENCY_LEVEL;
}

public DevBeanInfo getBean(String id) {
Expand All @@ -90,9 +90,9 @@ public DevInterceptorInfo getInterceptor(String id) {
}

public DependencyGraph getDependencyGraph(String beanId) {
Integer maxLevel = DevConsoleManager.getGlobal(ArcDevConsoleProcessor.MAX_DEPENDENCY_LEVEL);
Integer maxLevel = DevConsoleManager.getGlobal(MAX_DEPENDENCY_LEVEL);
if (maxLevel == null) {
maxLevel = ArcDevConsoleProcessor.DEFAULT_MAX_DEPENDENCY_LEVEL;
maxLevel = DEFAULT_MAX_DEPENDENCY_LEVEL;
}
DependencyGraph graph = dependencyGraphs.get(beanId);
return graph.maxLevel <= maxLevel ? graph : graph.forLevel(maxLevel);
Expand Down Expand Up @@ -143,4 +143,9 @@ void sort() {
Collections.sort(removedDecorators);
Collections.sort(removedInterceptors);
}

static final String BEAN_DESCRIPTION = "io.quarkus.arc.beanDescription";
static final String MAX_DEPENDENCY_LEVEL = "io.quarkus.arc.maxDependencyLevel";
public static final String BEAN_DEPENDENCIES = "io.quarkus.arc.beanDependencies";
static final int DEFAULT_MAX_DEPENDENCY_LEVEL = 10;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.quarkus.arc.deployment.devconsole;
package io.quarkus.arc.deployment.devui;

public enum DevBeanKind {
METHOD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import java.util.ArrayList;
import java.util.List;

import io.quarkus.arc.deployment.devconsole.DevBeanInfo;
import io.quarkus.arc.deployment.devconsole.DevBeanInfos;
import io.quarkus.arc.deployment.devconsole.DevInterceptorInfo;

public class DevBeanWithInterceptorInfo extends DevBeanInfo {

private final List<DevInterceptorInfo> interceptorInfos = new ArrayList<>();
Expand Down
Loading