com.google.api.ads.common.lib
Class AdsModule<C extends AdsServiceClient<S,D>,D extends AdsServiceDescriptor,S extends AdsSession>

java.lang.Object
  extended by com.google.inject.AbstractModule
      extended by com.google.api.ads.common.lib.AdsModule<C,D,S>
Type Parameters:
C - the subclass of AdsServiceClient
D - the subclass of AdsServiceDescriptor
S - the subclass of AdsSession
All Implemented Interfaces:
com.google.inject.Module
Direct Known Subclasses:
AdWordsModule, DfaModule, DfpModule

public class AdsModule<C extends AdsServiceClient<S,D>,D extends AdsServiceDescriptor,S extends AdsSession>
extends com.google.inject.AbstractModule

Guice module for common bindings.

Author:
Adam Rogal

Constructor Summary
AdsModule()
          Default constructor.
 
Method Summary
protected  void configure()
          Configure common Guice bindings.
protected  void configureAuthentication()
           
protected
<H extends AdsServiceClientFactoryHelper<C,S,D>>
void
configureFactories(com.google.inject.TypeLiteral adsServiceClientFactoryTypeLiteral, com.google.inject.TypeLiteral adsServiceDescriptorFactoryTypeLiteral, com.google.inject.TypeLiteral adsServiceClientTypeLiteral, com.google.inject.TypeLiteral adsServiceDescriptorTypeLiteral, Class<H> factoryHelperClass, Class<?> factoryClass)
          Configures the factories.
protected  void configureLogging(String loggerPrefix)
          Configures the loggers given the prefix.
protected  void configureSoap(Class<?> moduleFromFactoryConfiguration, Class<? extends Annotation> moduleAnnotationClass)
          Configures which SOAP framework to use.
 
Methods inherited from class com.google.inject.AbstractModule
addError, addError, addError, bind, bind, bind, bindConstant, binder, bindInterceptor, bindListener, bindScope, configure, convertToTypes, currentStage, getMembersInjector, getMembersInjector, getProvider, getProvider, install, requestInjection, requestStaticInjection, requireBinding, requireBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdsModule

public AdsModule()
Default constructor.

Method Detail

configure

protected void configure()
Configure common Guice bindings.

Specified by:
configure in class com.google.inject.AbstractModule

configureAuthentication

protected void configureAuthentication()

configureSoap

protected void configureSoap(Class<?> moduleFromFactoryConfiguration,
                             Class<? extends Annotation> moduleAnnotationClass)
Configures which SOAP framework to use. In order for this method to succeed without throwing an IllegalStateException, at least one of two possible states must exist: 1) A moduleFromFactoryConfiguration module was specified and can be instantiated. 2) Exactly one module on the classpath is annotated with moduleAnnotationClass and can be instantiated.

Parameters:
moduleFromFactoryConfiguration - the Class of the SOAP module to use which was specified in the user's properties file. If no class was specified, this is expected to be null.
moduleAnnotationClass - the Annotation used to mark classes that are valid modules to use with this product. If no moduleFromFactoryConfiguration was specified, the classpath will be searched for classes with this annotation.
Throws:
IllegalStateException - if no SOAP module is available or more than one SOAP module is available.

configureLogging

protected void configureLogging(String loggerPrefix)
Configures the loggers given the prefix.

Parameters:
loggerPrefix - the logger prefix

configureFactories

protected <H extends AdsServiceClientFactoryHelper<C,S,D>> void configureFactories(com.google.inject.TypeLiteral adsServiceClientFactoryTypeLiteral,
                                                                                   com.google.inject.TypeLiteral adsServiceDescriptorFactoryTypeLiteral,
                                                                                   com.google.inject.TypeLiteral adsServiceClientTypeLiteral,
                                                                                   com.google.inject.TypeLiteral adsServiceDescriptorTypeLiteral,
                                                                                   Class<H> factoryHelperClass,
                                                                                   Class<?> factoryClass)
Configures the factories.

Type Parameters:
H - the subclass of AdsServiceClientFactoryHelper
Parameters:
adsServiceClientFactoryTypeLiteral - the factory type literal which contains a FactoryModule.AdsServiceClientFactoryInterface
adsServiceDescriptorFactoryTypeLiteral - the factory type literal which contains a FactoryModule.AdsServiceDescriptorFactoryInterface
adsServiceClientTypeLiteral - the ads service client literal which contains a AdsServiceClient
adsServiceDescriptorTypeLiteral - the ads service descriptor literal which contains a AdsServiceDescriptor
factoryHelperClass - the factory helper class
factoryClass - the factory class


Copyright © 2012. All Rights Reserved.