File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
airframe-di/src/main/scala-3/wvlet/airframe
airframe-http-router/src/main/scala-3/wvlet/airframe/http/router Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ package object airframe {
37
37
def newSilentDesign : Design = newDesign.noLifeCycleLogging
38
38
39
39
import scala .jdk .CollectionConverters ._
40
+
40
41
// This will not be used in Scala 3, but left for the compatibility with Scala 2
41
42
val traitFactoryCache = new ConcurrentHashMap [Surface , Session => Any ].asScala
42
43
def getOrElseUpdateTraitFactoryCache (s : Surface , factory : Session => Any ): Session => Any = {
Original file line number Diff line number Diff line change @@ -16,9 +16,11 @@ package wvlet.airframe.http.router
16
16
import wvlet .airframe .http .Router
17
17
import wvlet .airframe .http .HttpFilterType
18
18
import wvlet .airframe .surface .Surface
19
+ import wvlet .airframe .Session
19
20
20
21
trait RouterBase { self : Router =>
21
22
inline def add [Controller ]: Router = {
23
+ // TODO registerTraitFactory
22
24
self.addInternal(Surface .of[Controller ], Surface .methodsOf[Controller ])
23
25
}
24
26
@@ -41,9 +43,22 @@ private[router] object RouterObjectMacros {
41
43
import quotes .reflect ._
42
44
43
45
if (TypeRepr .of[Controller ] <:< TypeRepr .of[HttpFilterType ]) {
46
+ // TODO registerTraitFactory
44
47
' { Router (filterSurface = Some (Surface .of[Controller ])) }
45
48
} else {
49
+ // TODO registerTraitFactory
46
50
' { Router .empty.add[Controller ] }
47
51
}
48
52
}
53
+
54
+ // def registerTraitFactory[T: Type](using quotes: Quotes): Expr[Unit] = {
55
+ // // TODO implement simlar thing method like AirframeMacros.shouldGenerateTrait
56
+ // // TODO instantiate an arbitrary trait https://github.com/lampepfl/dotty/issues/11685
57
+ // val t = Type.of[T].info
58
+ // '{ wvlet.airframe.getOrElseUpdateTraitFactoryCache(
59
+ // Surface.of[T],
60
+ // { (ss: Session) => (new ${t} {}).asInstanceOf[Any] }
61
+ // )
62
+ // }
63
+ // }
49
64
}
You can’t perform that action at this time.
0 commit comments