javax.jcr.observation.EventListener Java Examples

The following examples show how to use javax.jcr.observation.EventListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CatalogDataResourceProviderManagerImpl.java    From commerce-cif-connector with Apache License 2.0 5 votes vote down vote up
@Activate
protected synchronized void activate(final ComponentContext ctx) throws LoginException, RepositoryException {
    // check enabled state
    if (resolver == null) {
        bundleContext = ctx.getBundleContext();
        final Map<String, Object> map = new HashMap<>();
        map.put(ResourceResolverFactory.SUBSERVICE, VIRTUAL_PRODUCTS_SERVICE);
        resolver = resolverFactory.getServiceResourceResolver(map);

        // Watch for events on the root to register/deregister virtual catalogs data roots at runtime
        // For each observed path create an event listener object which redirects the event to the main class
        final Session session = resolver.adaptTo(Session.class);
        if (session != null) {
            this.observationEventListeners = new EventListener[this.observationPaths.length];
            for (int i = 0; i < this.observationPaths.length; i++) {
                this.observationEventListeners[i] = new EventListener() {
                    public void onEvent(EventIterator events) {
                        CatalogDataResourceProviderManagerImpl.this.onEvent(events);
                    }
                };
                session.getWorkspace()
                    .getObservationManager()
                    .addEventListener(this.observationEventListeners[i],
                        Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED,
                        this.observationPaths[i],
                        // absolute path
                        true,
                        // isDeep
                        null,
                        // uuids
                        null,
                        // node types
                        true); // noLocal
            }
        }

        // register all virtual catalog data definitions that already exist
        registerDataRoots();
    }
}
 
Example #2
Source File: ObservationManagerImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void addEventListener(EventListener listener, int eventTypes, String absPath, boolean isDeep, String[] uuid, String[] nodeTypeName, boolean noLocal) throws RepositoryException {
}
 
Example #3
Source File: ObservationManagerImpl.java    From jackalope with Apache License 2.0 4 votes vote down vote up
@Override
public void removeEventListener(EventListener listener) throws RepositoryException {
}
 
Example #4
Source File: EventListenerDefinition.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @return Returns the listener.
 */
public EventListener getListener() {
    return listener;
}
 
Example #5
Source File: EventListenerDefinition.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * @param listener The listener to set.
 */
public void setListener(EventListener listener) {
    this.listener = listener;
}