You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.4 KiB
Kotlin
44 lines
1.4 KiB
Kotlin
package wf.servitor.engine.dispatcher
|
|
|
|
import org.apache.commons.jexl3.JexlContext
|
|
import org.apache.commons.jexl3.introspection.JexlMethod
|
|
import wf.servitor.engine.exception.UnresolvedRemoteCallException
|
|
|
|
class NamespaceFaker(
|
|
private val namespace: String,
|
|
private val dispatchedValues: MutableList<Any?>,
|
|
val nextValueIndex: Int = dispatchedValues.size
|
|
) : JexlContext {
|
|
override fun has(name: String) = true
|
|
override fun get(name: String): Any {
|
|
return CallExecutor {
|
|
if (dispatchedValues.isNotEmpty()) {
|
|
val first = dispatchedValues.first()
|
|
dispatchedValues.removeAt(0)
|
|
first
|
|
} else {
|
|
throw UnresolvedRemoteCallException(namespace, name, it.toList(), nextValueIndex)
|
|
}
|
|
}
|
|
}
|
|
|
|
override fun set(name: String, value: Any?) {
|
|
throw UnsupportedOperationException()
|
|
}
|
|
|
|
class CallExecutor(val dispatchedValue: (Array<out Any?>) -> Any?) : JexlMethod {
|
|
override fun tryInvoke(name: String?, obj: Any?, vararg params: Any?): Any {
|
|
TODO("not implemented")
|
|
}
|
|
|
|
override fun isCacheable() = false;
|
|
override fun getReturnType(): Class<*> = TODO()
|
|
override fun tryFailed(rval: Any?) = true
|
|
|
|
override fun invoke(obj: Any?, vararg params: Any?): Any? {
|
|
return dispatchedValue(params);
|
|
}
|
|
|
|
}
|
|
}
|