List of usage examples for java.lang.ref WeakReference WeakReference
public WeakReference(T referent)
From source file:androidx.media.MediaSession2ImplBase.java
@Override void setInstance(MediaSession2 session) { mInstance = new WeakReference<>(session); }
From source file:co.beem.project.beem.FbTextService.java
public void setChatManagerReference(BeemChatManager manager) { chatManagerReference = new WeakReference<BeemChatManager>(manager); }
From source file:cn.com.incito.wisdom.sdk.net.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); }/* w w w .j av a 2 s . co m*/ 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.cndatacom.ordersystem.manager.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 . j av a 2s. c o m*/ Future<?> request = threadPool .submit(new AsyncHttpRequest(client, httpContext, uriRequest, responseHandler)); try { InputStream ins = ((HttpPost) uriRequest).getEntity().getContent(); BufferedReader in = new BufferedReader(new InputStreamReader(ins)); StringBuffer buffer = new StringBuffer(); String line = ""; while ((line = in.readLine()) != null) { buffer.append(line); } System.out.println("Request Params : " + buffer.toString()); } catch (IOException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } 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:cn.caimatou.canting.utils.http.asynchttp.AsyncHttpClient.java
protected void sendRequest(final DefaultHttpClient client, final HttpContext httpContext, final HttpUriRequest uriRequest, final String contentType, final AsyncHttpResponseHandler responseHandler, final Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }//from w ww .jav a 2s . c o m 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.roach.framework.http.AsyncHttpClient.java
private void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }/*from w w w . j a v a 2 s . c o m*/ 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.chuannuo.tangguo.net.TGHttpClient.java
protected void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, TGHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }//from w w w. j a v a 2s . c o m Future<?> request = threadPool .submit(new TGHttpRequest(client, httpContext, uriRequest, responseHandler, responseUrl)); 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:cn.kuwo.sing.phone4tv.commons.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); }/* w w w . java2 s. 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? } Log.d("AsyncHttpClient", "sendRequest: " + uriRequest.getURI().toString()); }
From source file:com.damytech.HttpConn.AsyncHttpClient.java
private void sendRequest(DefaultHttpClient client, HttpContext httpContext, HttpUriRequest uriRequest, String contentType, AsyncHttpResponseHandler responseHandler, Context context) { if (contentType != null) { uriRequest.addHeader("Content-Type", contentType); }/* w ww . jav a2 s . c o m*/ 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:org.red5.server.stream.ClientBroadcastStream.java
/** * Save broadcasted stream./*from w w w. jav a 2 s. c o m*/ * * @param name * Stream name * @param isAppend * Append mode * @throws IOException * File could not be created/written to */ public void saveAs(String name, boolean isAppend) throws IOException { log.debug("SaveAs - name: {} append: {}", name, isAppend); // get connection to check if client is still streaming IStreamCapableConnection conn = getConnection(); if (conn == null) { throw new IOException("Stream is no longer connected"); } // one recording listener at a time via this entry point if (recordingListener == null) { // XXX Paul: Revisit this section to allow for implementation of custom IRecordingListener //IRecordingListener listener = (IRecordingListener) ScopeUtils.getScopeService(conn.getScope(), IRecordingListener.class, RecordingListener.class, false); // create a recording listener IRecordingListener listener = new RecordingListener(); log.debug("Created: {}", listener); // initialize the listener if (listener.init(conn, name, isAppend)) { // get decoder info if it exists for the stream IStreamCodecInfo codecInfo = getCodecInfo(); log.debug("Codec info: {}", codecInfo); if (codecInfo instanceof StreamCodecInfo) { StreamCodecInfo info = (StreamCodecInfo) codecInfo; IVideoStreamCodec videoCodec = info.getVideoCodec(); log.debug("Video codec: {}", videoCodec); if (videoCodec != null) { //check for decoder configuration to send IoBuffer config = videoCodec.getDecoderConfiguration(); if (config != null) { log.debug("Decoder configuration is available for {}", videoCodec.getName()); VideoData videoConf = new VideoData(config.asReadOnlyBuffer()); try { log.debug("Setting decoder configuration for recording"); listener.getFileConsumer().setVideoDecoderConfiguration(videoConf); } finally { videoConf.release(); } } } else { log.debug("Could not initialize stream output, videoCodec is null."); } IAudioStreamCodec audioCodec = info.getAudioCodec(); log.debug("Audio codec: {}", audioCodec); if (audioCodec != null) { //check for decoder configuration to send IoBuffer config = audioCodec.getDecoderConfiguration(); if (config != null) { log.debug("Decoder configuration is available for {}", audioCodec.getName()); AudioData audioConf = new AudioData(config.asReadOnlyBuffer()); try { log.debug("Setting decoder configuration for recording"); listener.getFileConsumer().setAudioDecoderConfiguration(audioConf); } finally { audioConf.release(); } } } else { log.debug("No decoder configuration available, audioCodec is null."); } } // set as primary listener recordingListener = new WeakReference<IRecordingListener>(listener); // add as a listener addStreamListener(listener); // start the listener thread listener.start(); } else { log.warn("Recording listener failed to initialize for stream: {}", name); } } else { log.debug("Recording listener already exists for stream: {} auto record enabled: {}", name, automaticRecording); } }