Class CustomMeteringService


  • public class CustomMeteringService
    extends org.wso2.carbon.core.AbstractAdmin
    CustomMeteringService class defines methods to get recorded duration, to check whether usage entries exists, persist usage, retrieve usage and add usage.
    • Constructor Detail

      • CustomMeteringService

        public CustomMeteringService()
    • Method Detail

      • getRecordedDurations

        public String[] getRecordedDurations​(String measurement)
                                      throws Exception
        method to get recorded durations
        Parameters:
        measurement - the measurement name
        Returns:
        duration array
        Throws:
        Exception
      • isUsageEntryExists

        public boolean isUsageEntryExists​(String duration,
                                          String measurement)
                                   throws Exception
        method to check whether usage entry exists or not
        Parameters:
        duration - duration
        measurement - measurement name
        Returns:
        true if usage entry exist
        Throws:
        Exception
      • persistUsage

        public void persistUsage​(String duration,
                                 String measurement,
                                 String value)
                          throws Exception
        method to persist usage
        Parameters:
        duration -
        measurement - measurement name
        value - value of measurement
        Throws:
        Exception
      • retrieveUsage

        public String retrieveUsage​(String duration,
                                    String measurement)
                             throws UsageException
        method to retrieve usage
        Parameters:
        duration -
        measurement - measurement name
        Returns:
        usage value
        Throws:
        UsageException
      • addUsage

        public long addUsage​(String userName,
                             String duration,
                             String measurement,
                             long value)
                      throws Exception
        method to add usage entries
        Parameters:
        userName - user name
        duration - duration of the measurement
        measurement - measurement name
        value - usage value
        Returns:
        usage value
        Throws:
        Exception