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

public abstract class AbstractSampleProgram extends Object
Abstract class that sample programs should extend
  • 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

      public UsageRequestBuilderFactory 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

      public QueryRequestBuilderFactory getQueryRequestBuilderFactory()
      Get the Query RequestBuilderFactory
      Returns:
      the Query RequestBuilderFactory
    • getManagementRequestBuilderFactory

      public ManagementRequestBuilderFactory getManagementRequestBuilderFactory()
      Get the Management RequestBuilderFactory
      Returns:
      the Management RequestBuilderFactory
    • getPolicyRequestBuilderFactory

      public PolicyRequestBuilderFactory getPolicyRequestBuilderFactory()
      Get the PolicyRequestBuilderFactory
      Returns:
      the PolicyRequestBuilderFactory
    • getBatchRequestService

      public BatchRequestService getBatchRequestService()
      Get the BatchRequestService
      Returns:
      the BatchRequestService
    • getContext

      public org.springframework.context.support.ClassPathXmlApplicationContext getContext()
      Get the Spring context
      Returns:
      the Spring context
    • getServiceSpecRepository

      public ServiceSpecRepository getServiceSpecRepository()
      Get the ServiceSpecRepository, needed for building requests
      Returns:
      ServiceSpecRepository, needed for building requests
    • getResponsesReceived

      public List<Response> 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 send
      resubmit - to resubmit or not
      delay - delay im ms to wait between 2 asynchronous requests
      Throws:
      MessagesUsageException - if something goes wrong
      MessagesException - something wrong with the message
      SystemHealthException - unknown exception
      InterruptedException - process is interrupted
      ExecutionException - something wrong with the execution of the request
      TimeoutException - process takes too long
      UserNotFoundException
    • 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 message
      SystemHealthException - other exception
      UserNotFoundException
    • sendRequest

      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 send
      resubmit - to resubmit or not
      Returns:
      the first response coming back after the request was sent
      Throws:
      MessagesException - something wrong with the message
      SystemHealthException - unknown exception
      InterruptedException - process is interrupted
      ExecutionException - something wrong with the execution of the request
      TimeoutException - process takes too long
      UserNotFoundException
    • 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 request
      resubmit - flag
      Returns:
      update response
      Throws:
      MessagesException - something wrong with the message
      InterruptedException - process is interrupted
      ExecutionException - something wrong with the execution of the request
      TimeoutException - process takes too long
      UserNotFoundException
    • 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 requests
      resubmit - resubmit flag
      Returns:
      list of update responses
      Throws:
      MessagesException - if envelope creation goes wrong
      InterruptedException - process is interrupted
      ExecutionException - something wrong with the execution of the request
      TimeoutException - process takes too long
      UserNotFoundException
    • runSample

      protected abstract void runSample() throws Exception
      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

      public static String getStackTrace(Throwable aThrowable)
      Stack trace formatting
      Parameters:
      aThrowable - Exception
      Returns:
      the stack trace as a String