Skip to content

Commit

Permalink
Applying Scalariform
Browse files Browse the repository at this point in the history
  • Loading branch information
atooni committed Jun 4, 2019
1 parent 4810758 commit 4e08986
Show file tree
Hide file tree
Showing 51 changed files with 350 additions and 360 deletions.
Expand Up @@ -5,11 +5,11 @@ import blended.jms.utils.IdAwareConnectionFactory
import blended.util.logging.Logger
import org.osgi.framework.BundleContext

class DefaultVerificationFailedHandler(bundleContext: BundleContext) extends VerificationFailedHandler {
class DefaultVerificationFailedHandler(bundleContext : BundleContext) extends VerificationFailedHandler {

private val log: Logger = Logger[DefaultVerificationFailedHandler]
private val log : Logger = Logger[DefaultVerificationFailedHandler]

override def verificationFailed(cf: IdAwareConnectionFactory): Unit = {
override def verificationFailed(cf : IdAwareConnectionFactory) : Unit = {
// TODO: shutting down the container is a bit of overkill IMHO (TR), why not just unregister the connection?
log.error(s"Verification for connection [${cf.vendor}:${cf.provider}] has failed. Shutting down container ...")
bundleContext.getBundle(0).stop()
Expand Down
Expand Up @@ -4,9 +4,9 @@ import akka.http.scaladsl.server.Route

// TODO: think about more advanced options like ranking and the possibility to explicitly allow to extend an existing service
trait HttpContext {
def prefix: String
def route: Route
def prefix : String
def route : Route
}

case class SimpleHttpContext(prefix: String, route: Route) extends HttpContext
case class SimpleHttpContext(prefix : String, route : Route) extends HttpContext

4 changes: 2 additions & 2 deletions blended.dependencies/src/main/scala/Blended.scala
Expand Up @@ -5,9 +5,9 @@ import sbt._
trait Blended {

// TODO: Find a way to generate the current version
def blendedVersion: String // = version.value
def blendedVersion : String // = version.value

def blended(name: String) = "de.wayofquality.blended" %% name % blendedVersion
def blended(name : String) = "de.wayofquality.blended" %% name % blendedVersion

val activemqBrokerstarter = blended("blended.activemq.brokerstarter")
val activemqClient = blended("blended.activemq.client")
Expand Down
Expand Up @@ -10,12 +10,12 @@ import org.osgi.framework.BundleContext
trait TypesafeConfigWatching extends DominoImplicits {

/** Dependency */
protected def capsuleContext: CapsuleContext
protected def capsuleContext : CapsuleContext

/** Dependency */
protected def bundleContext: BundleContext
protected def bundleContext : BundleContext

def whenTypesafeConfigAvailable(f: (Config, ContainerIdentifierService) => Unit): Unit = {
def whenTypesafeConfigAvailable(f : (Config, ContainerIdentifierService) => Unit) : Unit = {
val m = new TypesafeConfigCapsule(capsuleContext, f, bundleContext)
capsuleContext.addCapsule(m)
}
Expand Down
28 changes: 14 additions & 14 deletions blended.file/src/main/scala/blended/file/EnvelopeFileDropper.scala
Expand Up @@ -12,21 +12,21 @@ import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.{Failure, Success, Try}

class EnvelopeFileDropper(
cfg: FileDropConfig,
cfg : FileDropConfig,
headerConfig : FlowHeaderConfig,
dropActor : ActorRef,
log : Logger
)(implicit system: ActorSystem) extends JmsEnvelopeHeader {
)(implicit system : ActorSystem) extends JmsEnvelopeHeader {

// Get the content of the envelope as a ByteString which we can write to disk
private def extractContent(env: FlowEnvelope): Try[ByteString] = Try {
private def extractContent(env : FlowEnvelope) : Try[ByteString] = Try {
env.flowMessage match {
case tMsg: TextFlowMessage =>
case tMsg : TextFlowMessage =>
val charSet = env.headerWithDefault[String](cfg.charsetHeader, "UTF-8")
log.info(s"Using charset [$charSet] to file drop text message [${env.id}]")
ByteString(tMsg.getText().getBytes(charSet))

case bMsg: BinaryFlowMessage =>
case bMsg : BinaryFlowMessage =>
bMsg.content

case m =>
Expand All @@ -38,15 +38,15 @@ class EnvelopeFileDropper(

// Try to get the correlation Id from the message, fall back with the correlation ID from
// the FlowEnvelope, finally fall back with the envelope ID
private[this] def corrId(env: FlowEnvelope): String = {
private[this] def corrId(env : FlowEnvelope) : String = {
env.headerWithDefault[String](
"JMSCorrelationID",
env.headerWithDefault[String](corrIdHeader(headerConfig.prefix), env.id)
)
}

// extract the drop Command from the envelope
private[this] def dropCmd(env: FlowEnvelope)(f: FlowEnvelope => Try[ByteString]): Try[FileDropCommand] = Try {
private[this] def dropCmd(env : FlowEnvelope)(f : FlowEnvelope => Try[ByteString]) : Try[FileDropCommand] = Try {
FileDropCommand(
id = env.id,
content = f(env).get,
Expand All @@ -55,24 +55,24 @@ class EnvelopeFileDropper(
compressed = env.headerWithDefault[Boolean](cfg.compressHeader, false),
append = env.headerWithDefault[Boolean](cfg.appendHeader, false),
timestamp = env.headerWithDefault[Long](timestampHeader(headerConfig.prefix), System.currentTimeMillis()),
properties = Map("JMSCorrelationID" -> corrId(env)) ++ env.flowMessage.header.mapValues(_.value),
properties = Map("JMSCorrelationID" -> corrId(env)) ++ env.flowMessage.header.mapValues(_.value)
)
}

private[this] def handleError(env: FlowEnvelope, error: Throwable): FileDropResult = {
private[this] def handleError(env : FlowEnvelope, error : Throwable) : FileDropResult = {
log.error(s"Error dropping envelope [${env.id}] to file : [${error.getMessage()}]")
val cmd = dropCmd(env)(e => Success(ByteString(""))).get
val cmd = dropCmd(env)(_ => Success(ByteString(""))).get
FileDropResult(cmd, Some(error))
}

def dropEnvelope(env: FlowEnvelope): (FileDropCommand, Future[FileDropResult]) = {
def dropEnvelope(env : FlowEnvelope) : (FileDropCommand, Future[FileDropResult]) = {

val p: Promise[FileDropResult] = Promise()
val p : Promise[FileDropResult] = Promise()

dropCmd(env)(extractContent) match {
case Success(cmd) =>
implicit val to: Timeout = Timeout(cfg.dropTimeout)
implicit val eCtxt: ExecutionContext = system.dispatcher
implicit val to : Timeout = Timeout(cfg.dropTimeout)
implicit val eCtxt : ExecutionContext = system.dispatcher

(dropActor ? cmd).mapTo[FileDropResult].onComplete {
case Success(r) => p.complete(Success(r))
Expand Down

0 comments on commit 4e08986

Please sign in to comment.