Return-Path: Delivered-To: apmail-incubator-connectors-commits-archive@minotaur.apache.org Received: (qmail 11594 invoked from network); 23 Oct 2010 07:26:26 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 23 Oct 2010 07:26:26 -0000 Received: (qmail 94820 invoked by uid 500); 23 Oct 2010 07:26:26 -0000 Delivered-To: apmail-incubator-connectors-commits-archive@incubator.apache.org Received: (qmail 94778 invoked by uid 500); 23 Oct 2010 07:26:24 -0000 Mailing-List: contact connectors-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: connectors-dev@incubator.apache.org Delivered-To: mailing list connectors-commits@incubator.apache.org Received: (qmail 94771 invoked by uid 99); 23 Oct 2010 07:26:24 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Oct 2010 07:26:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 23 Oct 2010 07:26:22 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o9N7Q0Yd025237 for ; Sat, 23 Oct 2010 07:26:00 GMT Date: Sat, 23 Oct 2010 03:26:00 -0400 (EDT) From: confluence@apache.org To: connectors-commits@incubator.apache.org Message-ID: <25782397.2108.1287818760182.JavaMail.confluence@thor> Subject: [CONF] Apache Connectors Framework > How to Write an Output Connector MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Auto-Submitted: auto-generated X-Virus-Checked: Checked by ClamAV on apache.org Space: Apache Connectors Framework (https://cwiki.apache.org/confluence/display/CONNECTORS) Page: How to Write an Output Connector (https://cwiki.apache.org/confluence/display/CONNECTORS/How+to+Write+an+Output+Connector) Comment: https://cwiki.apache.org/confluence/display/CONNECTORS/How+to+Write+an+Output+Connector?focusedCommentId=24184098#comment-24184098 Comment added by Karl Wright: --------------------------------------------------------------------- The thread context is set whenever the connector instance is grabbed by a thread, and must be forgetten when the connector instance is released by that thread.   Furthermore, connector instances are pooled, so there is no guarantee that the same instance will be used for subsequent operations within the same crawl. If you are trying to use the thread context and finding it to be null, you are by definition using it incorrectly. In reply to a comment by Farzad: So I figured out an answer, please verify it is correct. It seems thread context is set when a crawl is happening which makes sense. I overwrote the setThreadContext method and assigned an id. It works, is this the right way? {code} public void setThreadContext(IThreadContext threadContext) { super.setThreadContext(threadContext); if (threadContext != null) { Object id = currentContext.get("id"); if (id == null) { currentContext.save("id", new Integer(idNum)); idNum++; } System.out.println( Thread.currentThread().getStackTrace()[1].getMethodName() + ", id=" + "[" + currentContext.get("id") + "]"); } } {code} Change your notification preferences: https://cwiki.apache.org/confluence/users/viewnotifications.action