use of org.jboss.weld.probe.BootstrapStats.EventType in project core by weld.
the class JsonObjects method isUnrestrictedProcessAnnotatedTypeObserver.
private static boolean isUnrestrictedProcessAnnotatedTypeObserver(ObserverMethod<?> observerMethod) {
if (observerMethod instanceof ContainerLifecycleEventObserverMethod) {
ContainerLifecycleEventObserverMethod<?> containerLifecycleObserverMethod = (ContainerLifecycleEventObserverMethod<?>) observerMethod;
Class<?> rawObserverType = Reflections.getRawType(containerLifecycleObserverMethod.getObservedType());
if ((rawObserverType.equals(ProcessAnnotatedType.class) || rawObserverType.equals(ProcessSyntheticAnnotatedType.class)) && containerLifecycleObserverMethod.getRequiredAnnotations().isEmpty()) {
Type eventType = containerLifecycleObserverMethod.getObservedType();
Type[] typeArguments;
if (eventType instanceof ParameterizedType) {
typeArguments = ((ParameterizedType) eventType).getActualTypeArguments();
} else {
typeArguments = Arrays2.EMPTY_TYPE_ARRAY;
}
if (typeArguments.length == 0 || Reflections.isUnboundedWildcard(typeArguments[0]) || Reflections.isUnboundedTypeVariable(typeArguments[0])) {
return true;
}
}
}
return false;
}
use of org.jboss.weld.probe.BootstrapStats.EventType 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.BootstrapStats.EventType in project core by weld.
the class ProbeExtension method addContainerLifecycleEvent.
private <T> void addContainerLifecycleEvent(T event, Object info, BeanManagerImpl beanManagerImpl) {
ResolvedObservers<?> resolvedObservers = null;
Type eventType = null;
if (event instanceof AbstractContainerEvent) {
AbstractContainerEvent containerEvent = (AbstractContainerEvent) event;
eventType = containerEvent.getEventType();
resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods(eventType);
} else if (event instanceof ProcessAnnotatedTypeImpl) {
ProcessAnnotatedTypeImpl<?> processAnnotatedTypeEvent = (ProcessAnnotatedTypeImpl<?>) event;
eventType = ProcessAnnotatedType.class;
info = Formats.formatType(processAnnotatedTypeEvent.getOriginalAnnotatedType().getBaseType(), false);
resolvedObservers = beanManagerImpl.getGlobalLenientObserverNotifier().resolveObserverMethods(ProcessAnnotatedTypeEventResolvable.of(processAnnotatedTypeEvent, beanManagerImpl.getServices().get(RequiredAnnotationDiscovery.class)));
}
if (resolvedObservers != null && eventType != null) {
probe.addEvent(new EventInfo(eventType, Collections.emptySet(), info, null, Reflections.cast(resolvedObservers.getAllObservers()), true, System.currentTimeMillis(), false));
}
}
Aggregations