Search in sources :

Example 1 with UpdateListener

use of org.exist.storage.UpdateListener in project exist by eXist-db.

the class LocationStep method registerUpdateListener.

/**
 * Register the update listener
 */
protected void registerUpdateListener() {
    if (listener == null) {
        listener = new UpdateListener() {

            @Override
            public void documentUpdated(final DocumentImpl document, final int event) {
                cached = null;
                if (document == null || event == UpdateListener.ADD || event == UpdateListener.REMOVE) {
                    // clear all
                    currentDocs = null;
                    currentSet = null;
                } else {
                    if (currentDocs != null && currentDocs.contains(document.getDocId())) {
                        currentDocs = null;
                        currentSet = null;
                    }
                }
            }

            @Override
            public void nodeMoved(final NodeId oldNodeId, final NodeHandle newNode) {
            // no-op
            }

            @Override
            public void unsubscribe() {
                LocationStep.this.listener = null;
            }

            @Override
            public void debug() {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("UpdateListener: Line: {}; id: {}", LocationStep.this.toString(), LocationStep.this.getExpressionId());
                }
            }
        };
        context.registerUpdateListener(listener);
    }
}
Also used : NodeId(org.exist.numbering.NodeId) UpdateListener(org.exist.storage.UpdateListener)

Example 2 with UpdateListener

use of org.exist.storage.UpdateListener in project exist by eXist-db.

the class FunDoc method registerUpdateListener.

protected void registerUpdateListener() {
    if (listener == null) {
        listener = new UpdateListener() {

            @Override
            public void documentUpdated(DocumentImpl document, int event) {
            // clear all
            }

            @Override
            public void unsubscribe() {
                FunDoc.this.listener = null;
            }

            public void nodeMoved(NodeId oldNodeId, NodeHandle newNode) {
            // not relevant
            }

            @Override
            public void debug() {
                logger.debug("UpdateListener: Line: {}: {}", getLine(), FunDoc.this.toString());
            }
        };
        context.registerUpdateListener(listener);
    }
}
Also used : NodeHandle(org.exist.dom.persistent.NodeHandle) NodeId(org.exist.numbering.NodeId) UpdateListener(org.exist.storage.UpdateListener) DocumentImpl(org.exist.dom.persistent.DocumentImpl)

Example 3 with UpdateListener

use of org.exist.storage.UpdateListener in project exist by eXist-db.

the class ExtCollection method registerUpdateListener.

protected void registerUpdateListener() {
    if (listener == null) {
        listener = new UpdateListener() {

            @Override
            public void documentUpdated(final DocumentImpl document, final int event) {
            // Nothing to do (previously was cache management)
            }

            @Override
            public void unsubscribe() {
                ExtCollection.this.listener = null;
            }

            @Override
            public void nodeMoved(final NodeId oldNodeId, final NodeHandle newNode) {
            // not relevant
            }

            @Override
            public void debug() {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("UpdateListener: Line: {}: {}", getLine(), ExtCollection.this.toString());
                }
            }
        };
        context.registerUpdateListener(listener);
    }
}
Also used : NodeId(org.exist.numbering.NodeId) UpdateListener(org.exist.storage.UpdateListener)

Example 4 with UpdateListener

use of org.exist.storage.UpdateListener in project exist by eXist-db.

the class RootNode method registerUpdateListener.

protected void registerUpdateListener() {
    if (listener == null) {
        listener = new UpdateListener() {

            @Override
            public void documentUpdated(DocumentImpl document, int event) {
                // clear all
                cachedDocs = null;
                cached = null;
            }

            @Override
            public void unsubscribe() {
                RootNode.this.listener = null;
            }

            @Override
            public void nodeMoved(NodeId oldNodeId, NodeHandle newNode) {
            // not relevant
            }

            @Override
            public void debug() {
                LOG.debug("UpdateListener: Line: {}", RootNode.this.toString());
            }
        };
        context.registerUpdateListener(listener);
    }
}
Also used : NodeHandle(org.exist.dom.persistent.NodeHandle) NodeId(org.exist.numbering.NodeId) UpdateListener(org.exist.storage.UpdateListener) DocumentImpl(org.exist.dom.persistent.DocumentImpl)

Aggregations

NodeId (org.exist.numbering.NodeId)4 UpdateListener (org.exist.storage.UpdateListener)4 DocumentImpl (org.exist.dom.persistent.DocumentImpl)2 NodeHandle (org.exist.dom.persistent.NodeHandle)2