Skip to content

Commit

Permalink
Merge pull request quarkusio#33750 from michalvavrik/feature/fix-infi…
Browse files Browse the repository at this point in the history
…nispan-dev-mode-bean-jsonrpc

Fix that InifispanJsonRPCService bean is only available in DEV mode when DEV profile is active
  • Loading branch information
phillip-kruger authored Jun 1, 2023
2 parents ea88a3c + fa9f124 commit 8d4b3d1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.infinispan.commons.util.Version;

import io.quarkus.arc.processor.BuiltinScope;
import io.quarkus.deployment.IsDevelopment;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.devui.spi.JsonRPCProvidersBuildItem;
Expand Down Expand Up @@ -42,6 +43,6 @@ public CardPageBuildItem infinispanServer() {

@BuildStep(onlyIf = IsDevelopment.class)
public JsonRPCProvidersBuildItem createJsonRPCService() {
return new JsonRPCProvidersBuildItem(InfinispanJsonRPCService.class);
return new JsonRPCProvidersBuildItem(InfinispanJsonRPCService.class, BuiltinScope.SINGLETON.getName());
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package io.quarkus.infinispan.client.runtime.devconsole;

import jakarta.inject.Singleton;

import io.quarkus.arc.Arc;
import io.quarkus.arc.Unremovable;
import io.quarkus.arc.profile.IfBuildProfile;
import io.quarkus.logging.Log;
import io.smallrye.common.annotation.NonBlocking;

@IfBuildProfile("dev")
@Unremovable
@Singleton
public class InfinispanJsonRPCService {

@NonBlocking
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
import java.time.Duration;
import java.util.Map;

import jakarta.enterprise.context.ApplicationScoped;

import io.quarkus.arc.Arc;
import io.quarkus.vertx.http.runtime.HttpConfiguration;
import io.smallrye.common.annotation.NonBlocking;
import io.smallrye.config.SmallRyeConfig;
import io.smallrye.mutiny.Uni;
import io.vertx.core.Vertx;

@ApplicationScoped
public class OidcDevJsonRpcService {

private final String authorizationUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,13 @@ void additionalBean(BuildProducer<AdditionalBeanBuildItem> additionalBeanProduce

Class c = jsonRPCProvidersBuildItem.getJsonRPCMethodProviderClass();
additionalIndexProducer.produce(new AdditionalIndexedClassesBuildItem(c.getName()));
DotName defaultBeanScope = jsonRPCProvidersBuildItem.getDefaultBeanScope() == null
? BuiltinScope.APPLICATION.getName()
: jsonRPCProvidersBuildItem.getDefaultBeanScope();

additionalBeanProducer.produce(AdditionalBeanBuildItem.builder()
.addBeanClass(c)
.setDefaultScope(BuiltinScope.APPLICATION.getName())
.setDefaultScope(defaultBeanScope)
.setUnremovable().build());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
package io.quarkus.devui.spi;

import org.jboss.jandex.DotName;

/**
* This allows you to register a class that will provide data during runtime for JsonRPC Requests
*/
public final class JsonRPCProvidersBuildItem extends AbstractDevUIBuildItem {

private final Class jsonRPCMethodProviderClass;
private final DotName defaultBeanScope;

public JsonRPCProvidersBuildItem(Class jsonRPCMethodProviderClass) {
super();
this.jsonRPCMethodProviderClass = jsonRPCMethodProviderClass;
this.defaultBeanScope = null;
}

public JsonRPCProvidersBuildItem(Class jsonRPCMethodProviderClass, DotName defaultBeanScope) {
super();
this.jsonRPCMethodProviderClass = jsonRPCMethodProviderClass;
this.defaultBeanScope = defaultBeanScope;
}

public JsonRPCProvidersBuildItem(String customIdentifier, Class jsonRPCMethodProviderClass) {
super(customIdentifier);
this.jsonRPCMethodProviderClass = jsonRPCMethodProviderClass;
this.defaultBeanScope = null;
}

public Class getJsonRPCMethodProviderClass() {
return jsonRPCMethodProviderClass;
}

public DotName getDefaultBeanScope() {
return defaultBeanScope;
}
}

0 comments on commit 8d4b3d1

Please sign in to comment.