Polar Help

PolarApiAccessor Class

Introduction

The PolarApiAccessor class provides a way to access the Polar API. It serves as a factory for obtaining instances of the PolarApi interface.

Methods

access

public static synchronized WeakReference<PolarApi> access() throws PolarNotLoadedException;

Description:

This static method retrieves an instance of the PolarApi interface, wrapped in a WeakReference. If Polar is not loaded, a PolarNotLoadedException is thrown.

The method is synchronized; calling it concurrently from several threads causes contention. Call it once and keep the returned reference rather than calling it on every access.

Returns:

A WeakReference to the PolarApi instance. WeakReference#get() returns null if the API object has been collected, for example after Polar was unloaded.

Throws:

PolarNotLoadedException - If Polar is not loaded in the current environment. See Exceptions.

Example

try { PolarApi api = PolarApiAccessor.access().get(); if (api == null) { // Polar was unloaded return; } // use api } catch (PolarNotLoadedException e) { // Polar is not loaded }