Skip to content

Commit

Permalink
ArC: add support for inactive beans in dev UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladicek committed Oct 9, 2024
1 parent 75f88b0 commit d333987
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ public boolean isGenerated() {
return isGenerated;
}

// only exists to make sure that the JSON objects already have the field
// and don't have to change their shape later
public boolean isInactive() {
return false;
}

public String getDescription() {
return description(false);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LitElement, html, css} from 'lit';
import { JsonRpc } from 'jsonrpc';
import { columnBodyRenderer } from '@vaadin/grid/lit.js';
import { beans } from 'build-time-data';
import { beanIdsWithDependencyGraphs } from 'build-time-data';
Expand All @@ -13,6 +14,7 @@ import './qwc-arc-bean-graph.js';
* This component shows the Arc Beans
*/
export class QwcArcBeans extends LitElement {
jsonRpc = new JsonRpc(this);

static styles = css`
.arctable {
Expand Down Expand Up @@ -58,11 +60,27 @@ export class QwcArcBeans extends LitElement {
this._selectedBean = null;
}

connectedCallback() {
super.connectedCallback();

this.jsonRpc.getInactiveBeans().then(inactiveBeans => {
let inactive = new Set(inactiveBeans.result);
let newBeans = [];
for (let bean of this._beans) {
if (inactive.has(bean.id)) {
bean.inactive = true;
}
newBeans.push(bean);
}
this._beans = newBeans;
});
}

render() {
if (this._beans) {
if(this._selectedBean){
if (this._selectedBean) {
return this._renderBeanGraph();
}else{
} else {
return this._renderBeanList();
}
} else {
Expand Down Expand Up @@ -143,7 +161,7 @@ export class QwcArcBeans extends LitElement {
${level
? html`<qui-badge level='${level}' small><span>${kind}</span></qui-badge>`
: html`<qui-badge small><span>${kind}</span></qui-badge>`
}`;
} ${bean.inactive ? html`<qui-badge level='warning' small><span>Inactive</span></qui-badge>` : ''}`;
}

_kindClassRenderer(bean){
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LitElement, html, css} from 'lit';

import { JsonRpc } from 'jsonrpc';
import '@vaadin/tabs';
import '@vaadin/tabsheet';
import '@vaadin/grid';
Expand All @@ -15,6 +15,8 @@ import 'qui-ide-link';
* This component shows the Arc RemovedComponents
*/
export class QwcArcRemovedComponents extends LitElement {
jsonRpc = new JsonRpc(this);

static styles = css`
.fullHeight {
height: 100%;
Expand Down Expand Up @@ -45,6 +47,22 @@ export class QwcArcRemovedComponents extends LitElement {
this._removedInterceptors = removedInterceptors;
}

connectedCallback() {
super.connectedCallback();

this.jsonRpc.getInactiveBeans().then(inactiveBeans => {
let inactive = new Set(inactiveBeans.result);
let newRemovedBeans = [];
for (let bean of this._removedBeans) {
if (inactive.has(bean.id)) {
bean.inactive = true;
}
newRemovedBeans.push(bean);
}
this._removedBeans = newRemovedBeans;
});
}

render() {
return html`
<vaadin-tabsheet class="fullHeight">
Expand Down Expand Up @@ -175,7 +193,7 @@ export class QwcArcRemovedComponents extends LitElement {
${level
? html`<qui-badge level='${level}' small><span>${kind}</span></qui-badge>`
: html`<qui-badge small><span>${kind}</span></qui-badge>`
}`;
} ${bean.inactive ? html`<qui-badge level='warning' small><span>Inactive</span></qui-badge>` : ''}`;
}

_kindClassRenderer(bean){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
import java.util.ArrayList;
import java.util.List;

import jakarta.enterprise.inject.Any;
import jakarta.enterprise.inject.Instance;
import jakarta.enterprise.inject.spi.Bean;
import jakarta.inject.Inject;

import io.quarkus.arc.Arc;
import io.quarkus.arc.InjectableBean;
import io.quarkus.arc.runtime.devconsole.Invocation;
import io.quarkus.arc.runtime.devconsole.InvocationsMonitor;
import io.quarkus.arc.runtime.devmode.EventInfo;
Expand Down Expand Up @@ -103,4 +107,15 @@ private String timeString(LocalDateTime time) {
int lastIndexOfDot = timestamp.lastIndexOf(".");
return lastIndexOfDot > 0 ? timestamp.substring(0, lastIndexOfDot) : timestamp;
}

public List<String> getInactiveBeans() {
List<String> result = new ArrayList<>();
for (Bean<?> bean : Arc.container().beanManager().getBeans(Object.class, Any.Literal.INSTANCE)) {
InjectableBean<?> injectableBean = (InjectableBean<?>) bean;
if (!injectableBean.isActive()) {
result.add(injectableBean.getIdentifier());
}
}
return result;
}
}

0 comments on commit d333987

Please sign in to comment.