Class AbstractSampleProgram
java.lang.Object
oracle.communication.brm.charging.sdk.AbstractSampleProgram
- Direct Known Subclasses:
SampleAccountingOnOff
,SampleAuthenticationQuery
,SampleBalanceQueryRequestLauncher
,SampleDataSession
,SampleDebitRefundSession
,SampleExternalTopUpRequestLauncher
,SampleGenericSameSession
,SampleGenericSession
,SampleGenericSessionWithUsageDirection
,SampleGprsSession
,SampleIncrementalUsageRequestLauncher
,SamplePolicySessionRequestLauncher
,SamplePriceEnquiry
,SampleQueryLauncher
,SampleSpendingLimitReportRequestLauncher
,SampleStartUpdateAccountingRequestLauncher
,SampleSubscribeNotificationRequestLauncher
,SampleSubscriberPreferenceUpdateRequestLauncher
,SampleUserDataRequestLauncher
,SampleVoiceSession
Abstract class that sample programs should extend
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclass
AbstractSampleProgram.SampleResponseConsumer<T extends Response<?>>
Response consumer for the requests send by the AbstractSampleProgram -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateDefaultPayLoad
(UsageRequestBuilder usageRequestBuilder, String version, String productType, String eventType, Usage requestType, String calledIdStr) Creates default payload for usage request based on required blocks.Get the BatchRequestServiceorg.springframework.context.support.ClassPathXmlApplicationContext
Get the Spring contextoracle.communication.brm.charging.messages.update.ExternalTopUpUpdateRequestBuilderFactory
Get the ExternalTopUpUpdateRequestBuilderFactorystatic org.apache.logging.log4j.Logger
Get the Management RequestBuilderFactoryint
Get the number of responses received so farGet the PolicyRequestBuilderFactoryGet the Query RequestBuilderFactoryGet the responses received so farGet the ServiceSpecRepository, needed for building requestsstatic String
getStackTrace
(Throwable aThrowable) Stack trace formattingoracle.communication.brm.charging.statemanager.StateManager
Get the StateManageroracle.communication.brm.charging.messages.update.UpdateRequestBuilderFactory
Get the Update RequestBuilderFactoryGet the Usage RequestBuilderFactoryvoid
Clear the list of responses receivedprotected final void
run()
Main run method that should be called in the main of all sample programsprotected abstract void
To be implemented by each sample program for specific scenariovoid
sendAsynchronousRequest
(Request request, boolean resubmit) Send a single requestsendRequest
(Request request, boolean resubmit) Send a single request, wait for a response and return this response.protected <T extends Request>
voidsendRequests
(List<T> requests, boolean resubmit, long delay) Sends an array of requests, with a delay between them, waits for the responses to arriveoracle.communication.brm.charging.messages.update.UpdateResponse
sendUpdateRequest
(Request request, boolean resubmit) Send an update request synchronouslyList
<oracle.communication.brm.charging.messages.update.UpdateResponse> sendUpdateRequests
(List<oracle.communication.brm.charging.messages.update.UpdateRequest> requests, boolean resubmit) Submit a batch of update requests synchronouslyvoid
waitForResponses
(int nResponses) Wait until nResponses have been received
-
Constructor Details
-
AbstractSampleProgram
public AbstractSampleProgram()Constructor takes care of retrieving spring beans
-
-
Method Details
-
getStateManager
public oracle.communication.brm.charging.statemanager.StateManager getStateManager()Get the StateManager- Returns:
- the StateManager
-
getUsageRequestBuilderFactory
Get the Usage RequestBuilderFactory- Returns:
- the Usage RequestBuilderFactory
-
getUpdateRequestBuilderFactory
public oracle.communication.brm.charging.messages.update.UpdateRequestBuilderFactory getUpdateRequestBuilderFactory()Get the Update RequestBuilderFactory- Returns:
- the Update RequestBuilderFactory
-
getExternalTopUpUpdateRequestBuilderFactory
public oracle.communication.brm.charging.messages.update.ExternalTopUpUpdateRequestBuilderFactory getExternalTopUpUpdateRequestBuilderFactory()Get the ExternalTopUpUpdateRequestBuilderFactory- Returns:
- the ExternalTopUpUpdateRequestBuilderFactory
-
getQueryRequestBuilderFactory
Get the Query RequestBuilderFactory- Returns:
- the Query RequestBuilderFactory
-
getManagementRequestBuilderFactory
Get the Management RequestBuilderFactory- Returns:
- the Management RequestBuilderFactory
-
getPolicyRequestBuilderFactory
Get the PolicyRequestBuilderFactory- Returns:
- the PolicyRequestBuilderFactory
-
getBatchRequestService
Get the BatchRequestService- Returns:
- the BatchRequestService
-
getContext
public org.springframework.context.support.ClassPathXmlApplicationContext getContext()Get the Spring context- Returns:
- the Spring context
-
getServiceSpecRepository
Get the ServiceSpecRepository, needed for building requests- Returns:
- ServiceSpecRepository, needed for building requests
-
getResponsesReceived
Get the responses received so far- Returns:
- the responses received so far
-
getNResponsesReceived
public int getNResponsesReceived()Get the number of responses received so far- Returns:
- the number of responses received so far
-
resetResponsesReceived
public void resetResponsesReceived()Clear the list of responses received -
sendRequests
protected <T extends Request> void sendRequests(List<T> requests, boolean resubmit, long delay) throws MessagesException, SystemHealthException, InterruptedException, ExecutionException, TimeoutException, UserNotFoundException Sends an array of requests, with a delay between them, waits for the responses to arrive- Type Parameters:
T
- request of a specific type- Parameters:
requests
- array of requests to sendresubmit
- to resubmit or notdelay
- delay im ms to wait between 2 asynchronous requests- Throws:
MessagesUsageException
- if something goes wrongMessagesException
- something wrong with the messageSystemHealthException
- unknown exceptionInterruptedException
- process is interruptedExecutionException
- something wrong with the execution of the requestTimeoutException
- process takes too longUserNotFoundException
-
waitForResponses
public void waitForResponses(int nResponses) Wait until nResponses have been received- Parameters:
nResponses
- number of responses that must be received before the method returns
-
sendAsynchronousRequest
public void sendAsynchronousRequest(Request request, boolean resubmit) throws MessagesException, SystemHealthException, UserNotFoundException Send a single request- Parameters:
request
- request to send (should be of type UsageRequest, UpdateRequest or QueryRequest)resubmit
- to resubmit or not- Throws:
MessagesException
- something wrong with the messageSystemHealthException
- other exceptionUserNotFoundException
-
sendRequest
public Response sendRequest(Request request, boolean resubmit) throws MessagesException, SystemHealthException, InterruptedException, ExecutionException, TimeoutException, UserNotFoundException Send a single request, wait for a response and return this response. This resets the list of responses received so far.- Parameters:
request
- request to sendresubmit
- to resubmit or not- Returns:
- the first response coming back after the request was sent
- Throws:
MessagesException
- something wrong with the messageSystemHealthException
- unknown exceptionInterruptedException
- process is interruptedExecutionException
- something wrong with the execution of the requestTimeoutException
- process takes too longUserNotFoundException
-
sendUpdateRequest
public oracle.communication.brm.charging.messages.update.UpdateResponse sendUpdateRequest(Request request, boolean resubmit) throws MessagesException, InterruptedException, ExecutionException, TimeoutException, UserNotFoundException Send an update request synchronously- Parameters:
request
- update requestresubmit
- flag- Returns:
- update response
- Throws:
MessagesException
- something wrong with the messageInterruptedException
- process is interruptedExecutionException
- something wrong with the execution of the requestTimeoutException
- process takes too longUserNotFoundException
-
sendUpdateRequests
public List<oracle.communication.brm.charging.messages.update.UpdateResponse> sendUpdateRequests(List<oracle.communication.brm.charging.messages.update.UpdateRequest> requests, boolean resubmit) throws MessagesException, InterruptedException, ExecutionException, TimeoutException, UserNotFoundException Submit a batch of update requests synchronously- Parameters:
requests
- update requestsresubmit
- resubmit flag- Returns:
- list of update responses
- Throws:
MessagesException
- if envelope creation goes wrongInterruptedException
- process is interruptedExecutionException
- something wrong with the execution of the requestTimeoutException
- process takes too longUserNotFoundException
-
runSample
To be implemented by each sample program for specific scenario- Throws:
Exception
- if something goes wrong in the scenario!
-
run
protected final void run()Main run method that should be called in the main of all sample programs -
getLogger
public static org.apache.logging.log4j.Logger getLogger() -
createDefaultPayLoad
public Payload createDefaultPayLoad(UsageRequestBuilder usageRequestBuilder, String version, String productType, String eventType, Usage requestType, String calledIdStr) Creates default payload for usage request based on required blocks.- Parameters:
usageRequestBuilder
- , String version, String productType, UsageRequestBuilder- Returns:
- payload instance
-
getStackTrace
Stack trace formatting- Parameters:
aThrowable
- Exception- Returns:
- the stack trace as a String
-