use of org.jboss.weld.probe.Json.JsonArrayBuilder in project core by weld.
the class JsonObjects method createFullInvocationJson.
/**
* @param invocation
* @param probe
* @return
*/
static JsonObjectBuilder createFullInvocationJson(Invocation invocation, Probe probe) {
JsonObjectBuilder invocationBuilder = createBasicInvocationJson(invocation, probe);
invocationBuilder.add(TYPE, invocation.getType().toString());
if (invocation.hasChildren()) {
JsonArrayBuilder childrenBuilder = Json.arrayBuilder();
for (Invocation child : invocation.getChildren()) {
childrenBuilder.add(createFullInvocationJson(child, probe));
}
invocationBuilder.add(CHILDREN, childrenBuilder);
}
return invocationBuilder;
}
use of org.jboss.weld.probe.Json.JsonArrayBuilder 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;
}
use of org.jboss.weld.probe.Json.JsonArrayBuilder in project core by weld.
the class JsonObjects method createBasicObserverJson.
@SuppressFBWarnings(value = "BC_VACUOUS_INSTANCEOF", justification = "WELD-2452, with CDI 1.2 API, this doesn't need to be true.")
static JsonObjectBuilder createBasicObserverJson(ObserverMethod<?> observerMethod, Probe probe) {
JsonObjectBuilder observerBuilder = createSimpleObserverJson(observerMethod, probe);
observerBuilder.add(RECEPTION, observerMethod.getReception().toString());
observerBuilder.add(TX_PHASE, observerMethod.getTransactionPhase().toString());
if (!observerMethod.getObservedQualifiers().isEmpty()) {
JsonArrayBuilder qualifiersBuilder = Json.arrayBuilder();
for (Annotation qualifier : observerMethod.getObservedQualifiers()) {
qualifiersBuilder.add(qualifier.toString());
}
observerBuilder.add(QUALIFIERS, qualifiersBuilder);
}
if (observerMethod instanceof ObserverMethodImpl) {
ObserverMethodImpl<?, ?> observerMethodImpl = (ObserverMethodImpl<?, ?>) observerMethod;
observerBuilder.add(DECLARING_BEAN, createSimpleBeanJson(observerMethodImpl.getDeclaringBean(), probe));
}
if (isUnrestrictedProcessAnnotatedTypeObserver(observerMethod)) {
observerBuilder.add(DESCRIPTION, WARNING_UNRESTRICTED_PAT_OBSERVER);
}
// WELD-2452 to be removed once WFLY is EE 8 certified
if (observerMethod instanceof Prioritized) {
// Every OM is now instance of Prioritized
final int priority = Prioritized.class.cast(observerMethod).getPriority();
observerBuilder.add(PRIORITY, priority);
observerBuilder.add(PRIORITY_RANGE, Components.PriorityRange.of(priority).toString());
}
return observerBuilder;
}
use of org.jboss.weld.probe.Json.JsonArrayBuilder in project core by weld.
the class JsonObjects method createFilterJsonArray.
static JsonObjectBuilder createFilterJsonArray(Filter filter, String type) {
JsonObjectBuilder filterBuilder = Json.objectBuilder(true);
filterBuilder.add(TYPE, type);
filterBuilder.add(NAME, filter.getName());
JsonArrayBuilder activationsBuilder = Json.arrayBuilder(true);
filterBuilder.add(ACTIVATIONS, activationsBuilder);
if (filter.getClassAvailableActivations() != null && !filter.getClassAvailableActivations().isEmpty()) {
for (Metadata<ClassAvailableActivation> metadata : filter.getClassAvailableActivations()) {
activationsBuilder.add(Json.objectBuilder().add(INVERTED, metadata.getValue().isInverted()).add(CLASS_AVAILABILITY, metadata.getValue().getClassName()));
}
}
if (filter.getSystemPropertyActivations() != null && !filter.getSystemPropertyActivations().isEmpty()) {
for (Metadata<SystemPropertyActivation> metadata : filter.getSystemPropertyActivations()) {
JsonObjectBuilder sysPropBuilder = Json.objectBuilder().add(SYS_PROPERTY, metadata.getValue().getName());
if (metadata.getValue().getValue() != null) {
sysPropBuilder.add(VALUE, metadata.getValue().getValue());
}
activationsBuilder.add(sysPropBuilder);
}
}
return filterBuilder;
}
use of org.jboss.weld.probe.Json.JsonArrayBuilder in project core by weld.
the class JsonObjects method inspectContext.
private static JsonArrayBuilder inspectContext(Class<? extends Annotation> scope, BeanManagerImpl beanManager, Probe probe) {
Context context;
try {
context = beanManager.getContext(scope);
} catch (ContextNotActiveException e) {
return null;
}
JsonArrayBuilder builder = Json.arrayBuilder();
for (Bean<?> bean : probe.getBeans()) {
if (bean.getScope().equals(scope)) {
Object contextualInstance = context.get(bean);
if (contextualInstance != null) {
JsonObjectBuilder instanceBuilder = createSimpleBeanJson(bean, probe);
instanceBuilder.add(OBJECT_TO_STRING, contextualInstance.getClass().getName() + "@" + Integer.toHexString(contextualInstance.hashCode()));
instanceBuilder.add(AS_STRING, Strings.abbreviate(contextualInstance.toString(), CONTEXTUAL_INSTANCE_TO_STRING_LIMIT));
builder.add(instanceBuilder);
}
}
}
return builder;
}
Aggregations