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