Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: Re: Java listener Date: Tue, 27 Dec 2011 12:33:40 -0800 Organization: Canadian Mind Products Lines: 40 Message-ID: References: <9a7gf750th7582hnjvfv9n0iko35omb57o@4ax.com> Reply-To: Roedy Green NNTP-Posting-Host: Z2l1DcCELS0rATq8NqV4Sw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org X-Notice: Filtered by postfilter v. 0.8.2 X-Newsreader: Forte Agent 6.00/32.1186 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:11011 On Sun, 25 Dec 2011 23:12:55 -0800, Jim Lee wrote, quoted or indirectly quoted someone who said : >I have a java interface "ConnectionListener" ... > >And a method "httpPost" which pass a "ConnectionListener" as parameter > >How do I implement the ConnectionListener interface and how do I pass >it into "httpPost" method to get invoked when "listener event" get >response from the httpPost? > >===================================== > >public void httpPost(String url, List
headers, HttpEntity >body, ConnectionListener listener) { > HttpPostTask task = new HttpPostTask(url, headers, body, >listener); > mExecutor.submit(task); >} > >===================================== >import java.io.InputStream; >import org.apache.http.HttpMessage; > >public interface ConnectionListener { > > public void onConnection(int status, InputStream is, >HttpMessage message); > > public void onConnectionException(Exception e); >} You might use somebody else's code, such as Apache HTTPClient or mine http://mindprod.com/products.html#HTTP -- Roedy Green Canadian Mind Products http://mindprod.com If you can't remember the name of some method, consider changing it to something you can remember.