Search in sources :

Example 1 with EntityTraceRecordEntity

use of org.qi4j.logging.trace.records.EntityTraceRecordEntity in project qi4j-sdk by Qi4j.

the class TraceServiceMixin method createTraceRecord.

private void createTraceRecord(UnitOfWork uow, Class compositeType, Composite object, Method method, Object[] args, long entryTime, long durationNano, Throwable exception) {
    if (object instanceof EntityComposite) {
        EntityComposite entity = (EntityComposite) object;
        String identity = entity.identity().get();
        EntityComposite source = (EntityComposite) uow.get((Class<?>) first(Qi4j.FUNCTION_DESCRIPTOR_FOR.map(entity).types()), identity);
        EntityBuilder<EntityTraceRecordEntity> builder = uow.newEntityBuilder(EntityTraceRecordEntity.class);
        EntityTraceRecordEntity state = builder.instance();
        setStandardStuff(compositeType, method, args, entryTime, durationNano, state, exception);
        state.source().set(source);
        // Record is created.
        EntityTraceRecordEntity etr = builder.newInstance();
    } else if (object instanceof ServiceComposite) {
        ServiceComposite service = (ServiceComposite) object;
        EntityBuilder<ServiceTraceRecordEntity> builder = uow.newEntityBuilder(ServiceTraceRecordEntity.class);
        ServiceTraceRecordEntity state = builder.instance();
        setStandardStuff(compositeType, method, args, entryTime, durationNano, state, exception);
        state.source().set(service.toString());
        // Record is created.
        ServiceTraceRecordEntity str = builder.newInstance();
    } else {
        EntityBuilder<CompositeTraceRecordEntity> builder = uow.newEntityBuilder(CompositeTraceRecordEntity.class);
        CompositeTraceRecordEntity state = builder.instance();
        state.source().set(object);
        setStandardStuff(compositeType, method, args, entryTime, durationNano, state, exception);
        // Record is created.
        CompositeTraceRecordEntity ctr = builder.newInstance();
    }
}
Also used : EntityTraceRecordEntity(org.qi4j.logging.trace.records.EntityTraceRecordEntity) EntityComposite(org.qi4j.api.entity.EntityComposite) EntityBuilder(org.qi4j.api.entity.EntityBuilder) ServiceComposite(org.qi4j.api.service.ServiceComposite) CompositeTraceRecordEntity(org.qi4j.logging.trace.records.CompositeTraceRecordEntity) ServiceTraceRecordEntity(org.qi4j.logging.trace.records.ServiceTraceRecordEntity)

Aggregations

EntityBuilder (org.qi4j.api.entity.EntityBuilder)1 EntityComposite (org.qi4j.api.entity.EntityComposite)1 ServiceComposite (org.qi4j.api.service.ServiceComposite)1 CompositeTraceRecordEntity (org.qi4j.logging.trace.records.CompositeTraceRecordEntity)1 EntityTraceRecordEntity (org.qi4j.logging.trace.records.EntityTraceRecordEntity)1 ServiceTraceRecordEntity (org.qi4j.logging.trace.records.ServiceTraceRecordEntity)1