public abstract class AbstractKaaClient extends Object implements GenericKaaClient
Abstract class that holds general elements of Kaa library.
This class creates and binds Kaa library modules. Public access to each
module is performed using KaaClient
interface.
Class contains abstract methods
createHttpClient(String, PrivateKey, PublicKey, PublicKey)
and AbstractKaaClient#createPersistentStorage()
which are used to
reference the platform-specific implementation of http client and Kaa's state
persistent storage.
Http client (AbstractHttpClient
) is used to provide basic
communication with Bootstrap and Operation servers using HTTP protocol.
KaaClient
,
AbstractHttpClient
,
PersistentStorage
Modifier and Type | Field and Description |
---|---|
protected ConfigurationManager |
configurationManager |
protected KaaClientPlatformContext |
context |
protected AbstractLogCollector |
logCollector |
protected KaaClientStateListener |
stateListener |
Modifier and Type | Method and Description |
---|---|
boolean |
addConfigurationListener(ConfigurationListener listener)
Register configuration update listener
|
void |
addNotificationListener(NotificationListener listener)
Add listener to receive all notifications (both for mandatory and
optional topics).
|
void |
addNotificationListener(String topicId,
NotificationListener listener)
Add listener to receive notifications relating to the specified topic.
|
void |
addTopicListListener(NotificationTopicListListener listener)
Add listener for notification topics' list updates.
|
void |
attachEndpoint(EndpointAccessToken endpointAccessToken,
OnAttachEndpointOperationCallback resultListener)
Updates with new endpoint attach request
OnAttachEndpointOperationCallback is populated with EndpointKeyHash of an
attached endpoint. |
void |
attachUser(String userVerifierToken,
String userExternalId,
String userAccessToken,
UserAttachCallback callback)
Creates user attach request using specified verifier.
|
void |
attachUser(String userExternalId,
String userAccessToken,
UserAttachCallback callback)
Creates user attach request using default verifier.
|
protected BootstrapManager |
buildBootstrapManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected BootstrapTransport |
buildBootstrapTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected KaaInternalChannelManager |
buildChannelManager(BootstrapManager bootstrapManager,
Map<TransportProtocolId,List<TransportConnectionInfo>> bootstrapServers) |
protected ResyncConfigurationManager |
buildConfigurationManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext,
ExecutorContext executorContext) |
protected ConfigurationTransport |
buildConfigurationTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected DefaultEventManager |
buildEventManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected EventTransport |
buildEventTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected FailoverManager |
buildFailoverManager(KaaChannelManager channelManager) |
protected DefaultLogCollector |
buildLogCollector(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected LogTransport |
buildLogTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected DefaultNotificationManager |
buildNotificationManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected NotificationTransport |
buildNotificationTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected ProfileManager |
buildProfileManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected ProfileTransport |
buildProfileTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected RedirectionTransport |
buildRedirectionTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected DefaultEndpointRegistrationManager |
buildRegistrationManager(KaaClientProperties properties,
KaaClientState kaaClientState,
TransportContext transportContext) |
protected TransportContext |
buildTransportContext(KaaClientProperties properties,
KaaClientState kaaClientState) |
protected DefaultUserTransport |
buildUserTransport(KaaClientProperties properties,
KaaClientState kaaClientState) |
AbstractHttpClient |
createHttpClient(String url,
PrivateKey privateKey,
PublicKey publicKey,
PublicKey remotePublicKey) |
void |
detachEndpoint(EndpointKeyHash endpointKeyHash,
OnDetachEndpointOperationCallback resultListener)
Updates with new endpoint detach request
|
void |
findEventListeners(List<String> eventFQNs,
FindEventListenersCallback listener)
Submits an event listeners resolution request
|
KaaChannelManager |
getChannelManager()
Retrieves Kaa channel manager
|
PrivateKey |
getClientPrivateKey()
Retrieves the client's private key.
|
PublicKey |
getClientPublicKey()
Retrieves the client's public key.
|
String |
getEndpointAccessToken()
Retrieve an access token for a current endpoint
|
String |
getEndpointKeyHash()
Retrieves endpoint public key hash.
|
EventFamilyFactory |
getEventFamilyFactory()
Retrieves Kaa event family factory.
|
List<org.kaaproject.kaa.common.endpoint.gen.Topic> |
getTopics()
Retrieve a list of available notification topics.
|
protected void |
initializeChannels(KaaInternalChannelManager channelManager,
TransportContext transportContext) |
boolean |
isAttachedToUser()
Checks if current endpoint is attached to user.
|
void |
pause()
Pauses Kaa's workflow.
|
String |
refreshEndpointAccessToken()
Generate new access token for a current endpoint
|
boolean |
removeConfigurationListener(ConfigurationListener listener)
Removes configuration update listener
|
void |
removeNotificationListener(NotificationListener listener)
Remove listener receiving all notifications (both for mandatory and
optional topics).
|
void |
removeNotificationListener(String topicId,
NotificationListener listener)
Remove listener receiving notifications for the specified topic.
|
void |
removeTopicListListener(NotificationTopicListListener listener)
Remove listener of notification topics' list updates.
|
void |
resume()
Resumes Kaa's workflow.
|
void |
setAttachedListener(AttachEndpointToUserCallback listener)
Sets callback for notifications when current endpoint is attached to user
|
void |
setConfigurationStorage(ConfigurationStorage storage)
Sets the configuration storage that will be used to persist configuration.
|
void |
setDetachedListener(DetachEndpointFromUserCallback listener)
Sets callback for notifications when current endpoint is detached from user
|
void |
setEndpointAccessToken(String token)
Set new access token for a current endpoint
|
void |
setLogStorage(LogStorage storage)
Set user implementation of a log storage.
|
void |
setLogUploadStrategy(LogUploadStrategy strategy)
Set user implementation of a log upload strategy.
|
void |
setProfileContainer(ProfileContainer container)
Sets profile container implemented by the user.
|
void |
start()
Starts Kaa's workflow.
|
void |
stop()
Stops Kaa's workflow.
|
void |
subscribeToTopic(String topicId)
Subscribe to notifications relating to the specified optional topic.
|
void |
subscribeToTopic(String topicId,
boolean forceSync)
Subscribe to notifications relating to the specified optional topic.
|
void |
subscribeToTopics(List<String> topicIds)
Subscribe to notifications relating to the specified list of optional
topics.
|
void |
subscribeToTopics(List<String> topicIds,
boolean forceSync)
Subscribe to notifications relating to the specified list of optional
topics.
|
void |
syncTopicsList()
Force sync of pending subscription changes with server.
|
void |
unsubscribeFromTopic(String topicId)
Unsubscribe from notifications relating to the specified optional topic.
|
void |
unsubscribeFromTopic(String topicId,
boolean forceSync)
Unsubscribe from notifications relating to the specified optional topic.
|
void |
unsubscribeFromTopics(List<String> topicIds)
Unsubscribe from notifications relating to the specified list of optional
topics.
|
void |
unsubscribeFromTopics(List<String> topicIds,
boolean forceSync)
Unsubscribe from notifications relating to the specified list of optional
topics.
|
void |
updateProfile()
Sync of updated profile with server
|
protected final ConfigurationManager configurationManager
protected final AbstractLogCollector logCollector
protected final KaaClientPlatformContext context
protected final KaaClientStateListener stateListener
public void start()
GenericKaaClient
Starts Kaa's workflow.
start
in interface GenericKaaClient
start()
public void stop()
GenericKaaClient
stop
in interface GenericKaaClient
stop()
public void pause()
GenericKaaClient
pause
in interface GenericKaaClient
public void resume()
GenericKaaClient
resume
in interface GenericKaaClient
public void setProfileContainer(ProfileContainer container)
GenericKaaClient
setProfileContainer
in interface GenericKaaClient
container
- User-defined containerProfileContainer
public void updateProfile()
GenericKaaClient
updateProfile
in interface GenericKaaClient
public void setConfigurationStorage(ConfigurationStorage storage)
GenericKaaClient
setConfigurationStorage
in interface GenericKaaClient
storage
- to use for configuration persistencepublic boolean addConfigurationListener(ConfigurationListener listener)
GenericKaaClient
addConfigurationListener
in interface GenericKaaClient
listener
- to registerpublic boolean removeConfigurationListener(ConfigurationListener listener)
GenericKaaClient
removeConfigurationListener
in interface GenericKaaClient
listener
- to registerpublic List<org.kaaproject.kaa.common.endpoint.gen.Topic> getTopics()
GenericKaaClient
Retrieve a list of available notification topics.
getTopics
in interface GenericKaaClient
public void addTopicListListener(NotificationTopicListListener listener)
GenericKaaClient
Add listener for notification topics' list updates.
addTopicListListener
in interface GenericKaaClient
listener
- the listener to receive updates.NotificationTopicListListener
public void removeTopicListListener(NotificationTopicListListener listener)
GenericKaaClient
Remove listener of notification topics' list updates.
removeTopicListListener
in interface GenericKaaClient
listener
- listener the listener which is no longer needs updates.NotificationTopicListListener
public void addNotificationListener(NotificationListener listener)
GenericKaaClient
Add listener to receive all notifications (both for mandatory and optional topics).
addNotificationListener
in interface GenericKaaClient
listener
- Listener to receive notificationsNotificationListener
public void addNotificationListener(String topicId, NotificationListener listener) throws UnavailableTopicException
GenericKaaClient
Add listener to receive notifications relating to the specified topic.
Listener(s) for optional topics may be added/removed irrespective to whether subscription was already or not.
addNotificationListener
in interface GenericKaaClient
topicId
- Id of topic (both mandatory and optional).listener
- Listener to receive notifications.UnavailableTopicException
- Throw if unknown topic id is provided.NotificationListener
public void removeNotificationListener(NotificationListener listener)
GenericKaaClient
Remove listener receiving all notifications (both for mandatory and optional topics).
removeNotificationListener
in interface GenericKaaClient
listener
- Listener to receive notificationsNotificationListener
public void removeNotificationListener(String topicId, NotificationListener listener) throws UnavailableTopicException
GenericKaaClient
Remove listener receiving notifications for the specified topic.
Listener(s) for optional topics may be added/removed irrespective to whether subscription was already or not.
removeNotificationListener
in interface GenericKaaClient
topicId
- Id of topic (both mandatory and optional).listener
- Listener to receive notifications.UnavailableTopicException
- Throw if unknown topic id is provided.NotificationListener
public void subscribeToTopic(String topicId) throws UnavailableTopicException
GenericKaaClient
Subscribe to notifications relating to the specified optional topic.
subscribeToTopic
in interface GenericKaaClient
topicId
- Id of a optional topic.UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.public void subscribeToTopic(String topicId, boolean forceSync) throws UnavailableTopicException
GenericKaaClient
Subscribe to notifications relating to the specified optional topic.
subscribeToTopic
in interface GenericKaaClient
topicId
- Id of a optional topic.forceSync
- Define whether current subscription update should be accepted
immediately (see #sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.GenericKaaClient.syncTopicsList()
public void subscribeToTopics(List<String> topicIds) throws UnavailableTopicException
GenericKaaClient
Subscribe to notifications relating to the specified list of optional topics.
subscribeToTopics
in interface GenericKaaClient
topicIds
- List of optional topic id.UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.public void subscribeToTopics(List<String> topicIds, boolean forceSync) throws UnavailableTopicException
GenericKaaClient
Subscribe to notifications relating to the specified list of optional topics.
subscribeToTopics
in interface GenericKaaClient
topicIds
- List of optional topic id.forceSync
- Define whether current subscription update should be accepted
immediately (see #sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.GenericKaaClient.syncTopicsList()
public void unsubscribeFromTopic(String topicId) throws UnavailableTopicException
GenericKaaClient
Unsubscribe from notifications relating to the specified optional topic.
All previously added listeners will be removed automatically.
unsubscribeFromTopic
in interface GenericKaaClient
topicId
- Id of a optional topic.UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.public void unsubscribeFromTopic(String topicId, boolean forceSync) throws UnavailableTopicException
GenericKaaClient
Unsubscribe from notifications relating to the specified optional topic.
All previously added listeners will be removed automatically.
unsubscribeFromTopic
in interface GenericKaaClient
topicId
- Id of a optional topic.forceSync
- Define whether current subscription update should be accepted
immediately (see #sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.GenericKaaClient.syncTopicsList()
public void unsubscribeFromTopics(List<String> topicIds) throws UnavailableTopicException
GenericKaaClient
Unsubscribe from notifications relating to the specified list of optional topics.
All previously added listeners will be removed automatically.
unsubscribeFromTopics
in interface GenericKaaClient
topicIds
- List of optional topic id.UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.public void unsubscribeFromTopics(List<String> topicIds, boolean forceSync) throws UnavailableTopicException
GenericKaaClient
Unsubscribe from notifications relating to the specified list of optional topics.
All previously added listeners will be removed automatically.
unsubscribeFromTopics
in interface GenericKaaClient
topicIds
- List of optional topic id.forceSync
- Define whether current subscription update should be accepted
immediately (see #sync()
).UnavailableTopicException
- Throw if unknown topic id is provided or topic isn't
optional.GenericKaaClient.syncTopicsList()
public void syncTopicsList()
GenericKaaClient
Force sync of pending subscription changes with server.
Should be used after all GenericKaaClient.subscribeToTopic(String, boolean)
,
GenericKaaClient.subscribeToTopics(List, boolean)
,
GenericKaaClient.unsubscribeFromTopic(String, boolean)
,
GenericKaaClient.unsubscribeFromTopics(List, boolean)
calls with parameter
forceSync
set to false
.
Use it as a convenient way to make different consequent changes in the optional subscription:
{ // Make subscription changes kaaClient.subscribeOnTopics(Arrays.asList("optional_topic1", "optional_topic2", "optional_topic3"), false); kaaClient.unsubscribeFromTopic("optional_topic4", false); // Add listeners for topics here // Commit changes kaaClient.syncTopicsList(); }
syncTopicsList
in interface GenericKaaClient
public void setLogStorage(LogStorage storage)
GenericKaaClient
setLogStorage
in interface GenericKaaClient
storage
- User-defined log storage objectpublic void setLogUploadStrategy(LogUploadStrategy strategy)
GenericKaaClient
setLogUploadStrategy
in interface GenericKaaClient
strategy
- User-defined log upload strategy object.public EventFamilyFactory getEventFamilyFactory()
GenericKaaClient
getEventFamilyFactory
in interface GenericKaaClient
EventFamilyFactory
object.public void findEventListeners(List<String> eventFQNs, FindEventListenersCallback listener)
GenericKaaClient
findEventListeners
in interface GenericKaaClient
eventFQNs
- List of event class FQNs which have to be supported by endpoint.listener
- Result listener FindEventListenersCallback
}public KaaChannelManager getChannelManager()
GenericKaaClient
getChannelManager
in interface GenericKaaClient
KaaChannelManager
objectpublic PublicKey getClientPublicKey()
GenericKaaClient
Retrieves the client's public key.
Required in user implementation of an operation data channel. Public key hash (SHA-1) is used by servers as identification number to uniquely identify each connected endpoint.
getClientPublicKey
in interface GenericKaaClient
public String getEndpointKeyHash()
GenericKaaClient
Retrieves endpoint public key hash.
Required in EndpointRegistrationManager
implementation to react
on detach response from Operations server.
getEndpointKeyHash
in interface GenericKaaClient
public PrivateKey getClientPrivateKey()
GenericKaaClient
Retrieves the client's private key.
Required in user implementation of an operation data channel. Private key is used by encryption schema between endpoint and servers.
getClientPrivateKey
in interface GenericKaaClient
public void setEndpointAccessToken(String token)
GenericKaaClient
setEndpointAccessToken
in interface GenericKaaClient
public String refreshEndpointAccessToken()
GenericKaaClient
refreshEndpointAccessToken
in interface GenericKaaClient
public String getEndpointAccessToken()
GenericKaaClient
getEndpointAccessToken
in interface GenericKaaClient
public void attachEndpoint(EndpointAccessToken endpointAccessToken, OnAttachEndpointOperationCallback resultListener)
GenericKaaClient
OnAttachEndpointOperationCallback
is populated with EndpointKeyHash
of an
attached endpoint.attachEndpoint
in interface GenericKaaClient
endpointAccessToken
- Access token of the attaching endpointresultListener
- Listener to notify about result of the endpoint attachingEndpointAccessToken
,
OnAttachEndpointOperationCallback
public void detachEndpoint(EndpointKeyHash endpointKeyHash, OnDetachEndpointOperationCallback resultListener)
GenericKaaClient
detachEndpoint
in interface GenericKaaClient
endpointKeyHash
- Key hash of the detaching endpointresultListener
- Listener to notify about result of the enpoint attachingEndpointKeyHash
,
OnDetachEndpointOperationCallback
public void attachUser(String userExternalId, String userAccessToken, UserAttachCallback callback)
GenericKaaClient
attachUser
in interface GenericKaaClient
callback
- called when authentication result receivedUserAttachCallback
public void attachUser(String userVerifierToken, String userExternalId, String userAccessToken, UserAttachCallback callback)
GenericKaaClient
attachUser
in interface GenericKaaClient
callback
- called when authentication result receivedUserAttachCallback
public boolean isAttachedToUser()
GenericKaaClient
isAttachedToUser
in interface GenericKaaClient
public void setAttachedListener(AttachEndpointToUserCallback listener)
GenericKaaClient
setAttachedListener
in interface GenericKaaClient
AttachEndpointToUserCallback
public void setDetachedListener(DetachEndpointFromUserCallback listener)
GenericKaaClient
setDetachedListener
in interface GenericKaaClient
DetachEndpointFromUserCallback
protected TransportContext buildTransportContext(KaaClientProperties properties, KaaClientState kaaClientState)
protected KaaInternalChannelManager buildChannelManager(BootstrapManager bootstrapManager, Map<TransportProtocolId,List<TransportConnectionInfo>> bootstrapServers)
protected void initializeChannels(KaaInternalChannelManager channelManager, TransportContext transportContext)
protected FailoverManager buildFailoverManager(KaaChannelManager channelManager)
protected ResyncConfigurationManager buildConfigurationManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext, ExecutorContext executorContext)
protected DefaultLogCollector buildLogCollector(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
protected DefaultEndpointRegistrationManager buildRegistrationManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
protected DefaultEventManager buildEventManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
protected DefaultNotificationManager buildNotificationManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
protected ProfileManager buildProfileManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
protected BootstrapManager buildBootstrapManager(KaaClientProperties properties, KaaClientState kaaClientState, TransportContext transportContext)
public AbstractHttpClient createHttpClient(String url, PrivateKey privateKey, PublicKey publicKey, PublicKey remotePublicKey)
protected BootstrapTransport buildBootstrapTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected ProfileTransport buildProfileTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected ConfigurationTransport buildConfigurationTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected NotificationTransport buildNotificationTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected DefaultUserTransport buildUserTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected EventTransport buildEventTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected LogTransport buildLogTransport(KaaClientProperties properties, KaaClientState kaaClientState)
protected RedirectionTransport buildRedirectionTransport(KaaClientProperties properties, KaaClientState kaaClientState)
Copyright © 2015. All rights reserved.