Last active
August 29, 2015 13:57
-
-
Save sbimikesmullin/9905978 to your computer and use it in GitHub Desktop.
MBeans in Scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.management.ManagementFactory | |
import javax.management.ObjectName | |
import scala.beans.BeanProperty | |
trait DamnitJimMBean { | |
def getCount(): Int | |
} | |
class DamnitJim extends DamnitJimMBean { | |
@BeanProperty var count = 0 | |
} | |
object TestingScalaMBeans { | |
final def main(args: Array[String]) { | |
val mbean = new DamnitJim() | |
ManagementFactory.getPlatformMBeanServer.registerMBean(mbean, new ObjectName("whatever.whatever:type=Yolo!!!")) | |
var i = 0 | |
val MAX_CLIENTS = 100000 | |
while (i < MAX_CLIENTS) { | |
mbean.count = i | |
System.out.print(".") | |
Thread.sleep(1000); | |
i += 1 | |
} | |
System.out.println("done."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment