Search in sources :

Example 1 with ServiceComposite

use of org.qi4j.api.service.ServiceComposite 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)

Example 2 with ServiceComposite

use of org.qi4j.api.service.ServiceComposite in project qi4j-sdk by Qi4j.

the class DebuggingServiceMixin method createDebugRecord.

private void createDebugRecord(UnitOfWork uow, Composite composite, String message, List<Serializable> params) {
    if (composite instanceof ServiceComposite) {
        EntityBuilder<ServiceDebugRecordEntity> builder = uow.newEntityBuilder(ServiceDebugRecordEntity.class);
        ServiceDebugRecordEntity state = builder.instance();
        setStandardStuff(composite, message, state, params);
        state.source().set(((ServiceComposite) composite).identity().get());
        ServiceDebugRecordEntity slr = builder.newInstance();
    } else if (composite instanceof EntityComposite) {
        EntityBuilder<EntityDebugRecordEntity> builder = uow.newEntityBuilder(EntityDebugRecordEntity.class);
        EntityDebugRecordEntity state = builder.instance();
        setStandardStuff(composite, message, state, params);
        state.source().set((EntityComposite) composite);
        EntityDebugRecordEntity elr = builder.newInstance();
    } else {
        EntityBuilder<CompositeDebugRecordEntity> builder = uow.newEntityBuilder(CompositeDebugRecordEntity.class);
        CompositeDebugRecordEntity state = builder.instance();
        setStandardStuff(composite, message, state, params);
        state.source().set(composite);
        CompositeDebugRecordEntity clr = builder.newInstance();
    }
}
Also used : EntityComposite(org.qi4j.api.entity.EntityComposite) EntityBuilder(org.qi4j.api.entity.EntityBuilder) EntityDebugRecordEntity(org.qi4j.logging.debug.records.EntityDebugRecordEntity) ServiceComposite(org.qi4j.api.service.ServiceComposite) ServiceDebugRecordEntity(org.qi4j.logging.debug.records.ServiceDebugRecordEntity) CompositeDebugRecordEntity(org.qi4j.logging.debug.records.CompositeDebugRecordEntity)

Example 3 with ServiceComposite

use of org.qi4j.api.service.ServiceComposite in project qi4j-sdk by Qi4j.

the class LoggingServiceMixin method createLogRecord.

private void createLogRecord(UnitOfWork uow, LogType type, Composite composite, String category, String message, List<Serializable> params) {
    if (composite instanceof ServiceComposite) {
        EntityBuilder<ServiceLogRecord> builder = uow.newEntityBuilder(ServiceLogRecord.class);
        ServiceLogRecord state = builder.instance();
        setStandardStuff(type, composite, category, message, state, params);
        state.source().set(((ServiceComposite) composite).identity().get());
        ServiceLogRecord slr = builder.newInstance();
    } else if (composite instanceof EntityComposite) {
        EntityBuilder<EntityLogRecord> builder = uow.newEntityBuilder(EntityLogRecord.class);
        EntityLogRecord state = builder.instance();
        setStandardStuff(type, composite, category, message, state, params);
        state.source().set((EntityComposite) composite);
        EntityLogRecord elr = builder.newInstance();
    } else {
        EntityBuilder<CompositeLogRecord> builder = uow.newEntityBuilder(CompositeLogRecord.class);
        CompositeLogRecord state = builder.instance();
        setStandardStuff(type, composite, category, message, state, params);
        state.source().set(composite);
        CompositeLogRecord clr = builder.newInstance();
    }
}
Also used : EntityComposite(org.qi4j.api.entity.EntityComposite) CompositeLogRecord(org.qi4j.logging.log.records.CompositeLogRecord) EntityLogRecord(org.qi4j.logging.log.records.EntityLogRecord) EntityBuilder(org.qi4j.api.entity.EntityBuilder) ServiceLogRecord(org.qi4j.logging.log.records.ServiceLogRecord) ServiceComposite(org.qi4j.api.service.ServiceComposite)

Aggregations

EntityBuilder (org.qi4j.api.entity.EntityBuilder)3 EntityComposite (org.qi4j.api.entity.EntityComposite)3 ServiceComposite (org.qi4j.api.service.ServiceComposite)3 CompositeDebugRecordEntity (org.qi4j.logging.debug.records.CompositeDebugRecordEntity)1 EntityDebugRecordEntity (org.qi4j.logging.debug.records.EntityDebugRecordEntity)1 ServiceDebugRecordEntity (org.qi4j.logging.debug.records.ServiceDebugRecordEntity)1 CompositeLogRecord (org.qi4j.logging.log.records.CompositeLogRecord)1 EntityLogRecord (org.qi4j.logging.log.records.EntityLogRecord)1 ServiceLogRecord (org.qi4j.logging.log.records.ServiceLogRecord)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