Search in sources :

Example 1 with ObserverFilters

use of org.jboss.weld.probe.Queries.ObserverFilters in project core by weld.

the class JsonObjects method createBootstrapStatsJson.

static JsonArrayBuilder createBootstrapStatsJson(Probe probe) {
    JsonArrayBuilder builder = Json.arrayBuilder();
    Map<EventType, AtomicInteger> counts = probe.getBootstrapStats().getCounts();
    List<EventType> sortedKeys = new ArrayList<>(counts.keySet());
    Collections.sort(sortedKeys, new Comparator<EventType>() {

        @Override
        public int compare(EventType o1, EventType o2) {
            return Integer.compare(o1.getPriority(), o2.getPriority());
        }
    });
    for (EventType eventType : sortedKeys) {
        JsonObjectBuilder eventBuilder = Json.objectBuilder();
        eventBuilder.add(NAME, eventType.toString());
        eventBuilder.add(TYPE, eventType.getType());
        eventBuilder.add(FIRED, counts.get(eventType).get());
        eventBuilder.add(OBSERVERS, Queries.find(probe.getObservers(), 1, 0, new ObserverFilters(probe, eventType.getType(), null)).getTotal());
        builder.add(eventBuilder);
    }
    return builder;
}
Also used : EventType(org.jboss.weld.probe.BootstrapStats.EventType) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) ObserverFilters(org.jboss.weld.probe.Queries.ObserverFilters) JsonArrayBuilder(org.jboss.weld.probe.Json.JsonArrayBuilder) JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder)

Aggregations

ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 EventType (org.jboss.weld.probe.BootstrapStats.EventType)1 JsonArrayBuilder (org.jboss.weld.probe.Json.JsonArrayBuilder)1 JsonObjectBuilder (org.jboss.weld.probe.Json.JsonObjectBuilder)1 ObserverFilters (org.jboss.weld.probe.Queries.ObserverFilters)1