Skip to main content

Help needed with Activity Context Naming Facility

5 replies [Last post]
dudal09
Offline
Joined: 2009-01-29

Hello. everyone.

I'm trying to use Activity Context Naming Facility. But I can't share Activity Context Attribute. How I can?

I use two SBB(ProxySBB and WakeUpSBB). ProxySBB has an attribute that "AccessCounter".
When ProxySBB receive MESSAGE event, ProxySBB bind ActivityContext to name "name" using by Activity Context Naming Facility.
And MESSAGE event is passed to WakeUPSBB, then WakeUPSBB lookup the Activity Context by name "name".
I has checked that WakeUPSBB and ProxySBB share the Activity Context by name "name". But I can't access "AccessCounter" attribute. How I can get the "AccessCounter"??

my code is ...
1. ProxySBB
public interface ProxySbbActivityContextInterface extends
ActivityContextInterface {
public void setAccessCounter(int counter);
public int getAccessCounter();
}

public abstract class ProxySbb implements Sbb {
....
public void onMessageEvent(RequestEvent event, ActivityContextInterface ac) {
logger.info("/onMessageEvent/ "); //XXX

try {
ProxySbbActivityContextInterface proxySbbAci =
this.asSbbActivityContextInterface(ac);

namingFacility.bind(proxySbbAci, "name");
proxySbbAci.setAccessCounter(1);
logger.info("[XXX]NameFacility Bind SUCCESS(" + proxySbbAci.toString() + "):" +proxySbbAci.getActivity().toString());
logger.info("ACCESS Counter = " + proxySbbAci.getAccessCounter());

}
...
}

2. WakeUPSBB
public abstract class WakeUpSbb implements javax.slee.Sbb {
...
public void onMessageEvent(javax.sip.RequestEvent event, ActivityContextInterface aci) {
Request request = event.getRequest();

ActivityContextInterface nfaci = namingFacility.lookup("name");
logger.info("lookup name SUCCESS(" + nfaci.toString() + "):" + nfaci.getActivity().toString());
....
}

3. Result
11:32:43,765 INFO [ProxySbb] [XXX]NameFacility Bind SUCCESS(org.mobicents.slee.services.sip.proxy.ProxySbbActivityContextInterfaceImpl@d60225):[TransactionW WRAPPED[gov.nist.javax.sip.stack.SIPServerTransaction@4d67e13f] BRANCHID[z9hG4bK8017a4f0e3ecdd11b9d1001742930fab] STATE[Trying Transaction] DIALOG{ null } ]
11:32:43,765 INFO [ProxySbb] ACCESS Counter = 1

11:32:43,781 INFO [WakeUpSbb] lookup name SUCCESS(org.mobicents.slee.runtime.ActivityContextInterfaceImpl@a896b8):[TransactionW WRAPPED[gov.nist.javax.sip.stack.SIPServerTransaction@4d67e13f] BRANCHID[z9hG4bK8017a4f0e3ecdd11b9d1001742930fab] STATE[Completed Transaction] DIALOG{ null } ]

4. etc
At first, I tried to like this at WakeUPSBB

ProxySbbActivityContextInterface nfaci = (ProxySbbActivityContextInterface) namingFacility.lookup("name");
logger.info("lookup name SUCCESS(" + nfaci.toString() + "):" + nfaci.getAccessCounter());

But I get the exception..

16:55:10,984 ERROR [EventRouterImpl] Failure while routing event; second phase. DeferredEvent [EventTypeID[javax.sip.message.Request.MESSAGE#javax.sip#1.1], #77]
java.lang.ClassCastException: org.mobicents.slee.runtime.ActivityContextInterfaceImpl
at org.mobicents.slee.examples.wakeup.WakeUpSbb.onMessageEvent(WakeUpSbb.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mobicents.slee.runtime.sbbentity.SbbEntity.invokeEventHandler(SbbEntity.java:877)
at org.mobicents.slee.runtime.EventRouterImpl.routeQueuedEvent(EventRouterImpl.java:892)
at org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:64)
at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:121)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
16:55:10,984 INFO [EventRouterImpl] Caught RuntimeException in invoking SLEE originated invocation
java.lang.ClassCastException: org.mobicents.slee.runtime.ActivityContextInterfaceImpl
at org.mobicents.slee.examples.wakeup.WakeUpSbb.onMessageEvent(WakeUpSbb.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.mobicents.slee.runtime.sbbentity.SbbEntity.invokeEventHandler(SbbEntity.java:877)
at org.mobicents.slee.runtime.EventRouterImpl.routeQueuedEvent(EventRouterImpl.java:892)
at org.mobicents.slee.runtime.EventRouterImpl.access$100(EventRouterImpl.java:64)
at org.mobicents.slee.runtime.EventRouterImpl$EventExecutor.run(EventRouterImpl.java:121)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Message was edited by: dudal09

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
barreirao
Offline
Joined: 2006-01-18

You can't just cast the activity context.

You have to use the asSbbActivityContextInterface() method in both SBBs, and narrow the ACI to the same interface.

dudal09
Offline
Joined: 2009-01-29

thanks your answer.
but I can't understand still.
could you tell me more detail?

eduardomartins
Offline
Joined: 2005-10-10

What Luis is saying is that after you lookup the aci from the aci naming facility, you need to use the asSbbActivityContextInterface(aci) method to transform it to your sbb aci interface.

dudal09
Offline
Joined: 2009-01-29

What your mean is like below,right?

* ProxySbb.java
ProxySbbActivityContextInterface proxySbbAci = this.asSbbActivityContextInterface(ac);

namingFacility.bind(proxySbbAci, "name");
proxySbbAci.setAccessCounter(1);

* WakeUpSbb.java
ActivityContextInterface nfaci = namingFacility.lookup("name");
WakeUpSbbActivityContextInterface wakeupAci = this.asSbbActivityContextInterface(nfaci);

Although I use asSbbActivityContextInterface(aci) method to transform it to WakeUpSbb aci interface, I can't access "AccessCounter" attribute.

So, Do I must use AC attribute aliasing with AC Naming Facility to share the attribute between different type SBB entitys?

thanks your kindness. have a nice day~^^

Message was edited by: dudal09

baranowb
Offline
Joined: 2006-01-09

alias name must match between sbb definitions for attributes defined in custom ACIs to be conveyed accros SLEE. See how sip-services example works, it shows how to use aliasing. Also YOu may lookup java.net wiki for those example (I think there is copy on google mobicents-public space) which shows code snipets.