本文整理汇总了Java中javax.jcr.Workspace.getObservationManager方法的典型用法代码示例。如果您正苦于以下问题:Java Workspace.getObservationManager方法的具体用法?Java Workspace.getObservationManager怎么用?Java Workspace.getObservationManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.jcr.Workspace
的用法示例。
在下文中一共展示了Workspace.getObservationManager方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addListeners
import javax.jcr.Workspace; //导入方法依赖的package包/类
/**
* 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
*/
private Session addListeners(Session session) throws RepositoryException {
if (getRepository() == null) {
throw new IllegalArgumentException("repository is required");
}
if (eventListeners != null && eventListeners.length > 0) {
if (!supportsObservation(getRepository())) {
throw new IllegalArgumentException("repository " + getRepositoryInfo() + " does NOT support Observation; remove Listener definitions");
}
Workspace ws = session.getWorkspace();
ObservationManager manager = ws.getObservationManager();
for (EventListenerDefinition eventListener : eventListeners) {
manager.addEventListener(eventListener.getListener(), eventListener.getEventTypes(), eventListener.getAbsPath(), eventListener.isDeep(), eventListener.getUuid(), eventListener.getNodeTypeName(), eventListener.isNoLocal());
}
}
return session;
}
示例2: addListeners
import javax.jcr.Workspace; //导入方法依赖的package包/类
/**
* 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;
}