code: public void linkSipSessions(SipSession session1, SipSession session2) {
          if (session1 == null) {
              throw new NullPointerException("First argument is null");
          }
          if (session2 == null) {
              throw new NullPointerException("Second argument is null");
          }
  
          if (!((MobicentsSipSession) session1).isValidInternal() || !((MobicentsSipSession) session2).isValidInternal()
                  || State.TERMINATED.equals(((MobicentsSipSession) session1).getState())
                  || State.TERMINATED.equals(((MobicentsSipSession) session2).getState())
                  || !session1.getApplicationSession().equals(session2.getApplicationSession())
                  || (sessionMap.get(((MobicentsSipSession) session1).getId()) != null && !sessionMap.get(((MobicentsSipSession) session1).getId()).equals(((MobicentsSipSession) session2).getId()))
                  || (sessionMap.get(((MobicentsSipSession) session2).getId()) != null
                  && !sessionMap.get(((MobicentsSipSession) session2).getId()).equals(((MobicentsSipSession) session1).getId()))) {
              throw new IllegalArgumentException("either of the specified sessions has been terminated "
                      + "or the sessions do not belong to the same application session or "
                      + "one or both the sessions are already linked with some other session(s)");
          }
          this.sessionMap.put(((MobicentsSipSession) session1).getId(), ((MobicentsSipSession) session2).getId());
          this.sessionMap.put(((MobicentsSipSession) session2).getId(), ((MobicentsSipSession) session1).getId());
          if (logger.isDebugEnabled()) {
              logger.debug("sipsession " + ((MobicentsSipSession) session1).getKey() + " linked to sip session " + ((MobicentsSipSession) session2).getKey());
          }
          dumpAppSession((MobicentsSipSession) session1);
          dumpLinkedSessions();
      }
docs: /*
  (non-Javadoc)
  @see javax.servlet.sip.B2buaHelper#linkSipSessions(javax.servlet.sip.SipSession, javax.servlet.sip.SipSession)