aboutsummaryrefslogtreecommitdiff
path: root/kamon-autoweave
diff options
context:
space:
mode:
authorDiego <diegolparra@gmail.com>2015-12-17 14:27:13 -0300
committerDiego <diegolparra@gmail.com>2015-12-17 14:27:13 -0300
commit961c6080fbf3cb1662121992a6ba65d7ca999a1e (patch)
tree8d0b5217f1e22eaf0b892eb5918fcfb37bf88740 /kamon-autoweave
parent3cc8f31bcf18ca52f936e3408ee16cd08d5520b2 (diff)
downloadKamon-961c6080fbf3cb1662121992a6ba65d7ca999a1e.tar.gz
Kamon-961c6080fbf3cb1662121992a6ba65d7ca999a1e.tar.bz2
Kamon-961c6080fbf3cb1662121992a6ba65d7ca999a1e.zip
= All: downgrade sbt to 0.13.8 in order to avoid issues with scalariform
Diffstat (limited to 'kamon-autoweave')
-rw-r--r--kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala15
-rw-r--r--kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala45
2 files changed, 29 insertions, 31 deletions
diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala
index 29c4254a..58111b48 100644
--- a/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala
+++ b/kamon-autoweave/src/main/scala/kamon/autoweave/Autoweave.scala
@@ -19,14 +19,13 @@ import kamon.Kamon
import kamon.autoweave.loader.AgentLoader
import org.aspectj.weaver.loadtime.Agent
-
object Autoweave {
- val config = Kamon.config.getConfig("kamon.autowave.options")
- val verbose = config.getBoolean("verbose")
- val showWeaveInfo = config.getBoolean("showWeaveInfo")
+ val config = Kamon.config.getConfig("kamon.autowave.options")
+ val verbose = config.getBoolean("verbose")
+ val showWeaveInfo = config.getBoolean("showWeaveInfo")
- System.setProperty("aj.weaving.verbose", verbose.toString)
- System.setProperty("org.aspectj.weaver.showWeaveInfo", showWeaveInfo.toString)
+ System.setProperty("aj.weaving.verbose", verbose.toString)
+ System.setProperty("org.aspectj.weaver.showWeaveInfo", showWeaveInfo.toString)
- AgentLoader.attachAgentToJVM(classOf[Agent])
- }
+ AgentLoader.attachAgentToJVM(classOf[Agent])
+}
diff --git a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala
index d4efdb85..0ad7fdf7 100644
--- a/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala
+++ b/kamon-autoweave/src/main/scala/kamon/autoweave/loader/AgentLoader.scala
@@ -15,18 +15,18 @@
package kamon.autoweave.loader
-import java.io.{File, FileOutputStream, InputStream}
+import java.io.{ File, FileOutputStream, InputStream }
import java.lang.management.ManagementFactory
import java.util
import java.util.jar.Attributes.Name
-import java.util.jar.{JarEntry, JarOutputStream, Manifest}
+import java.util.jar.{ JarEntry, JarOutputStream, Manifest }
import com.sun.tools.attach.spi.AttachProvider
-import com.sun.tools.attach.{VirtualMachine, VirtualMachineDescriptor}
+import com.sun.tools.attach.{ VirtualMachine, VirtualMachineDescriptor }
import sun.tools.attach._
import scala.util.control.NoStackTrace
-import scala.util.{Failure, Success, Try}
+import scala.util.{ Failure, Success, Try }
object AgentLoader {
@@ -113,25 +113,25 @@ object AgentLoader {
private def unqualify(clazz: Class[_]): String = clazz.getName.replace('.', '/') + ".class"
/**
- * Gets the current HotSpotVirtualMachine implementation otherwise a failure.
- *
- * @return
- * Returns the HotSpotVirtualMachine implementation of the running JVM.
- */
- private def findVirtualMachineImplementation(): Try[Class[_ <: HotSpotVirtualMachine]] = System.getProperty("os.name") match {
- case os if os.startsWith("Windows") => Success(classOf[WindowsVirtualMachine])
- case os if os.startsWith("Mac OS X") => Success(classOf[BsdVirtualMachine])
- case os if os.startsWith("Solaris") => Success(classOf[SolarisVirtualMachine])
- case os if os.startsWith("Linux") || os.startsWith("LINUX") => Success(classOf[LinuxVirtualMachine])
- case other => Failure(new RuntimeException(s"Cannot use Attach API on unknown OS: $other") with NoStackTrace)
+ * Gets the current HotSpotVirtualMachine implementation otherwise a failure.
+ *
+ * @return
+ * Returns the HotSpotVirtualMachine implementation of the running JVM.
+ */
+ private def findVirtualMachineImplementation(): Try[Class[_ <: HotSpotVirtualMachine]] = System.getProperty("os.name") match {
+ case os if os.startsWith("Windows") ⇒ Success(classOf[WindowsVirtualMachine])
+ case os if os.startsWith("Mac OS X") ⇒ Success(classOf[BsdVirtualMachine])
+ case os if os.startsWith("Solaris") ⇒ Success(classOf[SolarisVirtualMachine])
+ case os if os.startsWith("Linux") || os.startsWith("LINUX") ⇒ Success(classOf[LinuxVirtualMachine])
+ case other ⇒ Failure(new RuntimeException(s"Cannot use Attach API on unknown OS: $other") with NoStackTrace)
}
/**
- * Attach to the running JVM.
- *
- * @return
- * Returns the attached VirtualMachine
- */
+ * Attach to the running JVM.
+ *
+ * @return
+ * Returns the attached VirtualMachine
+ */
private def attachToRunningJVM(): VirtualMachine = {
val AttachProvider = new AttachProvider() {
override def name(): String = null
@@ -141,15 +141,14 @@ object AgentLoader {
}
findVirtualMachineImplementation() match {
- case Success(vmClass) =>
+ case Success(vmClass) ⇒
val pid = getPidFromRuntimeMBean
// This is only done with Reflection to avoid the JVM pre-loading all the XyzVirtualMachine classes.
val vmConstructor = vmClass.getConstructor(classOf[AttachProvider], classOf[String])
val newVM = vmConstructor.newInstance(AttachProvider, pid)
newVM.asInstanceOf[VirtualMachine]
- case Failure(reason) => throw reason
+ case Failure(reason) ⇒ throw reason
}
}
}
-