Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.quarkus.runtime.annotations;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Adds metadata to a JsonRPC method to control its behavior and appearance.
*/
@Retention(RUNTIME)
@Target({ METHOD, PARAMETER })
@Documented
public @interface JsonRpcDescription {

/**
* @return the description text
*/
String value();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.quarkus.runtime.annotations;

import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
* Defines where the JsonRPC method should be available.
*/
@Retention(RUNTIME)
@Target({ METHOD })
@Documented
public @interface JsonRpcUsage {
Usage[] value();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.quarkus.runtime.annotations;

import java.util.EnumSet;

public enum Usage {
DEV_UI,
DEV_MCP;

public static EnumSet<Usage> onlyDevUI() {
return EnumSet.of(Usage.DEV_UI);
}

public static EnumSet<Usage> onlyDevMCP() {
return EnumSet.of(Usage.DEV_MCP);
}

public static EnumSet<Usage> devUIandDevMCP() {
return EnumSet.of(Usage.DEV_UI, Usage.DEV_MCP);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.quarkus.devui.spi;

import java.util.List;
import java.lang.invoke.MethodHandle;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;

import io.quarkus.builder.item.MultiBuildItem;
import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem;
import io.quarkus.deployment.util.ArtifactInfoUtil;
import io.quarkus.maven.dependency.ArtifactKey;

/**
* For All DEV UI Build Item, we need to distinguish between the extensions, and the internal usage of Dev UI
Expand All @@ -16,30 +17,33 @@ public abstract class AbstractDevUIBuildItem extends MultiBuildItem {

private final Class<?> callerClass;
private String extensionIdentifier = null;

private ArtifactKey artifactKey;
private static final String DOT = ".";
private final String customIdentifier;
private final boolean isInternal;

public AbstractDevUIBuildItem() {
this(null);
}

public AbstractDevUIBuildItem(String customIdentifier) {
this.customIdentifier = customIdentifier;

if (this.customIdentifier == null) {
this.extensionIdentifier = customIdentifier;
isInternal = customIdentifier == null;
if (customIdentifier == null) {
// Get the class that will be used to auto-detect the name
StackWalker stackWalker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);

List<StackWalker.StackFrame> stackFrames = stackWalker.walk(frames -> frames.collect(Collectors.toList()));
stackWalker.walk(frames -> frames.collect(Collectors.toList()));

Optional<StackWalker.StackFrame> stackFrame = stackWalker.walk(frames -> frames
.filter(frame -> (!frame.getDeclaringClass().getPackageName().startsWith("io.quarkus.devui.spi")
&& !frame.getDeclaringClass().getPackageName().startsWith("io.quarkus.devui.deployment")))
&& !frame.getDeclaringClass().getPackageName().startsWith("io.quarkus.devui.deployment")
&& !frame.getDeclaringClass().equals(MethodHandle.class)))
.findFirst());

if (stackFrame.isPresent()) {
this.callerClass = stackFrame.get().getDeclaringClass();
if (this.callerClass == null)
this.extensionIdentifier = DEV_UI;
} else {
throw new RuntimeException("Could not detect extension identifier automatically");
}
Expand All @@ -48,26 +52,28 @@ public AbstractDevUIBuildItem(String customIdentifier) {
}
}

public String getExtensionPathName(CurateOutcomeBuildItem curateOutcomeBuildItem) {
if (this.customIdentifier != null) {
return customIdentifier;
}
if (this.callerClass == null) {
return DEV_UI;
public ArtifactKey getArtifactKey(CurateOutcomeBuildItem curateOutcomeBuildItem) {
if (this.artifactKey == null) {
if (callerClass != null) {
Map.Entry<String, String> groupIdAndArtifactId = ArtifactInfoUtil.groupIdAndArtifactId(callerClass,
curateOutcomeBuildItem);
this.artifactKey = ArtifactKey.ga(groupIdAndArtifactId.getKey(), groupIdAndArtifactId.getValue());
}
}
return this.artifactKey;
}

public String getExtensionPathName(CurateOutcomeBuildItem curateOutcomeBuildItem) {
if (this.extensionIdentifier == null) {

Map.Entry<String, String> groupIdAndArtifactId = ArtifactInfoUtil.groupIdAndArtifactId(callerClass,
curateOutcomeBuildItem);
this.extensionIdentifier = groupIdAndArtifactId.getKey() + DOT + groupIdAndArtifactId.getValue();
ArtifactKey ak = getArtifactKey(curateOutcomeBuildItem);
this.extensionIdentifier = ak.getGroupId() + DOT + ak.getArtifactId();
}

return this.extensionIdentifier;
}

public boolean isInternal() {
return this.customIdentifier != null;
return this.isInternal;
}

public static final String DEV_UI = "devui";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ public class DevUIContent {
private final String fileName;
private final byte[] template;
private final Map<String, Object> data;
private final Map<String, String> descriptions;

private DevUIContent(DevUIContent.Builder builder) {
this.fileName = builder.fileName;
this.template = builder.template;
this.data = builder.data;
this.descriptions = builder.descriptions;
}

public String getFileName() {
Expand All @@ -29,6 +31,10 @@ public Map<String, Object> getData() {
return data;
}

public Map<String, String> getDescriptions() {
return descriptions;
}

public static Builder builder() {
return new Builder();
}
Expand All @@ -37,6 +43,7 @@ public static class Builder {
private String fileName;
private byte[] template;
private Map<String, Object> data;
private Map<String, String> descriptions;

private Builder() {
this.data = new HashMap<>();
Expand Down Expand Up @@ -69,6 +76,11 @@ public Builder addData(String key, Object value) {
return this;
}

public Builder descriptions(Map<String, String> descriptions) {
this.descriptions = descriptions;
return this;
}

public DevUIContent build() {
if (fileName == null) {
throw new RuntimeException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Define a action that can be executed against the deployment classpath in runtime
* This means a call will still be make with Json-RPC to the backend, but fall through to this action
*/
@Deprecated
public class BuildTimeAction {

private final String methodName;
Expand Down
Loading
Loading