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