All Downloads are FREE. Search and download functionalities are using the official Maven repository.

camundala.camunda7.worker.Camunda7Context.scala Maven / Gradle / Ivy

There is a newer version: 1.30.23
Show newest version
package camundala
package camunda7.worker

import camundala.domain.*
import camundala.worker.*
import org.camunda.bpm.client.variable.ClientValues
import org.slf4j.{Logger, LoggerFactory}
import org.springframework.context.annotation.Configuration
import scala.reflect.ClassTag

trait Camunda7Context extends EngineContext:

  def getLogger(clazz: Class[?]): WorkerLogger =
    Camunda7WorkerLogger(LoggerFactory.getLogger(clazz))

  lazy val toEngineObject: Json => Any =
    json => ClientValues.jsonValue(json.toString)

  def sendRequest[ServiceIn: InOutEncoder, ServiceOut: InOutDecoder: ClassTag](
      request: RunnableRequest[ServiceIn]
  ): SendRequestType[ServiceOut] =
    DefaultRestApiClient.sendRequest(request)

end Camunda7Context

@Configuration
class DefaultCamunda7Context extends Camunda7Context

case class Camunda7WorkerLogger(private val delegateLogger: Logger) extends WorkerLogger:

  def debug(message: String): Unit =
    if delegateLogger.isDebugEnabled then
      delegateLogger.debug(message)

  def info(message: String): Unit =
    if delegateLogger.isInfoEnabled then
      delegateLogger.info(message)

  def warn(message: String): Unit =
    if delegateLogger.isWarnEnabled then
      delegateLogger.warn(message)

  def error(err: CamundalaWorkerError): Unit =
    if delegateLogger.isErrorEnabled then
      delegateLogger.error(s"Error ${err.causeMsg}")

end Camunda7WorkerLogger




© 2015 - 2024 Weber Informatics LLC | Privacy Policy