blob: cccb0242e8b84c2d4f617258cc2f4b9c3c438618 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.container
import java.lang.reflect.Type
import com.google.inject.Key
import com.yahoo.config.ConfigInstance
import com.yahoo.vespa.config.ConfigKey
import scala.language.implicitConversions
/**
*
* @author gjoranv
* @author Tony Vaagenes
*/
package object di {
type ConfigKeyT = ConfigKey[_ <: ConfigInstance]
type GuiceInjector = com.google.inject.Injector
type JavaAnnotation = java.lang.annotation.Annotation
def createKey(instanceType: Type, annotation: JavaAnnotation) = {
{if (annotation == null)
Key.get(instanceType)
else
Key.get(instanceType, annotation)
}.asInstanceOf[Key[AnyRef]]
}
implicit def makeClassCovariant[SUB, SUPER >: SUB](clazz: Class[SUB]) : Class[SUPER] = {
clazz.asInstanceOf[Class[SUPER]]
}
def removeStackTrace(exception: Throwable): Throwable = {
if (preserveStackTrace) exception
else {
exception.setStackTrace(Array())
exception
}
}
//For debug purposes only
val preserveStackTrace: Boolean = Option(System.getProperty("jdisc.container.preserveStackTrace")).filterNot(_.isEmpty).isDefined
}
|