public abstract class AdsService

  1. Object
  2. ConnectionRequest
  3. AdsService

ImplementsIOProgressListener

Known subtypesInnerActive

Deprecated. this legacy banner ad service targets ad networks that no longer exist and predates consent management. Use the modern pluggable advertising API in AdManager instead.
This is an abstract Ads Service. Each supported Ad network needs to extend this Service and to implement the initService method

Constructors

protected AdsService()Empty constructor

Methods

public static AdsService createAdsService()Creates a new AdsService to be used by the Ads Component
public static void setAdsProvider(Class provider)Sets the provider of the ads service.
public void initialize(Ads adsComponent)Initialize the ads service.
public abstract void initService(Ads adsComponent)init the service requests.
public String getCurrentAd()Returns the last requested ad
public void requestAd()Schedule this service on the Network thread and executes the request
protected void readResponse(InputStream input) throws IOExceptionCallback for the server response with the input stream from the server.
public void onAdDisplay(HTMLComponent cmp)This a callback method to inform to the service the Ad is displayed
protected void handleErrorResponseCode(int code, String message)Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)
protected void handleRuntimeException(RuntimeException err)Handles an exception thrown when performing a network operation
protected void handleException(Exception err)Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.

Inherited nested types

Inherited fields

Inherited methods

From ConnectionRequest

getDefaultCacheMode, setDefaultCacheMode, isReadResponseForErrorsDefault, setReadResponseForErrorsDefault, isHandleErrorCodesInGlobalErrorHandler, setHandleErrorCodesInGlobalErrorHandler, getCookieHeader, setCookieHeader, isCookiesEnabledDefault, setCookiesEnabledDefault, isDefaultFollowRedirects, setDefaultFollowRedirects, isReadTimeoutSupported, purgeCacheDirectory, getDefaultUserAgent, setDefaultUserAgent, setUseNativeCookieStore, isNativeCookieSharingSupported, fetchJSON, fetchJSONAsync, getCacheMode, setCacheMode, isCheckSSLCertificates, setCheckSSLCertificates, isInsecure, setInsecure, getResponseData, getHttpMethod, setHttpMethod, addRequestHeader, removeRequestHeader, removeRequestHeaderIfUnchanged, checkSSLCertificates, getReadTimeout, setReadTimeout, initConnection, getCachedData, purgeCache, cacheUnmodified, cookieReceived, cookieSent, initCookieHeader, getResponseCode, getResposeCode, shouldConvertPostToGetOnRedirect, readHeaders, readErrorCodeHeaders, getHeader, getHeaders, getHeaderFieldNames, getYield, shouldAutoCloseResponse, handleIOException, canGetSSLCertificates, getSSLCertificates, retry, onRedirect, postResponse, createRequestURL, buildRequestBody, shouldWriteUTFAsGetBytes, kill, shouldStop, isPausable, pause, resume, isPost, setPost, addArgument, removeArgument, removeAllArguments, addArgumentNoEncoding, addArgumentNoEncoding, addArgumentNoEncodingArray, addArgument, addArgumentArray, addArgument, addArguments, getContentType, setContentType, isWriteRequest, setWriteRequest, isReadRequest, setReadRequest, isPaused, setPaused, isKilled, setKilled, getPriority, setPriority, getUserAgent, setUserAgent, isFollowRedirects, setFollowRedirects, getTimeout, setTimeout, getContentLength, ioStreamUpdate, getUrl, setUrl, addResponseListener, removeResponseListener, addResponseCodeListener, addExceptionListener, removeResponseCodeListener, removeExceptionListener, hasResponseListeners, fireResponseListener, isDuplicateSupported, setDuplicateSupported, hashCode, equals, validate, getDisposeOnCompletion, setDisposeOnCompletion, getShowOnInit, setShowOnInit, getSilentRetryCount, setSilentRetryCount, isFailSilently, setFailSilently, isReadResponseForErrors, setReadResponseForErrors, getResponseContentType, isRedirecting, getDestinationFile, setDestinationFile, getDestinationStorage, setDestinationStorage, isCookiesEnabled, setCookiesEnabled, setChunkedStreamingMode, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToStorage, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, downloadImageToFileSystem, getRequestBody, setRequestBody, setRequestBody, getRequestBodyData, getResponseErrorMessage

Constructor details

AdsService

protected AdsService()
Empty constructor

Method details

createAdsService

public static AdsService createAdsService()
Creates a new AdsService to be used by the Ads Component

setAdsProvider

public static void setAdsProvider(Class provider)
Sets the provider of the ads service.

Parameters

provider Class
this class needs to extend the AdsService class

initialize

public void initialize(Ads adsComponent)
Initialize the ads service.

initService

public abstract void initService(Ads adsComponent)
init the service requests.

getCurrentAd

public String getCurrentAd()
Returns the last requested ad

requestAd

public void requestAd()
Schedule this service on the Network thread and executes the request

readResponse

protected void readResponse(InputStream input) throws IOException
Callback for the server response with the input stream from the server. This method is invoked on the network thread

Parameters

input InputStream
the input stream containing the response

Throws

IOException
when a read input occurs

onAdDisplay

public void onAdDisplay(HTMLComponent cmp)
This a callback method to inform to the service the Ad is displayed

handleErrorResponseCode

protected void handleErrorResponseCode(int code, String message)
Handles a server response code that is not 200 and not a redirect (unless redirect handling is disabled)

Parameters

code int
the response code from the server
message String
the response message from the server

handleRuntimeException

protected void handleRuntimeException(RuntimeException err)
Handles an exception thrown when performing a network operation

Parameters

err RuntimeException
the exception thrown

handleException

protected void handleException(Exception err)
Handles an exception thrown when performing a network operation, the default implementation shows a retry dialog.

Parameters

err Exception
the exception thrown