Revision: 1255eef8e234
Author:   [email protected] <[email protected]>
Date:     Sat Jan 12 08:46:23 2013
Log:      docs changed CAP example

http://code.google.com/p/jss7/source/detail?r=1255eef8e234

Modified:
/cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallScfExample.java /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallSsfExample.java
 /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/Example.java
 /docs/sources/src/main/resources/en-US/Chapter-CAP.xml

=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallScfExample.java Tue Jan 8 05:30:00 2013 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallScfExample.java Sat Jan 12 08:46:23 2013
@@ -2,13 +2,15 @@

 import java.util.ArrayList;

+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.mobicents.protocols.ss7.cap.api.CAPDialog;
 import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
 import org.mobicents.protocols.ss7.cap.api.CAPException;
 import org.mobicents.protocols.ss7.cap.api.CAPMessage;
 import org.mobicents.protocols.ss7.cap.api.CAPParameterFactory;
 import org.mobicents.protocols.ss7.cap.api.CAPProvider;
-import org.mobicents.protocols.ss7.cap.api.CAPStack;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGeneralAbortReason;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGprsReferenceNumber;
import org.mobicents.protocols.ss7.cap.api.dialog.CAPNoticeProblemDiagnostic;
@@ -49,21 +51,24 @@
 import org.mobicents.protocols.ss7.inap.api.primitives.LegType;
import org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber;
 import org.mobicents.protocols.ss7.isup.message.parameter.NAINumber;
-import org.mobicents.protocols.ss7.sccp.SccpProvider;
 import org.mobicents.protocols.ss7.tcap.asn.comp.PAbortCauseType;
 import org.mobicents.protocols.ss7.tcap.asn.comp.Problem;

public class CallScfExample implements CAPDialogListener, CAPServiceCircuitSwitchedCallListener {

-       private CAPStack capStack;
        private CAPProvider capProvider;
        private CAPParameterFactory paramFact;
        private CAPDialogCircuitSwitchedCall currentCapDialog;
        private CallContent cc;

-       public CallScfExample(SccpProvider sccpPprovider, int ssn) {
-               capStack = new CAPStackImpl(sccpPprovider, ssn);
-               capProvider = capStack.getCAPProvider();
+       public CallScfExample() throws NamingException {
+               InitialContext ctx = new InitialContext();
+               try {
+                       String providerJndiName = "java:/mobicents/ss7/cap";
+                       this.capProvider = ((CAPProvider) 
ctx.lookup(providerJndiName));
+               } finally {
+                       ctx.close();
+               }
                paramFact = capProvider.getCAPParameterFactory();

                capProvider.addCAPDialogListener(this);
@@ -75,8 +80,6 @@
        }

        public void start() {
-               capStack.start();
-
                // Make the circuitSwitchedCall service activated
         capProvider.getCAPServiceCircuitSwitchedCall().acivate();

@@ -84,7 +87,7 @@
        }

        public void stop() {
-               capStack.stop();
+               capProvider.getCAPServiceCircuitSwitchedCall().deactivate();
        }

        @Override
=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallSsfExample.java Tue Jan 8 05:30:00 2013 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/CallSsfExample.java Sat Jan 12 08:46:23 2013
@@ -1,5 +1,8 @@
 package org.mobicents.protocols.ss7.cap;

+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.mobicents.protocols.ss7.cap.api.CAPApplicationContext;
 import org.mobicents.protocols.ss7.cap.api.CAPDialog;
 import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
@@ -49,6 +52,7 @@
import org.mobicents.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.DestinationRoutingAddress; import org.mobicents.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.EventSpecificInformationBCSM;
 import org.mobicents.protocols.ss7.inap.api.primitives.MiscCallInfo;
+import org.mobicents.protocols.ss7.map.api.MAPProvider;
import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation;
 import org.mobicents.protocols.ss7.sccp.SccpProvider;
 import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
@@ -57,15 +61,20 @@

public class CallSsfExample implements CAPDialogListener, CAPServiceCircuitSwitchedCallListener {

-       private CAPStack capStack;
        private CAPProvider capProvider;
        private CAPParameterFactory paramFact;
        private CAPDialogCircuitSwitchedCall currentCapDialog;
        private CallContent cc;

-       public CallSsfExample(SccpProvider sccpPprovider, int ssn) {
-               capStack = new CAPStackImpl(sccpPprovider, ssn);
-               capProvider = capStack.getCAPProvider();
+       public CallSsfExample() throws NamingException {
+               InitialContext ctx = new InitialContext();
+               try {
+                       String providerJndiName = "java:/mobicents/ss7/cap";
+                       this.capProvider = ((CAPProvider) 
ctx.lookup(providerJndiName));
+               } finally {
+                       ctx.close();
+               }
+
                paramFact = capProvider.getCAPParameterFactory();

                capProvider.addCAPDialogListener(this);
@@ -77,8 +86,6 @@
        }

        public void start() {
-               capStack.start();
-
                // Make the circuitSwitchedCall service activated
         capProvider.getCAPServiceCircuitSwitchedCall().acivate();

@@ -86,7 +93,7 @@
        }

        public void stop() {
-               capStack.stop();
+                capProvider.getCAPServiceCircuitSwitchedCall().deactivate();
        }

public void sendInitialDP(SccpAddress origAddress, SccpAddress remoteAddress,
=======================================
--- /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/Example.java Tue Jan 8 05:30:00 2013 +++ /cap/cap-impl/src/test/java/org/mobicents/protocols/ss7/cap/Example.java Sat Jan 12 08:46:23 2013
@@ -1,8 +1,5 @@
 package org.mobicents.protocols.ss7.cap;

-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.OAnswerSpecificInfo;
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.ODisconnectSpecificInfo;
 import org.mobicents.protocols.ss7.cap.api.isup.CalledPartyNumberCap;
@@ -24,24 +21,10 @@
 import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation;
-import org.mobicents.protocols.ss7.sccp.SccpProvider;
-import org.mobicents.protocols.ss7.sccp.SccpStack;
 import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;

 public class Example {

-       private static SccpProvider getSccpProvider() throws NamingException {
-               // no arg is ok, if we run in JBoss
-
-               InitialContext ctx = new InitialContext();
-               try {
-                       String providerJndiName = "/mobicents/ss7/sccp";
-                       return ((SccpStack) 
ctx.lookup(providerJndiName)).getSccpProvider();
-               } finally {
-                       ctx.close();
-               }
-       }
-
        private static SccpAddress createLocalAddress() {
return new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, 1, null, 146);
        }
@@ -52,8 +35,7 @@


        public static void startCallSsf() throws Exception {
-               SccpProvider sccpProvider = getSccpProvider(); // JNDI lookup 
of SCCP
-               CallSsfExample client = new CallSsfExample(sccpProvider, 146);
+               CallSsfExample client = new CallSsfExample();

                client.start();

@@ -137,8 +119,7 @@
        }

        public static void startCallScf() throws Exception {
-               SccpProvider sccpProvider = getSccpProvider(); // JNDI lookup 
of SCCP
-               CallScfExample server = new CallScfExample(sccpProvider, 146);
+               CallScfExample server = new CallScfExample();

                server.start();

=======================================
--- /docs/sources/src/main/resources/en-US/Chapter-CAP.xml Sun Sep 9 03:46:55 2012 +++ /docs/sources/src/main/resources/en-US/Chapter-CAP.xml Sat Jan 12 08:46:23 2013
@@ -114,27 +114,16 @@
                <para>
                        The 
<classname>org.mobicents.protocols.ss7.cap.CAPStackImpl</classname>
                        is concrete implementation of 
<classname>CAPStack.</classname>
- The CAP User application creates an instance of <classname>CAPStackImpl</classname> - passing the reference of <classname>SccpProvider</classname> and Sub System Number and
-                       then start it. All incoming messages are checked for 
destination SSN,
- if it matches with the one registered with this CAPStackImpl the corresponding listener
-                       is called, else the peer receives error.
+ The CAP User application gets access to <classname>CAPProvider</classname> by doing JNDI look-up as explained in <xref linkend="design_overview_ss7_service"/>.
                </para>

                <programlisting
                        language="Java"
-                       role="JAVA"><![CDATA[SccpProvider sccpProvider = 
getSccpProvider();
-        CAPStackImpl capStack = new CAPStackImpl(sccpProvider, 146);
-        capStack.start();
-        ...]]>
+ role="JAVA"><![CDATA[String providerJndiName = "java:/mobicents/ss7/cap";
+this.capProvider = ((CAPProvider) ctx.lookup(providerJndiName));
+...]]>
                </programlisting>

-               <para>
- The reference to <classname>SccpProvider</classname> is received from SccpStack. - To get handle to <classname>SccpStack</classname> do the JNDI look-up passing the JNDI name configured
-                       in SS7 service as explained in <xref 
linkend="sccp_access_point" />.
-               </para>
-
                <para>
The CAP User application should register the concrete implementation of <classname>CAPDialogListener</classname> with <classname>CAPProvider</classname> to listen for incoming CAP Dialog and CAP Primitive messages.
@@ -157,8 +146,7 @@

                <programlisting language="Java" role="JAVA"><![CDATA[
public class CAPExample implements CAPDialogListener, CAPServiceCircuitSwitchedCallListener {
-        ....
-        capProvider = capStack.getCAPProvider();
+           ....
         capProvider.addCAPDialogListener(this);
capProvider.getCAPServiceCircuitSwitchedCall().addCAPServiceListener(this);
         ....
@@ -441,9 +429,6 @@
                        role="JAVA"><![CDATA[
 package org.mobicents.protocols.ss7.cap;

-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.OAnswerSpecificInfo;
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.ODisconnectSpecificInfo;
 import org.mobicents.protocols.ss7.cap.api.isup.CalledPartyNumberCap;
@@ -465,17 +450,10 @@
 import org.mobicents.protocols.ss7.map.api.primitives.ISDNAddressString;
 import org.mobicents.protocols.ss7.map.api.primitives.NumberingPlan;
import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation;
-import org.mobicents.protocols.ss7.sccp.SccpProvider;
-import org.mobicents.protocols.ss7.sccp.SccpStack;
 import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;

 public class Example {

-       private static SccpProvider getSccpProvider()  {
-               ....
-               ....
-       }
-
        private static SccpAddress createLocalAddress() {
return new SccpAddress(RoutingIndicator.ROUTING_BASED_ON_DPC_AND_SSN, 1, null, 146);
        }
@@ -486,8 +464,7 @@


        public static void startCallSsf() throws Exception {
-               SccpProvider sccpProvider = getSccpProvider(); // JNDI lookup 
of SCCP
-               CallSsfExample client = new CallSsfExample(sccpProvider, 146);
+               CallSsfExample client = new CallSsfExample();

                client.start();

@@ -497,72 +474,71 @@

                int serviceKey = 1;

- CalledPartyNumber calledPartyNumber = client.getCAPProvider().getISUPParameterFactory().
-                       createCalledPartyNumber();
+ CalledPartyNumber calledPartyNumber = client.getCAPProvider().getISUPParameterFactory()
+                       .createCalledPartyNumber();
                calledPartyNumber.setAddress("552348762");
calledPartyNumber.setNatureOfAddresIndicator(NAINumber._NAI_INTERNATIONAL_NUMBER);
                
calledPartyNumber.setNumberingPlanIndicator(CalledPartyNumber._NPI_ISDN);
calledPartyNumber.setInternalNetworkNumberIndicator(CalledPartyNumber._INN_ROUTING_ALLOWED);
-               CalledPartyNumberCap calledPartyNumberCap = 
client.getCAPProvider().
-                       
getCAPParameterFactory().createCalledPartyNumberCap(calledPartyNumber);
+               CalledPartyNumberCap calledPartyNumberCap = 
client.getCAPProvider()
+                       
.getCAPParameterFactory().createCalledPartyNumberCap(calledPartyNumber);

- CallingPartyNumber callingPartyNumber = client.getCAPProvider().getISUPParameterFactory().
-                       createCallingPartyNumber();
+ CallingPartyNumber callingPartyNumber = client.getCAPProvider().getISUPParameterFactory()
+                       .createCallingPartyNumber();
                callingPartyNumber.setAddress("55998223");
callingPartyNumber.setNatureOfAddresIndicator(NAINumber._NAI_INTERNATIONAL_NUMBER); callingPartyNumber.setNumberingPlanIndicator(CalledPartyNumber._NPI_ISDN);
-               callingPartyNumber.setAddressRepresentationREstrictedIndicator(
-                       CallingPartyNumber._APRI_ALLOWED);
+ callingPartyNumber.setAddressRepresentationREstrictedIndicator(CallingPartyNumber._APRI_ALLOWED); callingPartyNumber.setScreeningIndicator(CallingPartyNumber._SI_NETWORK_PROVIDED);
-               CallingPartyNumberCap callingPartyNumberCap = 
client.getCAPProvider().
- getCAPParameterFactory().createCallingPartyNumberCap(callingPartyNumber);
+               CallingPartyNumberCap callingPartyNumberCap = 
client.getCAPProvider()
+ .getCAPParameterFactory().createCallingPartyNumberCap(callingPartyNumber);

- LocationNumber locationNumber = client.getCAPProvider().getISUPParameterFactory().
-                       createLocationNumber();
+ LocationNumber locationNumber = client.getCAPProvider().getISUPParameterFactory()
+               .createLocationNumber();
                locationNumber.setAddress("55200001");
locationNumber.setNatureOfAddresIndicator(NAINumber._NAI_INTERNATIONAL_NUMBER);
                
locationNumber.setNumberingPlanIndicator(LocationNumber._NPI_ISDN);
locationNumber.setAddressRepresentationRestrictedIndicator(LocationNumber._APRI_ALLOWED); locationNumber.setScreeningIndicator(LocationNumber._SI_NETWORK_PROVIDED); locationNumber.setInternalNetworkNumberIndicator(LocationNumber._INN_ROUTING_ALLOWED); - LocationNumberCap locationNumberCap = client.getCAPProvider().getCAPParameterFactory().
-                       createLocationNumberCap(locationNumber);
+ LocationNumberCap locationNumberCap = client.getCAPProvider().getCAPParameterFactory()
+                       .createLocationNumberCap(locationNumber);

ISDNAddressString vlrNumber = client.getCAPProvider().getMAPParameterFactory() .createISDNAddressString(AddressNature.international_number, NumberingPlan.ISDN,
-                               "552000002");
+                                               "552000002");
LocationInformation locationInformation = client.getCAPProvider().getMAPParameterFactory()
                                .createLocationInformation(10, null, vlrNumber, 
null, null, null, null,
-                               vlrNumber, null, false, false, null, null);
+                                               vlrNumber, null, false, false, 
null, null);

client.sendInitialDP(origAddress, destAddress, serviceKey, calledPartyNumberCap,
-                       callingPartyNumberCap, locationNumberCap, 
EventTypeBCSM.collectedInfo,
-                       locationInformation);
+                               callingPartyNumberCap, locationNumberCap, 
EventTypeBCSM.collectedInfo,
+                               locationInformation);

                // sending oAnswer in 5 sec
                Thread.sleep(5000);
OAnswerSpecificInfo oAnswerSpecificInfo = client.getCAPProvider().getCAPParameterFactory()
                                .createOAnswerSpecificInfo(null, false, false, 
null, null, null);
-               ReceivingSideID legID = 
client.getCAPProvider().getCAPParameterFactory().
-                       createReceivingSideID(LegType.leg2);
- MiscCallInfo miscCallInfo = client.getCAPProvider().getINAPParameterFactory().
-                       
createMiscCallInfo(MiscCallInfoMessageType.notification, null);
+               ReceivingSideID legID = 
client.getCAPProvider().getCAPParameterFactory()
+                       .createReceivingSideID(LegType.leg2);
+ MiscCallInfo miscCallInfo = client.getCAPProvider().getINAPParameterFactory()
+                       
.createMiscCallInfo(MiscCallInfoMessageType.notification, null);
client.sendEventReportBCSM_OAnswer(oAnswerSpecificInfo, legID, miscCallInfo);

                // sending oDisconnect in 20 sec
                Thread.sleep(20000);
- CauseIndicators causeIndicators = client.getCAPProvider().getISUPParameterFactory().
-                       createCauseIndicators();
+ CauseIndicators causeIndicators = client.getCAPProvider().getISUPParameterFactory()
+                       .createCauseIndicators();
                causeIndicators.setLocation(CauseIndicators._LOCATION_USER);
                
causeIndicators.setCodingStandard(CauseIndicators._CODING_STANDARD_ITUT);
                causeIndicators.setCauseValue(CauseIndicators._CV_ALL_CLEAR);
-               CauseCap releaseCause = 
client.getCAPProvider().getCAPParameterFactory().
-                       createCauseCap(causeIndicators);
- ODisconnectSpecificInfo oDisconnectSpecificInfo = client.getCAPProvider().
-                       
getCAPParameterFactory().createODisconnectSpecificInfo(releaseCause);
+               CauseCap releaseCause = 
client.getCAPProvider().getCAPParameterFactory()
+                       .createCauseCap(causeIndicators);
+               ODisconnectSpecificInfo oDisconnectSpecificInfo = 
client.getCAPProvider()
+                       
.getCAPParameterFactory().createODisconnectSpecificInfo(releaseCause);
legID = client.getCAPProvider().getCAPParameterFactory().createReceivingSideID(LegType.leg1);
-               miscCallInfo = 
client.getCAPProvider().getINAPParameterFactory().
-                       
createMiscCallInfo(MiscCallInfoMessageType.notification, null);
+               miscCallInfo = client.getCAPProvider().getINAPParameterFactory()
+                       
.createMiscCallInfo(MiscCallInfoMessageType.notification, null);
client.sendEventReportBCSM_ODisconnect(oDisconnectSpecificInfo, legID, miscCallInfo);

                // wait for answer
@@ -572,8 +548,7 @@
        }

        public static void startCallScf() throws Exception {
-               SccpProvider sccpProvider = getSccpProvider(); // JNDI lookup 
of SCCP
-               CallScfExample server = new CallScfExample(sccpProvider, 146);
+               CallScfExample server = new CallScfExample();

                server.start();

@@ -583,6 +558,7 @@
                server.stop();
        }
 }
+
 ]]>
        </programlisting>

@@ -591,6 +567,9 @@
                        role="JAVA"><![CDATA[
 package org.mobicents.protocols.ss7.cap;

+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.mobicents.protocols.ss7.cap.api.CAPApplicationContext;
 import org.mobicents.protocols.ss7.cap.api.CAPDialog;
 import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
@@ -601,7 +580,6 @@
 import org.mobicents.protocols.ss7.cap.api.CAPStack;
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.OAnswerSpecificInfo;
 import org.mobicents.protocols.ss7.cap.api.EsiBcsm.ODisconnectSpecificInfo;
-import org.mobicents.protocols.ss7.cap.api.dialog.CAPComponentErrorReason;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGeneralAbortReason;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGprsReferenceNumber;
import org.mobicents.protocols.ss7.cap.api.dialog.CAPNoticeProblemDiagnostic;
@@ -641,6 +619,7 @@
import org.mobicents.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.DestinationRoutingAddress; import org.mobicents.protocols.ss7.cap.api.service.circuitSwitchedCall.primitive.EventSpecificInformationBCSM;
 import org.mobicents.protocols.ss7.inap.api.primitives.MiscCallInfo;
+import org.mobicents.protocols.ss7.map.api.MAPProvider;
import org.mobicents.protocols.ss7.map.api.service.mobility.subscriberInformation.LocationInformation;
 import org.mobicents.protocols.ss7.sccp.SccpProvider;
 import org.mobicents.protocols.ss7.sccp.parameter.SccpAddress;
@@ -649,15 +628,20 @@

public class CallSsfExample implements CAPDialogListener, CAPServiceCircuitSwitchedCallListener {

-       private CAPStack capStack;
        private CAPProvider capProvider;
        private CAPParameterFactory paramFact;
        private CAPDialogCircuitSwitchedCall currentCapDialog;
        private CallContent cc;

-       public CallSsfExample(SccpProvider sccpPprovider, int ssn) {
-               capStack = new CAPStackImpl(sccpPprovider, ssn);
-               capProvider = capStack.getCAPProvider();
+       public CallSsfExample() throws NamingException {
+               InitialContext ctx = new InitialContext();
+               try {
+                       String providerJndiName = "java:/mobicents/ss7/cap";
+                       this.capProvider = ((CAPProvider) 
ctx.lookup(providerJndiName));
+               } finally {
+                       ctx.close();
+               }
+
                paramFact = capProvider.getCAPParameterFactory();

                capProvider.addCAPDialogListener(this);
@@ -669,8 +653,6 @@
        }

        public void start() {
-               capStack.start();
-
                // Make the circuitSwitchedCall service activated
         capProvider.getCAPServiceCircuitSwitchedCall().acivate();

@@ -678,23 +660,24 @@
        }

        public void stop() {
-               capStack.stop();
+                capProvider.getCAPServiceCircuitSwitchedCall().deactivate();
        }

- public void sendInitialDP(SccpAddress origAddress, SccpAddress remoteAddress, int serviceKey, - CalledPartyNumberCap calledPartyNumber, CallingPartyNumberCap callingPartyNumber,
-                       LocationNumberCap locationNumber, EventTypeBCSM 
eventTypeBCSM,
-                       LocationInformation locationInformation)
+ public void sendInitialDP(SccpAddress origAddress, SccpAddress remoteAddress,
+                       int serviceKey, CalledPartyNumberCap calledPartyNumber,
+ CallingPartyNumberCap callingPartyNumber, LocationNumberCap locationNumber,
+                       EventTypeBCSM eventTypeBCSM, LocationInformation 
locationInformation)
                        throws CAPException {
                // First create Dialog
                CAPApplicationContext acn = 
CAPApplicationContext.CapV2_gsmSSF_to_gsmSCF;
- currentCapDialog = capProvider.getCAPServiceCircuitSwitchedCall().createNewDialog(acn,
-                       origAddress, remoteAddress);
+ currentCapDialog = capProvider.getCAPServiceCircuitSwitchedCall().createNewDialog(
+                               acn, origAddress, remoteAddress);

- currentCapDialog.addInitialDPRequest(serviceKey, calledPartyNumber, callingPartyNumber,
-                       null, null, null, locationNumber, null, null, null, 
null, null,
-                       eventTypeBCSM, null, null, null, null, null, null, 
null, false, null,
-                       null, locationInformation, null, null, null, null, 
null, false, null);
+               currentCapDialog.addInitialDPRequest(serviceKey, 
calledPartyNumber,
+                               callingPartyNumber, null, null, null, 
locationNumber, null, null,
+                               null, null, null,
+                               eventTypeBCSM, null, null, null, null, null, 
null, null, false,
+ null, null, locationInformation, null, null, null, null, null, false, null);
                // This will initiate the TC-BEGIN with INVOKE component
                currentCapDialog.send();

@@ -707,10 +690,11 @@
public void sendEventReportBCSM_OAnswer(OAnswerSpecificInfo oAnswerSpecificInfo,
                        ReceivingSideID legID, MiscCallInfo miscCallInfo) 
throws CAPException {
                if (currentCapDialog != null && this.cc != null) {
- EventSpecificInformationBCSM eventSpecificInformationBCSM = this.capProvider. - getCAPParameterFactory().createEventSpecificInformationBCSM(oAnswerSpecificInfo);
+                       EventSpecificInformationBCSM 
eventSpecificInformationBCSM =
+ this.capProvider.getCAPParameterFactory().createEventSpecificInformationBCSM(
+                                               oAnswerSpecificInfo);
                        
currentCapDialog.addEventReportBCSMRequest(EventTypeBCSM.oAnswer,
-                               eventSpecificInformationBCSM, legID, 
miscCallInfo, null);
+                                       eventSpecificInformationBCSM, legID, 
miscCallInfo, null);
                        currentCapDialog.send();
                        this.cc.step = Step.answered;
                }
@@ -719,10 +703,11 @@
public void sendEventReportBCSM_ODisconnect(ODisconnectSpecificInfo oDisconnectSpecificInfo,
                        ReceivingSideID legID, MiscCallInfo miscCallInfo) 
throws CAPException {
                if (currentCapDialog != null && this.cc != null) {
- EventSpecificInformationBCSM eventSpecificInformationBCSM = this.capProvider. - getCAPParameterFactory().createEventSpecificInformationBCSM(oDisconnectSpecificInfo);
+                       EventSpecificInformationBCSM 
eventSpecificInformationBCSM =
+ this.capProvider.getCAPParameterFactory().createEventSpecificInformationBCSM(
+                                               oDisconnectSpecificInfo);
                        
currentCapDialog.addEventReportBCSMRequest(EventTypeBCSM.oDisconnect,
-                               eventSpecificInformationBCSM, legID, 
miscCallInfo, null);
+                                       eventSpecificInformationBCSM, legID, 
miscCallInfo, null);
                        currentCapDialog.send();
                        this.cc.step = Step.disconnected;
                }
@@ -735,6 +720,7 @@

                        // initiating BCSM events processing
                }
+               
ind.getCAPDialog().processInvokeWithoutAnswer(ind.getInvokeId());
        }

        @Override
@@ -753,6 +739,7 @@
        @Override
        public void onContinueRequest(ContinueRequest ind) {
                this.cc.step = Step.callAllowed;
+               
ind.getCAPDialog().processInvokeWithoutAnswer(ind.getInvokeId());
                // sending Continue to use the original calledPartyAddress
        }

@@ -760,6 +747,7 @@
        public void onConnectRequest(ConnectRequest ind) {
                this.cc.step = Step.callAllowed;
                this.cc.destinationRoutingAddress = 
ind.getDestinationRoutingAddress();
+               
ind.getCAPDialog().processInvokeWithoutAnswer(ind.getInvokeId());
                // sending Connect to force routing the call to a new  number
        }

@@ -788,14 +776,14 @@
        }

        @Override
-       public void onErrorComponent(CAPDialog capDialog, Long invokeId,
-                       CAPErrorMessage capErrorMessage) {
+ public void onErrorComponent(CAPDialog capDialog, Long invokeId, CAPErrorMessage capErrorMessage) {
                // TODO Auto-generated method stub

        }

        @Override
- public void onRejectComponent(CAPDialog capDialog, Long invokeId, Problem problem) { + public void onRejectComponent(CAPDialog capDialog, Long invokeId, Problem problem,
+                       boolean isLocalOriginated) {
                // TODO Auto-generated method stub

        }
@@ -805,13 +793,6 @@
                // TODO Auto-generated method stub

        }
-
-       @Override
-       public void onProviderErrorComponent(CAPDialog capDialog, Long invokeId,
-                       CAPComponentErrorReason providerError) {
-               // TODO Auto-generated method stub
-
-       }

        @Override
        public void onCAPMessage(CAPMessage capMessage) {
@@ -994,6 +975,7 @@
        }

 }
+
 ]]>
        </programlisting>

@@ -1004,14 +986,15 @@

 import java.util.ArrayList;

+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
 import org.mobicents.protocols.ss7.cap.api.CAPDialog;
 import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
 import org.mobicents.protocols.ss7.cap.api.CAPException;
 import org.mobicents.protocols.ss7.cap.api.CAPMessage;
 import org.mobicents.protocols.ss7.cap.api.CAPParameterFactory;
 import org.mobicents.protocols.ss7.cap.api.CAPProvider;
-import org.mobicents.protocols.ss7.cap.api.CAPStack;
-import org.mobicents.protocols.ss7.cap.api.dialog.CAPComponentErrorReason;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGeneralAbortReason;
 import org.mobicents.protocols.ss7.cap.api.dialog.CAPGprsReferenceNumber;
import org.mobicents.protocols.ss7.cap.api.dialog.CAPNoticeProblemDiagnostic;
@@ -1052,21 +1035,24 @@
 import org.mobicents.protocols.ss7.inap.api.primitives.LegType;
import org.mobicents.protocols.ss7.isup.message.parameter.CalledPartyNumber;
 import org.mobicents.protocols.ss7.isup.message.parameter.NAINumber;
-import org.mobicents.protocols.ss7.sccp.SccpProvider;
 import org.mobicents.protocols.ss7.tcap.asn.comp.PAbortCauseType;
 import org.mobicents.protocols.ss7.tcap.asn.comp.Problem;

public class CallScfExample implements CAPDialogListener, CAPServiceCircuitSwitchedCallListener {

-       private CAPStack capStack;
        private CAPProvider capProvider;
        private CAPParameterFactory paramFact;
        private CAPDialogCircuitSwitchedCall currentCapDialog;
        private CallContent cc;

-       public CallScfExample(SccpProvider sccpPprovider, int ssn) {
-               capStack = new CAPStackImpl(sccpPprovider, ssn);
-               capProvider = capStack.getCAPProvider();
+       public CallScfExample() throws NamingException {
+               InitialContext ctx = new InitialContext();
+               try {
+                       String providerJndiName = "java:/mobicents/ss7/cap";
+                       this.capProvider = ((CAPProvider) 
ctx.lookup(providerJndiName));
+               } finally {
+                       ctx.close();
+               }
                paramFact = capProvider.getCAPParameterFactory();

                capProvider.addCAPDialogListener(this);
@@ -1078,8 +1064,6 @@
        }

        public void start() {
-               capStack.start();
-
                // Make the circuitSwitchedCall service activated
         capProvider.getCAPServiceCircuitSwitchedCall().acivate();

@@ -1087,7 +1071,7 @@
        }

        public void stop() {
-               capStack.stop();
+               capProvider.getCAPServiceCircuitSwitchedCall().deactivate();
        }

        @Override
@@ -1095,6 +1079,8 @@
                this.cc = new CallContent();
                this.cc.idp = ind;
                this.cc.step = Step.initialDPRecieved;
+
+               
ind.getCAPDialog().processInvokeWithoutAnswer(ind.getInvokeId());
        }

        @Override
@@ -1111,6 +1097,8 @@
                                break;
                        }
                }
+
+               
ind.getCAPDialog().processInvokeWithoutAnswer(ind.getInvokeId());
        }

        @Override
@@ -1122,31 +1110,35 @@
                                        // informing SSF of BCSM events 
processing
                                        ArrayList<BCSMEvent> bcsmEventList = new 
ArrayList<BCSMEvent>();
BCSMEvent ev = this.capProvider.getCAPParameterFactory().createBCSMEvent(
-                                               
EventTypeBCSM.routeSelectFailure, MonitorMode.notifyAndContinue,
-                                               null, null, false);
+                                                       
EventTypeBCSM.routeSelectFailure, MonitorMode.notifyAndContinue,
+                                                       null, null, false);
                                        bcsmEventList.add(ev);
                                        ev = 
this.capProvider.getCAPParameterFactory().createBCSMEvent(
- EventTypeBCSM.oCalledPartyBusy, MonitorMode.interrupted, null, null, false);
+                                                       
EventTypeBCSM.oCalledPartyBusy, MonitorMode.interrupted, null,
+                                                       null, false);
                                        bcsmEventList.add(ev);
                                        ev = 
this.capProvider.getCAPParameterFactory().createBCSMEvent(
-                                               EventTypeBCSM.oNoAnswer, 
MonitorMode.interrupted, null, null, false);
+ EventTypeBCSM.oNoAnswer, MonitorMode.interrupted, null, null, false);
                                        bcsmEventList.add(ev);
                                        ev = 
this.capProvider.getCAPParameterFactory().createBCSMEvent(
- EventTypeBCSM.oAnswer, MonitorMode.notifyAndContinue, null, null, false);
+                                                       EventTypeBCSM.oAnswer, 
MonitorMode.notifyAndContinue, null,
+                                                       null, false);
                                        bcsmEventList.add(ev);
- LegID legId = this.capProvider.getINAPParameterFactory().createLegID(true,
-                                               LegType.leg1);
+                                       LegID legId = 
this.capProvider.getINAPParameterFactory().createLegID(
+                                                       true, LegType.leg1);
                                        ev = 
this.capProvider.getCAPParameterFactory()
                                                        
.createBCSMEvent(EventTypeBCSM.oDisconnect,
-                                                       
MonitorMode.notifyAndContinue, legId, null, false);
+                                                                       
MonitorMode.notifyAndContinue, legId, null, false);
                                        bcsmEventList.add(ev);
                                        legId = 
this.capProvider.getINAPParameterFactory().createLegID(true,
-                                               LegType.leg2);
+                                                       LegType.leg2);
                                        ev = 
this.capProvider.getCAPParameterFactory().createBCSMEvent(
- EventTypeBCSM.oDisconnect, MonitorMode.interrupted, legId, null, false);
+                                                       
EventTypeBCSM.oDisconnect, MonitorMode.interrupted, legId,
+                                                       null, false);
                                        bcsmEventList.add(ev);
                                        ev = 
this.capProvider.getCAPParameterFactory().createBCSMEvent(
- EventTypeBCSM.oAbandon, MonitorMode.notifyAndContinue, null, null, false);
+                                                       EventTypeBCSM.oAbandon, 
MonitorMode.notifyAndContinue, null,
+                                                       null, false);
                                        bcsmEventList.add(ev);
currentCapDialog.addRequestReportBCSMEventRequest(bcsmEventList, null);

@@ -1154,23 +1146,25 @@
                                        String newNumber = "22123124";
                                        if (newNumber != null) {
                                                // sending Connect to force 
routing the call to a new  number
-                                               ArrayList<CalledPartyNumberCap> 
calledPartyNumber = new
-                                                       
ArrayList<CalledPartyNumberCap>();
-                                               CalledPartyNumber cpn = 
this.capProvider.getISUPParameterFactory().
-                                                       
createCalledPartyNumber();
+                                               ArrayList<CalledPartyNumberCap> 
calledPartyNumber =
+                                                       new 
ArrayList<CalledPartyNumberCap>();
+                                               CalledPartyNumber cpn = 
this.capProvider.getISUPParameterFactory()
+                                                       
.createCalledPartyNumber();
                                                cpn.setAddress("5599999988");
                                                
cpn.setNatureOfAddresIndicator(NAINumber._NAI_INTERNATIONAL_NUMBER);
                                                
cpn.setNumberingPlanIndicator(CalledPartyNumber._NPI_ISDN);
- cpn.setInternalNetworkNumberIndicator(CalledPartyNumber._INN_ROUTING_ALLOWED); - CalledPartyNumberCap cpnc = this.capProvider.getCAPParameterFactory().
-                                                       
createCalledPartyNumberCap(cpn);
+                                               
cpn.setInternalNetworkNumberIndicator(
+                                                               
CalledPartyNumber._INN_ROUTING_ALLOWED);
+                                               CalledPartyNumberCap cpnc = 
this.capProvider.getCAPParameterFactory()
+                                               
.createCalledPartyNumberCap(cpn);
                                                calledPartyNumber.add(cpnc);
- DestinationRoutingAddress destinationRoutingAddress = this.capProvider.
-                                                       
getCAPParameterFactory().createDestinationRoutingAddress(
-                                                       calledPartyNumber);
- currentCapDialog.addConnectRequest(destinationRoutingAddress, null, null,
-                                                       null, null, null, null, 
null, null, null, null, null, null,
-                                                       false, false, false, 
null, false);
+ DestinationRoutingAddress destinationRoutingAddress = this.capProvider
+                                                       
.getCAPParameterFactory().createDestinationRoutingAddress(
+                                                               
calledPartyNumber);
+                                               
currentCapDialog.addConnectRequest(destinationRoutingAddress, null,
+                                                               null, null, 
null, null, null, null, null, null, null,
+                                                               null, null,
+                                                               false, false, 
false, null, false);
                                        } else {
                                                // sending Continue to use the 
original calledPartyAddress
                                                
currentCapDialog.addContinueRequest();
@@ -1193,8 +1187,8 @@

        @Override
        public void onDialogTimeout(CAPDialog capDialog) {
- if (currentCapDialog != null && this.cc != null && this.cc.step != Step.disconnected &&
-                               this.cc.activityTestInvokeId == null) {
+ if (currentCapDialog != null && this.cc != null && this.cc.step != Step.disconnected
+                               && this.cc.activityTestInvokeId == null) {
                        // check the SSF if the call is still alive
                        currentCapDialog.keepAlive();
                        try {
@@ -1234,16 +1228,10 @@
                // TODO Auto-generated method stub

        }
-
-       @Override
- public void onRejectComponent(CAPDialog capDialog, Long invokeId, Problem problem) {
-               // TODO Auto-generated method stub
-
-       }

        @Override
-       public void onProviderErrorComponent(CAPDialog capDialog, Long invokeId,
-                       CAPComponentErrorReason providerError) {
+ public void onRejectComponent(CAPDialog capDialog, Long invokeId, Problem problem,
+                       boolean isLocalOriginated) {
                // TODO Auto-generated method stub

        }
@@ -1437,7 +1425,6 @@
                public Long activityTestInvokeId;
        }
 }
-
 ]]>
        </programlisting>

Reply via email to