Get service name at runtime

Hi

Is it possible to get the “root” service name that was invoked, at runtime?
E.g. to get “common.utils:fooService”.

Example:
If a have tree services; serviceA, serviceB & serviceC.
serviceA is first invoked and serviceB is then called from serviceA and serviceC is then called from serviceB.
Can I from serviceC somehow find out that serviceA was the first service that was invoked in the execution chain?

Regards
Mikael

This uses unpublished methods so may break in future versions. Use at your own risk.

[highlight=java]getServiceStack(IData pipeline)
{
IDataCursor idc = pipeline.getCursor();
java.util.Stack callStack = com.wm.app.b2b.server.InvokeState.getCurrentState().getCallStack();

// Note that we allocated one less than what the stack has
// to omit this service from being in the list
String[] serviceStack = new String[callStack.size()-1];

for(int j=0,i=serviceStack.length; --i>=0;j++)
    serviceStack[j] = ((com.wm.lang.ns.NSService)callStack.elementAt(i)).toString();

IDataUtil.put(idc, "serviceStack", serviceStack);
idc.destroy();

}[/highlight]

This reverses the order of the stack. Depending on your preference, you might want to change the for loop to keep the order as returned by getCallStack.

HTH

Nice job! I tried your code and it worked flawlessly.