File tree 4 files changed +28
-8
lines changed
framework/src/main/kotlin/com/neva/javarel/framework
presentation/view/pebble/src/main/kotlin/com/neva/javarel/presentation/view/pebble/functions
4 files changed +28
-8
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.neva.javarel.framework.api.rest
2
2
3
3
import com.neva.javarel.communication.rest.api.UrlGenerator
4
4
import com.neva.javarel.foundation.api.injection.Osgi
5
+ import com.neva.javarel.framework.api.structure.App
5
6
import com.neva.javarel.presentation.asset.api.Asset
6
7
import com.neva.javarel.presentation.view.api.View
7
8
import com.neva.javarel.resource.api.ResourceResolver
@@ -15,6 +16,9 @@ abstract class Controller {
15
16
@Inject
16
17
protected lateinit var guard: Guard
17
18
19
+ @Osgi
20
+ protected lateinit var app: App
21
+
18
22
@Osgi
19
23
protected lateinit var dbAdmin: DatabaseAdmin
20
24
@@ -37,7 +41,8 @@ abstract class Controller {
37
41
38
42
protected val context: Map <String , Any > by lazy {
39
43
mapOf (
40
- " guard" to guard
44
+ " guard" to guard,
45
+ " app" to app
41
46
)
42
47
}
43
48
Original file line number Diff line number Diff line change @@ -2,6 +2,6 @@ package com.neva.javarel.framework.api.structure
2
2
3
3
interface App {
4
4
5
- val modules: Set <Module >
5
+ val modules: List <Module >
6
6
7
7
}
Original file line number Diff line number Diff line change 1
1
package com.neva.javarel.framework.impl.structure
2
2
3
- import com.google.common.collect.Sets
4
3
import com.neva.javarel.framework.api.structure.App
5
4
import com.neva.javarel.framework.api.structure.Module
6
5
import org.apache.felix.scr.annotations.*
@@ -16,10 +15,10 @@ class MultiModuleApp : App {
16
15
policy = ReferencePolicy .DYNAMIC ,
17
16
policyOption = ReferencePolicyOption .GREEDY
18
17
)
19
- private val allModules = Sets .newConcurrentHashSet< Module > (TreeSet <Module >({ m1, m2 -> m1.priority.compareTo(m2.priority) }))
18
+ private val allModules = Collections .synchronizedSortedSet (TreeSet <Module >({ m1, m2 -> m1.priority.compareTo(m2.priority) }))
20
19
21
- override val modules: Set <Module >
22
- get() = allModules.toSet ()
20
+ override val modules: List <Module >
21
+ get() = allModules.toList ()
23
22
24
23
protected fun bindModule (module : Module ) {
25
24
allModules.add(module)
Original file line number Diff line number Diff line change @@ -5,10 +5,26 @@ import com.neva.javarel.presentation.view.api.ViewException
5
5
6
6
class ServiceFunction (val osgiUtils : OsgiUtils ) : BaseFunction() {
7
7
8
+ companion object {
9
+ const val CLASS_ARG = " class"
10
+ }
11
+
12
+ override fun getArgumentNames (): MutableList <String > {
13
+ return mutableListOf (CLASS_ARG )
14
+ }
15
+
8
16
override fun execute (args : Map <String , Any >): Any {
9
- val serviceClass = firstArgument(args) as String
17
+ val serviceClass = args.get(CLASS_ARG ) as String?
18
+ if (serviceClass.isNullOrBlank()) {
19
+ throw ViewException (" OSGi service class cannot be empty." )
20
+ }
21
+
22
+ val service = osgiUtils.serviceOf<Any >(serviceClass!! )
23
+ if (service == null ) {
24
+ throw ViewException (" OSGi service '$serviceClass ' cannot be found." )
25
+ }
10
26
11
- return osgiUtils.serviceOf(serviceClass) ? : throw ViewException ( " OSGi service ' $serviceClass ' cannot be found. " )
27
+ return service
12
28
}
13
29
14
30
}
You can’t perform that action at this time.
0 commit comments