com.google.api.ads.common.lib.factory
Class FactoryConfiguration.Builder

java.lang.Object
  extended by com.google.api.ads.common.lib.factory.FactoryConfiguration.Builder
All Implemented Interfaces:
Builder<FactoryConfiguration>
Enclosing class:
FactoryConfiguration

public static class FactoryConfiguration.Builder
extends Object
implements Builder<FactoryConfiguration>

Builder for FactoryConfiguration.


Field Summary
 
Fields inherited from interface com.google.api.ads.common.lib.utils.Builder
DEFAULT_CONFIGURATION_FILENAME
 
Constructor Summary
FactoryConfiguration.Builder()
          Constructor.
 
Method Summary
 FactoryConfiguration build()
          Builds the FactoryConfiguration.
 FactoryConfiguration buildDefault()
          Tries to construct a FactoryConfiguration from file.
 FactoryConfiguration.Builder from(org.apache.commons.configuration.Configuration config)
          Reads properties from the provided Configuration object.

Known properties: api.ads.soapClientHandlerModule
 FactoryConfiguration.Builder fromFile()
          Loads credentials from "ads.properties" file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath
 FactoryConfiguration.Builder fromFile(File path)
          Populates this builder from a properties file from a specified path.
 FactoryConfiguration.Builder fromFile(String path)
          Populates this builder from a properties file from a specified path.
 FactoryConfiguration.Builder fromFile(URL path)
          Populates this builder from a properties file from a specified path.
 FactoryConfiguration.Builder withAdWordsSoapModule(ProductFrameworkModule soapModuleClass)
          Specifies which SOAP client handler module class to use for AdWords.
 FactoryConfiguration.Builder withDfaSoapModule(ProductFrameworkModule soapModuleClass)
          Specifies which SOAP client handler module class to use for DFA.
 FactoryConfiguration.Builder withDfpSoapModule(ProductFrameworkModule soapModuleClass)
          Specifies which SOAP client handler module class to use for DFP.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FactoryConfiguration.Builder

public FactoryConfiguration.Builder()
Constructor.

Method Detail

fromFile

public FactoryConfiguration.Builder fromFile()
                                      throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Loads credentials from "ads.properties" file in one of the following locations according to the following order: in the current directory, in the user home directory, in the classpath

Specified by:
fromFile in interface Builder<FactoryConfiguration>
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public FactoryConfiguration.Builder fromFile(String path)
                                      throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<FactoryConfiguration>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public FactoryConfiguration.Builder fromFile(File path)
                                      throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path.

Specified by:
fromFile in interface Builder<FactoryConfiguration>
Parameters:
path - the path to load properties from
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

fromFile

public FactoryConfiguration.Builder fromFile(URL path)
                                      throws com.google.api.ads.common.lib.conf.ConfigurationLoadException
Description copied from interface: Builder
Populates this builder from a properties file from a specified path. If not absolute, will look in user home directory, the current classpath and the system classpath.

Specified by:
fromFile in interface Builder<FactoryConfiguration>
Parameters:
path - the path to try first as a resource, then as a file
Returns:
Builder populated with properties.
Throws:
com.google.api.ads.common.lib.conf.ConfigurationLoadException - if the configuration could not be loaded.

from

public FactoryConfiguration.Builder from(org.apache.commons.configuration.Configuration config)
Reads properties from the provided Configuration object.

Known properties:

Specified by:
from in interface Builder<FactoryConfiguration>
Parameters:
config - the factory configuration
Returns:
Builder populated from the Configuration

withAdWordsSoapModule

public FactoryConfiguration.Builder withAdWordsSoapModule(ProductFrameworkModule soapModuleClass)
Specifies which SOAP client handler module class to use for AdWords.


withDfaSoapModule

public FactoryConfiguration.Builder withDfaSoapModule(ProductFrameworkModule soapModuleClass)
Specifies which SOAP client handler module class to use for DFA.


withDfpSoapModule

public FactoryConfiguration.Builder withDfpSoapModule(ProductFrameworkModule soapModuleClass)
Specifies which SOAP client handler module class to use for DFP.


buildDefault

@Nullable
public FactoryConfiguration buildDefault()
Tries to construct a FactoryConfiguration from file.

Returns:
Built FactoryConfiguration, or null if properties file doesn't exist.
Throws:
IllegalStateException - if we encounter an unexpected ConfigurationLoadException or we fail validation.

build

public FactoryConfiguration build()
                           throws ValidationException
Builds the FactoryConfiguration.

Specified by:
build in interface Builder<FactoryConfiguration>
Returns:
the built FactoryConfiguration
Throws:
ValidationException - if the FactoryConfiguration did not validate


Copyright © 2012. All Rights Reserved.