Index: xwiki-script/src/main/java/org/xwiki/script/ScriptServiceManager.java
===================================================================
--- xwiki-script/src/main/java/org/xwiki/script/ScriptServiceManager.java	(revision 0)
+++ xwiki-script/src/main/java/org/xwiki/script/ScriptServiceManager.java	(revision 0)
@@ -0,0 +1,12 @@
+package org.xwiki.script;
+
+import org.xwiki.component.annotation.ComponentRole;
+
+/**
+ * Script service manager
+ */
+@ComponentRole
+public interface ScriptServiceManager
+{
+    ScriptService get(String serviceName);    
+}

Property changes on: xwiki-script/src/main/java/org/xwiki/script/ScriptServiceManager.java
___________________________________________________________________
Name: svn:eol-style
   + native

Index: xwiki-script/src/main/java/org/xwiki/script/ScriptService.java
===================================================================
--- xwiki-script/src/main/java/org/xwiki/script/ScriptService.java	(revision 0)
+++ xwiki-script/src/main/java/org/xwiki/script/ScriptService.java	(revision 0)
@@ -0,0 +1,27 @@
+package org.xwiki.script;
+
+import org.xwiki.component.annotation.ComponentRole;
+
+/**
+ * A tag interface to mark a class so that it is mapped in the <code>service</code> binding exposed 
+ * to scripting languages.
+ * The hint of implementing class will be used as the key in the <code>service</code> map. For example
+ * the following class :
+ * <code>
+ * @Component("mymodule")
+ * public class MyModuleScriptService implements ScriptService, MyModuleBusinessInterface { 
+ *   public void myMethod() {} 
+ * }
+ * </code>
+ * 
+ * can be used from scripting services like this (here in velocity):
+ * <code>
+ * {{velocity}}
+ * $services.mymodule.myMethod
+ * {{/velocity}} 
+ * </code> 
+ */
+@ComponentRole
+public interface ScriptService
+{
+}

Property changes on: xwiki-script/src/main/java/org/xwiki/script/ScriptService.java
___________________________________________________________________
Name: svn:eol-style
   + native

Index: xwiki-script/src/main/java/org/xwiki/script/internal/DefaultScriptServiceManager.java
===================================================================
--- xwiki-script/src/main/java/org/xwiki/script/internal/DefaultScriptServiceManager.java	(revision 0)
+++ xwiki-script/src/main/java/org/xwiki/script/internal/DefaultScriptServiceManager.java	(revision 0)
@@ -0,0 +1,23 @@
+package org.xwiki.script.internal;
+
+import java.util.Map;
+
+import org.xwiki.component.annotation.Component;
+import org.xwiki.component.annotation.InstantiationStrategy;
+import org.xwiki.component.annotation.Requirement;
+import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
+import org.xwiki.script.ScriptService;
+import org.xwiki.script.ScriptServiceManager;
+
+@Component
+@InstantiationStrategy(value = ComponentInstantiationStrategy.PER_LOOKUP)
+public class DefaultScriptServiceManager implements ScriptServiceManager
+{
+    @Requirement(role = ScriptService.class)
+    private Map<String, ScriptService> services;
+    
+    public ScriptService get(String serviceName)
+    {
+        return this.services.get(serviceName);
+    }
+}
\ No newline at end of file

Property changes on: xwiki-script/src/main/java/org/xwiki/script/internal/DefaultScriptServiceManager.java
___________________________________________________________________
Name: svn:eol-style
   + native

Index: xwiki-script/src/main/resources/META-INF/components.txt
===================================================================
--- xwiki-script/src/main/resources/META-INF/components.txt	(revision 24797)
+++ xwiki-script/src/main/resources/META-INF/components.txt	(working copy)
@@ -1,2 +1,3 @@
 org.xwiki.script.internal.DefaultScriptContextManager
-org.xwiki.script.internal.ScriptExecutionContextInitializer
\ No newline at end of file
+org.xwiki.script.internal.ScriptExecutionContextInitializer
+org.xwiki.script.internal.DefaultScriptServiceManager
\ No newline at end of file
Index: xwiki-core/src/main/java/com/xpn/xwiki/render/XWikiScriptContextInitializer.java
===================================================================
--- xwiki-core/src/main/java/com/xpn/xwiki/render/XWikiScriptContextInitializer.java	(revision 24797)
+++ xwiki-core/src/main/java/com/xpn/xwiki/render/XWikiScriptContextInitializer.java	(working copy)
@@ -26,6 +26,7 @@
 import org.xwiki.context.Execution;
 import org.xwiki.rendering.syntax.SyntaxFactory;
 import org.xwiki.script.ScriptContextInitializer;
+import org.xwiki.script.ScriptServiceManager;
 
 import com.xpn.xwiki.XWikiContext;
 import com.xpn.xwiki.api.Context;
@@ -45,6 +46,9 @@
     @Requirement
     private Execution execution;
 
+    @Requirement
+    private ScriptServiceManager scriptServiceManager;
+    
     /**
      * {@inheritDoc}
      * 
@@ -59,6 +63,9 @@
             scriptContext.setAttribute("util", new com.xpn.xwiki.api.Util(xcontext.getWiki(), xcontext),
                 ScriptContext.ENGINE_SCOPE);
 
+            // We put the services API in the script context
+            scriptContext.setAttribute("services", scriptServiceManager, ScriptContext.ENGINE_SCOPE);
+            
             // We put the com.xpn.xwiki.api.XWiki object into the context and not the com.xpn.xwiki.XWiki one which is
             // for internal use only. In this manner we control what the user can access.
             scriptContext.setAttribute("xwiki", new XWiki(xcontext.getWiki(), xcontext), ScriptContext.ENGINE_SCOPE);
Index: xwiki-core/src/main/java/com/xpn/xwiki/render/DefaultVelocityManager.java
===================================================================
--- xwiki-core/src/main/java/com/xpn/xwiki/render/DefaultVelocityManager.java	(revision 24797)
+++ xwiki-core/src/main/java/com/xpn/xwiki/render/DefaultVelocityManager.java	(working copy)
@@ -31,6 +31,7 @@
 import org.xwiki.component.annotation.Requirement;
 import org.xwiki.context.Execution;
 import org.xwiki.rendering.syntax.SyntaxFactory;
+import org.xwiki.script.ScriptServiceManager;
 import org.xwiki.velocity.VelocityEngine;
 import org.xwiki.velocity.VelocityFactory;
 import org.xwiki.velocity.VelocityManager;
@@ -61,6 +62,9 @@
     @Requirement
     private Execution execution;
 
+    @Requirement
+    private ScriptServiceManager services;
+    
     public VelocityContext getVelocityContext()
     {
         // The Velocity Context is set in VelocityRequestInterceptor, when the XWiki Request is initialized so we are
@@ -76,6 +80,9 @@
             // Put the Util API in the Velocity context.
             vcontext.put("util", new com.xpn.xwiki.api.Util(xcontext.getWiki(), xcontext));
 
+            // Put the services object in the Velocity context
+            vcontext.put("services", services);
+            
             // We put the com.xpn.xwiki.api.XWiki object into the context and not the com.xpn.xwiki.XWiki one which is
             // for internal use only. In this manner we control what the user can access.
             vcontext.put("xwiki", new XWiki(xcontext.getWiki(), xcontext));
