?
Solved

How to incorporate Consumer functionatliy into Cairngorm?

Posted on 2009-02-10
3
Medium Priority
?
923 Views
Last Modified: 2013-11-11
Hi,

I'm converting a Flex application to Cairngorm and haven't been able to figure out what to do with the Consumer calls.  I've read through all the documentation and included CairngormEnterprise.swc into my build and added the Consumer instance to my ServiceLocator just as with any other http or RPC call.  The error I keep on getting is this:

Only one ServiceLocator instance can be instantiated

I'm guessing this is because I'm instantiating EnterpriseServiceLocator a long with ServiceLocator but I don't what else to do since the getConsumer() method is only in the EnterpriseServiceLcoator object.

Any help would be greatly appreciated.  I've included both my delegate and ServiceLocator classes.

Thanks!
blue
package control.delegates
{
	import com.adobe.cairngorm.business.ServiceLocator;
	
	import mx.messaging.Consumer;
	import mx.messaging.events.MessageEvent;
	import mx.rpc.IResponder;
	import mx.messaging.events.MessageFaultEvent;
	import com.adobe.cairngorm.enterprise.business.EnterpriseServiceLocator;
		
	public class ReceiveMessageDelegate
	{
		private var _responder:IResponder;
		private var _service:Consumer;
		
		public function ReceiveMessageDelegate(r:IResponder)
		{     		
			_service = EnterpriseServiceLocator.getInstance().getConsumer("receiveMessageEvent");
			_responder = r;
			_service.addEventListener(MessageEvent.MESSAGE, _responder.result);
			_service.addEventListener(MessageFaultEvent.FAULT, _responder.fault);
		}
		
		// Subscribes to the feed.
		public function subscribe():void
		{  
			_service.subscribe();
		}
		
		// Unsubscribes to the feed.
		public function unsubscribe():void
		{  
			_service.unsubscribe();
		}
	}
 
<!-------------- ServiceLocator ------------------>
 
<?xml version="1.0" encoding="utf-8"?>
<rds:ServiceLocator xmlns:rds="com.adobe.cairngorm.business.*"
	xmlns:mx="http://www.adobe.com/2006/mxml">
	
	<mx:Script>
		<![CDATA[
			
			import model.ModelLocator;
			
			[Bindable]
			private var __model:ModelLocator=ModelLocator.getInstance();
			
		]]>
	</mx:Script>
	
	<mx:Consumer id="receiveMessageEvent" destination="ColdFusionGateway" />
		
</rds:ServiceLocator>
}

Open in new window

0
Comment
Question by:blue44
  • 2
3 Comments
 

Accepted Solution

by:
blue44 earned 0 total points
ID: 23608798
Of course, right after I posted this, I figured it out.  I'm not sure why this is the case, but you have to have Caringrom.swc and CairngormEnterprise.swc in the lib directory of your Flex project not as separate swcs -- if that makes sense.  This way, the getConsumer() method is available from the ServiceLocator class so there's no need to instantiate EnterpriseServiceLocater either.  Nasty, nasty, one...

Hope this helps some other hapless soul out there...
0
 

Expert Comment

by:dkoleba
ID: 30830610
Nice work blue44. Could you give an example of how you changed you code to accommodate this?
0
 

Author Comment

by:blue44
ID: 30844326
Well, it's been over a year so I had to go back and review the code.  All I did was manually add both the Cairngorm.swc and CairngormEnterprise.swc to the lib directory in a Flex Project (assuming you're utilizing Flex Builder).  Then, if you go to your project properties > Flex Build Path, you'll find both under the lib directory.  Hope this helps!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question