diff --git a/src/helma/extensions/ConfigurationException.java b/src/helma/extensions/ConfigurationException.java
new file mode 100644
index 00000000..908c54a9
--- /dev/null
+++ b/src/helma/extensions/ConfigurationException.java
@@ -0,0 +1,9 @@
+package helma.extensions;
+
+public class ConfigurationException extends RuntimeException {
+
+ public ConfigurationException (String msg) {
+ super (msg);
+ }
+
+}
diff --git a/src/helma/extensions/HelmaExtension.java b/src/helma/extensions/HelmaExtension.java
new file mode 100644
index 00000000..22ae0f38
--- /dev/null
+++ b/src/helma/extensions/HelmaExtension.java
@@ -0,0 +1,40 @@
+package helma.extensions;
+
+import helma.framework.core.Application;
+import helma.main.Server;
+import helma.scripting.ScriptingEngine;
+
+/**
+ * Helma extensions have to subclass this. The extensions to be loaded are
+ * defined in server.properties
by setting extensions =
+ * packagename.classname, packagename.classname
.
+ */
+
+public abstract class HelmaExtension {
+
+ /**
+ * called by the Server at startup time. should check wheter the needed classes
+ * are present and throw a ConfigurationException if not.
+ */
+ public abstract void init (Server server) throws ConfigurationException;
+
+ /**
+ * called when an Application is started.
+ */
+ public abstract void applicationStarted (Application app) throws ConfigurationException;
+
+ /**
+ * called when an Application is stopped.
+ */
+ public abstract void applicationStopped (Application app);
+
+ /**
+ * called by the ScriptingEngine when it is initizalized. throws a ConfigurationException
+ * when this type of ScriptingEngine is not supported.
+ */
+ public abstract void initScripting (Application app, ScriptingEngine engine) throws ConfigurationException;
+
+ public abstract String getName ();
+
+}
+
diff --git a/src/helma/extensions/demo/DemoExtension.java b/src/helma/extensions/demo/DemoExtension.java
new file mode 100644
index 00000000..ed4e4755
--- /dev/null
+++ b/src/helma/extensions/demo/DemoExtension.java
@@ -0,0 +1,69 @@
+package helma.extensions.demo;
+
+import helma.extensions.HelmaExtension;
+import helma.extensions.ConfigurationException;
+import helma.framework.core.Application;
+import helma.main.Server;
+import helma.scripting.ScriptingEngine;
+
+// fesi-related stuff:
+import FESI.Data.ESObject;
+import FESI.Data.ESWrapper;
+import FESI.Data.GlobalObject;
+import FESI.Exceptions.EcmaScriptException;
+import FESI.Interpreter.Evaluator;
+import helma.scripting.fesi.FesiEvaluator;
+
+
+/**
+ * a demo extension implementation, to activate this add extensions =
+ * helma.extensions.demo.DemoExtensions
to your server.properties
.
+ * a new global object demo
that wraps helma.main.Server
+ * will be added to the scripting environment.
+ */
+
+public class DemoExtension extends HelmaExtension {
+
+ public void init (Server server) throws ConfigurationException {
+ try {
+ // just a demo with the server class itself (which is always there, obviously)
+ Class check = Class.forName("helma.main.Server");
+ } catch (ClassNotFoundException e) {
+ throw new ConfigurationException("helma-library not present in classpath. make sure helma.jar is included. get it from http://www.helma.org/");
+ }
+ }
+
+ public void applicationStarted (Application app) throws ConfigurationException {
+ app.logEvent ("DemoExtension init with app " + app.getName () );
+ }
+
+ public void applicationStopped (Application app) {
+ app.logEvent ("DemoExtension stopped on app " + app.getName () );
+ }
+
+ public void initScripting (Application app, ScriptingEngine engine) throws ConfigurationException {
+ if (engine instanceof FesiEvaluator) {
+ try {
+ initFesi (app, engine);
+ app.logEvent("initScripting DemoExtension with " + app.getName () + " and " + engine.toString() );
+ } catch (EcmaScriptException ecma) {
+ throw new ConfigurationException (ecma.getMessage());
+ }
+ } else {
+ throw new ConfigurationException ("scripting engine " + engine.toString () + " not supported in DemoExtension");
+ }
+ }
+
+ public String getName () {
+ return "DemoExtension";
+ }
+
+ private void initFesi (Application app, ScriptingEngine engine) throws EcmaScriptException {
+ Evaluator evaluator = ((FesiEvaluator)engine).getEvaluator ();
+ ESObject demo = new ESWrapper(Server.getServer (), evaluator);
+ GlobalObject go = evaluator.getGlobalObject();
+ go.putHiddenProperty ("demo", demo);
+ }
+
+}
+