A - the service provider's API typepublic abstract class AbstractConnection<A> extends Object implements Connection<A>
Connection implementations.
Defines the state and behavior that is common across connection implementations and independent of any specific authorization protocol.| Constructor and Description |
|---|
AbstractConnection(ApiAdapter<A> apiAdapter)
Creates a new connection.
|
AbstractConnection(ConnectionData data,
ApiAdapter<A> apiAdapter)
Creates a connection from the data provider.
|
| Modifier and Type | Method and Description |
|---|---|
abstract ConnectionData |
createData()
Creates a data transfer object that can be used to persist the state of this connection.
|
boolean |
equals(Object o) |
UserProfile |
fetchUserProfile()
Fetch a normalized model of the user's profile on the provider system.
|
abstract A |
getApi()
A Java binding to the service provider's native API.
|
String |
getDisplayName()
A display name or label for this connection.
|
String |
getImageUrl()
A link to a image that visualizes this connection.
|
ConnectionKey |
getKey()
The key identifying this connection.
|
protected Object |
getMonitor()
Provides subclasses with access to a monitor that can be used to synchronize access to this connection.
|
String |
getProfileUrl()
The public URL of the connected user's profile at the provider's site.
|
boolean |
hasExpired()
Returns true if this connection has expired.
|
int |
hashCode() |
protected void |
initKey(String providerId,
String providerUserId)
Hook that should be called by subclasses to initialize the key property when establishing a new connection.
|
void |
refresh()
Refresh this connection.
|
void |
sync()
Sync's this connection object with the current state of the external user's profile.
|
boolean |
test()
Test this connection.
|
void |
updateStatus(String message)
Update the user's status on the provider's system.
|
public AbstractConnection(ApiAdapter<A> apiAdapter)
apiAdapter - the Service API adapterpublic AbstractConnection(ConnectionData data, ApiAdapter<A> apiAdapter)
data - the connection dataapiAdapter - the Service API adapterpublic ConnectionKey getKey()
ConnectiongetKey in interface Connection<A>public String getDisplayName()
ConnectiongetDisplayName in interface Connection<A>Connection.sync()public String getProfileUrl()
ConnectiongetProfileUrl in interface Connection<A>Connection.sync()public String getImageUrl()
ConnectiongetImageUrl in interface Connection<A>Connection.sync()public boolean test()
Connectionapi will fail.
Used to proactively test authorization credentials such as an API access token before invoking the service API.test in interface Connection<A>public boolean hasExpired()
ConnectionConnection.test() return false, and any service API invocations fail.
If expired, you may call Connection.refresh() to renew the connection.
Not supported by all Connection implementations; always returns false if not supported.hasExpired in interface Connection<A>public void refresh()
ConnectionConnection.hasExpired() returns false.
Not supported by all connection implementations; if not supported, this method is a no-op.refresh in interface Connection<A>public UserProfile fetchUserProfile()
ConnectionfetchUserProfile in interface Connection<A>public void updateStatus(String message)
ConnectionupdateStatus in interface Connection<A>message - the status messagepublic void sync()
Connectionsync in interface Connection<A>public abstract A getApi()
ConnectiongetApi in interface Connection<A>public abstract ConnectionData createData()
ConnectioncreateData in interface Connection<A>protected void initKey(String providerId, String providerUserId)
providerId - the providerIdproviderUserId - the providerUserIdprotected Object getMonitor()