Skip to content

Commit

Permalink
KAA-1279: Fixed about 50 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sashadidukh committed Sep 29, 2016
1 parent 649df63 commit 2c88cb9
Show file tree
Hide file tree
Showing 16 changed files with 246 additions and 176 deletions.

Large diffs are not rendered by default.

Expand Up @@ -100,7 +100,7 @@ public interface GenericKaaClient {
void setProfileContainer(ProfileContainer container); void setProfileContainer(ProfileContainer container);


/** /**
* Sync of updated profile with server * Sync of updated profile with server.
*/ */
void updateProfile(); void updateProfile();


Expand All @@ -112,15 +112,15 @@ public interface GenericKaaClient {
void setConfigurationStorage(ConfigurationStorage storage); void setConfigurationStorage(ConfigurationStorage storage);


/** /**
* Register configuration update listener * Register configuration update listener.
* *
* @param listener to register * @param listener to register
* @return true if listener is registered, false if already registered * @return true if listener is registered, false if already registered
*/ */
boolean addConfigurationListener(ConfigurationListener listener); boolean addConfigurationListener(ConfigurationListener listener);


/** /**
* Removes configuration update listener * Removes configuration update listener.
* *
* @param listener to register * @param listener to register
* @return true if listener is removed, false if not found * @return true if listener is removed, false if not found
Expand Down Expand Up @@ -182,7 +182,8 @@ public interface GenericKaaClient {
* @throws UnavailableTopicException Throw if unknown topic id is provided. * @throws UnavailableTopicException Throw if unknown topic id is provided.
* @see NotificationListener * @see NotificationListener
*/ */
void addNotificationListener(Long topicId, NotificationListener listener) throws UnavailableTopicException; void addNotificationListener(Long topicId, NotificationListener listener)
throws UnavailableTopicException;


/** /**
* <p> * <p>
Expand Down Expand Up @@ -210,7 +211,8 @@ public interface GenericKaaClient {
* @throws UnavailableTopicException Throw if unknown topic id is provided. * @throws UnavailableTopicException Throw if unknown topic id is provided.
* @see NotificationListener * @see NotificationListener
*/ */
void removeNotificationListener(Long topicId, NotificationListener listener) throws UnavailableTopicException; void removeNotificationListener(Long topicId, NotificationListener listener)
throws UnavailableTopicException;


/** /**
* <p> * <p>
Expand Down Expand Up @@ -326,7 +328,8 @@ public interface GenericKaaClient {
* optional. * optional.
* @see #syncTopicsList() * @see #syncTopicsList()
*/ */
void unsubscribeFromTopics(List<Long> topicIds, boolean forceSync) throws UnavailableTopicException; void unsubscribeFromTopics(List<Long> topicIds, boolean forceSync)
throws UnavailableTopicException;


/** /**
* <p> Force sync of pending subscription changes with server. </p> * <p> Force sync of pending subscription changes with server. </p>
Expand Down Expand Up @@ -377,15 +380,15 @@ public interface GenericKaaClient {
EventFamilyFactory getEventFamilyFactory(); EventFamilyFactory getEventFamilyFactory();


/** /**
* Submits an event listeners resolution request * Submits an event listeners resolution request.
* *
* @param eventFQNs List of event class FQNs which have to be supported by endpoint. * @param eventFqns List of event class FQNs which have to be supported by endpoint.
* @param listener Result listener {@link FindEventListenersCallback}} * @param listener Result listener {@link FindEventListenersCallback}}
*/ */
void findEventListeners(List<String> eventFQNs, FindEventListenersCallback listener); void findEventListeners(List<String> eventFqns, FindEventListenersCallback listener);


/** /**
* Retrieves Kaa channel manager * Retrieves Kaa channel manager.
* *
* @return {@link KaaChannelManager} object * @return {@link KaaChannelManager} object
*/ */
Expand Down Expand Up @@ -435,28 +438,29 @@ public interface GenericKaaClient {
String getEndpointKeyHash(); String getEndpointKeyHash();


/** /**
* Generate new access token for a current endpoint * Generate new access token for a current endpoint.
* *
* @return String containing new endpoint access token * @return String containing new endpoint access token
*/ */
String refreshEndpointAccessToken(); String refreshEndpointAccessToken();


/** /**
* Retrieve an access token for a current endpoint * Retrieve an access token for a current endpoint.
* *
* @return String containing current endpoint access token * @return String containing current endpoint access token
*/ */
String getEndpointAccessToken(); String getEndpointAccessToken();


/** /**
* Set new access token for a current endpoint * Set new access token for a current endpoint.
* *
* @param token the token * @param token the token
*/ */
void setEndpointAccessToken(String token); void setEndpointAccessToken(String token);


/** /**
* Updates with new endpoint attach request<br> <br> {@link org.kaaproject.kaa.client.event.registration.OnAttachEndpointOperationCallback} * Updates with new endpoint attach request<br> <br> {@link
* org.kaaproject.kaa.client.event.registration.OnAttachEndpointOperationCallback}
* is populated with {@link org.kaaproject.kaa.client.event.EndpointKeyHash} of an attached * is populated with {@link org.kaaproject.kaa.client.event.EndpointKeyHash} of an attached
* endpoint. * endpoint.
* *
Expand All @@ -465,7 +469,8 @@ public interface GenericKaaClient {
* @see org.kaaproject.kaa.client.event.EndpointAccessToken * @see org.kaaproject.kaa.client.event.EndpointAccessToken
* @see org.kaaproject.kaa.client.event.registration.OnAttachEndpointOperationCallback * @see org.kaaproject.kaa.client.event.registration.OnAttachEndpointOperationCallback
*/ */
void attachEndpoint(EndpointAccessToken endpointAccessToken, OnAttachEndpointOperationCallback resultListener); void attachEndpoint(EndpointAccessToken endpointAccessToken,
OnAttachEndpointOperationCallback resultListener);


/** /**
* Updates with new endpoint detach request * Updates with new endpoint detach request
Expand All @@ -475,7 +480,8 @@ public interface GenericKaaClient {
* @see org.kaaproject.kaa.client.event.EndpointKeyHash * @see org.kaaproject.kaa.client.event.EndpointKeyHash
* @see OnDetachEndpointOperationCallback * @see OnDetachEndpointOperationCallback
*/ */
void detachEndpoint(EndpointKeyHash endpointKeyHash, OnDetachEndpointOperationCallback resultListener); void detachEndpoint(EndpointKeyHash endpointKeyHash,
OnDetachEndpointOperationCallback resultListener);


/** /**
* Creates user attach request using default verifier. Default verifier is selected during SDK * Creates user attach request using default verifier. Default verifier is selected during SDK
Expand All @@ -498,7 +504,8 @@ public interface GenericKaaClient {
* @param callback called when authentication result received * @param callback called when authentication result received
* @see UserAttachCallback * @see UserAttachCallback
*/ */
void attachUser(String userVerifierToken, String userExternalId, String userAccessToken, UserAttachCallback callback); void attachUser(String userVerifierToken, String userExternalId, String userAccessToken,
UserAttachCallback callback);


/** /**
* Checks if current endpoint is attached to user. * Checks if current endpoint is attached to user.
Expand Down
Expand Up @@ -26,62 +26,63 @@
import java.security.PublicKey; import java.security.PublicKey;


/** /**
* Represents platform specific context for Kaa client initialization * Represents platform specific context for Kaa client initialization.
* *
* @author Andrew Shvayka * @author Andrew Shvayka
*/ */
public interface KaaClientPlatformContext { public interface KaaClientPlatformContext {


/** /**
* Returns platform SDK properties * Returns platform SDK properties.
* *
* @return client SDK properties * @return client SDK properties
*/ */
KaaClientProperties getProperties(); KaaClientProperties getProperties();


/** /**
* Returns platform dependent implementation of http client * Returns platform dependent implementation of http client.
* *
* @param url the url * @param url the url
* @param privateKey the private key * @param privateKey the private key
* @param publicKey the public key * @param publicKey the public key
* @param remotePublicKey the remote public key * @param remotePublicKey the remote public key
* @return platform dependent implementation of http client * @return platform dependent implementation of http client
*/ */
AbstractHttpClient createHttpClient(String url, PrivateKey privateKey, PublicKey publicKey, PublicKey remotePublicKey); AbstractHttpClient createHttpClient(String url, PrivateKey privateKey, PublicKey publicKey,
PublicKey remotePublicKey);


/** /**
* Returns platform dependent implementation of {@link PersistentStorage * Returns platform dependent implementation of {@link PersistentStorage
* persistent storage} * persistent storage}.
* *
* @return implementation of {@link PersistentStorage persistent storage} * @return implementation of {@link PersistentStorage persistent storage}
*/ */
PersistentStorage createPersistentStorage(); PersistentStorage createPersistentStorage();


/** /**
* Returns platform dependent implementation of {@link Base64 base64} * Returns platform dependent implementation of {@link Base64 base64}
* algorithm * algorithm.
* *
* @return implementation of {@link Base64 base64} algorithm * @return implementation of {@link Base64 base64} algorithm
*/ */
Base64 getBase64(); Base64 getBase64();


/** /**
* Returns platform dependent implementation of {@link ConnectivityChecker} * Returns platform dependent implementation of {@link ConnectivityChecker}.
* *
* @return implementation of {@link ConnectivityChecker} * @return implementation of {@link ConnectivityChecker}
*/ */
ConnectivityChecker createConnectivityChecker(); ConnectivityChecker createConnectivityChecker();


/** /**
* Returns SDK thread execution context * Returns SDK thread execution context.
* *
* @return SDK thread execution context * @return SDK thread execution context
*/ */
ExecutorContext getExecutorContext(); ExecutorContext getExecutorContext();


/** /**
* Determines if client state should be checked * Determines if client state should be checked.
* *
* @return true if client state should be checked * @return true if client state should be checked
*/ */
Expand Down
Expand Up @@ -57,8 +57,8 @@ protected void shutdownExecutor(ExecutorService executor) {
LOG.debug("Waiting for executor service to shutdown for {} {}", getTimeout(), getTimeunit()); LOG.debug("Waiting for executor service to shutdown for {} {}", getTimeout(), getTimeunit());
try { try {
executor.awaitTermination(getTimeout(), getTimeunit()); executor.awaitTermination(getTimeout(), getTimeunit());
} catch (InterruptedException e) { } catch (InterruptedException ex) {
LOG.warn("Interrupted while waiting for executor to shutdown", e); LOG.warn("Interrupted while waiting for executor to shutdown", ex);
} }
} }
} }
Expand Up @@ -34,25 +34,25 @@
public interface ExecutorContext { public interface ExecutorContext {


/** /**
* Initialize executors * Initialize executors.
*/ */
void init(); void init();


/** /**
* Stops executors * Stops executors.
*/ */
void stop(); void stop();


/** /**
* Executes lifecycle events/commands of Kaa client * Executes lifecycle events/commands of Kaa client.
* *
* @return the lifecycle executor * @return the lifecycle executor
*/ */
ExecutorService getLifeCycleExecutor(); ExecutorService getLifeCycleExecutor();


/** /**
* Executes user API calls to SDK client. For example, serializing of log * Executes user API calls to SDK client. For example, serializing of log
* records before submit to transport * records before submit to transport.
* *
* @return the API executor * @return the API executor
*/ */
Expand All @@ -66,7 +66,7 @@ public interface ExecutorContext {
ExecutorService getCallbackExecutor(); ExecutorService getCallbackExecutor();


/** /**
* Executes scheduled tasks(periodically if needed) as log upload * Executes scheduled tasks(periodically if needed) as log upload.
* *
* @return the scheduled executor * @return the scheduled executor
*/ */
Expand Down
Expand Up @@ -25,7 +25,7 @@


/** /**
* Simple implementation of {@link ExecutorContext executorContext} that uses * Simple implementation of {@link ExecutorContext executorContext} that uses
* one thread per each executor * one thread per each executor.
* *
* @author Andrew Shvayka * @author Andrew Shvayka
*/ */
Expand All @@ -48,7 +48,8 @@ public SimpleExecutorContext() {
this(SINGLE_THREAD, SINGLE_THREAD, SINGLE_THREAD, SINGLE_THREAD); this(SINGLE_THREAD, SINGLE_THREAD, SINGLE_THREAD, SINGLE_THREAD);
} }


public SimpleExecutorContext(int lifeCycleThreadCount, int apiThreadCount, int callbackThreadCount, int scheduledThreadCount) { public SimpleExecutorContext(int lifeCycleThreadCount, int apiThreadCount,
int callbackThreadCount, int scheduledThreadCount) {
super(); super();
this.lifeCycleThreadCount = lifeCycleThreadCount; this.lifeCycleThreadCount = lifeCycleThreadCount;
this.apiThreadCount = apiThreadCount; this.apiThreadCount = apiThreadCount;
Expand Down Expand Up @@ -94,19 +95,19 @@ public ScheduledExecutorService getScheduledExecutor() {
return scheduledExecutor; return scheduledExecutor;
} }


private ExecutorService createExecutor(int nThreads) { private ExecutorService createExecutor(int threadsNumber) {
if (nThreads == 1) { if (threadsNumber == 1) {
return Executors.newSingleThreadExecutor(); return Executors.newSingleThreadExecutor();
} else { } else {
return Executors.newFixedThreadPool(nThreads); return Executors.newFixedThreadPool(threadsNumber);
} }
} }


private ScheduledExecutorService createScheduledExecutor(int nThreads) { private ScheduledExecutorService createScheduledExecutor(int threadsNumber) {
if (nThreads == 1) { if (threadsNumber == 1) {
return Executors.newSingleThreadScheduledExecutor(); return Executors.newSingleThreadScheduledExecutor();
} else { } else {
return Executors.newScheduledThreadPool(nThreads); return Executors.newScheduledThreadPool(threadsNumber);
} }
} }
} }
Expand Up @@ -23,7 +23,8 @@
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;


public class SingleThreadExecutorContext extends AbstractExecutorContext implements ExecutorContext { public class SingleThreadExecutorContext extends AbstractExecutorContext implements
ExecutorContext {
private static final Logger LOG = LoggerFactory.getLogger(SingleThreadExecutorContext.class); private static final Logger LOG = LoggerFactory.getLogger(SingleThreadExecutorContext.class);


private ScheduledExecutorService singleThreadExecutor; private ScheduledExecutorService singleThreadExecutor;
Expand Down
Expand Up @@ -98,8 +98,9 @@ public LogTransport getLogTransport() {
} }


public void initTransports(KaaChannelManager channelManager, KaaClientState clientState) { public void initTransports(KaaChannelManager channelManager, KaaClientState clientState) {
for (KaaTransport transport : Arrays.asList(bootstrapTransport, profileTransport, eventTransport, notificationTransport, for (KaaTransport transport : Arrays.asList(bootstrapTransport, profileTransport,
configurationTransport, userTransport, logTransport)) { eventTransport, notificationTransport, configurationTransport, userTransport,
logTransport)) {
transport.setChannelManager(channelManager); transport.setChannelManager(channelManager);
transport.setClientState(clientState); transport.setClientState(clientState);
} }
Expand Down
Expand Up @@ -32,11 +32,11 @@ public InputStream openForRead(String path) throws IOException {


@Override @Override
public OutputStream openForWrite(String path) throws IOException { public OutputStream openForWrite(String path) throws IOException {
File f = new File(path); File file = new File(path);
if (f.getParentFile() != null && !f.getParentFile().exists()) { if (file.getParentFile() != null && !file.getParentFile().exists()) {
f.getParentFile().mkdirs(); file.getParentFile().mkdirs();
} }
return new FileOutputStream(f); return new FileOutputStream(file);
} }


@Override @Override
Expand Down

0 comments on commit 2c88cb9

Please sign in to comment.