com.highdeal.cnd.message
Class StatelessServiceClient

java.lang.Object
  extended by com.highdeal.cnd.message.StatelessServiceClient
All Implemented Interfaces:
com.highdeal.barbus.ISSLContextProvider

public class StatelessServiceClient
extends java.lang.Object

This Java class allows your client application to send some stateless rating and prerating events to the connected SAP CC Core Server system by using the Message TCP high-speed technical interface.

Consider the following information in this topic:

Synchronous Services and Operations

Features

This rating and charging client benefits from the functions provided by the Message TCP technical interface. Refer to its features about:

Communication Timeout

When a timeout is associated to a given message client, it must be performed during this limited time. If this limited time is exceeded, the operation is rolled back but client timeout does not guarantee that related operations successfully ended (see Technical Reference Guide).

High Performances

By default, this charging client provides high throughput performances and very low latency responses. For very high troughput performances, consider the fine-tuning activity.

High Availability (HA)

By default, this charging client provides high availability services with an SAP CC system with distributed instances in HA setup.

Security

Use setSslContext(javax.net.ssl.SSLContext )

Implementation in Your Client Application

Initializing and Connecting

Your charging client (based on this StatefulServiceClient class) must be initialized via establishing a connection to one of more dispatcher instances available in the distant SAP CC system. Once at least one dispatcher of the SAP CC system is connected from the client application, the client application retrieves automatically the list of all available dispatcher instances on the server system side. It establishes a connection with every one of them automatically.

Implementing Event-Based Rating Services

Depending on your business requirements, you implement one of the following operations in your Java-based client application:

Additional Information

Consult all the online and offline charging services that you can implement in your Java-based client application and in your system landscape.

Consult the SAP CC Library (Application Help) for more information about the online charging services, the charging process and its execution modes (stateless, stateful).


Nested Class Summary
protected static interface AsyncRatingServiceClient.RegisterListener
           
 
Field Summary
static int ALL_TRANSACTION
          Constant to return all the usage transactions
static int ALL_TRANSACTION_AND_RECURRING
          Constant to return all the usage transactions and all the recurring/one-shot transactions
static int CANCELLED
          Constant to set up the resolution used when the time to live (TTL) is expired as canceled
static int CONFIRMED
          Constant to set up the resolution used when the time to live (TTL) is expired as confirmed
protected  java.util.List<AsyncRatingServiceClient.RegisterListener> listeners
           
static int MASTER_TRANSACTION
          Constant to return the master usage transaction
static int NONE_TRANSACTION
          Constant to return no usage transaction
static int POST_RATE_CANCELLATION
           
static int POST_RATE_CONFIRMATION
           
protected  com.highdeal.cnd.message.AsyncRatingServiceClient.RLListener ratingListListener
           
 
Constructor Summary
StatelessServiceClient()
          Creates a non-initialized stateless service client in your client application.
StatelessServiceClient(java.lang.String hostName, int port)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, FoundLostRatingListener ratingListener)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, FoundLostRatingListener ratingListener, int timeout)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, int timeout)
          Creates a stateless service client and connect it to a server.
StatelessServiceClient(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout)
          Creates a stateless service client and connect it to a server.
 
Method Summary
protected  void addListener(AsyncRatingServiceClient.RegisterListener listener)
           
protected  void asyncSend(com.highdeal.cnd.message.common.CollectorMessage m, int maxTimeout, ResponseHandlerWrapper handler, com.highdeal.util.IEventListener eventListener)
          FOR INTERNAL USE ONLY - Sends asynchronously the message m; When a response or an exception is received by the client application, it must back the response handler.
protected  void beginSession()
          FOR INTERNAL USE ONLY - Begins a client session for this thread; All the messages are stored in memory and are not sent until the method sendSession() is called.
protected  boolean checkDB()
          This method is for internal use only.
 void close()
          Closes the connection with the connected SAP CC system; This method allows to release all the resources attached (sockets and buffers) in the charging client.
 void connect(InstanceMap imap, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config)
          Deprecated. use connect(String, int, String, FoundLostRatingListener, int, ServiceClientTuning)
 void connect(InstanceMap imap, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config)
          Connects this charging client with the SAP CC system by using an instance map; A timeout must be specified.
 void connect(java.lang.String systemName, java.net.InetSocketAddress... bootDispatcherAddresses)
          Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.
 void connect(java.lang.String systemName, com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses)
          Connects this charging client with the Rating Instances.
 void connect(java.lang.String hostname, int hostport)
          Connects this charging client to the distant SAP CC Core Server system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.
 void connect(java.lang.String hostname, int port, boolean secure, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config)
          Connects this message client with the Rating Instances.
 void connect(java.lang.String hostname, int hostport, FoundLostRatingListener ratingListener)
          Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.
 void connect(java.lang.String systemName, int lookupDuration, java.net.InetSocketAddress discoveryAddress, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config, java.net.InetSocketAddress... bootDispatcherAddresses)
          Connects this message client with the Rating Instances.
 void connect(java.lang.String systemName, int lookupDuration, java.net.InetSocketAddress discoveryAddress, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config, com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses)
          Connects this charging client with the SAP CC system by using the UDP discovery function.
 void connect(java.lang.String hostname, int hostport, int timeout)
          Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; A client timeout must be specified.
 void connect(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostName, int port, java.lang.String bindAddress, FoundLostRatingListener ratingListener, int timeout, ServiceClientTuning config)
          Connect this stateless service client using the round robin with the server.
 void connect(java.lang.String hostname, int hostport, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener)
          Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.
 void connect(java.lang.String hostname, int port, java.lang.String bindAddress, int timeout, FoundLostRatingListener ratingListener, ServiceClientTuning config)
          Connects this message client with the Rating Instances.
protected  int currentQueueSize()
          This method is for internal use only.
 BootMode getBootMode()
          Returns which API is used to retrieve from the remote instances, the Instance Map needed for the connection.
protected  com.highdeal.barbus.RoundRobinClient getClient()
          Deprecated. Deprecated since version 2.0 of SAP CC and should not be called anymore
 ClientOpEventListener getClientOpEventListener(ClientOpEventTopic topic)
          Gets the client operation event listener used by the client for the specified topic.
protected  java.lang.String getClusterName()
          Deprecated. Deprecated since version 2.0 of SAP CC Gets the system name.
protected  ServiceClientTuning getDefaultServiceClientTuning()
          Gets the default service tuning of this client useful to configure connections.
protected  com.highdeal.util.IEventListener getEventListenerFromListener(java.lang.Object listener)
           
protected  FoundLostRatingListener getFoundLostRatingListener()
          Returns the rating listener previously set.
protected  com.highdeal.barbus.Topic getRatingTopic()
          Gets the rating topic of this client used to send rating messages.
protected  com.highdeal.cnd.message.sensor.SensorsManager getSensorsManager()
           
 javax.net.ssl.SSLContext getSslContext()
          Returns the SSL context used with secure connections.
 int getTimeout()
          Returns the client communication timeout in milliseconds for each request (or -1 to wait indefinitely).
protected  com.highdeal.barbus.Topic[] getTopicsToSubscribe()
          Returns an array of topics that client must subscribe to.
 boolean isConnected()
          Gets the connected connection status.
 boolean isNoTimeout()
          Checks if this charging client handles timeout.
protected  boolean isValid(ChargeableItem ci, InvalidItemListener listener)
          Checks whether the specified chargeable item is valid or not; A call back listener has to be given to handle errors.
protected  void notifyHeartBeat(com.highdeal.barbus.Client client)
           
protected  void register(com.highdeal.hmi.IConnectable connectable)
           
protected  void sendSession()
          FOR INTERNAL USE ONLY - All the messages between the last call of the method beginSession() and now for this thread are sent.
 void setBootMode(BootMode mode)
          Deprecated.  
 void setClientOpEventListener(ClientOpEventTopic topic, ClientOpEventListener listener)
          Sets the client operation event listener to the specified topics; It will be notified each time an event corresponding to the registered topics.
protected  void setClusterName(java.lang.String name)
          Deprecated. Deprecated since version 2.0 of SAP CC
protected  void setFoundLostRatingListener(FoundLostRatingListener ratingListener)
          Sets the rating listener that will be notified each time a rater instance of the SAP CC system will be found or lost.
 void setHAEventListener(HAEventListener listener)
          Deprecated. Deprecated since version 0.0 of SAP CC

Sets the HA listener dedicated to High Availability events; It will be notified each time the status of an instance of the connected SAP CC system has changed.

 void setNoTimeout(boolean noTimeout)
          Sets that this charging client handles timeout.
 void setSslContext(javax.net.ssl.SSLContext sslContext)
          Sets the SSL context used with secure connections.
 StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, boolean withDetails, ChargeableItem newCi)
          This method is dedicated to the stateless post-rating.
 StatelessPostRateResult statelessPostRate(long reservationUID, StatelessPreRatingContext preRatingContext, int resolution, java.lang.String[] retainedDetails, ChargeableItem newCi)
          Similar to statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details.
 StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, java.lang.String chargeCode, StatelessPreRatingContext preRatingContext, java.util.Date ratingDate, long reservationUID, long postrateDeadline, boolean withDetails, boolean checkDates)
          This method is dedicated to the stateless pre-rating.
 StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent, java.lang.String chargeCode, StatelessPreRatingContext preRatingContext, java.util.Date ratingDate, long reservationUID, long postrateDeadline, java.lang.String[] retainedDetails, boolean checkDates)
          Similar to statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details.
 StatelessRateResult statelessRate(java.lang.String chargeCode, java.util.Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, boolean withDetails, boolean checkDates)
          This main business operation requests the SAP CC system to rate (dynamically determine the price)
 StatelessRateResult statelessRate(java.lang.String chargeCode, java.util.Date ratingDate, StatelessRatingEvent event, StatelessRatingContext context, java.lang.String[] retainedDetails, boolean checkDates)
          Similar to statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details.
 java.lang.Object[] translate(java.lang.String tableCode, int operator, java.util.Date date, java.util.Date referenceDate, java.lang.String[] inValues)
          Translates some values by using a translation table.
 java.lang.Object[] translate(java.lang.String tableCode, int operator, java.util.Date date, java.lang.String[] inValues)
          Translates some values by using an instance of translation table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POST_RATE_CONFIRMATION

public static final int POST_RATE_CONFIRMATION
See Also:
Constant Field Values

POST_RATE_CANCELLATION

public static final int POST_RATE_CANCELLATION
See Also:
Constant Field Values

listeners

protected java.util.List<AsyncRatingServiceClient.RegisterListener> listeners

ratingListListener

protected final com.highdeal.cnd.message.AsyncRatingServiceClient.RLListener ratingListListener

NONE_TRANSACTION

public static final int NONE_TRANSACTION
Constant to return no usage transaction

See Also:
Constant Field Values

MASTER_TRANSACTION

public static final int MASTER_TRANSACTION
Constant to return the master usage transaction

See Also:
Constant Field Values

ALL_TRANSACTION

public static final int ALL_TRANSACTION
Constant to return all the usage transactions

See Also:
Constant Field Values

ALL_TRANSACTION_AND_RECURRING

public static final int ALL_TRANSACTION_AND_RECURRING
Constant to return all the usage transactions and all the recurring/one-shot transactions

See Also:
Constant Field Values

CANCELLED

public static final int CANCELLED
Constant to set up the resolution used when the time to live (TTL) is expired as canceled

See Also:
Constant Field Values

CONFIRMED

public static final int CONFIRMED
Constant to set up the resolution used when the time to live (TTL) is expired as confirmed

See Also:
Constant Field Values
Constructor Detail

StatelessServiceClient

public StatelessServiceClient()
                       throws java.io.IOException
Creates a non-initialized stateless service client in your client application.

One of the methods connect() must then be used to connect it to the SAP CC system.

Throws:
java.io.IOException - if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - The host name of the server
port - The port on which the server waits for request
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              FoundLostRatingListener ratingListener)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
ratingListener - the listener informed when rating is found or lost.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              FoundLostRatingListener ratingListener,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
ratingListener - the listener informed when rating is found or lost.
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.

StatelessServiceClient

public StatelessServiceClient(java.lang.String hostName,
                              int port,
                              java.lang.String bindAddress,
                              FoundLostRatingListener ratingListener,
                              int timeout)
                       throws java.io.IOException
Creates a stateless service client and connect it to a server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - address to bind description.
ratingListener - the listener informed when rating is found or lost.
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance) or if an error occurred reading the currency resources.
Method Detail

connect

public void connect(java.lang.String hostName,
                    int port,
                    java.lang.String bindAddress,
                    FoundLostRatingListener ratingListener,
                    int timeout)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - the host name of the server.
port - the port on which the server waits for request.
bindAddress - the address to bind description.
ratingListener - the FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
timeout - the timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

public void connect(java.lang.String hostName,
                    int port,
                    java.lang.String bindAddress,
                    FoundLostRatingListener ratingListener,
                    int timeout,
                    ServiceClientTuning config)
             throws java.io.IOException
Connect this stateless service client using the round robin with the server.

Parameters:
hostName - The host name of the server
port - The port on which the server waits for request
bindAddress - The address to bind description
ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
config - A tuned configuration for this client, can be null.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

connect

@Deprecated
public void connect(InstanceMap imap,
                               java.lang.String bindAddress,
                               FoundLostRatingListener ratingListener,
                               int timeout,
                               ServiceClientTuning config)
             throws java.io.IOException
Deprecated. use connect(String, int, String, FoundLostRatingListener, int, ServiceClientTuning)

Connects this stateless service client using the round robin with the distant SAP CC system.

Parameters:
imap - The instance map
bindAddress - The address to bind description
ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
config - A tuned configuration for this client, can be null.
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for instance).

statelessRate

public StatelessRateResult statelessRate(java.lang.String chargeCode,
                                         java.util.Date ratingDate,
                                         StatelessRatingEvent event,
                                         StatelessRatingContext context,
                                         boolean withDetails,
                                         boolean checkDates)
                                  throws StatelessRateException,
                                         InvalidItemException,
                                         ForbiddenChargeException,
                                         CommunicationFailureException,
                                         ServerFailureException
This main business operation requests the SAP CC system to rate (dynamically determine the price)

This method should not be used on a StatelessRatingContext which is embeded into a StatelessPreRatingContext. See StatelessPreRatingContext documentation.

Parameters:
chargeCode - The identification code of the master charge configured in SAP CC; This charge includes a particular price plan dedicated to the stateless rating services.
ratingDate - The date of the rating
event - The event to rate or take into account
context - The context of the rating
withDetails - With all or main details in the returned results
checkDates - Check date chronology
Throws:
StatelessRateException - if the rate stateless fails
InvalidItemException - if the item is invalid
ForbiddenChargeException - if the process is forbidden (no access in the price plan of the specified charge, agreement is not valid any longer, the price plan forbids rating or when arguments are not correct)
CommunicationFailureException - if all the rater instances are unavailable in the connected SAP CC system.
ServerFailureException - if a failure occurred on SAP CC Core Server system side

statelessRate

public StatelessRateResult statelessRate(java.lang.String chargeCode,
                                         java.util.Date ratingDate,
                                         StatelessRatingEvent event,
                                         StatelessRatingContext context,
                                         java.lang.String[] retainedDetails,
                                         boolean checkDates)
                                  throws StatelessRateException,
                                         InvalidItemException,
                                         ForbiddenChargeException,
                                         CommunicationFailureException,
                                         ServerFailureException
Similar to statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
chargeCode - The code of the charge
ratingDate - The date of the rating
event - The event to rate
context - The context of the rating
retainedDetails - The list of names of transaction details to retain in resulting transaction(s).
checkDates - Check date chronology
Throws:
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessRate(String, Date, StatelessRatingEvent, StatelessRatingContext, boolean, boolean)

translate

public java.lang.Object[] translate(java.lang.String tableCode,
                                    int operator,
                                    java.util.Date date,
                                    java.lang.String[] inValues)
                             throws DoesNotExistException,
                                    CommunicationFailureException,
                                    ServerFailureException
Translates some values by using an instance of translation table.

Parameters:
tableCode - The code of the translation table which must be used
operator - The comparison operator
date - The version date of the translation table
inValues - An array of String which represents the input values
Returns:
An array of the translated Object
Throws:
DoesNotExistException - thrown if the translation table does not exist
CommunicationFailureException - if all the raters are unavailable
ServerFailureException - if a failure occurred on server side
See Also:
TranslateValueOp

translate

public java.lang.Object[] translate(java.lang.String tableCode,
                                    int operator,
                                    java.util.Date date,
                                    java.util.Date referenceDate,
                                    java.lang.String[] inValues)
                             throws DoesNotExistException,
                                    CommunicationFailureException,
                                    ServerFailureException
Translates some values by using a translation table.

Parameters:
tableCode - The code of the translation table which must be used
operator - The comparison operator
date - The version date of the translation table
referenceDate - The reference date used to check column "start date" and column "end date"
inValues - An array of String which represents the input values
Returns:
An array of the translated Object
Throws:
DoesNotExistException - thrown if the translation table does not exist
CommunicationFailureException - if all the raters are unavailable
ServerFailureException - if a failure occurred on server side
See Also:
TranslateValueOp

statelessPreRate

public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent,
                                               java.lang.String chargeCode,
                                               StatelessPreRatingContext preRatingContext,
                                               java.util.Date ratingDate,
                                               long reservationUID,
                                               long postrateDeadline,
                                               boolean withDetails,
                                               boolean checkDates)
                                        throws StatelessPreRatingException,
                                               StatelessRateException,
                                               InvalidItemException,
                                               ForbiddenChargeException,
                                               CommunicationFailureException,
                                               ServerFailureException
This method is dedicated to the stateless pre-rating.

After a call to this method, the passed StatelessPreRatingContext is not modified. It must be updated (if needed) explicitly calling the StatelessPreRateResult.update(StatelessPreRatingContext) method of the result.

The underlying rating is done using the StatelessRatingContext associated with the charge code in the given StatelessPreRatingContext. If no such StatelessRatingContext exists, it's created (it will be then really added in the StatelessPreRatingContext by the further call to StatelessPreRateResult.update(StatelessPreRatingContext)).

See also StatelessPreRatingContext documentation for limitation and constraints to follow.

Parameters:
ratingEvent - the event to rate.
chargeCode - the code of the charge.
preRatingContext - the context of the stateless pre-rating.
ratingDate - a date based on which the chargeable item is rated.
reservationUID - the unique identifier of the reservation.
postrateDeadline - the delay after which the availability of pending prerating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.
withDetails - with all or main details in results.
checkDates - check date chronology.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.

statelessPreRate

public StatelessPreRateResult statelessPreRate(StatelessRatingEvent ratingEvent,
                                               java.lang.String chargeCode,
                                               StatelessPreRatingContext preRatingContext,
                                               java.util.Date ratingDate,
                                               long reservationUID,
                                               long postrateDeadline,
                                               java.lang.String[] retainedDetails,
                                               boolean checkDates)
                                        throws StatelessPreRatingException,
                                               StatelessRateException,
                                               InvalidItemException,
                                               ForbiddenChargeException,
                                               CommunicationFailureException,
                                               ServerFailureException
Similar to statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
ratingEvent - the event to rate.
chargeCode - the code of the charge.
preRatingContext - the context of the stateless pre-rating.
ratingDate - a date based on which the chargeable item is rated.
reservationUID - the unique identifier of the reservation.
postrateDeadline - the delay after which the availability of pending pre-rating is no longer guarantied in case of post-rate call using the related reservationUID. A value <= 0 means the pre-rating is 'auto-confirmed' and not available for post-rate.
retainedDetails - list of names of transaction details to retain in resulting transaction(s).
checkDates - check date chronology.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessPreRate(StatelessRatingEvent, String, StatelessPreRatingContext, Date, long, long, boolean, boolean)

statelessPostRate

public StatelessPostRateResult statelessPostRate(long reservationUID,
                                                 StatelessPreRatingContext preRatingContext,
                                                 int resolution,
                                                 boolean withDetails,
                                                 ChargeableItem newCi)
                                          throws StatelessPreRatingException,
                                                 StatelessRateException,
                                                 InvalidItemException,
                                                 ForbiddenChargeException,
                                                 CommunicationFailureException,
                                                 ServerFailureException
This method is dedicated to the stateless post-rating.

After a call to this method, the passed StatelessPreRatingContext is not modified. It must be updated (if needed) explicitly calling the StatelessPostRateResult.update(StatelessPreRatingContext) method of the result.

Parameters:
reservationUID - the unique identifier of the reservation.
preRatingContext - the context of the stateless pre-rating.
resolution - the resolution (one of POST_RATE_CONFIRMATION or POST_RATE_CONFIRMATION).
withDetails - with all or main details in results.
newCi - the new chargeable item, in case of confirmation with new CI.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.

statelessPostRate

public StatelessPostRateResult statelessPostRate(long reservationUID,
                                                 StatelessPreRatingContext preRatingContext,
                                                 int resolution,
                                                 java.lang.String[] retainedDetails,
                                                 ChargeableItem newCi)
                                          throws StatelessPreRatingException,
                                                 StatelessRateException,
                                                 InvalidItemException,
                                                 ForbiddenChargeException,
                                                 CommunicationFailureException,
                                                 ServerFailureException
Similar to statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem), but with finest selection of resulting transaction details. Indeed, the retainedDetails parameter enables to list the transaction details to retain in the resulting transaction(s).

When retainedDetails is null, this is equivalent to statelessRate(chargeCode, ratingDate, event, context, false, checkDates). Main details that are present in this case are always present, whatever the content of retainedDetails is.

Parameters:
reservationUID - the unique identifier of the reservation.
preRatingContext - the context of the stateless pre-rating.
resolution - the resolution (one of POST_RATE_CONFIRMATION or POST_RATE_CONFIRMATION).
retainedDetails - list of names of transaction details to retain in resulting transaction(s).
newCi - the new chargeable item, in case of confirmation with new CI.
Throws:
StatelessPreRatingException - when the pre rate stateless fails.
StatelessRateException - when the rate stateless fails.
InvalidItemException - when the item is invalid.
ForbiddenChargeException - when the charge process is forbidden (no access, agreement is not valid any longer, the price plan forbids charging or when arguments are not correct).
CommunicationFailureException - if all the raters are unavailable.
ServerFailureException - if a failure occurred on server side.
See Also:
statelessPostRate(long, StatelessPreRatingContext, int, boolean, ChargeableItem)

currentQueueSize

protected final int currentQueueSize()
                              throws CommunicationFailureException
This method is for internal use only. It returns the size of the message queue of the stateful service server.

Returns:
the size of the queue of the stateful service server.
Throws:
CommunicationFailureException

checkDB

protected final boolean checkDB()
                         throws CommunicationFailureException
This method is for internal use only. It returns a boolean specifying if the server is connected to the database.

Returns:
a boolean specifying if the server is connected to the database.
Throws:
CommunicationFailureException

getRatingTopic

protected final com.highdeal.barbus.Topic getRatingTopic()
Gets the rating topic of this client used to send rating messages.

Returns:
The rating topic of this client

getTopicsToSubscribe

protected final com.highdeal.barbus.Topic[] getTopicsToSubscribe()
Returns an array of topics that client must subscribe to.

Returns:
An array of topics

getDefaultServiceClientTuning

protected final ServiceClientTuning getDefaultServiceClientTuning()
Gets the default service tuning of this client useful to configure connections.

Returns:
The service tuning of this client

getSslContext

public javax.net.ssl.SSLContext getSslContext()
Returns the SSL context used with secure connections.

Specified by:
getSslContext in interface com.highdeal.barbus.ISSLContextProvider
Returns:
The SSL context used with secure connections

setSslContext

public void setSslContext(javax.net.ssl.SSLContext sslContext)
Sets the SSL context used with secure connections.

Parameters:
sslContext - The SSL context used with secure connections

connect

public final void connect(java.lang.String hostname,
                          int hostport)
                   throws java.io.IOException
Connects this charging client to the distant SAP CC Core Server system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.

This method is equivalent to: connect(hostname, hostport, -1, null);.

Parameters:
hostname - The name of the machine that hosts a dispatcher instance of the SAP CC Core Server system
hostport - The communication port on which the server system waits for requests on TCP/IP channel used by the Message TCP/IP technical interface
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running, for example).

connect

public final void connect(java.lang.String hostname,
                          int hostport,
                          int timeout)
                   throws java.io.IOException
Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; A client timeout must be specified.

This method is equivalent to: connect(hostname, hostport, null, timeout);.

Parameters:
hostname - The name of the machine that hosts a dispatcher instance of the SAP CC Core Server system
hostport - The port on which the server waits for requests
timeout - The timeout in milliseconds for each operation request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the operation request.
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running for example)

connect

public final void connect(java.lang.String hostname,
                          int hostport,
                          FoundLostRatingListener ratingListener)
                   throws java.io.IOException
Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape; No client timeout is specified.

Parameters:
hostname - The host name of the server
hostport - The port on which the server waits for request
ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example)

connect

public final void connect(java.lang.String hostname,
                          int hostport,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener)
                   throws java.io.IOException
Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.

Parameters:
hostname - The host name of the server
hostport - The port on which the server waits for request
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost.
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example)
java.lang.IllegalArgumentException - if hostname is null or if the port is out of range

connect

public final void connect(java.lang.String hostname,
                          int port,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener,
                          ServiceClientTuning config)
                   throws java.io.IOException
Connects this message client with the Rating Instances.

First of all, this client contacts the boot instance defined by the arguments hostname and port to get its instance map. Then this client opens connections with all the rating instances defined in the instance map.

Parameters:
hostname - The host name of the server
port - The port on which the server waits for request
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
ratingListener - The FoundLostRatingListener that will be notified each time a rating instance will be found or lost
config - The service tuning configuration
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if server is not running, for example).
java.lang.IllegalArgumentException - if hostname is null or if the port is out of range.

connect

public final void connect(java.lang.String hostname,
                          int port,
                          boolean secure,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener,
                          ServiceClientTuning config)
                   throws java.io.IOException
Connects this message client with the Rating Instances.

First of all, this client contacts the boot instance defined by the arguments hostname and port to get its instance map. Then this client opens connections with all the rating instances defined in the instance map.

Parameters:
hostname - The host name of the server
port - The port on which the server waits for request
secure - true if the connection to the server is secure
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
config - The service tuning configuration
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for example).
java.lang.IllegalArgumentException - if hostname is null or if the port is out if range.

connect

public final void connect(java.lang.String systemName,
                          java.net.InetSocketAddress... bootDispatcherAddresses)
                   throws java.io.IOException
Connects this charging client to the distant SAP CC system that is the Online Charging System (OCS) or Offline Charging System (OFCS) in your SAP system landscape.

If systemName is not null, this charging client looks up for an SAP CC system named systemName during 2 seconds to discover some rating boot instances registered to the distant system. The charging client uses the IPv4 multicast address 234.5.6.7:8910. If some instances have been found, your charging client opens connections with the discovered rater instances. If the provided systemName is null or empty, or if preceding discovery has failed, this client will use bootDispatcherAddresses as a boot rating instance address list to connect to the SAP CC system. Again, the client opens connections with the discovered rater instances.

Prerequisites: At least systemName or bootDispatcherAddresses must be provided.

Parameters:
systemName - The SAP CC system name
bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for example)
java.lang.IllegalArgumentException - if some arguments are badly provided

connect

public final void connect(java.lang.String systemName,
                          int lookupDuration,
                          java.net.InetSocketAddress discoveryAddress,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener,
                          ServiceClientTuning config,
                          java.net.InetSocketAddress... bootDispatcherAddresses)
                   throws java.io.IOException
Connects this message client with the Rating Instances.

If systemName is not null, this client lookups for a rating system named systemName during lookupDuration milliseconds in order to discover some rating boot instances registered to the system. If some instances have been found, this client opens connections with the discovered rating instances. If provided systemName is null or empty, or if preceding discovery has failed, this client will use bootDispatcherAddresses as a boot rating instance address list to connect to the rating system. Again, the client opens connections with the discovered rating instances. At least systemName or bootDispatcherAddresses must be provided.

Parameters:
systemName - The SAP CC system name
lookupDuration - The system discovery lookup duration
discoveryAddress - The lookup discovery address, which must be an IPv4 multicast address
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending request.
ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
config - The service tuning configuration
bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for example).
java.lang.IllegalArgumentException - if some arguments are badly provided

connect

public final void connect(java.lang.String systemName,
                          com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses)
                   throws java.io.IOException
Connects this charging client with the Rating Instances.

If systemName is not null, this client lookups for a rating system named systemName during 2 seconds in order to discover some rating boot instances registered to the system. This client will use IPv4 multicast address 234.5.6.7:8910. If some instances have been found, this charging client opens connections with the discovered rating instances. If provided systemName is null or empty, or if preceding discovery has failed, this client will use bootDispatcherAddresses as a boot rating instance address list to connect to the rating system. Again, the client opens connections with the discovered rating instances.

At least systemName or bootDispatcherAddresses must be provided.

Parameters:
systemName - The SAP CC system name
bootDispatcherAddresses - a backup rating instance boot dispatcher list, provided only if for some reasons
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for example).
java.lang.IllegalArgumentException - if some arguments are badly provided

connect

public final void connect(java.lang.String systemName,
                          int lookupDuration,
                          java.net.InetSocketAddress discoveryAddress,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener,
                          ServiceClientTuning config,
                          com.highdeal.barbus.InstanceAddress... bootDispatcherAddresses)
                   throws java.io.IOException
Connects this charging client with the SAP CC system by using the UDP discovery function.

If systemName is not null, this client looks up for a rating system named systemName during lookupDuration milliseconds in order to discover some rating boot instances registered to the system. If some instances have been found, this client opens connections with the discovered rating instances. If provided systemName is null or empty, or if preceding discovery has failed, this client will use bootDispatcherAddresses as a boot rating instance address list to connect to the rating system. Again, the client opens connections with the discovered rating instances. At least systemName or bootDispatcherAddresses must be provided.

Parameters:
systemName - The Rating system name
lookupDuration - The system discovery lookup duration
discoveryAddress - The lookup discovery address, which must be an IPv4 multicast address
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
ratingListener - The FoundLostRatingListener that will be notified each time a Rating Instance will be found or lost.
config - The service tuning configuration
bootDispatcherAddresses - A backup rating instance boot dispatcher list, provided only if for some reasons
Throws:
java.io.IOException - if the client cannot connect to the server (if server is not running, for example)
java.lang.IllegalArgumentException - if some arguments are badly provided

connect

public final void connect(InstanceMap imap,
                          java.lang.String bindAddress,
                          int timeout,
                          FoundLostRatingListener ratingListener,
                          ServiceClientTuning config)
                   throws java.io.IOException
Connects this charging client with the SAP CC system by using an instance map; A timeout must be specified.

Parameters:
imap - The instance map that describes the SAP CC system to connect to; Cannot be null.
bindAddress - The address to bind to, can be null
timeout - The timeout in milliseconds for each request (or -1 to wait indefinitely). If you use zero and acknowledgments are requested then a CommunicationFailureException will be thrown without sending the request.
ratingListener - The FoundLostRatingListener that will be notified each time a rater instance will be found or lost.
config - The service tuning configuration
Throws:
java.io.IOException - if the client cannot connect to the distant SAP CC system (if the server system is not running, for example).

isNoTimeout

public final boolean isNoTimeout()
Checks if this charging client handles timeout.

Returns:
true if the charging client handles timeout

setNoTimeout

public final void setNoTimeout(boolean noTimeout)
Sets that this charging client handles timeout.

Parameters:
noTimeout - true if your client handles timeout

setClientOpEventListener

public final void setClientOpEventListener(ClientOpEventTopic topic,
                                           ClientOpEventListener listener)
Sets the client operation event listener to the specified topics; It will be notified each time an event corresponding to the registered topics.
  • It is not possible to set null for the default topic.
  • If the listener is null, then the default listener is set (@link ClientOpEventTopic#DEFAULT).

Parameters:
topic - The topic to plug the client operation event listener to
listener - The client operation event listener

getClientOpEventListener

public final ClientOpEventListener getClientOpEventListener(ClientOpEventTopic topic)
Gets the client operation event listener used by the client for the specified topic. If the topic is null the default topic listener is returned ( getClientOpEventListener(ClientOpEventTopic.DEFAULT) ). There is always a default listener for a specific topic.

Parameters:
topic - The topic plugged the client operation event listener
Returns:
not null

getTimeout

public final int getTimeout()
Returns the client communication timeout in milliseconds for each request (or -1 to wait indefinitely).

Returns:
The timeout in milliseconds, or -1 if no timeout has been defined

isConnected

public final boolean isConnected()
Gets the connected connection status.

Returns:
true if the charging client is connected and false otherwise.

close

public final void close()
Closes the connection with the connected SAP CC system; This method allows to release all the resources attached (sockets and buffers) in the charging client.


setBootMode

@Deprecated
public final void setBootMode(BootMode mode)
Deprecated. 

Defines which API will be used to retrieve from the remote instances, the Instance Map needed for the connection. As BootMode.HTTP_BOOT_MODE and BootMode.HTTPS_BOOT_MODE are deprecated, this method is deprecated too.

Parameters:
mode - Is this method is deprecated and to use the Message TCP communication or is HTTP_BOOT_MODE to use the HTTP communication.

getBootMode

public final BootMode getBootMode()
Returns which API is used to retrieve from the remote instances, the Instance Map needed for the connection.

Returns:
MESSAGE_BOOT_MODE because BootMode.HTTP_BOOT_MODE and BootMode.HTTPS_BOOT_MODE are deprecated.

isValid

protected final boolean isValid(ChargeableItem ci,
                                InvalidItemListener listener)
Checks whether the specified chargeable item is valid or not; A call back listener has to be given to handle errors.

Parameters:
ci - The chargeable item to check
listener - The call back listener
Returns:
true if chargeable item is valid, false otherwise

asyncSend

protected final void asyncSend(com.highdeal.cnd.message.common.CollectorMessage m,
                               int maxTimeout,
                               ResponseHandlerWrapper handler,
                               com.highdeal.util.IEventListener eventListener)
FOR INTERNAL USE ONLY - Sends asynchronously the message m; When a response or an exception is received by the client application, it must back the response handler.

Parameters:
m - The message that must be sent asynchronously
maxTimeout - The maximum timeout before getting a communication failure
handler - The call back handler

beginSession

protected final void beginSession()
FOR INTERNAL USE ONLY - Begins a client session for this thread; All the messages are stored in memory and are not sent until the method sendSession() is called. If there is already a session, the session is sent by a call of the method sendSession() and a new session is created.


sendSession

protected final void sendSession()
FOR INTERNAL USE ONLY - All the messages between the last call of the method beginSession() and now for this thread are sent. The memory session is closed.


getEventListenerFromListener

protected com.highdeal.util.IEventListener getEventListenerFromListener(java.lang.Object listener)

setClusterName

@Deprecated
protected final void setClusterName(java.lang.String name)
Deprecated. Deprecated since version 2.0 of SAP CC

Sets the system name from the cluster name.

Parameters:
name - The system name

getClusterName

@Deprecated
protected final java.lang.String getClusterName()
Deprecated. Deprecated since version 2.0 of SAP CC Gets the system name.

Returns:
The system name

setHAEventListener

@Deprecated
public final void setHAEventListener(HAEventListener listener)
Deprecated. Deprecated since version 0.0 of SAP CC

Sets the HA listener dedicated to High Availability events; It will be notified each time the status of an instance of the connected SAP CC system has changed.

Parameters:
listener - The listener for High Availability events

setFoundLostRatingListener

protected final void setFoundLostRatingListener(FoundLostRatingListener ratingListener)
Sets the rating listener that will be notified each time a rater instance of the SAP CC system will be found or lost.

Parameters:
ratingListener - The rating listener
See Also:
getFoundLostRatingListener()

getFoundLostRatingListener

protected final FoundLostRatingListener getFoundLostRatingListener()
Returns the rating listener previously set.

Returns:
The rating listener previously set
See Also:
setFoundLostRatingListener(FoundLostRatingListener)

getClient

@Deprecated
protected final com.highdeal.barbus.RoundRobinClient getClient()
Deprecated. Deprecated since version 2.0 of SAP CC and should not be called anymore

Gets the inner client.

Returns:
inner client

notifyHeartBeat

protected final void notifyHeartBeat(com.highdeal.barbus.Client client)

register

protected final void register(com.highdeal.hmi.IConnectable connectable)

addListener

protected void addListener(AsyncRatingServiceClient.RegisterListener listener)

getSensorsManager

protected com.highdeal.cnd.message.sensor.SensorsManager getSensorsManager()

Document Published: October 2015 (SAP CC 4.0 SP10 and Later)