Example usage for org.apache.lucene.search IndexSearcher toString

List of usage examples for org.apache.lucene.search IndexSearcher toString

Introduction

In this page you can find the example usage for org.apache.lucene.search IndexSearcher toString.

Prototype

@Override
    public String toString() 

Source Link

Usage

From source file:org.sakaiproject.search.mbeans.SearchServiceManagement.java

License:Educational Community License

/**
 * /*from w w  w.j a v  a  2 s.c  o  m*/
 */
public void init() {
    try {

        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

        final ObjectName searchServiceON = new ObjectName(MBEAN_COMPONENT_BASE + name);
        mbs.registerMBean(this, searchServiceON);

        indexStorageProvider.addIndexListener(new IndexListener() {

            public void doIndexReaderClose(IndexReader oldMultiReader) throws IOException {
                sendNotification(new Notification("index-reader-close", searchServiceON, notificationNo++,
                        "Closed oldMultiReader"));
            }

            public void doIndexReaderOpen(IndexReader newMultiReader) {
                sendNotification(new Notification("index-reader-open", searchServiceON, notificationNo++,
                        "Opened newMultiReader"));
            }

            public void doIndexSearcherClose(IndexSearcher indexSearcher) throws IOException {
                sendNotification(new Notification("index-searcher-close", searchServiceON, notificationNo++,
                        "Closed " + indexSearcher.toString()));

            }

            public void doIndexSearcherOpen(IndexSearcher indexSearcher) {
                sendNotification(new Notification("index-searcher-open", searchServiceON, notificationNo++,
                        "Opened " + indexSearcher.toString()));
            }

        });

        indexWorker.addIndexWorkerDocumentListener(new IndexWorkerDocumentListener() {

            public void indexDocumentEnd(IndexWorker worker, String ref) {
                sendNotification(new Notification("index-document-start", searchServiceON, notificationNo++,
                        "Doc Ref " + ref));
            }

            public void indexDocumentStart(IndexWorker worker, String ref) {
                sendNotification(new Notification("index-document-end", searchServiceON, notificationNo++,
                        "Doc Ref " + ref));
            }

        });

        indexWorker.addIndexWorkerListener(new IndexWorkerListener() {

            public void indexWorkerEnd(IndexWorker worker) {
                sendNotification(new Notification("index-woker-start", searchServiceON, notificationNo++,
                        "Worker " + worker));

            }

            public void indexWorkerStart(IndexWorker worker) {
                sendNotification(new Notification("index-woker-end", searchServiceON, notificationNo++,
                        "Worker " + worker));
            }

        });

    } catch (Exception ex) {
        log.warn("Failed to register mbean for search service ", ex);

    }

}