Monthly Archives: November 2015
SBT Good to know…
Dependecy problems I have been having some difficulties figuring out what depends on what. I found the following set plugins which I think can be really helpful; https://github.com/jrudolph/sbt-dependency-graph and https://github.com/gilt/sbt-dependency-graph-sugar Be sure to install GraphWiz first, I used Homebrew on … Continue reading
Create an MBean (JMX) in Scala
Create the MBean like this
1 2 3 4 5 6 7 8 9 10 11 12 13 |
trait OrderTrackerMBean { def getOrderId : Int def setOrderId(orderId:Int) } class OrderTracker extends OrderTrackerMBean { var orderId = 0 override def getOrderId: Int = orderId override def setOrderId(_orderId: Int)= { orderId = _orderId } } |
NOTE, that the interface/trait must end with MBean in the name And this is how you register your MBean
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package com.tsoft.playingWithLogback import java.lang.management.ManagementFactory import javax.management.{ObjectName, MBeanServer} import org.slf4j.{MarkerFactory, Marker, LoggerFactory} import org.slf4j.MDC import scala.concurrent.{Await, Future} import scala.concurrent.duration._ import scala.concurrent.ExecutionContext.Implicits.global object LotsOfLogOutput { val logger = LoggerFactory.getLogger(this.getClass) val orderTrackerBean = new OrderTracker val mbs:MBeanServer = ManagementFactory.getPlatformMBeanServer(); val mBeanName:ObjectName = new ObjectName("com.tsoft.playingWithLogback:type=Tracking"); mbs.registerMBean( orderTrackerBean, mBeanName); ... |
And the simply launch Java Mission Control (imc), attach to the JVM, and modify … Continue reading
SBT module not found, why ?
I have an build.sbt file that looks like this
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
name := "TobiasPlayground" version := "1.0" scalaVersion := "2.11.7" scalacOptions := Seq("-unchecked", "-deprecation", "-encoding", "utf8") libraryDependencies ++= { val akkaV = "2.3.9" val sprayV = "1.3.3" Seq( "io.spray" %% "spray-client" % sprayV, "io.spray" %% "spray-can" % sprayV, "io.spray" %% "spray-routing" % sprayV, "io.spray" %% "spray-testkit" % sprayV % "test", "com.typesafe.akka" %% "akka-actor" % akkaV, "com.typesafe.akka" %% "akka-testkit" % akkaV % "test", "org.specs2" %% "specs2-core" % "2.3.11" % "test", "org.slf4j" %% "slf4j-api" % "1.7.10" ) } |
But for some reason I can’t get slf4j downloaded from the Maven repository (http://mvnrepository.com) If I search the Maven Repository, I can clearly see that the version I intend to … Continue reading