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 edited 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}
Comment was previously :
---------------------------------------------------------------------
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
|