I got this to work - here is the screen shot
Here is the drop-down with the first value being returned from an AEM Service:

Here is the updated Script datasource.jsp from the artilce:
<%@page session="false" import="
org.apache.sling.api.resource.Resource,
org.apache.sling.api.resource.ResourceUtil,
org.apache.sling.api.resource.ValueMap,
org.apache.sling.api.resource.ResourceResolver,
org.apache.sling.api.resource.ResourceMetadata,
org.apache.sling.api.wrappers.ValueMapDecorator,
java.util.List,
java.util.ArrayList,
java.util.HashMap,
java.util.Locale,
com.adobe.granite.ui.components.ds.DataSource,
com.adobe.granite.ui.components.ds.EmptyDataSource,
com.adobe.granite.ui.components.ds.SimpleDataSource,
com.adobe.granite.ui.components.ds.ValueMapResource,
com.day.cq.wcm.api.Page,
com.day.cq.wcm.api.PageManager"%><%
%><%@taglib prefix="cq" uri="http://www.day.com/taglibs/cq/1.0" %><%
%><cq:defineObjects/><%
// set fallback
request.setAttribute(DataSource.class.getName(), EmptyDataSource.instance());
ResourceResolver resolver = resource.getResourceResolver();
//Create an ArrayList to hold data
List<Resource> fakeResourceList = new ArrayList<Resource>();
ValueMap vm = null;
//INVOKE A BACKEND OSGI Service
com.community.aem.datasource.HelloService mySource = sling.getService(com.community.aem.datasource.HelloService.class) ;
String osgiValue = mySource.getData();
String Text="";
//Add 5 values to drop down!
for (int i=0; i<5; i++)
{
//allocate memory to the Map instance
vm = new ValueMapDecorator(new HashMap<String, Object>());
// Specify the value and text values
String Value = "value"+i ;
if (i==0)
Text = osgiValue;
else
Text = "text"+i ;
//populate the map
vm.put("value",Value);
vm.put("text",Text);
fakeResourceList.add(new ValueMapResource(resolver, new ResourceMetadata(), "nt:unstructured", vm));
System.out.print("*** THE VALUE OF i IS " +i) ;
}
//Create a DataSource that is used to populate the drop-down control
DataSource ds = new SimpleDataSource(fakeResourceList.iterator());
request.setAttribute(DataSource.class.getName(), ds);
%>
I will add this to the article. The OSGi service is very simple and exposes this method:
package com.community.aem.datasource.impl;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.jcr.api.SlingRepository;
import com.community.aem.datasource.HelloService;
@Service
@Component(metatype = false)
public class HelloServiceImpl implements HelloService {
public String getData()
{
return "returned from an OSGi Service" ;
}
}
In this example - we hard coded the return value. However - if you want to use OSGi config values, you can read them in your service and return them. TO learn how to read OSGi config values from an OSGi service - read this community document.
Reading AEM OSGi Configuration Values