Search in sources :

Example 6 with ArcContainerImpl

use of io.quarkus.arc.impl.ArcContainerImpl in project quarkus by quarkusio.

the class ArcDevRecorder method createRemovedBeansHandler.

public Handler<RoutingContext> createRemovedBeansHandler(List<String[]> removedInterceptorsDecorators) {
    return new Handler<RoutingContext>() {

        @Override
        public void handle(RoutingContext ctx) {
            ArcContainerImpl container = ArcContainerImpl.instance();
            ctx.response().putHeader("Content-Type", "application/json");
            JsonArrayBuilder removed = Json.array();
            for (RemovedBean removedBean : container.getRemovedBeans()) {
                JsonObjectBuilder bean = Json.object();
                bean.put("kind", removedBean.getKind().toString());
                bean.put("description", removedBean.getDescription());
                JsonArrayBuilder types = Json.array();
                for (Type beanType : removedBean.getTypes()) {
                    types.add(beanType instanceof Class ? ((Class<?>) beanType).getName() : beanType.toString());
                }
                // java.lang.Object is always skipped
                types.add(Object.class.getName());
                bean.put("types", types);
                JsonArrayBuilder qualifiers = Json.array();
                for (Annotation qualifier : removedBean.getQualifiers()) {
                    if (qualifier.annotationType().equals(Any.class) || qualifier.annotationType().equals(Default.class)) {
                        qualifiers.add("@" + qualifier.annotationType().getSimpleName());
                    } else {
                        qualifiers.add(qualifier.toString());
                    }
                }
                bean.put("qualifiers", qualifiers);
                removed.add(bean);
            }
            for (String[] interceptorDecorator : removedInterceptorsDecorators) {
                JsonObjectBuilder bean = Json.object();
                bean.put("kind", interceptorDecorator[0]);
                bean.put("description", interceptorDecorator[1]);
                removed.add(bean);
            }
            ctx.response().end(removed.build());
        }
    };
}
Also used : DevConsolePostHandler(io.quarkus.devconsole.runtime.spi.DevConsolePostHandler) Handler(io.vertx.core.Handler) RemovedBean(io.quarkus.arc.RemovedBean) Any(javax.enterprise.inject.Any) Default(javax.enterprise.inject.Default) Annotation(java.lang.annotation.Annotation) RoutingContext(io.vertx.ext.web.RoutingContext) Type(java.lang.reflect.Type) ArcContainerImpl(io.quarkus.arc.impl.ArcContainerImpl) JsonArrayBuilder(io.quarkus.vertx.http.runtime.devmode.Json.JsonArrayBuilder) JsonObjectBuilder(io.quarkus.vertx.http.runtime.devmode.Json.JsonObjectBuilder)

Example 7 with ArcContainerImpl

use of io.quarkus.arc.impl.ArcContainerImpl in project quarkus by quarkusio.

the class ArcDevRecorder method createSummaryHandler.

public Handler<RoutingContext> createSummaryHandler(Map<String, String> configProperties, String rootPath, int removedInterceptorsDecorators) {
    return new Handler<RoutingContext>() {

        @Override
        public void handle(RoutingContext ctx) {
            ctx.response().putHeader("Content-Type", "application/json");
            ArcContainerImpl container = ArcContainerImpl.instance();
            JsonObjectBuilder summary = Json.object();
            summary.put("beans", container.getBeans().size());
            summary.put("removedBeans", container.getRemovedBeans().size() + removedInterceptorsDecorators);
            summary.put("observers", container.getObservers().size());
            summary.put("interceptors", container.getInterceptors().size());
            JsonArrayBuilder scopes = Json.array();
            container.getScopes().stream().map(Class::getName).forEach(scopes::add);
            summary.put("scopes", scopes);
            JsonObjectBuilder config = Json.object();
            for (Entry<String, String> entry : configProperties.entrySet()) {
                if (entry.getValue().equals("true") || entry.getValue().equals("false")) {
                    config.put(entry.getKey(), Boolean.parseBoolean(entry.getValue()));
                } else {
                    config.put(entry.getKey(), entry.getValue());
                }
            }
            summary.put("config", config);
            JsonObjectBuilder links = Json.object();
            links.put("beans", rootPath + "arc/beans");
            links.put("observers", rootPath + "arc/observers");
            links.put("removed-beans", rootPath + "arc/removed-beans");
            summary.put("links", links);
            ctx.response().end(summary.build());
        }
    };
}
Also used : RoutingContext(io.vertx.ext.web.RoutingContext) ArcContainerImpl(io.quarkus.arc.impl.ArcContainerImpl) DevConsolePostHandler(io.quarkus.devconsole.runtime.spi.DevConsolePostHandler) Handler(io.vertx.core.Handler) JsonArrayBuilder(io.quarkus.vertx.http.runtime.devmode.Json.JsonArrayBuilder) JsonObjectBuilder(io.quarkus.vertx.http.runtime.devmode.Json.JsonObjectBuilder)

Aggregations

ArcContainerImpl (io.quarkus.arc.impl.ArcContainerImpl)7 DevConsolePostHandler (io.quarkus.devconsole.runtime.spi.DevConsolePostHandler)4 JsonArrayBuilder (io.quarkus.vertx.http.runtime.devmode.Json.JsonArrayBuilder)4 JsonObjectBuilder (io.quarkus.vertx.http.runtime.devmode.Json.JsonObjectBuilder)4 Handler (io.vertx.core.Handler)4 RoutingContext (io.vertx.ext.web.RoutingContext)4 Annotation (java.lang.annotation.Annotation)3 Type (java.lang.reflect.Type)2 Any (javax.enterprise.inject.Any)2 Default (javax.enterprise.inject.Default)2 InjectableBean (io.quarkus.arc.InjectableBean)1 InjectableObserverMethod (io.quarkus.arc.InjectableObserverMethod)1 RemovedBean (io.quarkus.arc.RemovedBean)1 PreloadedTestApplicationClassPredicate (io.quarkus.arc.runtime.test.PreloadedTestApplicationClassPredicate)1 ShutdownEvent (io.quarkus.runtime.ShutdownEvent)1 StartupEvent (io.quarkus.runtime.StartupEvent)1 TestApplicationClassPredicate (io.quarkus.runtime.test.TestApplicationClassPredicate)1 ArrayList (java.util.ArrayList)1