Search in sources :

Example 1 with EventType

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;
}
Also used : ContainerLifecycleEventObserverMethod(org.jboss.weld.event.ContainerLifecycleEventObserverMethod) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) ParameterizedType(java.lang.reflect.ParameterizedType) ParameterizedType(java.lang.reflect.ParameterizedType) EventType(org.jboss.weld.probe.BootstrapStats.EventType) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) ProcessSyntheticAnnotatedType(javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType) Type(java.lang.reflect.Type) ProcessSyntheticAnnotatedType(javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType)

Example 2 with EventType

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;
}
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)

Example 3 with EventType

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));
    }
}
Also used : ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) EventType(org.jboss.weld.probe.BootstrapStats.EventType) ProcessAnnotatedType(javax.enterprise.inject.spi.ProcessAnnotatedType) Type(java.lang.reflect.Type) AnnotatedType(javax.enterprise.inject.spi.AnnotatedType) VetoedSuppressedAnnotatedType(org.jboss.weld.util.annotated.VetoedSuppressedAnnotatedType) AbstractContainerEvent(org.jboss.weld.bootstrap.events.AbstractContainerEvent) ProcessAnnotatedTypeImpl(org.jboss.weld.bootstrap.events.ProcessAnnotatedTypeImpl)

Aggregations

EventType (org.jboss.weld.probe.BootstrapStats.EventType)3 Type (java.lang.reflect.Type)2 ProcessAnnotatedType (javax.enterprise.inject.spi.ProcessAnnotatedType)2 ParameterizedType (java.lang.reflect.ParameterizedType)1 ArrayList (java.util.ArrayList)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 AnnotatedType (javax.enterprise.inject.spi.AnnotatedType)1 ProcessSyntheticAnnotatedType (javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType)1 AbstractContainerEvent (org.jboss.weld.bootstrap.events.AbstractContainerEvent)1 ProcessAnnotatedTypeImpl (org.jboss.weld.bootstrap.events.ProcessAnnotatedTypeImpl)1 ContainerLifecycleEventObserverMethod (org.jboss.weld.event.ContainerLifecycleEventObserverMethod)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 VetoedSuppressedAnnotatedType (org.jboss.weld.util.annotated.VetoedSuppressedAnnotatedType)1