Hi,

 

I am trying to send messages from a Java Interface to a c++ program
using the following code:

 

STAFHandle modify_handle = handle;

             STAFMapClassDefinition modifyClass = new
STAFMapClassDefinition("STAF/Test/LogRecord");

             modifyClass.addKey("message", "Message");

             modifyClass.addKey("param", "Parameter");

             modifyClass.addKey("value", "New value");

             

             STAFMarshallingContext mc = new STAFMarshallingContext();

             mc.setMapClassDefinition(modifyClass);

             

             Map modifyRecord = modifyClass.createInstance();

             

             modifyRecord.put("message", "MODIFY");

             modifyRecord.put("param", "ITERATIONS");

             modifyRecord.put("value", "200");

 

             mc.setRootObject(modifyRecord);

             String send = mc.marshall();

             String wrappedMessage = STAFUtil.wrapData(send);

             System.out.println(wrappedMessage + hammer_handle);

             modify_handle.submit2(cyclMachine, "QUEUE", "QUEUE TYPE
Modify MESSAGE " + wrappedMessage + " HANDLE " + hammer_handle);

 

On the c++ code side, I use a QUEUE LIST to obtain the queued messages
and process them. In Case of messages with TYPE Modify - this is the
code I use to un-marshall the map:

 

STAFString message = queueMap->get("message")->asString();

259         cout << message << endl;

260         STAFObjectPtr mc = STAFObject::unmarshall(message,
kSTAFIgnoreIndirectObjects);

261         STAFObjectPtr modifyList = mc->getRootObject();

262         STAFObjectIteratorPtr iter = modifyList->iterate();

263

264         while(iter->hasNext())

265         {

266                 STAFObjectPtr modifyQueueMap = iter->next();

267                 STAFString messg =
modifyQueueMap->get("message")->asString();

268                 param = modifyQueueMap->get("param")->asString();

269                 value = modifyQueueMap->get("value")->asString();

270                 //param = param_str.c_str();

271                 //value = value_str.c_str();

272                 cout << "Message: " << messg << endl

273                         << "Parameter to be changed: " << param <<
endl

274                         << "New Value : " << value << endl;

275

276                 int corrNum = NameConv(messg, handle_from);

277                 int perform_action = perform_action =
SwitchCase(corrNum);

278                 int act_prfmd = 0;

279                 if(perform_action == 1)

280                         act_prfmd = switch_to_action(corrNum,
handle_from);

281                 return corrNum;

282

283         }

 

It was working fine when I was sending messages to and from c++ programs
but when I added the Java interface it gives me :

 

terminate called after throwing an instance of
'STAFInvalidObjectException'

 

Can you please point me to the fault in my code? 

 

Thanks so much,

 

Hardik.

<<image001.gif>>

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to