<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/bundle/AMFServicesTracker.java</filename>
    </added>
    <added>
      <filename>uk.co.arum.osgi.amf3.sample/src/uk/co/arum/osgi/amf3/sample/bundle/PublishedObjectEventHandler.java</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,17 +2,20 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: AMF3 Flex Remoting for OSGi
 Bundle-SymbolicName: uk.co.arum.osgi.amf3.flex.remoting
-Bundle-Version: 1.0.1
-Bundle-Activator: uk.co.arum.osgi.amf3.flex.remoting.bundle.Activator
+Bundle-Version: 1.0.2
 Bundle-Vendor: Arum Systems Ltd
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Import-Package: org.osgi.framework;version=&quot;1.3.0&quot;,
- org.osgi.service.event;version=&quot;1.1.0&quot;,
- org.osgi.service.log;version=&quot;1.3.0&quot;,
- org.osgi.util.tracker;version=&quot;1.3.3&quot;,
- uk.co.arum.osgi.amf3;version=&quot;1.0.0&quot;,
- uk.co.arum.osgi.amf3.flex.remoting;version=&quot;1.0.0&quot;,
- uk.co.arum.osgi.amf3.flex.remoting.events;version=&quot;1.0.0&quot;
+Import-Package: flex.messaging.io,
+ org.osgi.framework;version=&quot;[1.3.0,2.0.0)&quot;,
+ org.osgi.service.event;version=&quot;[1.1.0,2.0.0)&quot;,
+ org.osgi.service.log;version=&quot;[1.3.0,2.0.0)&quot;,
+ org.osgi.util.tracker;version=&quot;[1.3.3,2.0.0)&quot;,
+ uk.co.arum.osgi.amf3;version=&quot;[1.0.0,2.0.0)&quot;,
+ uk.co.arum.osgi.amf3.flex.remoting;version=&quot;[1.0.0,2.0.0)&quot;,
+ uk.co.arum.osgi.amf3.flex.remoting.events;version=&quot;[1.0.0,2.0.0)&quot;,
+ uk.co.arum.osgi.glue;version=&quot;[1.0.1,2.0.0)&quot;
 Export-Package: flex.messaging.messages,
  uk.co.arum.osgi.amf3.flex.remoting;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.flex.remoting.events;version=&quot;1.0.0&quot;;uses:=&quot;org.osgi.service.event&quot;
+Glueable-Component: uk.co.arum.osgi.amf3.flex.remoting.bundle.MessagingManager, 
+ uk.co.arum.osgi.amf3.flex.remoting.bundle.FlexRemotingAMFFactory</diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/META-INF/MANIFEST.MF</filename>
    </modified>
    <modified>
      <diff>@@ -4,7 +4,7 @@
 	xsi:noNamespaceSchemaLocation=&quot;http://ant.apache.org/ivy/schemas/ivy.xsd&quot;&gt;
 	&lt;info organisation=&quot;uk.co.arum&quot; module=&quot;uk.co.arum.osgi.amf3.flex.remoting&quot; /&gt;
 	&lt;publications&gt;
-		&lt;artifact name=&quot;uk.co.arum.osgi.amf3.flex.remoting_1.0.1&quot; ext=&quot;jar&quot;/&gt;
+		&lt;artifact name=&quot;uk.co.arum.osgi.amf3.flex.remoting_1.0.2&quot; ext=&quot;jar&quot;/&gt;
 	&lt;/publications&gt;
 	&lt;dependencies&gt;
 		&lt;dependency org=&quot;uk.org.brindy&quot; name=&quot;uk.org.brindy.osgibb&quot;
@@ -14,5 +14,6 @@
 		&lt;dependency org=&quot;org.osgi&quot; name=&quot;org.osgi.core&quot; rev=&quot;4.1.0&quot; /&gt;
 		&lt;dependency org=&quot;org.osgi&quot; name=&quot;org.osgi.compendium&quot; rev=&quot;4.1.0&quot; /&gt;
 		&lt;dependency org=&quot;uk.co.arum&quot; name=&quot;uk.co.arum.osgi.amf3&quot; rev=&quot;1.0.1&quot; /&gt;
+		&lt;dependency org=&quot;uk.co.arum&quot; name=&quot;uk.co.arum.osgi.glue&quot; rev=&quot;1.0.0&quot; /&gt;
 	&lt;/dependencies&gt;
 &lt;/ivy-module&gt;</diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/ivy.xml</filename>
    </modified>
    <modified>
      <diff>@@ -25,15 +25,19 @@ import java.io.ObjectInput;
 import java.io.ObjectOutput;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
-import java.util.ArrayList;
+import java.util.Dictionary;
 import java.util.List;
 import java.util.UUID;
 
+import org.osgi.framework.BundleContext;
 import org.osgi.service.log.LogService;
 
 import uk.co.arum.osgi.amf3.AMFFactory;
 import uk.co.arum.osgi.amf3.flex.remoting.RemotingContext;
 import uk.co.arum.osgi.amf3.flex.remoting.events.PublishedObjectEvent;
+import uk.co.arum.osgi.glue.Activatable;
+import uk.co.arum.osgi.glue.Contextual;
+import uk.co.arum.osgi.glue.GlueableService;
 import flex.messaging.messages.AcknowledgeMessage;
 import flex.messaging.messages.AsyncMessage;
 import flex.messaging.messages.CommandMessage;
@@ -41,7 +45,8 @@ import flex.messaging.messages.ErrorMessage;
 import flex.messaging.messages.Message;
 import flex.messaging.messages.RemotingMessage;
 
-public class FlexRemotingAMFFactory implements AMFFactory {
+public class FlexRemotingAMFFactory implements GlueableService, Activatable,
+		Contextual, AMFFactory {
 
 	private static final String NIL_DSID = &quot;nil&quot;;
 
@@ -49,19 +54,24 @@ public class FlexRemotingAMFFactory implements AMFFactory {
 
 	private static final String DSID = &quot;DSId&quot;;
 
-	private final OSGiAMFConfig config;
+	private OSGiAMFConfig config;
 
-	private final MessagingManager messagingManager;
+	private MessagingManager messagingManager;
 
 	private LogService logService;
 
-	public FlexRemotingAMFFactory(OSGiAMFConfig config,
-			MessagingManager messagingManager) {
-		this.config = config;
-		this.messagingManager = messagingManager;
+	private BundleContext context;
+
+	private AMFServicesTracker amfServicesTracker;
+
+	public FlexRemotingAMFFactory() {
+	}
+
+	public void bind(MessagingManager mgr) {
+		this.messagingManager = mgr;
 	}
 
-	public void setLogService(LogService logService) {
+	public void bind(LogService logService) {
 		this.logService = logService;
 	}
 
@@ -154,8 +164,59 @@ public class FlexRemotingAMFFactory implements AMFFactory {
 
 	}
 
+	public Object handleException(Exception ex) {
+		return new ErrorMessage(ex);
+	}
+
+	public Object readExternal(String name, ObjectInput deserializer) {
+		return null;
+	}
+
+	public boolean writeExternal(Object o, ObjectOutput serialiser) {
+		return false;
+	}
+
+	public void activate() throws Exception {
+		logService.log(LogService.LOG_DEBUG,
+				&quot;FlexRemotingAMFFactory - ACTIVATED&quot;);
+		config = new OSGiAMFConfig(context);
+		amfServicesTracker = new AMFServicesTracker(context, config);
+		amfServicesTracker.open();
+	}
+
+	public void deactivate() throws Exception {
+		logService.log(LogService.LOG_DEBUG,
+				&quot;FlexRemotingAMFFactory - DEACTIVATING&quot;);
+
+		amfServicesTracker.close();
+		amfServicesTracker = null;
+
+		config.dispose();
+		config = null;
+	}
+
+	public void bindContext(BundleContext context) {
+		this.context = context;
+	}
+
+	public void unbindContext(BundleContext context) {
+		this.context = null;
+	}
+
+	public Dictionary&lt;?, ?&gt; getProperties(String serviceName) {
+		return null;
+	}
+
+	public String getServiceFilter(String serviceName, String name) {
+		return null;
+	}
+
+	public String[] getServiceNames() {
+		return new String[] { AMFFactory.class.getName() };
+	}
+
 	private Object doProcess(Object o) {
-		if (o instanceof ArrayList) {
+		if (o instanceof List&lt;?&gt;) {
 			List&lt;?&gt; list = (List&lt;?&gt;) o;
 			if (list.size() &gt; 0) {
 				o = list.get(0);
@@ -389,16 +450,4 @@ public class FlexRemotingAMFFactory implements AMFFactory {
 		return null;
 	}
 
-	public Object handleException(Exception ex) {
-		return new ErrorMessage(ex);
-	}
-
-	public Object readExternal(String name, ObjectInput deserializer) {
-		return null;
-	}
-
-	public boolean writeExternal(Object o, ObjectOutput serialiser) {
-		return false;
-	}
-
 }</diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/bundle/FlexRemotingAMFFactory.java</filename>
    </modified>
    <modified>
      <diff>@@ -23,8 +23,10 @@ package uk.co.arum.osgi.amf3.flex.remoting.bundle;
 
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Dictionary;
 import java.util.HashMap;
 import java.util.HashSet;
+import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
@@ -35,31 +37,37 @@ import java.util.UUID;
 
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
+import org.osgi.service.event.EventConstants;
 import org.osgi.service.event.EventHandler;
-import org.osgi.service.log.LogService;
 
 import uk.co.arum.osgi.amf3.flex.remoting.events.PublishedObjectEvent;
+import uk.co.arum.osgi.glue.Activatable;
+import uk.co.arum.osgi.glue.GlueableService;
 import flex.messaging.messages.AsyncMessage;
 
 @SuppressWarnings(&quot;unchecked&quot;)
-public class MessagingManager implements EventHandler {
+public class MessagingManager implements Activatable, GlueableService,
+		EventHandler {
 
 	// TODO make this configurable? if so, how?
 	public static final long SUBSCRIPTION_TIMEOUT = 1000 * 30;
 
-	private EventAdmin eventAdmin;
+	private final Map&lt;String, Long&gt; accessTimes = new HashMap&lt;String, Long&gt;();
 
-	private LogService logService;
+	private EventAdmin eventAdmin;
 
 	private final Set&lt;Subscription&gt; subscriptions = Collections
 			.synchronizedSet(new HashSet&lt;Subscription&gt;());
 
-	private final Map&lt;String, List&gt; waitingMessages = new HashMap&lt;String, List&gt;();
+	private Timer timer;
 
-	private final Map&lt;String, Long&gt; accessTimes = new HashMap&lt;String, Long&gt;();
+	private final Map&lt;String, List&gt; waitingMessages = new HashMap&lt;String, List&gt;();
 
 	public MessagingManager() {
-		Timer timer = new Timer();
+	}
+
+	public void activate() throws Exception {
+		timer = new Timer();
 		timer.schedule(new TimerTask() {
 			@Override
 			public void run() {
@@ -68,24 +76,13 @@ public class MessagingManager implements EventHandler {
 		}, SUBSCRIPTION_TIMEOUT);
 	}
 
-	public void setEventAdmin(EventAdmin eventAdmin) {
+	public void bind(EventAdmin eventAdmin) {
 		this.eventAdmin = eventAdmin;
 	}
 
-	public void setLogService(LogService logService) {
-		this.logService = logService;
-	}
-
-	public void handleEvent(Event event) {
-		if (event instanceof PublishedObjectEvent) {
-			PublishedObjectEvent poevent = (PublishedObjectEvent) event;
-
-			// if the event was generated internally dispatch the event to
-			// connected clients
-			if (null == poevent.getSourceID()) {
-				dispatch(poevent);
-			}
-		}
+	public void deactivate() throws Exception {
+		timer.cancel();
+		timer = null;
 	}
 
 	public void dispatch(PublishedObjectEvent event) {
@@ -97,12 +94,7 @@ public class MessagingManager implements EventHandler {
 
 		// if the event was generated externally dispatch an osgi event
 		if (null != event.getSourceID()) {
-			if (eventAdmin != null) {
-				eventAdmin.postEvent(event);
-			} else {
-				logService.log(LogService.LOG_WARNING,
-						&quot;PublishedObjectEvent: No event admin&quot;);
-			}
+			eventAdmin.postEvent(event);
 		}
 	}
 
@@ -134,34 +126,25 @@ public class MessagingManager implements EventHandler {
 		return null;
 	}
 
-	public void subscribe(String subscriptionID, String channel) {
-
-		subscriptions.add(new Subscription(channel, null, this));
-		addSubscriber(subscriptionID, channel, null);
-
-		if (null == waitingMessages.get(subscriptionID)) {
-			waitingMessages.put(subscriptionID, new LinkedList());
-		}
+	public Dictionary getProperties(String serviceName) {
 
-		if (null == accessTimes.get(subscriptionID)) {
-			accessTimes.put(subscriptionID, System.currentTimeMillis());
+		if (serviceName.equals(EventHandler.class.getName())) {
+			String[] topics = new String[] { PublishedObjectEvent.TOPIC };
+			Hashtable ht = new Hashtable();
+			ht.put(EventConstants.EVENT_TOPIC, topics);
+			return ht;
 		}
 
+		return null;
 	}
 
-	public void unsubscribe(String subscriptionID, String channel) {
-
-		Set&lt;Subscription&gt; expiredSubscriptions = new HashSet&lt;Subscription&gt;();
-		for (Subscription sub : getSubscriptions(subscriptionID)) {
-			if (sub.getChannel().equals(channel)) {
-				if (sub.removeSubscription(subscriptionID) &lt;= 0) {
-					expiredSubscriptions.add(sub);
-				}
-			}
-		}
-
-		subscriptions.removeAll(expiredSubscriptions);
+	public String getServiceFilter(String serviceName, String name) {
+		return null;
+	}
 
+	public String[] getServiceNames() {
+		return new String[] { EventHandler.class.getName(),
+				MessagingManager.class.getName() };
 	}
 
 	public Collection&lt;Subscription&gt; getSubscriptions(String subscriptionID) {
@@ -176,6 +159,18 @@ public class MessagingManager implements EventHandler {
 		return subs;
 	}
 
+	public void handleEvent(Event event) {
+		if (event instanceof PublishedObjectEvent) {
+			PublishedObjectEvent poevent = (PublishedObjectEvent) event;
+
+			// if the event was generated internally dispatch the event to
+			// connected clients
+			if (null == poevent.getSourceID()) {
+				dispatch(poevent);
+			}
+		}
+	}
+
 	public void sendMessage(String subscriptionID, String channelID,
 			Object message) {
 		List messages = waitingMessages.get(subscriptionID);
@@ -195,6 +190,44 @@ public class MessagingManager implements EventHandler {
 		}
 	}
 
+	public void subscribe(String subscriptionID, String channel) {
+
+		subscriptions.add(new Subscription(channel, null, this));
+		addSubscriber(subscriptionID, channel, null);
+
+		if (null == waitingMessages.get(subscriptionID)) {
+			waitingMessages.put(subscriptionID, new LinkedList());
+		}
+
+		if (null == accessTimes.get(subscriptionID)) {
+			accessTimes.put(subscriptionID, System.currentTimeMillis());
+		}
+
+	}
+
+	public void unsubscribe(String subscriptionID, String channel) {
+
+		Set&lt;Subscription&gt; expiredSubscriptions = new HashSet&lt;Subscription&gt;();
+		for (Subscription sub : getSubscriptions(subscriptionID)) {
+			if (sub.getChannel().equals(channel)) {
+				if (sub.removeSubscription(subscriptionID) &lt;= 0) {
+					expiredSubscriptions.add(sub);
+				}
+			}
+		}
+
+		subscriptions.removeAll(expiredSubscriptions);
+
+	}
+
+	private void addSubscriber(String subscriptionID, String channel,
+			String topic) {
+		Collection&lt;Subscription&gt; subs = find(channel);
+		for (Subscription sub : subs) {
+			sub.addSubscription(subscriptionID);
+		}
+	}
+
 	private void cleanupSubscriptions() {
 
 		long now = System.currentTimeMillis();
@@ -223,12 +256,4 @@ public class MessagingManager implements EventHandler {
 		return subs;
 	}
 
-	private void addSubscriber(String subscriptionID, String channel,
-			String topic) {
-		Collection&lt;Subscription&gt; subs = find(channel);
-		for (Subscription sub : subs) {
-			sub.addSubscription(subscriptionID);
-		}
-	}
-
 }</diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/bundle/MessagingManager.java</filename>
    </modified>
    <modified>
      <diff>@@ -151,14 +151,16 @@ public class OSGiAMFConfig {
 			throw new RuntimeException(e);
 		}
 
-		for (ServiceReference ref : refs) {
-			Translator t = (Translator) context.getService(ref);
-			try {
-				if (t.canTranslate(from)) {
-					return t.translate(from);
+		if (null != refs) {
+			for (ServiceReference ref : refs) {
+				Translator t = (Translator) context.getService(ref);
+				try {
+					if (t.canTranslate(from)) {
+						return t.translate(from);
+					}
+				} finally {
+					context.ungetService(ref);
 				}
-			} finally {
-				context.ungetService(ref);
 			}
 		}
 </diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/bundle/OSGiAMFConfig.java</filename>
    </modified>
    <modified>
      <diff>@@ -28,12 +28,15 @@ import java.util.UUID;
 import org.osgi.service.event.Event;
 
 /**
- * A published object event. If source id has been set, it is assume this object
- * was published from a Flex client. Bundles are free to dispatch this event in
- * order to send objects to Flex clients subscribed to the specified channels
- * and topics, but should specify null for the source id.
+ * A published object event.
+ * &lt;p/&gt;
+ * If source id has been set, it is assumed this object was published from a
+ * Flex client.
+ * &lt;p/&gt;
+ * On the server, bundles are free to dispatch this event in order to send
+ * objects to Flex clients subscribed to the specified channels and topics, but
+ * should specify null for the source id.
  * &lt;p/&gt;
- * 
  * Likewise, bundles can listen for this event, filtering on the appropriate
  * properties if desired in order to handle messages from Flex clients.
  * &lt;/p&gt;</diff>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/events/PublishedObjectEvent.java</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
 Bundle-Name: AMF3 Support for OSGi Over HTTP
 Bundle-SymbolicName: uk.co.arum.osgi.amf3.http
 Bundle-Version: 1.0.0
-Bundle-Activator: uk.co.arum.osgi.amf3.http.bundle.Activator
 Bundle-Vendor: Arum Systems Ltd
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Import-Package: javax.servlet;version=&quot;2.4.0&quot;,
@@ -16,6 +15,8 @@ Import-Package: javax.servlet;version=&quot;2.4.0&quot;,
  uk.co.arum.osgi.amf3;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.http;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.http.events;version=&quot;1.0.0&quot;,
- uk.co.arum.osgi.amf3.io;version=&quot;1.0.0&quot;
+ uk.co.arum.osgi.amf3.io;version=&quot;1.0.0&quot;,
+ uk.co.arum.osgi.glue;version=&quot;[1.0.1,2.0.0)&quot;
 Export-Package: uk.co.arum.osgi.amf3.http;version=&quot;1.0.0&quot;;uses:=&quot;javax.servlet.http&quot;,
  uk.co.arum.osgi.amf3.http.events;version=&quot;1.0.0&quot;;uses:=&quot;uk.co.arum.osgi.amf3.http,org.osgi.service.event&quot;
+Glueable-Component: uk.co.arum.osgi.amf3.http.bundle.AMFServlet</diff>
      <filename>uk.co.arum.osgi.amf3.http/META-INF/MANIFEST.MF</filename>
    </modified>
    <modified>
      <diff>@@ -33,6 +33,7 @@ import javax.servlet.http.HttpSessionBindingEvent;
 import javax.servlet.http.HttpSessionBindingListener;
 
 import org.osgi.service.event.EventAdmin;
+import org.osgi.service.http.HttpService;
 import org.osgi.service.log.LogService;
 
 import uk.co.arum.osgi.amf3.AMFFactory;
@@ -41,29 +42,64 @@ import uk.co.arum.osgi.amf3.http.HttpRequestContext;
 import uk.co.arum.osgi.amf3.http.events.HttpSessionCreatedEvent;
 import uk.co.arum.osgi.amf3.http.events.HttpSessionExpiredEvent;
 import uk.co.arum.osgi.amf3.io.AMFProcessor;
+import uk.co.arum.osgi.glue.Activatable;
+import uk.co.arum.osgi.glue.Glueable;
 
-public class AMFServlet extends HttpServlet {
+public class AMFServlet extends HttpServlet implements Glueable, Activatable {
+
+	private static final String ALIAS_OSGIAMF = &quot;/amf3osgi&quot;;
 
 	private static final long serialVersionUID = 1L;
 
-	private final AMFProcessor processor;
+	private CompoundAMFFactory compoundFactory;
+
+	private AMFProcessor processor;
+
+	private HttpService httpService;
 
 	private EventAdmin eventAdmin;
 
 	private LogService logService;
 
-	public AMFServlet(AMFFactory factory) {
-		this.processor = new AMFProcessor(factory);
+	public AMFServlet() {
+	}
+
+	public void bind(HttpService httpService) {
+		this.httpService = httpService;
 	}
 
-	public void setEventAdmin(EventAdmin eventAdmin) {
+	public void bind(EventAdmin eventAdmin) {
 		this.eventAdmin = eventAdmin;
 	}
 
-	public void setLogService(LogService logService) {
+	public void bind(LogService logService) {
 		this.logService = logService;
 	}
 
+	public void bind(AMFFactory[] factories) {
+		compoundFactory = new CompoundAMFFactory();
+		for (AMFFactory factory : factories) {
+			compoundFactory.add(factory);
+		}
+	}
+
+	public void unbind(AMFFactory[] factories) {
+		for (AMFFactory factory : factories) {
+			compoundFactory.remove(factory);
+		}
+		compoundFactory = null;
+	}
+
+	public void activate() throws Exception {
+		processor = new AMFProcessor(compoundFactory);
+		httpService.registerServlet(ALIAS_OSGIAMF, this, null, null);
+	}
+
+	public void deactivate() throws Exception {
+		httpService.unregister(ALIAS_OSGIAMF);
+		processor = null;
+	}
+
 	@Override
 	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
 			throws ServletException, IOException {
@@ -122,4 +158,7 @@ public class AMFServlet extends HttpServlet {
 		response.getOutputStream().write(outBytes.toByteArray());
 	}
 
+	public String getServiceFilter(String serviceName, String name) {
+		return null;
+	}
 }</diff>
      <filename>uk.co.arum.osgi.amf3.http/src/uk/co/arum/osgi/amf3/http/bundle/AMFServlet.java</filename>
    </modified>
    <modified>
      <diff>@@ -41,7 +41,7 @@ public class HttpSessionCreatedEvent extends Event {
 	 *            the request context
 	 */
 	public HttpSessionCreatedEvent(HttpRequestContext context) {
-		super(TOPIC, (Dictionary) null);
+		super(TOPIC, (Dictionary&lt;?, ?&gt;) null);
 		this.context = context;
 	}
 </diff>
      <filename>uk.co.arum.osgi.amf3.http/src/uk/co/arum/osgi/amf3/http/events/HttpSessionCreatedEvent.java</filename>
    </modified>
    <modified>
      <diff>@@ -41,7 +41,7 @@ public class HttpSessionExpiredEvent extends Event {
 	 *            the request context
 	 */
 	public HttpSessionExpiredEvent(HttpRequestContext context) {
-		super(TOPIC, (Dictionary) null);
+		super(TOPIC, (Dictionary&lt;?, ?&gt;) null);
 		this.context = context;
 	}
 </diff>
      <filename>uk.co.arum.osgi.amf3.http/src/uk/co/arum/osgi/amf3/http/events/HttpSessionExpiredEvent.java</filename>
    </modified>
    <modified>
      <diff>@@ -3,7 +3,6 @@ Bundle-ManifestVersion: 2
 Bundle-Name: Sample Flex OSGi AMF Bundle
 Bundle-SymbolicName: uk.co.arum.osgi.amf3.sample
 Bundle-Version: 1.0.0
-Bundle-Activator: uk.co.arum.osgi.amf3.sample.bundle.Activator
 Bundle-Vendor: Arum Systems Ltd
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Import-Package: flex.messaging.messages,
@@ -11,8 +10,11 @@ Import-Package: flex.messaging.messages,
  javax.servlet.http;version=&quot;2.4.0&quot;,
  org.osgi.framework;version=&quot;1.3.0&quot;,
  org.osgi.service.event;version=&quot;1.1.0&quot;;resolution:=optional,
- org.osgi.service.http;version=&quot;1.2.0&quot;,
+ org.osgi.service.http;version=&quot;[1.2.0,2.0.0)&quot;,
  uk.co.arum.osgi.amf3;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.flex.remoting;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.flex.remoting.events;version=&quot;1.0.0&quot;,
- uk.co.arum.osgi.amf3.http;version=&quot;1.0.0&quot;
+ uk.co.arum.osgi.amf3.http;version=&quot;1.0.0&quot;,
+ uk.co.arum.osgi.glue;version=&quot;[1.0.1,2.0.0)&quot;
+Glueable-Component: uk.co.arum.osgi.amf3.sample.bundle.PublishedObjectEventHandler,
+ uk.co.arum.osgi.amf3.sample.bundle.SimpleServiceImpl</diff>
      <filename>uk.co.arum.osgi.amf3.sample/META-INF/MANIFEST.MF</filename>
    </modified>
    <modified>
      <diff>@@ -21,17 +21,23 @@
 
 package uk.co.arum.osgi.amf3.sample.bundle;
 
+import java.util.Dictionary;
 import java.util.Enumeration;
+import java.util.Hashtable;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.osgi.service.http.HttpService;
+import org.osgi.service.http.NamespaceException;
+
 import uk.co.arum.osgi.amf3.flex.remoting.RemotingContext;
 import uk.co.arum.osgi.amf3.http.HttpRequestContext;
 import uk.co.arum.osgi.amf3.sample.SampleObject;
 import uk.co.arum.osgi.amf3.sample.SimpleService;
 import uk.co.arum.osgi.amf3.sample.VerySimpleObject;
+import uk.co.arum.osgi.glue.GlueableService;
 
-public class SimpleServiceImpl implements SimpleService {
+public class SimpleServiceImpl implements SimpleService, GlueableService {
 
 	private SampleObject sampleObject;
 
@@ -49,6 +55,35 @@ public class SimpleServiceImpl implements SimpleService {
 
 	}
 
+	public void bind(HttpService httpService) {
+		try {
+			httpService.registerResources(&quot;/sample&quot;, &quot;/flexbin&quot;, null);
+		} catch (NamespaceException e) {
+			throw new RuntimeException(e);
+		}
+	}
+
+	public void unbind(HttpService httpService) {
+		httpService.unregister(&quot;/sample&quot;);
+	}
+
+	public Dictionary&lt;?, ?&gt; getProperties(String serviceName) {
+		if (serviceName.equals(SimpleService.class.getName())) {
+			Dictionary&lt;String, String&gt; properties = new Hashtable&lt;String, String&gt;();
+			properties.put(&quot;AMF_SERVICE_NAME&quot;, SimpleService.class.getName());
+			return properties;
+		}
+		return null;
+	}
+
+	public String getServiceFilter(String serviceName, String name) {
+		return null;
+	}
+
+	public String[] getServiceNames() {
+		return new String[] { SimpleService.class.getName() };
+	}
+
 	private SampleObject createSampleObject(SampleObject parent, String name,
 			long value) {
 		SampleObject sampleObject = new SampleObject();</diff>
      <filename>uk.co.arum.osgi.amf3.sample/src/uk/co/arum/osgi/amf3/sample/bundle/SimpleServiceImpl.java</filename>
    </modified>
    <modified>
      <diff>@@ -6,9 +6,11 @@ Bundle-Version: 1.0.1
 Bundle-Vendor: Arum Systems Ltd
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ClassPath: .
-Export-Package: uk.co.arum.osgi.amf3;version=&quot;1.0.0&quot;,
+Export-Package: flex.messaging.io,
+ uk.co.arum.osgi.amf3;version=&quot;1.0.0&quot;,
  uk.co.arum.osgi.amf3.io;version=&quot;1.0.0&quot;;uses:=&quot;uk.co.arum.osgi.amf3&quot;
-Import-Package: javax.xml.parsers,
+Import-Package: flex.messaging.io,
+ javax.xml.parsers,
  javax.xml.transform,
  javax.xml.transform.dom,
  javax.xml.transform.stream,</diff>
      <filename>uk.co.arum.osgi.amf3/META-INF/MANIFEST.MF</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
 
   You should have received a copy of the GNU Lesser General Public License
   along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.
-*/
+ */
 
 package flex.messaging.io;
 
@@ -30,50 +30,53 @@ import java.util.Collection;
 /**
  * @author Franck WOLFF
  */
-public class ArrayCollection extends ArrayList&lt;Object&gt; implements Externalizable {
-
-    private static final long serialVersionUID = 1L;
-
-    public ArrayCollection() {
-        super();
-    }
-
-    public ArrayCollection(int capacity) {
-        super(capacity);
-    }
-
-    public ArrayCollection(Collection&lt;?&gt; col) {
-        super(col);
-    }
-
-    public ArrayCollection(Object[] array) {
-        super();
-        addAll(array);
-    }
-
-    public void addAll(Object[] array) {
-        for (Object o : array)
-            add(o);
-    }
-
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(toArray());
-    }
-
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        Object o = in.readObject();
-        if (o != null) {
-            if (o instanceof Collection)
-                addAll((Collection&lt;?&gt;)o);
-            else if (o.getClass().isArray())
-                addAll((Object[])o);
-            else // should we throw an exception ?
-                add(o);
-        }
-    }
-
-    @Override
-    public String toString() {
-        return super.toString();
-    }
+public class ArrayCollection extends ArrayList&lt;Object&gt; implements
+		Externalizable {
+
+	private static final long serialVersionUID = 1L;
+
+	public ArrayCollection() {
+		super();
+	}
+
+	public ArrayCollection(int capacity) {
+		super(capacity);
+	}
+
+	public ArrayCollection(Collection&lt;?&gt; col) {
+		super(col);
+	}
+
+	public ArrayCollection(Object[] array) {
+		super();
+		addAll(array);
+	}
+
+	public void addAll(Object[] array) {
+		for (Object o : array)
+			add(o);
+	}
+
+	public void writeExternal(ObjectOutput out) throws IOException {
+		out.writeObject(toArray());
+	}
+
+	public void readExternal(ObjectInput in) throws IOException,
+			ClassNotFoundException {
+		Object o = in.readObject();
+		if (o != null) {
+			if (o instanceof Collection&lt;?&gt;)
+				addAll((Collection&lt;?&gt;) o);
+			else if (o.getClass().isArray())
+				addAll((Object[]) o);
+			else
+				// should we throw an exception ?
+				add(o);
+		}
+	}
+
+	@Override
+	public String toString() {
+		return super.toString();
+	}
 }</diff>
      <filename>uk.co.arum.osgi.amf3/src/flex/messaging/io/ArrayCollection.java</filename>
    </modified>
    <modified>
      <diff>@@ -40,7 +40,6 @@ import uk.co.arum.osgi.amf3.AMFFactory;
 import flex.messaging.io.ASObject;
 import flex.messaging.io.ASRecordSet;
 
-
 /**
  * AMF Serializer
  * 
@@ -52,7 +51,7 @@ import flex.messaging.io.ASRecordSet;
  * @version $Revision: 1.54 $, $Date: 2006/03/25 23:41:41 $
  */
 public class AMF0Serializer {
-	
+
 	private static final int MILLS_PER_HOUR = 60000;
 	/**
 	 * Null message
@@ -193,11 +192,11 @@ public class AMF0Serializer {
 			if (value instanceof Object[]) {
 				// write Object Array
 				writeArray((Object[]) value);
-			} else if (value instanceof Iterator) {
+			} else if (value instanceof Iterator&lt;?&gt;) {
 				write((Iterator&lt;?&gt;) value);
-			} else if (value instanceof Collection) {
+			} else if (value instanceof Collection&lt;?&gt;) {
 				write((Collection&lt;?&gt;) value);
-			} else if (value instanceof Map) {
+			} else if (value instanceof Map&lt;?, ?&gt;) {
 				writeMap((Map&lt;?, ?&gt;) value);
 			} else if (value instanceof ResultSet) {
 				ASRecordSet asRecordSet = new ASRecordSet();
@@ -207,11 +206,11 @@ public class AMF0Serializer {
 				write((Document) value);
 			} else {
 				/*
-				MM's gateway requires all objects to be marked with the
-				Serializable interface in order to be serialized
-				That should still be followed if possible, but there is
-				no good reason to enforce it.
-				*/
+				 * MM's gateway requires all objects to be marked with the
+				 * Serializable interface in order to be serialized That should
+				 * still be followed if possible, but there is no good reason to
+				 * enforce it.
+				 */
 				writeObject(value);
 			}
 		}</diff>
      <filename>uk.co.arum.osgi.amf3/src/org/granite/messaging/amf/io/AMF0Serializer.java</filename>
    </modified>
    <modified>
      <diff>@@ -16,7 +16,7 @@
 
   You should have received a copy of the GNU Lesser General Public License
   along with this library; if not, see &lt;http://www.gnu.org/licenses/&gt;.
-*/
+ */
 
 package org.granite.messaging.amf.io;
 
@@ -95,7 +95,7 @@ public class AMF3Serializer extends DataOutputStream implements ObjectOutput,
 				writeAMF3Date(((Calendar) o).getTime());
 			} else if (o instanceof Document) {
 				writeAMF3Xml((Document) o);
-			} else if (o instanceof Collection) {
+			} else if (o instanceof Collection&lt;?&gt;) {
 				writeAMF3Collection((Collection&lt;?&gt;) o);
 			} else if (o.getClass().isArray()) {
 				if (o.getClass().getComponentType() == Byte.TYPE) {</diff>
      <filename>uk.co.arum.osgi.amf3/src/org/granite/messaging/amf/io/AMF3Serializer.java</filename>
    </modified>
    <modified>
      <diff>@@ -13,8 +13,8 @@ package uk.co.arum.osgi.glue;
  * all dependencies are satisfied the component is then considered activated.
  * 
  * &lt;p/&gt;
- * optional (0..1) - services are bound using optionalBind (and unbound
- * using optionalUnbind), otherwise bind must be used. e.g.
+ * optional (0..1) - services are bound using optionalBind (and unbound using
+ * optionalUnbind), otherwise bind must be used. e.g.
  * &lt;p/&gt;
  * &lt;code&gt;&lt;pre&gt;
  * // activation will not occur until this has been called
@@ -62,10 +62,10 @@ package uk.co.arum.osgi.glue;
  * a new array of matching services will be passed to the bind method.
  * &lt;p/&gt;
  * 
- * Finally, in order to have the same type of service injected multiple
- * times but with a different service filter Glue will take any text after the
- * bind or set part of the method name. Matching unbind/optionalUnbind methods
- * must still be specified, e.g.
+ * Finally, in order to have the same type of service injected multiple times
+ * but with a different service filter Glue will take any text after the bind or
+ * set part of the method name. Matching unbind/optionalUnbind methods must
+ * still be specified, e.g.
  * &lt;p/&gt;
  * 
  * &lt;code&gt;&lt;pre&gt;
@@ -106,11 +106,11 @@ public interface Glueable {
 	 * 
 	 * @param serviceName
 	 *            the name of the OSGi service to lookup
-	 * @param name
+	 * @param bindName
 	 *            any text after 'bind' or 'optionalBind' for a given service,
 	 *            blank if none, but always non-null
 	 * @return the filter to use
 	 */
-	String getServiceFilter(String serviceName, String name);
+	String getServiceFilter(String serviceName, String bindName);
 
 }</diff>
      <filename>uk.co.arum.osgi.glue/src/uk/co/arum/osgi/glue/Glueable.java</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,6 @@
 package uk.co.arum.osgi.glue.bundle;
 
+import java.lang.reflect.Array;
 import java.lang.reflect.Method;
 import java.util.Arrays;
 import java.util.Collection;
@@ -105,8 +106,12 @@ public class GlueManager {
 					bindings = new Bindings(paramType.getComponentType()
 							.getName());
 					bindings.multiple = true;
+					System.out.println(&quot;creating array binding &quot;
+							+ paramType.getComponentType().getName() + &quot;[]&quot;);
 				} else {
 					bindings = new Bindings(paramType.getName());
+					System.out.println(&quot;creating binding &quot;
+							+ paramType.getName());
 				}
 				bindings.bindMethod = bindMethod;
 
@@ -307,7 +312,8 @@ public class GlueManager {
 		public Bindings(String serviceName) {
 			this.serviceName = serviceName;
 			uid = UUID.randomUUID().toString();
-			logService.log(LogService.LOG_DEBUG, uid + &quot; bindings created&quot;);
+			logService.log(LogService.LOG_DEBUG, uid + &quot; &quot; + serviceName
+					+ &quot; bindings created for &quot; + bound);
 		}
 
 		public void serviceChanged(ServiceEvent event) {
@@ -372,10 +378,20 @@ public class GlueManager {
 				services.add(o);
 
 				// rebind
-				Object bound = services.toArray();
+				Class&lt;?&gt; t = getArrayClass(services.iterator().next());
+				Object array = Array.newInstance(t, services.size());
 
-				bindMethod.invoke(glueable, new Object[] { bound });
-				this.bound = bound;
+				// Object bound = services.toArray();
+				int i = 0;
+				for (Object value : services) {
+					Array.set(array, i++, value);
+				}
+
+				System.out.println(&quot;invoking &quot; + bindMethod.getDeclaringClass()
+						+ &quot;#bind(&quot; + t + &quot;[])&quot;);
+				bindMethod.invoke(glueable, new Object[] { array });
+
+				this.bound = array;
 
 				// check
 				check();
@@ -399,6 +415,20 @@ public class GlueManager {
 
 		}
 
+		Class&lt;?&gt; getArrayClass(Object o) {
+			System.out.println(&quot;Looking for &quot; + serviceName);
+
+			Class&lt;?&gt;[] at = o.getClass().getInterfaces();
+			for (Class&lt;?&gt; i : at) {
+				if (i.getName().equals(serviceName)) {
+					return i;
+				}
+			}
+
+			throw new RuntimeException(&quot;Unable to find class &quot; + serviceName
+					+ &quot; in &quot; + o);
+		}
+
 		void serviceUnregistered(Object o) throws Exception {
 
 			if (multiple) {</diff>
      <filename>uk.co.arum.osgi.glue/src/uk/co/arum/osgi/glue/bundle/GlueManager.java</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
 &lt;classpath&gt;
-	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot;/&gt;
+	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5&quot;/&gt;
 	&lt;classpathentry kind=&quot;con&quot; path=&quot;org.eclipse.pde.core.requiredPlugins&quot;/&gt;
 	&lt;classpathentry kind=&quot;src&quot; path=&quot;src&quot;/&gt;
 	&lt;classpathentry kind=&quot;output&quot; path=&quot;bin&quot;/&gt;</diff>
      <filename>uk.co.arum.osgi.log.sysout/.classpath</filename>
    </modified>
    <modified>
      <diff>@@ -8,3 +8,4 @@ Bundle-Vendor: Arum Systems Ltd
 Import-Package: org.osgi.framework;version=&quot;1.3.0&quot;,
  org.osgi.service.log;version=&quot;1.3.0&quot;,
  org.osgi.util.tracker;version=&quot;1.3.3&quot;
+Bundle-RequiredExecutionEnvironment: J2SE-1.5</diff>
      <filename>uk.co.arum.osgi.log.sysout/META-INF/MANIFEST.MF</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>uk.co.arum.osgi.amf3.flex.remoting/src/uk/co/arum/osgi/amf3/flex/remoting/bundle/Activator.java</filename>
    </removed>
    <removed>
      <filename>uk.co.arum.osgi.amf3.http/src/uk/co/arum/osgi/amf3/http/bundle/Activator.java</filename>
    </removed>
    <removed>
      <filename>uk.co.arum.osgi.amf3.sample/src/uk/co/arum/osgi/amf3/sample/bundle/Activator.java</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>9b2490cab0509ff44ddbb02e8bac007b8ed5450c</id>
    </parent>
  </parents>
  <author>
    <name>brindy</name>
    <email>brindy@brindy.org.uk</email>
  </author>
  <url>http://github.com/arum/bundles/commit/6fdec706a434ce8ebbb9d4beb05d78fef56ee412</url>
  <id>6fdec706a434ce8ebbb9d4beb05d78fef56ee412</id>
  <committed-date>2009-10-16T18:18:28-07:00</committed-date>
  <authored-date>2009-10-16T18:09:15-07:00</authored-date>
  <message>AMF3 OSGi now uses Arum Glue for dependency injection.

Added translator facility.

Added RemoteContext facility.

Fixed imports and exports.</message>
  <tree>1c08bc0360bf2227d0ac8a7a90ec1094a452bc09</tree>
  <committer>
    <name>brindy</name>
    <email>brindy@brindy.org.uk</email>
  </committer>
</commit>
