The Source for Java Technology Collaboration


Parent child interaction example - simple call blocking forwarding - based on call-cotroller first design

Dependencies

  1. SIP RA 1.2
  2. Sip proxy/registrar

Design

See design of call controller - Secodn design ---+ Install and run Download whole cvs tree of examples or if You have all dependencies (lib dir) download call-controller

Than follow instructions:

  1. Run server.
  2. Go to ${MOBICENT_EXAMPLES}/lib dir
  3. In slee-sip-ra dir run ant deploy
  4. In sipservices dir run ant jar-with-invite-not-initial and ant deploy
  5. In ${MOBICENT_EXAMPLES}/call-controller run ant deploy

Code disscusion

Previously this code was considered as call-controller example. However upon invention of new designs for that particular purpose this example became redundant. However it still has something of use for those who are new to SLEE. It is good example how arrange SBBs and how parent and children should comunicate.

First lets look how SBBs are decalred in their sbb-jar.xml files: (Proxy)

          <sbb-name>ProxySbb</sbb-name>
         <sbb-vendor>NIST</sbb-vendor>
         <sbb-version>1.0</sbb-version>

and second(it also defines Sbb local inteface with sbb-local-interface element):

         <sbb-name>CallBlockingSbb</sbb-name>
         <sbb-vendor>org.mobicents</sbb-vendor>
         <sbb-version>0.1</sbb-version>
         .....
         <sbb-classes>
           .......
            <sbb-local-interface>
                <sbb-local-interface-name>org.mobicents.slee.examples.blocking.CallBlockingSbbLocalObject</sbb-local-interface-name>
            </sbb-local-interface>
        </sbb-classes>

and in third:

         <sbb-name>CallForwardingSbb</sbb-name>
         <sbb-vendor>org.mobicents</sbb-vendor>
         <sbb-version>0.1</sbb-version>

Now lets find out how we can create relation between them. To do that we have to create child relation method (abstract SLEE implements it) and declare it in sbb-jar.xml file.
In sbb section of particlar sbb we have to declare sbb-ref elements for each child. Note that name,vendor and version match declarations in other sbb-jar.xml files (see above) Here is declaration(in CallControllerSbb?):

      <sbb-name>CallControllerSbb</sbb-name>
      <sbb-vendor>org.mobicents</sbb-vendor>
      <sbb-version>0.1</sbb-version>
      <sbb-ref>
         <sbb-name>ProxySbb</sbb-name>
         <sbb-vendor>NIST</sbb-vendor>
         <sbb-version>1.0</sbb-version>
         <sbb-alias>JainSipProxySbb</sbb-alias>
      </sbb-ref>
      <sbb-ref>
         <sbb-name>CallBlockingSbb</sbb-name>
         <sbb-vendor>org.mobicents</sbb-vendor>
         <sbb-version>0.1</sbb-version>
         <sbb-alias>CallBlockingSbb</sbb-alias>
      </sbb-ref>
      <sbb-ref>
         <sbb-name>CallForwardingSbb</sbb-name>
         <sbb-vendor>org.mobicents</sbb-vendor>
         <sbb-version>0.1</sbb-version>
         <sbb-alias>CallForwardingSbb</sbb-alias>
      </sbb-ref>
When we have sbb-refs and aliases for each child we can use alias to tell SLEE which method allows sbb to retrieve particular child. TIP - compare sbb-alias-ref and sbb-alias elements
      <sbb-classes>
         <sbb-abstract-class>
            <sbb-abstract-class-name>org.mobicents.slee.examples.controller.CallControllerSbb</sbb-abstract-class-name>

            <get-child-relation-method>
               <sbb-alias-ref>JainSipProxySbb</sbb-alias-ref>
               <get-child-relation-method-name>getJainSipProxySbb</get-child-relation-method-name>
               <default-priority>0</default-priority>
            </get-child-relation-method>
            <get-child-relation-method>
               <sbb-alias-ref>CallBlockingSbb</sbb-alias-ref>
               <get-child-relation-method-name>getCallBlockingSbb</get-child-relation-method-name>
               <default-priority>0</default-priority>
            </get-child-relation-method>
            <get-child-relation-method>
               <sbb-alias-ref>CallForwardingSbb</sbb-alias-ref>
               <get-child-relation-method-name>getCallForwardingSbb</get-child-relation-method-name>
               <default-priority>0</default-priority>
            </get-child-relation-method>

         </sbb-abstract-class>
      </sbb-classes>

and signature:

   public abstract ChildRelation getJainSipProxySbb();
   public abstract ChildRelation getCallBlockingSbb();
   public abstract ChildRelation getCallForwardingSbb();

Additionaly lets define CustomSbbLocalObject interface:

public interface CallBlockingSbbLocalObject extends javax.slee.SbbLocalObject {

   
   public boolean accept(javax.sip.RequestEvent event, ActivityContextInterface ac);
}
This interface has to be implemented by sbb, this method is not created by SLEE during concrete sbb class generation, its body has to be created by programmer.

Just to explain shortly ChildRelation object is collection like object that stores references to LocalObjects. It allows programmer to create and remove of children.

Now having everythin decalred we can show how parents can communicate with children.

  • through local interface:
              public void onInviteEvent(javax.sip.RequestEvent event, ActivityContextInterface aci) {
      
      try {       
         // Child relation between Controller and Call Blocking SBB
          ChildRelation blockingRelation = getCallBlockingSbb();
          CallBlockingSbbLocalObject blockingChild = (CallBlockingSbbLocalObject) blockingRelation.create();         
                //This calls method implemented by programer in synchronous manner - it is executed in Thread.currentThread()
         if (blockingChild.accept(event, aci)) 
                         logger.info("##### INVITE BLOCKED #####\n");   
          }
       ......
}
  • With use of SLEE mechanisms - event routing. To do this parent has to create child and attach it to particular activity context interface. Generaly if parent wants child to receive some event - like currently processed it only needs to attach child to aci of this event. Depending on life cycle of this aci or activity object this communication channel can be long lasting or very impermanent.
    • Here is how chilred are attached to the aci of current event:

                                                ChildRelation proxyRelation = getJainSipProxySbb();
                  SbbLocalObject proxyChild = proxyRelation.create();
                  // Attach Proxy Child to the activity
                  aci.attach(proxyChild);
Communication can be in both ways - child can fire event as well as parent - however there is little, or no at all control how long they can do that.
    • Here is how(not used in cc code) parent can create long lasting communication channel. It requires NullActivity object and NullActivityContextInterface. Here is how can it be obtained:
      ActivityContextInterface localACI = null;
      NullActivityFactory nullACFactory = null;
      NullActivityContextInterfaceFactory nullActivityContextFactory = null;
      try {
         logger.info("Creating nullActivity!!!");
         Context myEnv = (Context) new InitialContext()
               .lookup("java:comp/env");
         nullACFactory = (NullActivityFactory) myEnv
               .lookup("slee/nullactivity/factory");
         NullActivity na = nullACFactory.createNullActivity();
         nullActivityContextFactory = (NullActivityContextInterfaceFactory) myEnv
               .lookup("slee/nullactivity/activitycontextinterfacefactory");
         localACI = nullActivityContextFactory
               .getActivityContextInterface(na);

      } catch (NamingException ne) {
         logger.info("Could not create nullActivityFactory: "
               + ne.getMessage());
      } catch (UnrecognizedActivityException UAE) {
         logger
               .info("Could not create nullActivityContextInterfaceFactory: "
                     + UAE.getMessage());
      }

To utilize this we need attach child and parent, create event,EventTypeID and enque event in SLEE:

//attaching, both will receive events fired to this aci
localACI.attach(proxyChild);
localACI.attach(this.getSbbContext().getSbbLocalObject());
//create event type id
EventTypeID eventTypeID = SleeContainer.lookupFromJndi().getEventType(new ComponentKey("Name","Vendor","Version"));
Event event1=....;
SleeContainer.lookupFromJndi().getSleeEndpoint().enqueueEvent(eventTypeID, event1, localACI.getActivity(), null);

-- Main.baranowb - 25 Jan 2007

Topic Parent_Child_Interaction_1 . { Edit | Ref-By | Printable | Diffs r2 < r1 | More }
 XML java.net RSS

Revision r2 - 26 Jan 2007 - 00:07:38 - Main.baranowb
Parents: MobicentsExamples