code
stringlengths
25
201k
docstring
stringlengths
19
96.2k
func_name
stringlengths
0
235
language
stringclasses
1 value
repo
stringlengths
8
51
path
stringlengths
11
314
url
stringlengths
62
377
license
stringclasses
7 values
public <T> void getFromCacheAndLoadFromNetworkIfExpired(final SpiceRequest<T> request, final Object requestCacheKey, final long cacheExpiryDuration, final RequestListener<T> requestListener) { final CachedSpiceRequest<T> cachedSpiceRequest = new CachedSpiceRequest<T>(request, requestCacheKey, cacheExpiryDuration); cachedSpiceRequest.setAcceptingDirtyCache(true); execute(cachedSpiceRequest, requestListener); }
Gets data from cache, expired or not, and executes a request normaly. Before invoking the method {@link SpiceRequest#loadDataFromNetwork()}, the cache will be checked : if a result has been cached with the cache key <i>requestCacheKey</i>, RoboSpice will consider the parameter <i>cacheExpiryDuration</i> to determine whether the result in the cache is expired or not. If it is not expired, then listeners will receive the data in cache only. If the result is absent or expired, then {@link SpiceRequest#loadDataFromNetwork()} will be invoked and the result will be stored in cache using the cache key <i>requestCacheKey</i>. @param request the request to execute @param requestCacheKey the key used to store and retrieve the result of the request in the cache @param cacheExpiryDuration duration in milliseconds after which the content of the cache will be considered to be expired. {@link DurationInMillis#ALWAYS_RETURNED} means data in cache is always returned if it exists. {@link DurationInMillis#ALWAYS_EXPIRED} doesn't make much sense here. @param requestListener the listener to notify when the request will finish
getFromCacheAndLoadFromNetworkIfExpired
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> void putInCache(final Class<? super T> clazz, final Object requestCacheKey, final T data) { putInCache(clazz, requestCacheKey, data, null); }
Adds some data to the cache, asynchronously. Same as {@link #putInCache(Class, Object, Object, RequestListener)} with a null listener. Operation will take place but you won't be notified. @param clazz a super class or the class of data. @param requestCacheKey the request cache key that data will be stored in. @param data the data to store. Maybe null if supported by underlying ObjectPersister.
putInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@SuppressWarnings("unchecked") public <T> void putInCache(final Object requestCacheKey, final T data, RequestListener<T> listener) { putInCache((Class<T>) data.getClass(), requestCacheKey, data, listener); }
Adds some data to the cache, asynchronously. Same as {@link #putInCache(Class, Object, Object, RequestListener)} where the class used to identify the request is data.getClass(). @param requestCacheKey the request cache key that data will be stored in. @param data the data to store. Maybe null if supported by underlying ObjectPersister. @param listener a listener that will be notified of this request's success or failure. May be null.
putInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@SuppressWarnings("unchecked") public <T> void putInCache(final Object requestCacheKey, final T data) { putInCache((Class<T>) data.getClass(), requestCacheKey, data); }
Adds some data to the cache, asynchronously. Same as {@link #putInCache(Class, Object, Object, RequestListener)} where the class used to identify the request is data.getClass() and with a null listener. Operation will take place but you won't be notified. @param requestCacheKey the request cache key that data will be stored in. @param data the data to store. Maybe null if supported by underlying ObjectPersister.
putInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void dontNotifyRequestListenersForRequestInternal(final SpiceRequest<?> request) { lockSendRequestsToService.lock(); try { final boolean requestNotPassedToServiceYet = removeListenersOfCachedRequestToLaunch(request); Ln.v("Removed from requests to launch list : " + requestNotPassedToServiceYet); // if the request was already passed to service, bind to // service and // unregister listeners. if (!requestNotPassedToServiceYet) { removeListenersOfPendingCachedRequest(request); Ln.v("Removed from pending requests list"); } } catch (final InterruptedException e) { Ln.e(e, "Interrupted while removing listeners."); } finally { lockSendRequestsToService.unlock(); } }
Internal method to remove requests. If request has not been passed to the {@link SpiceService} yet, all listeners are unregistered locally before being passed to the service. Otherwise, it will asynchronously ask to the {@link SpiceService} to remove the listeners of the request being processed. @param request Request for which listeners are to unregistered.
dontNotifyRequestListenersForRequestInternal
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private boolean removeListenersOfCachedRequestToLaunch(final SpiceRequest<?> request) { synchronized (mapRequestToLaunchToRequestListener) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) { if (match(cachedSpiceRequest, request)) { final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); setRequestListeners.clear(); return true; } } return false; } }
Remove all listeners of a request that has not yet been passed to the {@link SpiceService}. @param request the request for which listeners must be unregistered. @return a boolean indicating if the request could be found inside the list of requests to be launched. If false, the request was already passed to the service.
removeListenersOfCachedRequestToLaunch
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void removeListenersOfPendingCachedRequest(final SpiceRequest<?> request) throws InterruptedException { synchronized (mapPendingRequestToRequestListener) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapPendingRequestToRequestListener.keySet()) { if (match(cachedSpiceRequest, request)) { waitForServiceToBeBound(); if (spiceService == null) { return; } final Set<RequestListener<?>> setRequestListeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); mapPendingRequestToRequestListener.remove(cachedSpiceRequest); break; } } } }
Remove all listeners of a request that may have already been passed to the {@link SpiceService}. If the request has already been passed to the {@link SpiceService}, the method will bind to the service and ask it to remove listeners. @param request the request for which listeners must be unregistered.
removeListenersOfPendingCachedRequest
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected void dontNotifyAnyRequestListenersInternal() { lockSendRequestsToService.lock(); try { if (spiceService == null) { return; } synchronized (mapRequestToLaunchToRequestListener) { if (!mapRequestToLaunchToRequestListener.isEmpty()) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToLaunchToRequestListener.keySet()) { final Set<RequestListener<?>> setRequestListeners = mapRequestToLaunchToRequestListener.get(cachedSpiceRequest); if (setRequestListeners != null) { Ln.d("Removing listeners of request to launch : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size()); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); } } } mapRequestToLaunchToRequestListener.clear(); } Ln.v("Cleared listeners of all requests to launch"); removeListenersOfAllPendingCachedRequests(); } catch (final InterruptedException e) { Ln.e(e, "Interrupted while removing listeners."); } finally { lockSendRequestsToService.unlock(); } }
Remove all listeners of requests. All requests that have not been yet passed to the service will see their of listeners cleaned. For all requests that have been passed to the service, we ask the service to remove their listeners.
dontNotifyAnyRequestListenersInternal
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private void removeListenersOfAllPendingCachedRequests() throws InterruptedException { synchronized (mapPendingRequestToRequestListener) { if (!mapPendingRequestToRequestListener.isEmpty()) { for (final CachedSpiceRequest<?> cachedSpiceRequest : mapPendingRequestToRequestListener.keySet()) { final Set<RequestListener<?>> setRequestListeners = mapPendingRequestToRequestListener.get(cachedSpiceRequest); if (setRequestListeners != null) { Ln.d("Removing listeners of pending request : " + cachedSpiceRequest.toString() + " : " + setRequestListeners.size()); spiceService.dontNotifyRequestListenersForRequest(cachedSpiceRequest, setRequestListeners); } } mapPendingRequestToRequestListener.clear(); } } Ln.v("Cleared listeners of all pending requests"); }
Asynchronously ask service to remove all listeners of pending requests. @throws InterruptedException in case service binding fails.
removeListenersOfAllPendingCachedRequests
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
private boolean match(final CachedSpiceRequest<?> cachedSpiceRequest, final SpiceRequest<?> spiceRequest) { if (spiceRequest instanceof CachedSpiceRequest) { return spiceRequest == cachedSpiceRequest; } else { return cachedSpiceRequest.getSpiceRequest() == spiceRequest; } }
Wether or not a given {@link CachedSpiceRequest} matches a {@link SpiceRequest}. @param cachedSpiceRequest the request know by the {@link SpiceManager}. @param spiceRequest the request that we wish to remove notification for. @return true if {@link CachedSpiceRequest} matches contentRequest.
match
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<T> getDataFromCache(final Class<T> clazz, final Object cacheKey) throws CacheLoadingException { return executeCommand(new GetDataFromCacheCommand<T>(this, clazz, cacheKey)); }
Get some data previously saved in cache with key <i>requestCacheKey</i>. This method doesn't perform any network processing, it just checks if there are previously saved data. Don't call this method in the main thread because you could block it. Instead, use the asynchronous version of this method: {@link #getFromCache(Class, Object, long, RequestListener)}. @param clazz the class of the result to retrieve from cache. @param cacheKey the key used to store and retrieve the result of the request in the cache @return a future object that will hold data in cache. Calling get on this future will block until the data is actually effectively taken from cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
getDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<T> putDataInCache(final Object cacheKey, final T data) throws CacheSavingException, CacheCreationException { return executeCommand(new PutDataInCacheCommand<T>(this, data, cacheKey)); }
Put some new data in cache using cache key <i>requestCacheKey</i>. This method doesn't perform any network processing, it just data in cache, erasing any previsouly saved date in cache using the same class and key. Don't call this method in the main thread because you could block it. Instead, use the asynchronous version of this method: {@link #putInCache(Class, Object, Object)}. @param cacheKey the key used to store and retrieve the result of the request in the cache @param data the data to be saved in cache. @return the data has it has been saved by an ObjectPersister in cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
putDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<Boolean> isDataInCache(Class<?> clazz, final Object cacheKey, long cacheExpiryDuration) throws CacheCreationException { return executeCommand(new IsDataInCacheCommand(this, clazz, cacheKey, cacheExpiryDuration)); }
Tests whether some data is present in cache or not. @param clazz the class of the result to retrieve from cache. @param cacheKey the key used to store and retrieve the result of the request in the cache @param cacheExpiryDuration duration in milliseconds after which the content of the cache will be considered to be expired. {@link DurationInMillis#ALWAYS_RETURNED} means data in cache is always returned if it exists. {@link DurationInMillis#ALWAYS_EXPIRED} means data in cache is never returned.(see {@link DurationInMillis}) @return the data has it has been saved by an ObjectPersister in cache. @throws CacheCreationException Exception thrown when a problem occurs while looking for data in cache.
isDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<Date> getDateOfDataInCache(Class<?> clazz, final Object cacheKey) throws CacheCreationException { return executeCommand(new GetDateOfDataInCacheCommand(this, clazz, cacheKey)); }
Returns the last date of storage of a given data into the cache. @param clazz the class of the result to retrieve from cache. @param cacheKey the key used to store and retrieve the result of the request in the cache @return the date at which data has been stored in cache. Null if no such data is in Cache. @throws CacheLoadingException Exception thrown when a problem occurs while loading data from cache.
getDateOfDataInCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<?> removeDataFromCache(final Class<T> clazz, final Object cacheKey) { if (clazz == null || cacheKey == null) { throw new IllegalArgumentException("Both parameters must be non null."); } return executeCommand(new RemoveDataFromCacheCommand(this, clazz, cacheKey)); }
Remove some specific content from cache @param clazz the Type of data you want to remove from cache @param cacheKey the key of the object in cache
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public <T> Future<?> removeDataFromCache(final Class<T> clazz) { if (clazz == null) { throw new IllegalArgumentException("Clazz must be non null."); } return executeCommand(new RemoveDataClassFromCacheCommand(this, clazz)); }
Remove some specific content from cache @param clazz the type of data you want to remove from cache.
removeDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
public Future<?> removeAllDataFromCache() { return executeCommand(new RemoveAllDataFromCacheCommand(this)); }
Remove all data from cache. This will clear all data stored by the {@link CacheManager} of the {@link SpiceService}.
removeAllDataFromCache
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
@Override public void onServiceConnected(final ComponentName name, final IBinder service) { lockAcquireService.lock(); try { if (service instanceof SpiceServiceBinder) { spiceService = ((SpiceServiceBinder) service).getSpiceService(); spiceService.addSpiceServiceListener(removerSpiceServiceListener); Ln.d("Bound to service : " + spiceService.getClass().getSimpleName()); conditionServiceBound.signalAll(); } else { Ln.e("Unexpected IBinder service at onServiceConnected :%s ", service.getClass().getName()); } } finally { lockAcquireService.unlock(); } }
Reacts to binding/unbinding with {@link SpiceService}.
onServiceConnected
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceManager.java
Apache-2.0
protected RequestProcessor createRequestProcessor(CacheManager cacheManager, RequestProgressManager requestProgressManager, RequestRunner requestRunner) { return new RequestProcessor(cacheManager, requestProgressManager, requestRunner); }
Factory method to create an entity responsible for processing requests send to the SpiceService. The default implementation of this method will return a {@link RequestProcessor}. Override this method if you want to inject a custom request processor. This feature has been implemented following a request from Christopher Jenkins. @param cacheManager the cache manager used by this service. @param requestProgressManager will notify of requests progress. @param requestRunner executes requests. @return a {@link RequestProcessor} that will be used to process requests.
createRequestProcessor
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestProcessorListener createRequestProcessorListener() { return new SelfStopperRequestProcessorListener(); }
Creates a {@link RequestProcessorListener} for the {@link RequestProcessor} used by this service. See a typical implementation : @see {@link SelfStopperRequestProcessorListener}. @return a new instance {@link RequestProcessorListener} for the {@link RequestProcessor} used by this service.
createRequestProcessorListener
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestProcessor getRequestProcessor() { return requestProcessor; }
For testing purposes only. @return the request processor of this spice service.
getRequestProcessor
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected RequestListenerNotifier createRequestRequestListenerNotifier() { return new DefaultRequestListenerNotifier(); }
Method to create a Request Progress Reporter object which is responsible for informing the listeners of the current state of each request. You can use this method to modify the existing behavior @return {@link RequestListenerNotifier}
createRequestRequestListenerNotifier
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected NetworkStateChecker getNetworkStateChecker() { return new DefaultNetworkStateChecker(); }
Factory method to create an entity responsible to check for network state. The default implementation of this method will return a {@link DefaultNetworkStateChecker}. Override this method if you want to inject a custom network state for testing or to adapt to connectivity changes on the Android. This method is also useful to create non-network related requests. In that case create a {@link NetworkStateChecker} that always return true. This feature has been implemented following a request from Pierre Durand. @return a {@link NetworkStateChecker} that will be used to determine if network state allows requests executions.
getNetworkStateChecker
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected ExecutorService getExecutorService() { final int coreThreadCount = getCoreThreadCount(); final int maxThreadCount = getMaximumThreadCount(); final int threadPriority = getThreadPriority(); if (coreThreadCount <= 0 || maxThreadCount <= 0) { throw new IllegalArgumentException("Thread count must be >= 1"); } else { PriorityThreadPoolExecutor executor = PriorityThreadPoolExecutor .getPriorityExecutor(coreThreadCount, maxThreadCount, threadPriority); executor.setKeepAliveTime(getKeepAliveTime(), TimeUnit.NANOSECONDS); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) { executor.allowCoreThreadTimeOut(getKeepAliveTime() != 0 && isCoreThreadDisposable()); } return executor; } }
Factory method to create an {@link ExecutorService} that will be used to execute requests. The default implementation of this method will create a single threaded or multi-threaded {@link ExecutorService} depending on the number of threads returned by {@link #getThreadCount()} and will assign them the priority returned by {@link #getThreadPriority()}. <p/> If you override this method in your service, you can supply a custom {@link ExecutorService}. <p/> This feature has been implemented following a request from Riccardo Ciovati. @return the {@link ExecutorService} to be used to execute requests .
getExecutorService
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
protected SpiceServiceListenerNotifier createSpiceServiceListenerNotifier() { return new SpiceServiceListenerNotifier(); }
Creates the SpiceServiceListenerNotifier. @return {@link SpiceServiceListenerNotifier}
createSpiceServiceListenerNotifier
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getThreadCount() { return DEFAULT_THREAD_COUNT; }
Override this method to increase the number of threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getCoreThreadCount() { return getThreadCount(); }
Override this method to increase the number of core threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getCoreThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getMaximumThreadCount() { return getThreadCount(); }
Override this method to increase the number of maximum threads used to process requests. This method will have no effect if you override {@link #getExecutorService()}. @return the number of threads used to process requests. Defaults to {@link #DEFAULT_THREAD_COUNT}.
getMaximumThreadCount
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public int getKeepAliveTime() { return DEFAULT_THREAD_KEEP_ALIVE_TIME; }
Override this method to set the keep alive time for core threads {@link #getExecutorService()}. @return the time to keep alive idle threads on {@see TimeUnit.NANOSECONDS}. Defaults to {@link #DEFAULT_THREAD_KEEP_ALIVE_TIME}.
getKeepAliveTime
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
public boolean isCoreThreadDisposable() { return true; }
Override this method to disable timeout on core threads. This is only taken into consideration for Android SDK 9+. {@link #getExecutorService()}. @return whether core threads are disposable or not (DEFAULT=true).
isCoreThreadDisposable
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/SpiceService.java
Apache-2.0
@Override public Thread newThread(Runnable runnable) { Thread thread = new Thread(runnable); thread.setPriority(threadPriority); return thread; }
Creates threads with a low priority. @author SNI
newThread
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/CustomizablePriorityThreadFactory.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/priority/CustomizablePriorityThreadFactory.java
Apache-2.0
public boolean processBytes(final byte[] buffer, final int offset, final int length) throws IOException { bos.write(buffer, offset, length); progress += length - offset; spiceRequest.publishProgress((float) progress / total); return !Thread.interrupted(); }
Inspired from Guava com.google.common.io.ByteProcessor
processBytes
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/ProgressByteProcessor.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/ProgressByteProcessor.java
Apache-2.0
public void notifyObserversOfRequestNotFound(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestNotFoundNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that couldn't be aggregated to another request.
notifyObserversOfRequestNotFound
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestAdded(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAddedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that has been added to processing queue.
notifyObserversOfRequestAdded
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestAggregated(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestAggregatedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Inform the observers of a request. The observers can optionally observe the new request if required. @param request the request that has been aggregated.
notifyObserversOfRequestAggregated
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestFailure(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestFailedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request failed. @param request the request that failed.
notifyObserversOfRequestFailure
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public <T> void notifyObserversOfRequestSuccess(CachedSpiceRequest<T> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestSucceededNotifier<T>(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request succeeded. @param request the request that succeeded.
notifyObserversOfRequestSuccess
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestCancellation(CachedSpiceRequest<?> request) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); post(new RequestCancelledNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers that the request was cancelled. @param request the request that was cancelled.
notifyObserversOfRequestCancellation
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestProgress(CachedSpiceRequest<?> request, RequestProgress requestProgress) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestProgress(requestProgress); post(new RequestProgressNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers of request progress. @param request the request in progress. @param requestProgress the progress of the request.
notifyObserversOfRequestProgress
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
public void notifyObserversOfRequestProcessed(CachedSpiceRequest<?> request, Set<RequestListener<?>> requestListeners) { RequestProcessingContext requestProcessingContext = new RequestProcessingContext(); requestProcessingContext.setExecutionThread(Thread.currentThread()); requestProcessingContext.setRequestListeners(requestListeners); post(new RequestProcessedNotifier(request, spiceServiceListenerList, requestProcessingContext)); }
Notify interested observers of request completion. @param request the request that has completed. @param requestListeners the listeners to notify.
notifyObserversOfRequestProcessed
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
protected void post(Runnable runnable) { Ln.d("Message queue is " + messageQueue); if (messageQueue == null) { return; } messageQueue.postAtTime(runnable, SystemClock.uptimeMillis()); }
Add the request update to the observer message queue. @param runnable a runnable to be posted immediatly on the queue.
post
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request not found: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestNotFound(request, requestProcessingContext); } } }
Runnable to inform interested observers of request not found @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestFailed(request, requestProcessingContext); } } }
Runnable to inform interested observers of request failed @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestSucceeded(request, requestProcessingContext); } } }
Runnable to inform interested observers of request completed @author Andrew.Clark @param <T>
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { Ln.d("Processing request cancelled: %s", request); synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestCancelled(request, requestProcessingContext); } } }
Runnable to inform interested observers of request cancelled @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestProgressUpdated(request, requestProcessingContext); } } }
Runnable to inform interested observers of request progress @author Andrew.Clark
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public void run() { synchronized (spiceServiceListenerList) { for (SpiceServiceListener listener : spiceServiceListenerList) { listener.onRequestProcessed(request, requestProcessingContext); } } }
Runnable to inform interested observers of request processing end. @author SNI
run
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/notifier/SpiceServiceListenerNotifier.java
Apache-2.0
@Override public InputStream processStream(final int contentLength, final InputStream inputStream) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); readBytes(inputStream, new ProgressByteProcessor(this, bos, contentLength)); final byte[] bytes = bos.toByteArray(); return new ByteArrayInputStream(bytes); }
Downloads small images in size. All data is passed to the listener using memory. This class is meant to help download small images (like thumbnails). If you wish to download bigger documents (or if you don't know the size of your documents), you would be better using {@link BigBinaryRequest}. @author sni & jva
processStream
java
stephanenicolas/robospice
robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/SmallBinaryRequest.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice/src/main/java/com/octo/android/robospice/request/simple/SmallBinaryRequest.java
Apache-2.0
public void await(long millisecond) throws InterruptedException { ((SpiceRequestStub<?>) getSpiceRequest()).awaitForLoadDataFromNetworkIsCalled(millisecond); }
@see {@link SpiceRequestStub#awaitForLoadDataFromNetworkIsCalled(long)}. @param millisecond @throws InterruptedException
await
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/CachedSpiceRequestStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/CachedSpiceRequestStub.java
Apache-2.0
protected void signalStopWaiting() { lock.lock(); try { requestFinishedCondition.signal(); } finally { lock.unlock(); } }
Indicates whether or not request can be considered as finished.
signalStopWaiting
java
stephanenicolas/robospice
robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/SpiceRequestStub.java
https://github.com/stephanenicolas/robospice/blob/master/robospice-core-parent/robospice-core-test/src/main/java/com/octo/android/robospice/stub/SpiceRequestStub.java
Apache-2.0
@Override public void run() { try { bind(inst, agentLoader, agentArgs); } catch (Throwable throwable) { throwable.printStackTrace(ps); } }
Use a dedicated thread to run the binding logic to prevent possible memory leak. #195
run
java
alibaba/arthas
agent/src/main/java/com/taobao/arthas/agent334/AgentBootstrap.java
https://github.com/alibaba/arthas/blob/master/agent/src/main/java/com/taobao/arthas/agent334/AgentBootstrap.java
Apache-2.0
public static void attach(Map<String, String> configMap) { new ArthasAgent(configMap).init(); }
@see https://arthas.aliyun.com/doc/arthas-properties.html @param configMap
attach
java
alibaba/arthas
arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java
https://github.com/alibaba/arthas/blob/master/arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java
Apache-2.0
public static void attach(String arthasHome) { new ArthasAgent(arthasHome).init(); }
use the specified arthas @param arthasHome arthas directory
attach
java
alibaba/arthas
arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java
https://github.com/alibaba/arthas/blob/master/arthas-agent-attach/src/main/java/com/taobao/arthas/agent/attach/ArthasAgent.java
Apache-2.0
public void open() throws SocketException { _socket_ = _socketFactory_.createDatagramSocket(); _socket_.setSoTimeout(_timeout_); _isOpen_ = true; }
Opens a DatagramSocket on the local host at the first available port. Also sets the timeout on the socket to the default timeout set by {@link #setDefaultTimeout setDefaultTimeout() }. <p> _isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket. @exception SocketException If the socket could not be opened or the timeout could not be set. *
open
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void open(int port) throws SocketException { _socket_ = _socketFactory_.createDatagramSocket(port); _socket_.setSoTimeout(_timeout_); _isOpen_ = true; }
Opens a DatagramSocket on the local host at a specified port. Also sets the timeout on the socket to the default timeout set by {@link #setDefaultTimeout setDefaultTimeout() }. <p> _isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket. @param port The port to use for the socket. @exception SocketException If the socket could not be opened or the timeout could not be set. *
open
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void open(int port, InetAddress laddr) throws SocketException { _socket_ = _socketFactory_.createDatagramSocket(port, laddr); _socket_.setSoTimeout(_timeout_); _isOpen_ = true; }
Opens a DatagramSocket at the specified address on the local host at a specified port. Also sets the timeout on the socket to the default timeout set by {@link #setDefaultTimeout setDefaultTimeout() }. <p> _isOpen_ is set to true after calling this method and _socket_ is set to the newly opened socket. @param port The port to use for the socket. @param laddr The local address to use. @exception SocketException If the socket could not be opened or the timeout could not be set. *
open
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void close() { if (_socket_ != null) { _socket_.close(); } _socket_ = null; _isOpen_ = false; }
Closes the DatagramSocket used for the connection. You should call this method after you've finished using the class instance and also before you call {@link #open open() } again. _isOpen_ is set to false and _socket_ is set to null. If you call this method when the client socket is not open, a NullPointerException is thrown. *
close
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public boolean isOpen() { return _isOpen_; }
Returns true if the client has a currently open socket. @return True if the client has a curerntly open socket, false otherwise. *
isOpen
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void setDefaultTimeout(int timeout) { _timeout_ = timeout; }
Set the default timeout in milliseconds to use when opening a socket. After a call to open, the timeout for the socket is set using this value. This method should be used prior to a call to {@link #open open()} and should not be confused with {@link #setSoTimeout setSoTimeout()} which operates on the currently open socket. _timeout_ contains the new timeout value. @param timeout The timeout in milliseconds to use for the datagram socket connection. *
setDefaultTimeout
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public int getDefaultTimeout() { return _timeout_; }
Returns the default timeout in milliseconds that is used when opening a socket. @return The default timeout in milliseconds that is used when opening a socket. *
getDefaultTimeout
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void setSoTimeout(int timeout) throws SocketException { _socket_.setSoTimeout(timeout); }
Set the timeout in milliseconds of a currently open connection. Only call this method after a connection has been opened by {@link #open open()}. @param timeout The timeout in milliseconds to use for the currently open datagram socket connection. @throws SocketException if an error setting the timeout *
setSoTimeout
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public int getSoTimeout() throws SocketException { return _socket_.getSoTimeout(); }
Returns the timeout in milliseconds of the currently opened socket. If you call this method when the client socket is not open, a NullPointerException is thrown. @return The timeout in milliseconds of the currently opened socket. @throws SocketException if an error getting the timeout *
getSoTimeout
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public int getLocalPort() { return _socket_.getLocalPort(); }
Returns the port number of the open socket on the local host used for the connection. If you call this method when the client socket is not open, a NullPointerException is thrown. @return The port number of the open socket on the local host used for the connection. *
getLocalPort
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public InetAddress getLocalAddress() { return _socket_.getLocalAddress(); }
Returns the local address to which the client's socket is bound. If you call this method when the client socket is not open, a NullPointerException is thrown. @return The local address to which the client's socket is bound. *
getLocalAddress
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public void setDatagramSocketFactory(DatagramSocketFactory factory) { if (factory == null) { _socketFactory_ = __DEFAULT_SOCKET_FACTORY; } else { _socketFactory_ = factory; } }
Sets the DatagramSocketFactory used by the DatagramSocketClient to open DatagramSockets. If the factory value is null, then a default factory is used (only do this to reset the factory after having previously altered it). @param factory The new DatagramSocketFactory the DatagramSocketClient should use. *
setDatagramSocketFactory
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
public String getCharsetName() { return charset.name(); }
Gets the charset name. @return the charset name. @since 3.3 TODO Will be deprecated once the code requires Java 1.6 as a mininmum
getCharsetName
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DatagramSocketClient.java
Apache-2.0
@Override public DatagramSocket createDatagramSocket() throws SocketException { return new DatagramSocket(); }
Creates a DatagramSocket on the local host at the first available port. @return a new DatagramSocket @exception SocketException If the socket could not be created. *
createDatagramSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
Apache-2.0
@Override public DatagramSocket createDatagramSocket(int port) throws SocketException { return new DatagramSocket(port); }
Creates a DatagramSocket on the local host at a specified port. @param port The port to use for the socket. @return a new DatagramSocket @exception SocketException If the socket could not be created. *
createDatagramSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
Apache-2.0
@Override public DatagramSocket createDatagramSocket(int port, InetAddress laddr) throws SocketException { return new DatagramSocket(port, laddr); }
Creates a DatagramSocket at the specified address on the local host at a specified port. @param port The port to use for the socket. @param laddr The local address to use. @return a new DatagramSocket @exception SocketException If the socket could not be created. *
createDatagramSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultDatagramSocketFactory.java
Apache-2.0
@Override public Socket createSocket() throws IOException { if (connProxy != null) { return new Socket(connProxy); } return new Socket(); }
Creates an unconnected Socket. @return A new unconnected Socket. @exception IOException If an I/O error occurs while creating the Socket. @since 3.2
createSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
@Override public Socket createSocket(String host, int port) throws UnknownHostException, IOException { if (connProxy != null) { Socket s = new Socket(connProxy); s.connect(new InetSocketAddress(host, port)); return s; } return new Socket(host, port); }
Creates a Socket connected to the given host and port. @param host The hostname to connect to. @param port The port to connect to. @return A Socket connected to the given host and port. @exception UnknownHostException If the hostname cannot be resolved. @exception IOException If an I/O error occurs while creating the Socket. *
createSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
@Override public Socket createSocket(InetAddress address, int port) throws IOException { if (connProxy != null) { Socket s = new Socket(connProxy); s.connect(new InetSocketAddress(address, port)); return s; } return new Socket(address, port); }
Creates a Socket connected to the given host and port. @param address The address of the host to connect to. @param port The port to connect to. @return A Socket connected to the given host and port. @exception IOException If an I/O error occurs while creating the Socket. *
createSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
@Override public Socket createSocket(String host, int port, InetAddress localAddr, int localPort) throws UnknownHostException, IOException { if (connProxy != null) { Socket s = new Socket(connProxy); s.bind(new InetSocketAddress(localAddr, localPort)); s.connect(new InetSocketAddress(host, port)); return s; } return new Socket(host, port, localAddr, localPort); }
Creates a Socket connected to the given host and port and originating from the specified local address and port. @param host The hostname to connect to. @param port The port to connect to. @param localAddr The local address to use. @param localPort The local port to use. @return A Socket connected to the given host and port. @exception UnknownHostException If the hostname cannot be resolved. @exception IOException If an I/O error occurs while creating the Socket. *
createSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
@Override public Socket createSocket(InetAddress address, int port, InetAddress localAddr, int localPort) throws IOException { if (connProxy != null) { Socket s = new Socket(connProxy); s.bind(new InetSocketAddress(localAddr, localPort)); s.connect(new InetSocketAddress(address, port)); return s; } return new Socket(address, port, localAddr, localPort); }
Creates a Socket connected to the given host and port and originating from the specified local address and port. @param address The address of the host to connect to. @param port The port to connect to. @param localAddr The local address to use. @param localPort The local port to use. @return A Socket connected to the given host and port. @exception IOException If an I/O error occurs while creating the Socket. *
createSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
public ServerSocket createServerSocket(int port) throws IOException { return new ServerSocket(port); }
Creates a ServerSocket bound to a specified port. A port of 0 will create the ServerSocket on a system-determined free port. @param port The port on which to listen, or 0 to use any free port. @return A ServerSocket that will listen on a specified port. @exception IOException If an I/O error occurs while creating the ServerSocket. *
createServerSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
public ServerSocket createServerSocket(int port, int backlog) throws IOException { return new ServerSocket(port, backlog); }
Creates a ServerSocket bound to a specified port with a given maximum queue length for incoming connections. A port of 0 will create the ServerSocket on a system-determined free port. @param port The port on which to listen, or 0 to use any free port. @param backlog The maximum length of the queue for incoming connections. @return A ServerSocket that will listen on a specified port. @exception IOException If an I/O error occurs while creating the ServerSocket. *
createServerSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
public ServerSocket createServerSocket(int port, int backlog, InetAddress bindAddr) throws IOException { return new ServerSocket(port, backlog, bindAddr); }
Creates a ServerSocket bound to a specified port on a given local address with a given maximum queue length for incoming connections. A port of 0 will create the ServerSocket on a system-determined free port. @param port The port on which to listen, or 0 to use any free port. @param backlog The maximum length of the queue for incoming connections. @param bindAddr The local address to which the ServerSocket should bind. @return A ServerSocket that will listen on a specified port. @exception IOException If an I/O error occurs while creating the ServerSocket. *
createServerSocket
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/DefaultSocketFactory.java
Apache-2.0
public String getCommand() { return __command; }
Returns the string representation of the command type sent (e.g., "STAT" or "GET"). If the ProtocolCommandEvent is a reply event, then null is returned. @return The string representation of the command type sent, or null if this is a reply event. *
getCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
Apache-2.0
public int getReplyCode() { return __replyCode; }
Returns the reply code of the received server reply. Undefined if this is not a reply event. @return The reply code of the received server reply. Undefined if not a reply event. *
getReplyCode
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
Apache-2.0
public boolean isCommand() { return __isCommand; }
Returns true if the ProtocolCommandEvent was generated as a result of sending a command. @return true If the ProtocolCommandEvent was generated as a result of sending a command. False otherwise. *
isCommand
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
Apache-2.0
public boolean isReply() { return !isCommand(); }
Returns true if the ProtocolCommandEvent was generated as a result of receiving a reply. @return true If the ProtocolCommandEvent was generated as a result of receiving a reply. False otherwise. *
isReply
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
Apache-2.0
public String getMessage() { return __message; }
Returns the entire message sent to or received from the server. Includes the line terminator. @return The entire message sent to or received from the server. *
getMessage
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandEvent.java
Apache-2.0
public void addProtocolCommandListener(ProtocolCommandListener listener) { __listeners.addListener(listener); }
Adds a ProtocolCommandListener. @param listener The ProtocolCommandListener to add. *
addProtocolCommandListener
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
Apache-2.0
public void removeProtocolCommandListener(ProtocolCommandListener listener) { __listeners.removeListener(listener); }
Removes a ProtocolCommandListener. @param listener The ProtocolCommandListener to remove. *
removeProtocolCommandListener
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
Apache-2.0
public int getListenerCount() { return __listeners.getListenerCount(); }
Returns the number of ProtocolCommandListeners currently registered. @return The number of ProtocolCommandListeners currently registered. *
getListenerCount
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/ProtocolCommandSupport.java
Apache-2.0
protected void _connectAction_() throws IOException { _socket_.setSoTimeout(_timeout_); _input_ = _socket_.getInputStream(); _output_ = _socket_.getOutputStream(); }
Because there are so many connect() methods, the _connectAction_() method is provided as a means of performing some action immediately after establishing a connection, rather than reimplementing all of the connect() methods. The last action performed by every connect() method after opening a socket is to call this method. <p> This method sets the timeout on the just opened socket to the default timeout set by {@link #setDefaultTimeout setDefaultTimeout() }, sets _input_ and _output_ to the socket's InputStream and OutputStream respectively, and sets _isConnected_ to true. <p> Subclasses overriding this method should start by calling <code> super._connectAction_() </code> first to ensure the initialization of the aforementioned protected variables. @throws IOException (SocketException) if a problem occurs with the socket
_connectAction_
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(InetAddress host, int port) throws SocketException, IOException { _hostname_ = null; _socket_ = _socketFactory_.createSocket(); if (receiveBufferSize != -1) { _socket_.setReceiveBufferSize(receiveBufferSize); } if (sendBufferSize != -1) { _socket_.setSendBufferSize(sendBufferSize); } _socket_.connect(new InetSocketAddress(host, port), connectTimeout); _connectAction_(); }
Opens a Socket connected to a remote host at the specified port and originating from the current host at a system assigned port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param host The remote host. @param port The port to connect to on the remote host. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(String hostname, int port) throws SocketException, IOException { connect(InetAddress.getByName(hostname), port); _hostname_ = hostname; }
Opens a Socket connected to a remote host at the specified port and originating from the current host at a system assigned port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param hostname The name of the remote host. @param port The port to connect to on the remote host. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it. @exception java.net.UnknownHostException If the hostname cannot be resolved.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(InetAddress host, int port, InetAddress localAddr, int localPort) throws SocketException, IOException { _hostname_ = null; _socket_ = _socketFactory_.createSocket(); if (receiveBufferSize != -1) { _socket_.setReceiveBufferSize(receiveBufferSize); } if (sendBufferSize != -1) { _socket_.setSendBufferSize(sendBufferSize); } _socket_.bind(new InetSocketAddress(localAddr, localPort)); _socket_.connect(new InetSocketAddress(host, port), connectTimeout); _connectAction_(); }
Opens a Socket connected to a remote host at the specified port and originating from the specified local address and port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param host The remote host. @param port The port to connect to on the remote host. @param localAddr The local address to use. @param localPort The local port to use. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(String hostname, int port, InetAddress localAddr, int localPort) throws SocketException, IOException { connect(InetAddress.getByName(hostname), port, localAddr, localPort); _hostname_ = hostname; }
Opens a Socket connected to a remote host at the specified port and originating from the specified local address and port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param hostname The name of the remote host. @param port The port to connect to on the remote host. @param localAddr The local address to use. @param localPort The local port to use. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it. @exception java.net.UnknownHostException If the hostname cannot be resolved.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(InetAddress host) throws SocketException, IOException { _hostname_ = null; connect(host, _defaultPort_); }
Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param host The remote host. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void connect(String hostname) throws SocketException, IOException { connect(hostname, _defaultPort_); _hostname_ = hostname; }
Opens a Socket connected to a remote host at the current default port and originating from the current host at a system assigned port. Before returning, {@link #_connectAction_ _connectAction_() } is called to perform connection initialization actions. <p> @param hostname The name of the remote host. @exception SocketException If the socket timeout could not be set. @exception IOException If the socket could not be opened. In most cases you will only want to catch IOException since SocketException is derived from it. @exception java.net.UnknownHostException If the hostname cannot be resolved.
connect
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public boolean isConnected() { if (_socket_ == null) { return false; } return _socket_.isConnected(); }
Returns true if the client is currently connected to a server. <p> Delegates to {@link Socket#isConnected()} @return True if the client is currently connected to a server, false otherwise.
isConnected
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void setDefaultPort(int port) { _defaultPort_ = port; }
Sets the default port the SocketClient should connect to when a port is not specified. The {@link #_defaultPort_ _defaultPort_ } variable stores this value. If never set, the default port is equal to zero. <p> @param port The default port to set.
setDefaultPort
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public int getDefaultPort() { return _defaultPort_; }
Returns the current value of the default port (stored in {@link #_defaultPort_ _defaultPort_ }). <p> @return The current value of the default port.
getDefaultPort
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void setSendBufferSize(int size) throws SocketException { sendBufferSize = size; }
Set the underlying socket send buffer size. <p> @param size The size of the buffer in bytes. @throws SocketException never thrown, but subclasses might want to do so @since 2.0
setSendBufferSize
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
protected int getSendBufferSize(){ return sendBufferSize; }
Get the current sendBuffer size @return the size, or -1 if not initialised @since 3.0
getSendBufferSize
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void setReceiveBufferSize(int size) throws SocketException { receiveBufferSize = size; }
Sets the underlying socket receive buffer size. <p> @param size The size of the buffer in bytes. @throws SocketException never (but subclasses may wish to do so) @since 2.0
setReceiveBufferSize
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
protected int getReceiveBufferSize(){ return receiveBufferSize; }
Get the current receivedBuffer size @return the size, or -1 if not initialised @since 3.0
getReceiveBufferSize
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0
public void setTcpNoDelay(boolean on) throws SocketException { _socket_.setTcpNoDelay(on); }
Enables or disables the Nagle's algorithm (TCP_NODELAY) on the currently opened socket. <p> @param on True if Nagle's algorithm is to be enabled, false if not. @exception SocketException If the operation fails. @throws NullPointerException if the socket is not currently open
setTcpNoDelay
java
alibaba/arthas
client/src/main/java/org/apache/commons/net/SocketClient.java
https://github.com/alibaba/arthas/blob/master/client/src/main/java/org/apache/commons/net/SocketClient.java
Apache-2.0