Tuesday, April 14, 2009

 

Use of ElemAppInit in 3.0

Q: I'm using ElemAppInit in 3.0 - any known issues?

A: Here is a tip from Jim R:

Just an FYI – in Element 3.0 and later there is a problem if a component uses ElemAppInit instead of the ELEM_MAIN macro. The problem is with the long component names in the amf (saAppliction->Service Group->Component->blah blah blah). There are two ways around this: the easy way is to change the “Process Name Format” to comp in the AMF entry for you component – and make your component name match what you pass into ElemAppInit. Then there’s the right way – Dan S. provided this code fragment below that gets around this problem.

char *clientName;

/*
** Read the client name environmet variable. There will always be one if the Element loader
** is starting the application
*/

if (clientName == NULL)
{
/* No environment variable is present start using app name and hope its unique*/
status = ElemAppInit(pEnv->Name);
H_ASSERT_M(status == ELEM_STATUS_OK);
}
else
{
/* Initialize Element messaging interface and clientName is no longer valid*/
status = ElemAppInit(clientName);
H_ASSERT_M(status == ELEM_STATUS_OK);
}

In most cases this won’t be a problem because people will probably use ELEM_MAIN – but keep this in mind if they are using ElemAppInit.

Labels:


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?

free web hit counter
free invisible web counter