javax.jcr.observation.ObservationManager Java Examples

The following examples show how to use javax.jcr.observation.ObservationManager. 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: LongSessionEventListener.java    From AEM-Rules-for-SonarQube with Apache License 2.0 6 votes vote down vote up
@Deactivate
public void deactivate(final Map<String, String> config) throws RepositoryException {
    try {
        final ObservationManager observationManager = observationSession.getWorkspace().getObservationManager();

        if (observationManager != null) {
            observationManager.removeEventListener(this);
        }
    } finally {
        if (observationSession != null) {
            observationSession.logout();
        }
        if (resolver != null) {
            resolver.close();
        }
    }
}
 
Example #2
Source File: JcrSessionFactory.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Hook for adding listeners to the newly returned session. We have to treat
 * exceptions manually and can't reply on the template.
 * 
 * @param session
 *            JCR session
 * @return the listened session
 * @throws javax.jcr.RepositoryException
 */
protected Session addListeners(Session session) throws RepositoryException {
	if (eventListeners != null && eventListeners.length > 0) {
		Workspace ws = session.getWorkspace();
		ObservationManager manager = ws.getObservationManager();

		LOG.debug("adding listeners "
				+ Arrays.asList(eventListeners).toString()
				+ " for session " + session);

		for (int i = 0; i < eventListeners.length; i++) {
			manager.addEventListener(eventListeners[i].getListener(),
					eventListeners[i].getEventTypes(),
					eventListeners[i].getAbsPath(),
					eventListeners[i].isDeep(),
					eventListeners[i].getUuid(),
					eventListeners[i].getNodeTypeName(),
					eventListeners[i].isNoLocal());
		}
	}
	return session;
}
 
Example #3
Source File: LongSessionEventListenerError.java    From AEM-Rules-for-SonarQube with Apache License 2.0 5 votes vote down vote up
@Deactivate
public void deactivate(final Map<String, String> config) throws RepositoryException {
    final ObservationManager observationManager = observationSession.getWorkspace().getObservationManager();

    if (observationManager != null) {
        observationManager.removeEventListener(this);
    }
}
 
Example #4
Source File: WorkspaceImpl.java    From jackalope with Apache License 2.0 5 votes vote down vote up
@Override
public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException, RepositoryException {
    if (observationManager == null) {
        observationManager = new ObservationManagerImpl();
    }
    return observationManager;
}
 
Example #5
Source File: WorkspaceWrapper.java    From sling-whiteboard with Apache License 2.0 4 votes vote down vote up
@Override
public ObservationManager getObservationManager() throws UnsupportedRepositoryOperationException, RepositoryException {
    return delegate.getObservationManager();
}
 
Example #6
Source File: LongSessionEventListenerError.java    From AEM-Rules-for-SonarQube with Apache License 2.0 4 votes vote down vote up
@Activate
public void activate(final Map<String, String> config) throws RepositoryException {
    observationSession = repository.loginAdministrative(null);
    final ObservationManager observationManager = observationSession.getWorkspace().getObservationManager();
}
 
Example #7
Source File: LongSessionEventListener.java    From AEM-Rules-for-SonarQube with Apache License 2.0 4 votes vote down vote up
@Activate
public void activate(final Map<String, String> config) throws RepositoryException, LoginException {
    observationSession = repository.loginAdministrative(null);
    final ObservationManager observationManager = observationSession.getWorkspace().getObservationManager();
    resolver = resourceResolverFactory.getAdministrativeResourceResolver(null);
}