Package com.google.api.ads.dfp.lib

Examples of com.google.api.ads.dfp.lib.ServiceAccountantManager


    // Get DfpUser from "~/dfp.properties".
    DfpUser user = new DfpUser();

    // Create the service accountant manager to automatically create
    // service accountants on first call and to not retain services.
    ServiceAccountantManager serviceAccountantManager = ServiceAccountantManager.getInstance();

    // Get the CompanyService.
    CompanyServiceInterface companyService = user.getService(DfpService.V201306.COMPANY_SERVICE);

    // Get the UserService.
    UserServiceInterface userService = user.getService(DfpService.V201306.USER_SERVICE);

    // Get the InventoryService.
    InventoryServiceInterface inventoryService =
        user.getService(DfpService.V201306.INVENTORY_SERVICE);

    // Turn on retain service here to just retain the creative service.
    serviceAccountantManager.setRetainServices(true);

    // Get the CreativeService.
    CreativeServiceInterface creativeService = user.getService(DfpService.V201306.CREATIVE_SERVICE);

    // Since autoCreateAccountant is set to true in the service accountant
    // manager, all service accountants will be created during this method call.
    performOperations(companyService, userService, inventoryService, creativeService);

    // Get the CompanyService ServiceAccountant.
    ServiceAccountant companyServiceAccountant =
        serviceAccountantManager.getServiceAccountant(companyService);

    // Get the UserService ServiceAccountant.
    ServiceAccountant userServiceAccountant =
        serviceAccountantManager.getServiceAccountant(userService);

    // Get the InventoryService ServiceAccountant.
    ServiceAccountant inventoryServiceAccountant =
        serviceAccountantManager.getServiceAccountant(inventoryService);

    // Get the CreativeService ServiceAccountant.
    ServiceAccountant creativeServiceAccountant =
        serviceAccountantManager.getServiceAccountant(creativeService);

    // Retrieve the total response time for each service object we used.
    System.out.println("CampaignService used "
        + companyServiceAccountant.getTotalResponseTime() + " millisecond(s).");
    System.out.println("UserService used "
        + userServiceAccountant.getTotalResponseTime() + " millisecond(s).");
    System.out.println("InventoryService used "
        + inventoryServiceAccountant.getTotalResponseTime() + " millisecond(s).");
    System.out.println("CreativeService used "
        + creativeServiceAccountant.getTotalResponseTime() + " millisecond(s).");

    // Retrieve the total amounts using the ServiceAccountantManager.
    System.out.println("There were " + ServiceAccountantManager.getInstance().getTotalResponseTime()
        + " millisecond(s) used all together.");
    System.out.println("There were "
        + ServiceAccountantManager.getInstance().getTotalOperationCount()
        + " operations performed all together.");

    // Get all services that were retained.
    Stub[] retainedServices = serviceAccountantManager.getRetainedServicesForUser(user);

    // Recall retained service to use again if needed.
    creativeService = (CreativeServiceInterface) retainedServices[0];

    // Retrieve the last response time for the creativeService object.
    System.out.println("The last call to CreativeService took "
        + serviceAccountantManager.getServiceAccountant(creativeService).getLastResponseTime()
        + " milliseconds.");

    // Remove retained service so that it can be garbage collected.
    serviceAccountantManager.removeService(creativeService);

    if (serviceAccountantManager.getRetainedServicesForUser(user).length == 0) {
      System.out.println("All services were cleared for garabage collection.");
    }

    // Remove all remaining retained services for the user, which should be
    // none at this point.
    serviceAccountantManager.removeAllServicesForUser(user);
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.lib.ServiceAccountantManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.