Search in sources :

Example 1 with JPAWorkingMemoryDbLogger

use of org.jbpm.process.audit.JPAWorkingMemoryDbLogger in project jbpm by kiegroup.

the class InjectableRegisterableItemsFactory method getAuditLoggerInstance.

/**
 * Provides  AuditLogger implementation, JPA or JMS.
 * JPA is the default one and JMS requires to have configuration file (.properties)
 * to be available on classpath under 'jbpm.audit.jms.properties' name.
 * This file must have following properties defined:
 * <ul>
 *  <li>jbpm.audit.jms.connection.factory.jndi - JNDI name of the connection factory to look up - type String</li>
 *  <li>jbpm.audit.jms.queue.jndi - JNDI name of the queue to look up - type String</li>
 * </ul>
 * @return instance of the audit logger
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected AbstractAuditLogger getAuditLoggerInstance(RuntimeEngine engine) {
    DeploymentDescriptor descriptor = getRuntimeManager().getDeploymentDescriptor();
    AbstractAuditLogger auditLogger = null;
    if ("true".equals(System.getProperty("jbpm.audit.jms.enabled")) || descriptor.getAuditMode() == AuditMode.JMS) {
        try {
            Properties properties = new Properties();
            properties.load(getRuntimeManager().getEnvironment().getClassLoader().getResourceAsStream("/jbpm.audit.jms.properties"));
            auditLogger = AuditLoggerFactory.newJMSInstance((Map) properties);
        } catch (IOException e) {
            logger.error("Unable to load jms audit properties from {}", "/jbpm.audit.jms.properties", e);
        }
        auditLogger.setBuilder(getAuditBuilder(engine));
    } else if (descriptor.getAuditMode() == AuditMode.JPA) {
        if (descriptor.getPersistenceUnit().equals(descriptor.getAuditPersistenceUnit())) {
            auditLogger = AuditLoggerFactory.newJPAInstance(engine.getKieSession().getEnvironment());
        } else {
            auditLogger = new JPAWorkingMemoryDbLogger(EntityManagerFactoryManager.get().getOrCreate(descriptor.getAuditPersistenceUnit()));
        }
        auditLogger.setBuilder(getAuditBuilder(engine));
    }
    return auditLogger;
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) IOException(java.io.IOException) Properties(java.util.Properties) JPAWorkingMemoryDbLogger(org.jbpm.process.audit.JPAWorkingMemoryDbLogger) AbstractAuditLogger(org.jbpm.process.audit.AbstractAuditLogger) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 AbstractAuditLogger (org.jbpm.process.audit.AbstractAuditLogger)1 JPAWorkingMemoryDbLogger (org.jbpm.process.audit.JPAWorkingMemoryDbLogger)1 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)1