Home

Mobicents JAIN SLEE Sip Service Example User Guide

image

Contents

1. SProxyMachine 4 1 1 Initial event handler As root of service proxy declares requests as initial It does that with xml descriptor of event handler in sbb jar xml for instance lt event event direction Receive initial event True gt lt event name gt InviteEvent lt event name gt lt event type ref gt lt event type name gt javax sip message Request INVITE lt event type name gt lt event type vendor gt net java slee lt event type vendor gt lt event type version gt 1 2 lt event type version gt lt event type ref gt lt initial event selector method name gt calllDSelect lt initial event selector method name gt lt event gt 11 Chapter 4 Source Code Overview Event handlers declaration has initial event selector method name element This element identifies callback method name which is invoked by JSLEE for all fired events This callback is used by JSLEE to determine if event should create sBB Entity if it does not exists and determine name which distinguishes it Proxysbb has following definition of initial event handler callback public InitialEventSelector calllDSelect InitialEventSelector ies Object event ies getEvent String callld null if event instanceof ResponseEvent ies setlnitialEvent false return ies else if event instanceof RequestEvent f request event the convergence name to callld Request request RequestEvent event getRequest
2. asSbbActivityContextInterface aci rgAci setTimerlD timerlD rgAci setContactAddress contactAddress rgAci setSipAddress sipAddress if logger isInfoEnabled logger info added binding sipAddress sipAddress contactAddress contactAddress return registrationBinding update binding and restart expiration timer public void updateBinding RegistrationBinding registrationBinding throws LocationServiceException if logger isDebugEnabled logger debug updateBinding registrationBinding registrationBinding get named aci 35 Chapter 4 Source Code Overview Activity ContextInterface aci activityContextNamingFacility lookup getACIName registrationBinding getContactAddress registrationBinding getSipAddress get the timer id from the aci and reset the timer RegistrationBindingActivityContextInterface rgAci asSbbActivityContextInterface aci timerFacility cancelTimer rgAci getTimerlD rgAci setTimerlD timerFacility setTimer aci null registrationBinding getRegistrationDate registrationBinding getExpires 1 1000 defaultTimerOptions update in location service locationService updateBinding registrationBinding if logger isInfoEnabled logger info binding updated sipAddress registrationBinding getSipAddress contactAddress registrationBinding getContactAddress remove binding and cancel expiration timer public void removeBinding St
3. if isRegisterLocal uri getProxyConfigurator getLocalDomainNames try ac attach getRegistrarSbbChildRelation create catch Exception e failed to attach the register send error back logger error e detach myself ac detach sbbContext getSbbLocalObject else processRequest event getServerTransaction event getRequest ac 4 1 5 Child relation ProxySbb relies on its children to perform task on aor that is store manage and retrieve bindings Child relation is declared in SBB descriptor as follows lt sbb ref gt lt sbb name gt SipRegistrarSbb lt sbb name gt lt sbb vendor gt org mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt sbb alias gt RegistrarSbb lt sbb alias gt lt sbb ref gt lt sbb classes gt lt sbb abstract class gt lt sbb abstract class name gt 20 Child relation org mobicents slee services sip proxy ProxySbb lt sbb abstract class name gt lt get child relation method gt lt sbb alias ref gt RegistrarSbb lt sbb alias ref gt lt get child relation method name gt getRegistrarSbbChildRelation lt get child relation method name gt lt default priority gt 0 lt default priority gt lt get child relation method gt lt sbb abstract class gt lt sbb classes gt Parent declaration in descriptor defines method name in case of example its getRegistrarSbbChildRelation implented by JSLEE This method allows parent to
4. if Irequest getMethod equals Request ACK callld ViaHeader request getHeaders ViaHeader NAME next getBranch else callld ViaHeader request getHeaders ViaHeader NAME next getBranch ACK Set the convergence name if logger isDebugEnabled logger debug Setting convergence name to callld ies setCustomName callld return ies Response events are not considered as initial because there should be SBB Entity attached to client transactions activity context interface This entity will handle those responses 12 Request handlers 4 1 2 Request handlers Request handlers are only responsible for relying message to ProxyMachine Example request handler look as follows public void onInviteEvent RequestEvent event ActivityContextInterface ac if logger isDebugEnabled logger debug Received INVITE request processRequest event getServerTransaction event getRequest ac private void processRequest ServerTransaction serverTransaction Request request ActivityContextinterface ac if logger isInfoEnabled logger info processing request method n request getMethod toString try if getServerTransactionTerminated if logger isDebugEnabled logger debug PROXY MACHINE ixTERM n request return if getServerTX null setServerTX serverTransaction Go if it is invite here serverTransact
5. 3 step 6 sendErrorResponse Response BAD_REQUEST event getServerTransaction event getRequest return 25 Chapter 4 Source Code Overview if logger isDebugEnabled logger debug Removing bindings Go through list of current bindings if callid doesn t match remove binding if callid matches and seq greater remove binding Iterator lt RegistrationBinding gt it bindings values iterator try while it hasNext RegistrationBinding binding RegistrationBinding it next if callld equals binding getCallld if seq gt binding getCSeq it remove locationService removeBinding sipAddressOfRecord binding getContactAddress else sendErrorResponse Response BAD_REQUEST event getServerTransaction event getRequest return else it remove locationService removeBinding sipAddressOfRecord binding getContactAddress catch LocationServiceException Ise logger error Ise sendErrorResponse Response SERVER INTERNAL ERROR event getServerTransaction event getRequest return sendRegistrationOKResponse event getServerTransaction event getRequest bindings jelse check condition for udpate update bindings add remove and send response 26 Register handler jelse Update bindings if logger isDebugEnabled logger debug Updating bindings Listlterator li newContacts listlterator while li hasNe
6. Sip Service Example To install the Example simply execute provided ant script build xm1 default target usr ant The script will copy the Example s deployable unit jar to the defau1t Mobicents JAIN SLEE server profile deploy directory to deploy to another server profile use the argument Dnode 3 Note Some services may wish to receive INVITE request Call Uninstalling Mobicents JAIN SLEE Sip Service Example usr ant deploy all without initial invite 2 4 Uninstalling Mobicents JAIN SLEE Sip Service Example To uninstall the Example simply execute provided ant script build xml undeploy target usr ant undeploy The script will delete the Example s deployable unit jar from the defau1t Mobicents JAIN SLEE server profile deploy directory to undeploy from another server profile use the argument Dnode usr ant undeploy all without initial invite Chapter 3 Design Overview The Sip Service Example is JAIN SLEE 1 1 Application which handles incoming SIP messages Depending on message target and message method example takes different action General rule of message traversal through this example look as follows Is Local Domain Pass to Registrar SBB Perform Proxy Operation Sip Service Example Flow 3 1 Example Components Example consist of three SBBs Each one performs different task ProxySbb Is responsible for routing procedures lt performs operations defi
7. library ref gt lt library name gt sip services library lt library name gt lt library vendor gt org mobicents lt library vendor gt lt library version gt 1 2 lt library version gt lt library ref gt 31 Chapter 4 Source Code Overview lt sbb classes gt lt sbb abstract class gt lt sbb abstract class name gt org mobicents slee services sip location LocationSbb lt sbb abstract class name gt lt sbb abstract class gt lt sbb local interface gt lt sbb local interface name gt org mobicents slee services sip location LocationSbbLocalObject lt sbb local interface name gt lt sbb local interface gt lt sbb classes gt lt sbb gt lt sbb jar gt org mobicents slee services sip location LocationSbbLocalObject is defined as follows package org mobicents slee services sip location import javax slee SbbLocalObject public interface LocationSbbLocalObject extends SbbLocalObject LocationService package org mobicents slee services sip location public interface LocationService extends je Adds new contact binding for particular user param sipAddress 32 SBB Interface sip address of record sip ala ma kota w domu com param contactAddress i contact address tel 381243256 param comment 3 possible comment note param expires long seconds for which this contact is to remain valid param registrationDate long date when the
8. registration was created updated param qValue g q parameter param callld 5 call id param cSeg seq numbers return binding created in this operation throws LocationServiceException EA public RegistrationBinding addBinding String sipAddress String contactAddress String comment long expires long registrationDate float qValue String callld long cSeq throws LocationServiceException ya Returns set of user that have registered set contains adress of record for each user something like sip ala kocia domena com Oreturn throws LocationServiceException Y public Set lt String gt getRegisteredUsers throws LocationServiceException ye Returns map which contains mapping contactAddress gt registrationBinding for particular user address of record sip nie ma mnie tu param sipAddress Oreturn throws LocationServiceException public Map lt String RegistrationBinding gt getBindings String sipAddress throws LocationServiceException 33 Chapter 4 Source Code Overview je Updates the specified registration binding param registrationBinding throws LocationServiceException Y public void updateBinding RegistrationBinding registrationBinding throws LocationServiceException jes Removes contact address from user bindings param sip address of record sip ala kocia domena au param contactAddress tel 481234567890 throws LocationServiceExcept
9. to access javax slee ChildRelation object representing link to defined child childRelation object gives access to sbbLocalobject interface This object allows parent to attach child to ActivityContextInterface to make it eligible to receive events e invoke synchronously methods defined in child sbbLocal0bject lts defined in source as follows 30 LocationSbb public abstract class RegistrarSbb implements Sbb location service child relation public abstract ChildRelation getLocationSbbChildRelation public LocationSbbLocalObject getLocationSbb throws TransactionRequiredLocalException SLEEException CreateException return LocationSbbLocalObject getLocationSbbChildRelation create 4 3 LocationSbb Locationsbb is responsible for storing and managing expiration of address bindings Class org mobicents slee services sip location Locationsbb includes all the service logic required to perform management of contact addresses 4 3 1 SBB Interface LocationSbb declares custom sbbLocalobject interface Declared methods are used by ProxySbb and Registrarsbb to access registration data Declaration in sbb jar xml look as follows lt sbb jar gt lt sbb id sip registrar location sbb gt lt description gt Location Service JPA based lt description gt lt sbb name gt LocationSbb lt sbb name gt lt sbb vendor gt org mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt
10. 1 1 ProxySbb RegistrarSbb RegistrarSbb javax slee SbbNotification service ServicelD name SIP Registrar Service vendor org mobicents version 1 2 sbb SbbID name SipRegistrarSbb vendor org mobicents version 1 2 RegisterSbb LocationSbb LocationSbb javax slee SbbNotification service ServicelD name SIP Registrar Service vendor org mobicents version 1 2 sbb SbbID name LocationSbb vendor org mobicents version 1 2 LocationSbb Important Spaces where introduced in 1064J category column values to correctly render the table Please remove them when using copy paste 6 2 Alarms The example Application does not sets JAIN SLEE Alarms 45 46 Appendix A Revision History Revision History Revision 1 0 Mon Feb 8 2010 BartoszBaranowski Creation of the Mobicents JAIN SLEE Sip Service Example User Guide 47 48 Index F feedback viii 49 50
11. Mobicents JAIN SLEE Sip Service Example User Guide by Eduardo Martins Bartosz Baranowski and Alexandre Mendon a Preface PDP PO PROS e V 1 Document CONVENTIONS u ee lieh v 1 1 Typographic Conventions cece ee ae ee eeeeeeeeeeeeaaeaeeneeseeeeeeaeaaeaees v 1 2 Pull quote Conventions 200 00 cece cece cece cece cece eter ee ee nc nn nnanannrnn nn nn conri vii 1 3 Notes and Warnings cece eee tees eee eeeeaaaeeeeeaaaeeeeeaaaeeeeeaaaeeeeeaaeeees vii 2 Provide feedback to the authors erre aca arana marra viii 1 Introduction to Mobicents JAIN SLEE Sip Service Example nn 1 2 SOUUP coito lr 3 2 1 Pre Install Requirements and Prerequisites noni 3 2 1 1 Hardware Requirements sossen ini an iia nr non nn ercer 3 2 1 2 Software Prerequisites oooocccnnonnnnccnncccccononncncnnnnncnnnnnnnancnnnancnnnnnnnancnnnancnnns 3 2 2 Mobicents JAIN SLEE Sip Service Example Source Code n 3 2 2 1 Release Source Code Building aa 3 2 2 2 Development Trunk Source Building ra 4 2 3 Installing Mobicents JAIN SLEE Sip Service Example c eeseeeeeeeeeeeeeeneeeees 4 2 4 Uninstalling Mobicents JAIN SLEE Sip Service Example ii 5 3 Design Overview a rei 7 3 1 Example ComponentS vicioso idas ti ia lia lila 7 3 2 Location and Registrar Operations ooocooococonncccccnconcnnnnnn
12. RegistrationOKResponse event getServerTransaction event getRequest bindings 4 2 2 Child relation Registrarsbb defines Locationsbb as child Locationsbb child is used as manager for RegistrationBindings Child relation is declared in sbb jar xml descriptor lt sbb id sip registrar sbb gt lt description gt JAIN SIP Registrar SBB lt description gt lt sbb name gt SipRegistrarSbb lt sbb name gt 29 Chapter 4 Source Code Overview lt sbb vendor gt org mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt sbb ref gt lt sbb name gt LocationSbb lt sbb name gt lt sbb vendor gt org mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt sbb alias gt LocationSbb lt sbb alias gt lt sbb ref gt lt sbb classes gt lt sbb abstract class gt lt sbb abstract class name gt org mobicents slee services sip registrar RegistrarSbb lt sbb abstract class name gt lt get child relation method gt lt sbb alias ref gt LocationSbb lt sbb alias ref gt lt get child relation method name gt getLocationSbbChildRelation lt get child relation method name gt lt default priority gt 0 lt default priority gt lt get child relation method gt lt sbb abstract class gt lt sbb classes gt lt sbb gt lt sbb jar gt Parent declaration in descriptor defines method name in case of example its getLocationSbbChildRelation implented by JSLEE This method allows parent
13. ST event getServerTransaction event getRequest return if requestedExpires 0 if logger isDebugEnabled logger debug Removing binding sipAddressOfRecord gt contactAddress bindings remove contactAddress locationService removeBinding sipAddressOfRecord binding getContactAddress else if logger isDebugEnabled logger debug Updating binding sipAddressOfRecord gt contactAddress logger debug contact contact toString Lets push it into location service this will update version of binding binding setCallld callld binding setExpires requestedExpires binding setRegistrationDate System currentTimeMillis binding setCSeq seq binding setQValue q 28 Child relation locationService updateBinding binding else Create new binding if requestedExpires 0 if logger isDebugEnabled logger debug Adding new binding sipAddressOfRecord gt contactAddress logger debug contact toString removed comment parameter to registration binding Address and Contact headers don t have comments in 1 1 RegistrationBinding registrationBinding locationService addBinding sipAddress contactAddress requestedExpires System currentTimeMillis q callld seq bindings put registrationBinding getContactAddress registrationBinding Update bindings return 200 if successful 500 on error send
14. access javax slee ChildRelation object representing link to defined child childRelation object gives access to sbbLocalobject interface This object allows parent to attach child to ActivityContextInterface to make it eligible to receive events e invoke synchronously methods defined in child SbbLocalObject ProxySbb invokes its children with both RegistrarSbb is beeing attached to ActivityContextInterface LocationSbb is invoked in synchronous way It exposes SbbLocalObject extending org mobicents slee services sip location LocationService interface It is defined and used as follows public interface LocationSbbLocalObject extends SbbLocalObject LocationService public abstract class ProxySbb implements Sbb public abstract ChildRelation getLocationSbbChildRelation public LocationSbbLocalObject getLocationSbb throws TransactionRequiredLocalException 21 Chapter 4 Source Code Overview SLEEException CreateException final ChildRelation childRelation getLocationSbbChildRelation if childRelation isEmpty return LocationSbbLocalObject childRelation create else return LocationSbbLocalObject childRelation iterator next private void processRequest ServerTransaction serverTransaction Request request ActivityContextinterface ac new ProxyMachine getProxyConfigurator getLocationSbb this addressFactory this headerFactory this messageFactory this provider processReques
15. ace GJ Note A note is a tip or shortcut or alternative approach to the task at hand Ignoring a note should have no negative consequences but you might miss out on a trick that makes your life easier Important Important boxes detail things that are easily missed configuration changes that only apply to the current session or services that need restarting before an update will apply Ignoring Important boxes won t cause data loss but may cause irritation and frustration Warning A Warning should not be ignored Ignoring warnings will most likely cause data loss 2 Provide feedback to the authors If you find a typographical error in this manual or if you have thought of a way to make this manual better we would love to hear from you Please submit a report in the the ssue Tracker http code google com p mobicents issues list against the product Mobicents JAIN SLEE Sip Service Example or contact the authors When submitting a bug report be sure to mention the manuals identifier JAIN SLEE SipServices EXAMPLE User Guide If you have a suggestion for improving the documentation try to be as specific as possible when describing it If you have found an error please include the section number and some of the surrounding text so we can find it easily viii Chapter 1 Introduction to Mobicents JAIN SLEE Sip Service Example This example is a JAIN SLEE application which processes SIP Messages from SIP UAs t
16. ation In PDF and paper editions this manual uses typefaces drawn from the Liberation Fonts https fedorahosted org liberation fonts set The Liberation Fonts set is also used in HTML editions if the set is installed on your system If not alternative but equivalent typefaces are displayed Note Red Hat Enterprise Linux 5 and later includes the Liberation Fonts set by default 1 1 Typographic Conventions Four typographic conventions are used to call attention to specific words and phrases These conventions and the circumstances they apply to are as follows Mono spaced Bold Used to highlight system input including shell commands file names and paths Also used to highlight key caps and key combinations For example To see the contents of the file my_next_bestselling_novel in your current working directory enter the cat my_next_bestselling_novel command at the shell prompt and press Enter to execute the command The above includes a file name a shell command and a key cap all presented in Mono spaced Bold and all distinguishable thanks to context Key combinations can be distinguished from key caps by the hyphen connecting each part of a key combination For example Press Enter to execute the command Press Ctrl Alt F1 to switch to the first virtual terminal Press Ctrl Alt F7 to return to your X Windows session The first sentence highlights the particular key cap to press The second highlights two sets of three
17. b activity context interface name gt lt sbb activity context interface gt lt sbb classes gt lt sbb gt lt sbb jar gt 38 Expiration timer Custom Activity Context Interface accessor is defined as follows public abstract class LocationSbb implements public abstract RegistrationBindingActivityContextinterface asSbbActivityContextInterface ActivityContextinterface aci Variables are defined in Java Bean convetion by declaration of setter and getter pair in custom Activity Context Interface public interface RegistrationBindingActivityContextinterface extends ActivityContextinterface public abstract TimerlD getTimerlD public abstract void setTimerlD TimerlD timerlD public abstract String getContactAddress public abstract void setContactAddress String contactAddress public abstract String getSipAddress public abstract void setSipAddress String sipAddress 4 3 3 Expiration timer Timer supervising expiration is created with binding lts attached to named ACI Timeout value is based on data passed from Registrarsbb Timer event handler is invoked in case of contact address expiration its purpose is to retrieve data stored in custom Activity Context Interface clean ACI name binding remove AOR binding from LocationService 39 Chapter 4 Source Code Overview Timer event handler is defined as follows public void onTimerEvent TimerEvent timer ActivityContextInter
18. cation and Registrar Operations Location SBB creates JSLEE timer for each pair AOR contact address Once timer expires contact address is considered as invalid Time between creation of this mapping and expiration depends ON Expires Header content 10 Chapter 4 Source Code Overview Important To obtain the example s complete source code please refer to Section 2 2 Mobicents JAIN SLEE Sip Service Example Source Code Chapter Chapter 3 Design Overview explains top level view of example This chapter explains how components perform their tasks For more detailed explanation of JSLEE related source code and xml descriptors please refer to simpler examples like sip wakeup 4 1 ProxySbb overview Proxy SBB is top component in this example itis declared as root SBB It declares event handlers for all SIP11 ResourceAdaptor transactional events ProxySbb expects transactional events to be fired that is it assumes that if in Dialog event is fired some other application is responsible for messages ProxySbb expects also that at any given time it is attached only to one incoming transaction Server and one or more ongoing Client That is because ProxySbb uses sbbcontext facility to retrieve list of current activities it is attached to Class org mobicents slee services sip proxy ProxySbb has all the logic linking JSLEE with routing logic declared in inner class org mobicents slee services sip proxy ProxySbb
19. ce registrarAccess AddressFactory af HeaderFactory hf MessageFactory mf SipProvider prov throws ParseException 14 Request handlers super config reg registrarAccess this mf mf this af af this hf hf this provider prov this config config SipUri localMachineURI new SipUri localMachineURI setHost this config getSipHostname localMachineURI setPort this config getSipPort this localMachinelnterfaces add localMachineURI public void processRequest ServerTransaction stx Request req if log isDebugEnabled log debug processRequest try Request impNewRequest Request req clone 16 3 Request Validation validateRequest stx impNewRequest 16 4 Route Information Preprocessing routePreProcess tmpNewRequest logger debug Server transaction stx 16 5 Determining Request Targets List targets determineRequestTargets tmpNewRequest Iterator it targets iterator while it hasNext Request newRequest Request impNewRequest clone URI target URI it next Part of loop detection here we will stop initial reqeust that makes loop in local stack if isLocalMachine target continue 16 6 Request Forwarding 1 Copy request 15 Chapter 4 Source Code Overview 2 Request URI if target isSipURI amp amp SipUri target hasLrParam newRequest setRequestURl target NEW CANCEL pro
20. cessing CANCELs are hop by hop so here must remove any existing Via headers Record Route headers We insert Via header below so we will get response if newRequest getMethod equals Request CANCEL newRequest removeHeader ViaHeader NAME newRequest removeHeader RecordRouteHeader NAME else 3 Max Forwards decrementMaxForwards newRequest 4 Record Route addRecordRouteHeader newRequest 5 Add Additional Header Fields TBD 6 Postprocess routing information TBD 7 Determine Next Hop Address Port and Transport TBD 8 Add a Via header field value addViaHeader newRequest 9 Add a Content Leangth header field if necessary TBD 10 Forward Request ClientTransaction ctx forwardRequest stx newRequest 11 Set timer C catch SipSendErrorResponseException se 16 Response handlers se printStackTrace int statusCode se getStatusCode sendErrorResponse stx reg statusCode catch SipLoopDetectedException slde log warn Loop detected droping message side printStackTrace catch Exception e e printStackTrace 4 1 3 Response handlers Response handlers are invoked for incoming responses In case multiple final responses incoming in sequence first response is forwarded in stateful manner others are forwarded in stateles manner Example response handler look as follows public void onRedirRespEve
21. cnccancnnnnnnnnnancrnnnnn non nnnnn ern 8 4 Source Code Overview err rraraa acena a daaa ad nana 11 4 1 ProxySbb overview e te ee ee ee arena aaa rranaa nana aaa rrarararananaa 11 4 1 1 Initial event handler cece ce eeee cece eee ee AAEE 11 4 1 2 Request h ndlers u en be baceet SEM sena lgnintastes 13 4 1 3 Response handlers 0 cccccceceeeceeeeeeeeeeee ceca ea eeeeeeeeeeeaeaaaaeeeeeeeeeeaeaaaaees 17 4 1 4 Register handler ccoo tes 19 4 1 5 Child relation staunen a 20 4 2 Registrar SHD ranas 24 4 2 1 Register handler viii caia li 24 4 2 2 Child relation secos aan 29 AS LOCA ONO to EO ERES aa a eenes 31 4 3 1 SBB INterfate use une R sE 31 4 3 2 SBB Activity Context Interface i aee 38 4 3 3 Expiration Mer vorar een en 39 4 3 4 SBB Activity Context Interface naming rn 40 4 3 5 SBB environment entries cece ae ea eeeeeeeeeeeeaaaaeeeeeeeeeeeeaeaaeeees 41 4 4 Location SerViCE cuina 42 5 Running the Example ee eeee aaa eeeeaaaeeeeeaaaeeeeeaaeeeees 43 DL Configuration c a 43 6 Traces and Alam S cia tc ata aba dad 45 DB PTAC ONS e A cir 45 6 2 ALANIS a a iaa 45 A REVISION HISTON auch ee 47 INOX ua A O T I E E A OO 49 Preface 1 Document Conventions This manual uses several conventions to highlight certain words and phrases and draw attention to specific pieces of inform
22. ebug onRegisterEvent address of record from request sipAddressOfRecord 24 Register handler map will be empty if user not in LS Note we don t care if the user has a valid account in the LS we just add them anyway String sipAddress getCanonicalAddress HeaderAddress event getRequest getHeader ToHeader NAME Map lt String RegistrationBinding gt bindings locationService getBindings sipAddress Do we have any contact header s if event getRequest getHeader ContactHeader NAME null Just send OK with current bindings this request was a query logger info query for bindings sipAddress sipAddress sendRegistrationOKResponse event getServerTransaction event getRequest bindings return check if request is remove action if so remove bindings from data base Check contact callid cseq ArrayList newContacts getContactHeaderList event getRequest getHeaders ContactHeader NAME final String callld CallldHeader event getRequest getHeader CallldHeader NAME getCallld final long seg CSeqHeader event getRequest getHeader CSeqHeader NAME getSeqNumber ExpiresHeader expiresHeader event getRequest getExpires if hasWildCard newContacts This is a Contact remove all bindings request if expiresHeader null expiresHeader getExpires 0 newContacts size gt 1 malformed request in RFC3261 ch10
23. face aci if logger isFineEnabled logger fine onTimerEvent aci detach sbbContext getSbbLocalObject cast to rg aci RegistrationBindingActivityContextInterface rgAci asSbbActivityContextInterface aci get data from aci String contactAddress rgAci getContactAddress String sipAddress rgAci getSipAddress unbind from aci so it ends try activityContextNamingFacility unbind getACIName contactAddress sipAddress catch Exception e logger severe e remove rg from location service try locationService removeBinding sipAddress contactAddress catch Exception e logger severe e if logger isInfoEnabled logger info binding expired sipAddress sipAddress contactAddress contactAddress 4 3 4 SBB Activity Context Interface naming Locat ionSbb associates name to ACI on which expiration timer runs This makes ACI accessible with given name Name and ACI association is created with JSLEE activity Context Naming Facility Name uniquely identifies Timer ACI for given AOR and contact address 40 SBB environment entries 4 3 5 SBB environment entries Locationsbb environment entry controls LocationService type used JPA and local XML descriptor defines entry as follows lt sbb id sip registrar location sbb gt lt description gt Location Service JPA based lt description gt lt sbb name gt LocationSbb lt sbb name gt lt sbb vendor gt org
24. if logger isDebugEnabled logger debug getBindings sipAddress sipAddress return locationService getBindings sipAddress 37 Chapter 4 Source Code Overview 4 3 2 SBB Activity Context Interface LocationSbb defines custom Activity Context Interface with variables Variables are used to store data required to manage expiration timer and access binding in storage that is JSLEE timer id of timer running for contact address contact address for which expiration timer runs sip address AOR of binding Custom Activity Context Interface is defined in sbb jar xml descriptor as follows lt sbb id sip registrar location sbb gt lt description gt Location Service JPA based lt description gt lt sbb name gt LocationSbb lt sbb name gt lt sbb vendor gt org mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt library ref gt lt library name gt sip services library lt library name gt lt library vendor gt org mobicents lt library vendor gt lt library version gt 1 2 lt library version gt lt library ref gt lt sbb classes gt lt sbb abstract class gt lt sbb abstract class name gt org mobicents slee services sip location LocationSbb lt sbb abstract class name gt lt sbb abstract class gt lt sbb activity context interface gt lt sbb activity context interface name gt org mobicents slee services sip location RegistrationBindingActivityContextInterface lt sb
25. in the Text to copy field and then click the Copy button Now switch back to your document and choose Edit gt Paste from the gedit menu bar Proportional Bold and all distinguishable by context Note the gt shorthand used to indicate traversal through a menu and its sub menus This is to e difficult to follow Select Mouse from the Preferences sub menu in the System menu avoid th of the m ain menu bar approach Mono spaced Bold Italic Ol Proportional Bold Italic Whether Mono spaced Bold or Proportional Bold the addition of Italics indicates replaceable or text Italics denotes text you do not input literally or displayed text that changes depending variable on circu Note the words in bold italics above username domain name file system package version and Each word is a placeholder either for text you enter when issuing a command or for text release mstance For example To connect to a remote machine using ssh type ssh username domain name at a shell prompt If the remote machine is example com and your username on that machine is john type ssh john example com The mount o remount file system command remounts the named file system For example to remount the home file system the command is mount o remount home To see the version of a currently installed package use the rpm q package command It will return a result as follows package version release displayed by the system Aside from
26. ion Y public void removeBinding String sipAddress String contactAddress throws LocationServiceException Methods defined by LocationsbbLocalobject are implemented by Locationsbb class Those methods are invoked in synchronous manner in order to perform binding operations add binding and create expiration timer public RegistrationBinding addBinding String sipAddress String contactAddress String comment long expires long registrationDate float qValue String callld long cSeq throws LocationServiceException add binding RegistrationBinding registrationBinding locationService addBinding sipAddress contactAddress comment expires registrationDate Value callld cSeq if logger isDebugEnabled 34 SBB Interface logger debug addBinding registrationBinding create null aci NullActivity nullActivity nullActivityFactory createNullActivity Activity ContextInterface aci null try aci nullACIFactory getActivityContextInterface nullActivity set name activityContextNamingFacility bind aci getACIName contactAddress sipAddress catch Exception e throw new LocationServiceException e getLocalizedMessage atach to this activity aci attach sbbContext getSbbLocalObject set timer TimerlD timerlD timerFacility setTimer aci null registrationDate expires 1 1000 defaultTimerOptions save data in aci RegistrationBindingActivityContextInterface rgAci
27. ion can be CANCEL transaction so we dont want to overwrite it above new ProxyMachine getProxyConfigurator getLocationSbb this addressFactory this headerFactory this messageFactory this provider processRequest serverTransaction request catch Exception e Send error response so client can deal with it logger warn Exception during processRequest e try 13 Chapter 4 Source Code Overview serverTransaction sendResponse messageFactory createResponse Response SERVER_INTERNAL_ERROR request catch Exception ex logger warn Exception during processRequest e ProxyMachine Class performs all required operations to forward request check if request is properly built process information in request and determine targets forward message to all possible targets attach to outgoing legs class ProxyMachine extends MessageUtils implements MessageHandlerlInterface protected final Logger log Logger getLogger ProxyMachine class We can use those variables from top level class but let us have our own protected LocationService reg null protected AddressFactory af null protected HeaderFactory hf null protected MessageFactory mf null protected SipProvider provider null protected HashSet lt URI gt localMachinelnterfaces new HashSet lt URI gt protected ProxyConfiguration config null public ProxyMachine ProxyConfiguration config LocationServi
28. key caps each set pressed simultaneously If source code is discussed class names methods functions variable names and returned values mentioned within a paragraph will be presented as above in Mono spaced Bold For example File related classes include filesystem for file systems file for files and dir for directories Each class has its own associated set of permissions Proportional Bold This denotes words or phrases encountered on a system including application names dialogue box text labelled buttons check box and radio button labels menu titles and sub menu titles For example Preface The above text includes application names system wide menu names and items application menu names and buttons and text found within a GUI interface all presented in specific Choose System gt Preferences gt Mouse from the main menu bar to launch Mouse Preferences In the Buttons tab click the Left handed mouse check box and click Close to switch the primary mouse button from the left to the right making the mouse suitable for use in the left hand To insert a special character into a gedit file choose Applications gt Accessories gt Character Map from the main menu bar Next choose Search gt Find from the Character Map menu bar type the name of the character in the Search field and click Next The character you sought will be highlighted in the Character Table Double click this highlighted character to place it
29. main set to either nist gov or mobicents org 5 1 Configuration Two components can be configured in example LocationSbb location components supports two different storage providers HA and local Default storage is local lt can be changed with sbb env property LOCATION_SERVICE_CLASS_NAME lt can have one of two values org mobicents slee services sip location nonha NonHALocationService this class implements local service not replicated based on java java util Map org mobicents slee services sip location jpa JPALocationService this class implements HA service replicated storage based on JPA LocationSbb exposes JMX properties which can be accessed under ObjectName slee sipservice Location Supported properties Table 5 1 LocationSbb JMX properties Name Type Description registeredUsers java util Set lt java lang String gt Read only property It return value is set with AORs of Users registeredUserCount java lang Integer Read only property Indicates how many users are registered ProxySbb Configuration can be changed in configuration properties file or during runtime with JMX Bean Bean is accessible under objectName slee sipproxyconfigurator only_human where sipproxyconfigurator value is equal to configuration name Supported properties Table 5 2 ProxySbb JMX properties Description supportedURIScheme java lang String URI scheme supported by proxy It coma separated li
30. mobicents lt sbb vendor gt lt sbb version gt 1 2 lt sbb version gt lt library ref gt lt library name gt sip services library lt library name gt lt library vendor gt org mobicents lt library vendor gt lt library version gt 1 2 lt library version gt lt library ref gt lt env entry gt lt env entry name gt LOCATION_SERVICE_CLASS_NAME lt env entry name gt lt env entry type gt java lang String lt env entry type gt lt choose your location service filtered on compliation gt lt env entry value gt org mobicents slee services sip location nonha NonHALocationService lt env entry value gt lt env entry gt lt sbb gt lt sbb jar gt Environment entries are accessible with JNDI lookups Context myEnv Context new InitialContext lookup java comp env String value String myEnv lookup LOCATION SERVICE CLASS NAME 41 Chapter 4 Source Code Overview 4 4 Location Service Location service is simple POJO based service lts only purpose is to persist bindings It stores data for each AOR in following form AOR sip newbie mobicents org Sip Service Example location information structure 42 Chapter 5 Running the Example The easiest way to test example is to deploy example and start container register two UACs and make call from one to another UACs must be configured to use container as proxy by default each UAC should point to proxy at 127 0 0 1 5060 and have do
31. ned in section 16 http tools ietf org html ric3261 section 16 of RFC3261 and sends message to proper node It is first SBB to receive any incoming message RegistrarSbb Is responsible for proper REGISTER request processing lt performs operations defined in section 10 http tools ietf org ntml rfc326 1 fsection 10 of RFC3261 Registrar creates AOR Address Of Record and based on REGISTER content performs update to location data LocationSbb Is responsible for storing and invalidating entries for aors That is it stores mapping between AOR and contact addresses and on contact address expiration removes it Root SBB of service is ProxySbb which receives messages as first Relation between SBB s look as follows Chapter 3 Design Overview Parent ProxySbb Parent child ProxySbb Sip Service Example components relations 3 2 Location and Registrar Operations REGISTER requests which are passed to RegistrarSbb trigger routine which updates user contact database and associated expiration date Simple sequence diagram for success case look as follows Locationsbb ACI Namina TmerFacii EN FOR Contact c 3 getBindingO 4 getBinding ee ae A O O A U 8 storeBinding Fegak ndnotmeo io H 11 bindNameTOACI 1 13 SIP 200 OK Sip Service Registrar and Location sequence Lo
32. nt ResponseEvent event ActivityContextinterface ac if logger isDebugEnabled logger debug Received 3xx REDIRECT response processResponse event getClientTransaction event getResponse ac private void processResponse ClientTransaction clientTransaction Response response ActivityContextInterface ac if logger isInfoEnabled logger info processing response status n response getStatusCode try 17 Chapter 4 Source Code Overview if getServerTransactionTerminated return Go ServerTransaction serverTransaction getServerTransaction clientTransaction if serverTransaction null new ProxyMachine getProxyConfigurator getLocationSbb this addressFactory this headerFactory this messageFactory this provider processResponse serverTransaction clientTransaction response else logger warn Weird got null tx for response catch Exception e Send error response so client can deal with it logger warn Exception during processResponse e ProxyMachine class performs all required operations to forward response check if response should be forwarded forward it public void processResponse ServerTransaction stx ClientTransaction ctx Response resp Now check if we really want to send it right away log info this getClass getName processResponse try Response newResponse Response resp clone 16 7 Resp
33. o act as a simple proxy and registrar Example implements proxy routines defined in section 16 http tools ietf org html rfc3261 section 16 and registrar routines defined in section 10 http tools ietf org html r c3261 tsection 10 of RFC3261 It is not a trivial example as it provides usage of child relations timers null activities SBB activity context interfaces activity context interfaces variables SBB environment entries SBB local interfaces SBB local interfaces JAIN SIP RA code Thus it should be considered as target for more advanced users Example service is capable of routing SIP messages based on registrar entries or target domain Registrar entries are based on received SIP REGISTER request for example local domains Chapter 2 Setup 2 1 Pre Install Requirements and Prerequisites Ensure that the following requirements have been met before continuing with the install 2 1 1 Hardware Requirements The Example doesn t change the Mobicents JAIN SLEE Hardware Requirements refer to Mobicents JAIN SLEE documentation for more information 2 1 2 Software Prerequisites The Example requires Mobicents JAIN SLEE properly set with SIP11 Resource Adaptor deployed 2 2 Mobicents JAIN SLEE Sip Service Example Source Code This section provides instructions on how to obtain and build the Sip Service Example from source code 2 2 1 Release Source Code Building 1 Downloading the so
34. onse Processing 1 Find appropriate response context 18 Register handler 2 Update timer C for provisional responses 3 Remove topmost via Iterator viaHeaderlt newResponse getHeaders ViaHeader NAME viaHeaderlt next viaHeaderlt remove if IviaHeaderlt hasNexit return response was meant for this proxy 4 Add the response to the response context 5 Check to see if this response should be forwarded immediately if newResponse getStatusCode Response TRYING return 6 When necessary choose the best final response from the 7 Aggregate authorization header fields if necessary 8 Optionally rewrite Record Route header field values 9 Forward the response forwardResponse stx newResponse 10 Generate any necessary CANCEL requesis catch Exception e e printStackTrace 4 1 4 Register handler REGIST ER request are handled differently Depending on target domain incoming message is forwarded if target domain does not match configured local domains e directed to Proxysbb child for processing 19 Chapter 4 Source Code Overview public void onRegisterEvent RequestEvent event ActivityContextinterface ac if logger isDebugEnabled logger debug Received REGISTER request class event getClass see http tools ietf org html rfc3261 section 10 2 SipURI uri SipURI event getRequest getRequestURI
35. ring sipAddress String contactAddress throws LocationServiceException if logger isDebugEnabled logger debug removeBinding sipAddress sipAddress contactAddress contactAddress try lookup null aci from aci naming facility get timerid and cancel timer when present ActivityContextInterface aci activityContextNamingFacility lookup getACIName contactAddress sipAddress if aci null timerFacility cancelTimer asSbbActivityContextInterface aci getTimerlD activityContexiNamingFacility unbind getACIName contactAddress sipAddress end null activity detach is no good because this is a different sbb entity then the one that create the binding NullActivity aci getActivity endActivity 36 SBB Interface catch Exception e throw new LocationServiceException e getLocalizedMessage remove from location service locationService removeBinding sipAddress contactAddress if logger isInfoEnabled logger info removed binding sipAddress sipAddress contactAddress contactAddress get registered users AOR public Set lt String gt getRegisteredUsers throws LocationServiceException if logger isDebugEnabled logger debug getRegisteredUsers return locationService getRegisteredUsers retrieve all bindings for aor public Map lt String RegistrationBinding gt getBindings String sipAddress throws LocationServiceException
36. ror e if listOfTargets size 0 throw new SipSendErrorResponseException User temporarily unavailable Response TEMPORARILY_UNAVAILABLE 23 Chapter 4 Source Code Overview return listOfTargets 4 2 RegistrarSbb RegistrarSbb is responsible for handling REGISTER requests and sending proper response Registrarsbb receives requests on ActivityContextInterface to which it is attached by its parent please see Section 4 1 4 Register handler for explanation and code example Class org mobicents slee services sip registrar RegistrarSbb includes all the service logic required to perform registry tasks 4 2 1 Register handler RegistrarSbb operate ON RegistrationBindingS managed by LocationService Registrarsbb performs following operations in REGISTER event handler e check if request is a query if so send response with list of contacts see if child sbb local object is already in CMP LocationSbbLocalObject locationService getLocationSbb get configuration from MBean final long maxExpires config getSipRegistrationMaxExpires final long minExpires config getSipRegistrationMinExpires Process require header Authenticate Authorize OK we re authorized now extract address of record String sipAddressOfRecord getCanonicalAddress HeaderAddress event getRequest getHeader ToHeader NAME if logger isDebugEnabled logger d
37. st 43 Chapter 5 Running the Example Name Type Description By default it has value of sip sips localDomain java lang String domain for which this proxy should provide services lis comma separated list of values By default it has value of 127 0 0 1 nist gov mobicents org transports java lang String list of transports which can be used by proxy Its comma separated list of values By default it has value of udp by default proxy uses first one available sipPort java lang Integer Port which is used to send and receive messages By defautl it has value of 5060 RegistrarSbb Configuration can be changed during runtime with JMX Bean Bean is accessible under ObjectName slee sipregistrarconfigurator vlRegistrarConf Supported properties Table 5 3 RegistrarSbb JMX properties Description sipRegistrationMinExpires java lang Integer Minimal acceptable value of Expires Header sipRegistrationMaxExpires java lang Integer Maximal acceptable value of Expires Header 44 Chapter 6 Traces and Alarms 6 1 Tracers The example Application uses multiple JAIN SLEE 1 1 Tracer facility instances Below is full list Table 6 1 Sip Service Tracer and Log Categories E Tracer name LOG4J category ProxySbb ProxySbb javax slee SbbNotification service ServicelD name JAIN SIP Proxy Service vendor mobicents version 1 1 sbb SbbID name ProxySbb vendor mobicents version
38. standard usage for presenting the title of a work italics denotes the first use of a new and imp ortant term For example When the Apache HTTP Server accepts requests it dispatches child processes or threads to handle them This group of child processes or threads is known as vi Pull quote Conventions a server pool Under Apache HTTP Server 2 0 the responsibility for creating and maintaining these server pools has been abstracted to a group of modules called Multi Processing Modules MPMs Unlike other modules only one module from the MPM group can be loaded by the Apache HTTP Server 1 2 Pull quote Conventions Two commonly multi line data types are set off visually from the surrounding text Output sent to a terminal is set in Mono spaced Roman and presented thus Source code listings are also set in Mono spaced Roman but are presented and highlighted as follows package org jboss book jca ex1 import javax naming InitialContext public class ExClient public static void main String args throws Exception InitialContext iniCtx new InitialContext Object ref iniCtx lookup EchoBean EchoHome home EchoHome ref Echo echo home create System out printin Created Echo System out printin Echo echo Hello echo echo Hello 1 3 Notes and Warnings Finally we use three visual styles to draw attention to information that might otherwise be overlooked vil Pref
39. t serverTransaction request class ProxyMachine extends MessageUtils implements MessageHandlerInterface protected LocationService reg null public ProxyMachine ProxyConfiguration config LocationService registrarAccess AddressFactory af HeaderFactory hf MessageFactory mf SipProvider prov throws ParseException reg registrarAccess 22 Child relation yu Attempts to find a locally registered contact address for the given URI using the location service interface Y public LinkedList lt URI gt findLocalTarget URI uri throws SipSendErrorResponseException String addressOfRecord uri toString Map lt String RegistrationBinding gt bindings null LinkedList lt URI gt listOfTargets new LinkedList lt URI gt try bindings reg getBindings addressOfRecora catch LocationServiceException e e printStackTrace return listOfTargets if bindings null throw new SipSendErrorResponseException User not found Response NOT_FOUND if bindings isEmpty throw new SipSendErrorResponseException User temporarily unavailable Response TEMPORARILY_UNAVAILABLE Iterator it bindings values iterator URI target null while it hasNext String contactAddress RegistrationBinding it next getContactAddress try listOfTargets add af createURl contactAddress catch ParseException e log warn Ignoring contact address contactAddress due to parse er
40. urce code Important Subversion is used to manage its source code Instructions for using Subversion including install can be found at htip svnbook red bean com Use SVN to checkout a specific release source the base URL is http mobicents googlecode com svn tags servers jain slee 2 x y examples sip services then add the specific release version lets consider 2 4 0 FINAL usr svn co http mobicents googlecode com svn tags servers jain slee 2 x y examples sip services 2 4 0 FINAL slee example sip services 2 4 0 FINAL Chapter 2 Setup 2 Building the source code Important Maven 2 0 9 or higher is used to build the release Instructions for using Maven2 including install can be found at http maven apache org Use Maven to build the deployable unit binary usr cd slee example sip services 2 4 0 FINAL usr mvn install Once the process finishes you should have the deployable unit jar file in the target directory if Mobicents JAIN SLEE is installed and environment variable JBOSS_HOME is pointing to its underlying JBoss Application Server directory then the deployable unit jar will also be deployed in the container 2 2 2 Development Trunk Source Building Similar process as for Section 2 2 1 Release Source Code Building the only change is the SVN source code URL which is http mobicents googlecode com svn trunk servers jain slee examples sip services 2 3 Installing Mobicents JAIN SLEE
41. xt ContactHeader contact ContactHeader li next get expires value either in header or default do min expires etc long requestedExpires 0 if contact getExpires gt 0 requestedExpires contact getExpires else if expiresHeader null amp amp expiresHeader getExpires gt 0 requestedExpires expiresHeader getExpires else requestedExpires 3600 default f expires too large reset to our local max if requestedExpires gt maxExpires requestedExpires maxExpires else if requestedExpires gt 0 amp amp requestedExpires lt minExpires requested expiry too short send response with min expires sendintervalTooBriefResponse event getServerTransaction event getRequest minExpires return Get the q value preference for this binding default to 0 0 min float q 0 if contact getQValue 1 q contact getQValue if q gt 1 Il q lt 0 27 Chapter 4 Source Code Overview sendErrorResponse Response BAD_REQUEST event getServerTransaction event getRequest return Find existing binding String contactAddress contact getAddress getURI toString RegistrationBinding binding RegistrationBinding bindings get contactAddress if binding null Update this binding if callld equals binding getCallld if seg lt binding getCSeq sendErrorResponse Response BAD_REQUE

Download Pdf Manuals

image

Related Search

Related Contents

Samsung SGH-L870 User Manual  Weider WEEVBE3722 User's Manual  iPoMan 8000  Portable Testing Device for Testing of electricity meters User Manual  masibus  Triarch 25312 User's Manual  製品安全データシート - 株式会社パーキンエルマージャパン  

Copyright © All rights reserved.
Failed to retrieve file