Wednesday, September 5, 2007

Framework start event

Wait for the framework start event to lookup services registered by the activator.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:framework="com.esri.aws.osgi.framework.*"
xmlns:services="com.esri.aws.services.*"
layout="absolute"
>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import com.esri.aws.services.IRouteFinder;
import flash.utils.getQualifiedClassName;
import com.esri.aws.osgi.framework.IServiceReference;
import com.esri.aws.osgi.framework.Framework;
import com.esri.aws.osgi.framework.IBundleContext;

private function frameworkStartHandler() : void
{
var context : IBundleContext = Framework.getInstance().systemContext;
var ref : IServiceReference = context.getServiceReference( getQualifiedClassName(IRouteFinder));
if( ref != null)
{
var routeFinder : IRouteFinder = context.getService( ref) as IRouteFinder;
trace( routeFinder);
}
else
{
Alert.show( "No IRouteFinder Reference");
}
}
]]>
</mx:Script>
<framework:Framework apiKey="19640523" frameworkStart="frameworkStartHandler()">
<services:RouteFinderActivator/>
</framework:Framework>
</mx:Application>

No comments: