FELIX-2396: Ability to have callbacks when accessing session variables
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@999782 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
index a8b042a..9958936 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/CommandSessionImpl.java
@@ -23,6 +23,7 @@
import org.apache.felix.service.command.CommandSession;
import org.apache.felix.service.command.Converter;
+import org.apache.felix.service.command.Function;
import org.apache.felix.service.threadio.ThreadIO;
import java.io.InputStream;
@@ -102,6 +103,22 @@
return processor.constants.get(name);
}
+ if (variables.containsKey("#" + name))
+ {
+ Object f = variables.get("#" + name);
+ if (f instanceof Function)
+ {
+ try
+ {
+ f = ((Function) f).execute(this, null);
+ }
+ catch (Exception e)
+ {
+ // Ignore
+ }
+ }
+ return f;
+ }
if (variables.containsKey(name))
{
return variables.get(name);