On Mon, 2006-05-15 at 06:35 +0200, karl wettin wrote:

> Perhaps I can find a way to select notification strategy using
> the same listener interface.

I mostly look for the Solr-kind-of-solution for now, but I will
absolutely keep my mind set on that the layer should allow hooks deep in
the code.

I'm considering a couple of things. Feel free to comment: 

0. One notification service instance per index. A listener could however
be bound to multiple services. (Perhaps an index is a notification
service.)

1. IndexReader and IndexWriter facades as inner classes of the
notification service. I think this is my favorite so far. It would work
with any persistence. Somewhat problematic as there are protected
methods s.a. doSetNorm of IndexReader. Nothing that can't be fixed.

class WriterFacade extendes Writer {
    private final IndexWriter writer;
    private final List<Document> newDocuments;
    public WriterFacade (IndexWriter writer) {
        this.writer=writer;
    }
    public addDocument(.. {
        writer.addDocument( ..;
        newDocuments.add(doc)
    }
    public close() {
        NotificationService.this.notifyCreate(
    }
}

2. Adding call back hooks in the code. Could be difficult to keep track
of the notification service everywhere. 

3. Passive checksum tests of version numbers, docCount et.c. Will
require some kind of cron tab. 

4. All of above. The notification service can be associated with one
hook per notification type.



The following I'm quite certain at:

/** one per index. or perhaps a part of an index? */
class NotificationService {
        Set<UpdateListener> updateListeners..
    Set<CreateListener> createListeners..

    registerListener(..

    notifyUpdate(..
}

interface UpdateListener {
    /** General index update trigger. */
    void onDelete(NotificationService service);
}
interface CreateListener {
    /** is int[] easy available? */
    void onDelete(NotificationService service,
                  Document[] documents);
}

interface DeleteListener {
    void onDelete(NotificationService service,
                  int[] documentNumbers);
}

/** this will require deep hooks in code */
interface OptimizeListener {
    void onOptimization(NotificationService service,
                        int[] fromDocumentNumbers, 
                        int[] toDocumentNumbers);
}



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to