Search in sources :

Example 16 with JsonObjectBuilder

use of org.jboss.weld.probe.Json.JsonObjectBuilder 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;
}
Also used : Prioritized(javax.enterprise.inject.spi.Prioritized) ObserverMethodImpl(org.jboss.weld.event.ObserverMethodImpl) JsonArrayBuilder(org.jboss.weld.probe.Json.JsonArrayBuilder) JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder) Annotation(java.lang.annotation.Annotation) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 17 with JsonObjectBuilder

use of org.jboss.weld.probe.Json.JsonObjectBuilder in project core by weld.

the class JsonObjects method createSimpleBdaJson.

static JsonObjectBuilder createSimpleBdaJson(String bdaId) {
    JsonObjectBuilder bdaBuilder = Json.objectBuilder(true);
    bdaBuilder.add(BDA_ID, bdaId);
    bdaBuilder.add(ID, Components.getId(bdaId));
    return bdaBuilder;
}
Also used : JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder)

Example 18 with JsonObjectBuilder

use of org.jboss.weld.probe.Json.JsonObjectBuilder 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;
}
Also used : ClassAvailableActivation(org.jboss.weld.bootstrap.spi.ClassAvailableActivation) SystemPropertyActivation(org.jboss.weld.bootstrap.spi.SystemPropertyActivation) JsonArrayBuilder(org.jboss.weld.probe.Json.JsonArrayBuilder) JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder)

Example 19 with JsonObjectBuilder

use of org.jboss.weld.probe.Json.JsonObjectBuilder 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;
}
Also used : Context(javax.enterprise.context.spi.Context) AbstractConversationContext(org.jboss.weld.contexts.AbstractConversationContext) ContextNotActiveException(javax.enterprise.context.ContextNotActiveException) ProxyObject(org.jboss.weld.bean.proxy.ProxyObject) JsonArrayBuilder(org.jboss.weld.probe.Json.JsonArrayBuilder) JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder)

Example 20 with JsonObjectBuilder

use of org.jboss.weld.probe.Json.JsonObjectBuilder in project core by weld.

the class JsonObjects method createBasicInvocationJson.

static JsonObjectBuilder createBasicInvocationJson(Invocation invocation, Probe probe) {
    JsonObjectBuilder invocationBuilder = Json.objectBuilder();
    if (invocation.getEntryPointIdx() != null) {
        invocationBuilder.add(ID, invocation.getEntryPointIdx());
    }
    if (invocation.getInterceptedBean() != null) {
        invocationBuilder.add(INTERCEPTED_BEAN, createSimpleBeanJson(invocation.getInterceptedBean(), probe));
    } else {
        invocationBuilder.add(DECLARING_CLASS, invocation.getDeclaringClassName());
    }
    if (invocation.getDescription() != null) {
        invocationBuilder.add(DESCRIPTION, invocation.getDescription());
    }
    invocationBuilder.add(METHOD_NAME, invocation.getMethodName());
    invocationBuilder.add(START, invocation.getStart());
    invocationBuilder.add(TIME, invocation.getDuration());
    return invocationBuilder;
}
Also used : JsonObjectBuilder(org.jboss.weld.probe.Json.JsonObjectBuilder)

Aggregations

JsonObjectBuilder (org.jboss.weld.probe.Json.JsonObjectBuilder)25 JsonArrayBuilder (org.jboss.weld.probe.Json.JsonArrayBuilder)16 ProxyObject (org.jboss.weld.bean.proxy.ProxyObject)5 AbstractBuiltInBean (org.jboss.weld.bean.builtin.AbstractBuiltInBean)4 ObserverMethodImpl (org.jboss.weld.event.ObserverMethodImpl)4 BeanManagerImpl (org.jboss.weld.manager.BeanManagerImpl)4 EventType (org.jboss.weld.probe.BootstrapStats.EventType)3 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)2 Annotation (java.lang.annotation.Annotation)2 ParameterizedType (java.lang.reflect.ParameterizedType)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)2 AnnotatedMethod (javax.enterprise.inject.spi.AnnotatedMethod)2 Bean (javax.enterprise.inject.spi.Bean)2 ProcessAnnotatedType (javax.enterprise.inject.spi.ProcessAnnotatedType)2 ProcessSyntheticAnnotatedType (javax.enterprise.inject.spi.ProcessSyntheticAnnotatedType)2 AbstractClassBean (org.jboss.weld.bean.AbstractClassBean)2 AbstractProducerBean (org.jboss.weld.bean.AbstractProducerBean)2 SessionBean (org.jboss.weld.bean.SessionBean)2 ModuleEnablement (org.jboss.weld.bootstrap.enablement.ModuleEnablement)2