List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:com.frand.easyandroid.http.FFHttpClient.java
protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, FFHttpRespHandler responseHandler, Context context, int reqTag, String reqUrl) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }//from w w w.j av a2 s . co m Future<?> request = threadPool .submit(new FFHttpRequest(client, httpContext, uriRequest, responseHandler, reqTag, reqUrl)); if (context != null) { List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); } }
From source file:com.mustardgrain.solr.SolrClient.java
/** * SolrClient outputs some statistics to the log on a regular interval. Use * this to set that interval/*w w w. j a v a 2 s. co m*/ * * @param interval time in milliseconds */ public void setStatsInterval(int interval) { if (interval <= 0) { throw new IllegalArgumentException( "SolrStats interval must be " + "positive, specified value = " + interval); } this.statsInterval = interval; if (statsExecutor != null) statsExecutor.scheduleAtFixedRate(getStatsRunner(new WeakReference<SolrClient>(this)), this.statsInterval, this.statsInterval, TimeUnit.MILLISECONDS); }
From source file:com.moscona.dataSpace.persistence.DirectoryDataStore.java
@Override public synchronized void register(DataSpace dataSpace) { referencingDataSpaces.add(new WeakReference<DataSpace>(dataSpace)); }
From source file:com.mustardgrain.solr.SolrClient.java
private void startStatsExecutor() { statsExecutor = Executors.newSingleThreadScheduledExecutor(new SolrjNamedThreadFactory("statsExecutor")); statsExecutor.scheduleAtFixedRate(getStatsRunner(new WeakReference<SolrClient>(this)), this.statsInterval, this.statsInterval, TimeUnit.MILLISECONDS); }
From source file:com.moscona.dataSpace.persistence.DirectoryDataStore.java
@Override public synchronized void register(IVector vector) { referencingVectors.add(new WeakReference<IVector>(vector)); }
From source file:com.meidusa.amoeba.net.poolable.copy.CursorableLinkedList.java
/** * Registers a {@link CursorableLinkedList.Cursor} to be notified * of changes to this list.//from ww w . j a v a2 s . c o m */ protected void registerCursor(Cursor cur) { // We take this opportunity to clean the _cursors list // of WeakReference objects to garbage-collected cursors. for (Iterator it = _cursors.iterator(); it.hasNext();) { WeakReference ref = (WeakReference) it.next(); if (ref.get() == null) { it.remove(); } } _cursors.add(new WeakReference(cur)); }
From source file:net.minecraftforge.fml.client.FMLClientHandler.java
public void setPlayClient(NetHandlerPlayClient netHandlerPlayClient) { this.currentPlayClient = new WeakReference<NetHandlerPlayClient>(netHandlerPlayClient); }
From source file:com.waltz3d.common.httpclient.AsyncHttpClient.java
protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }/* w w w .ja v a 2s .c om*/ Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } }
From source file:com.pyj.http.AsyncHttpClient.java
protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }//from www .j ava2s . c o m Future<?> request = threadPool.submit( new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler, responseHandler.reqCode)); if (context != null) { // Add request to request map List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); // TODO: Remove dead weakrefs from requestLists? } }
From source file:com.mike.aframe.http.KJHttp.java
/** * ??// w w w.j ava 2s.co m * * @param client * httpClient * @param callback * Http? * @param context */ protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, HttpCallBack callback, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); } Future<?> request = threadPool.submit(new AsyncHttpRequest(client, httpContext, uriRequest, callback)); if (context != null) { // List<WeakReference<Future<?>>> requestList = requestMap.get(context); if (requestList == null) { requestList = new LinkedList<WeakReference<Future<?>>>(); requestMap.put(context, requestList); } requestList.add(new WeakReference<Future<?>>(request)); } }