• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EventIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中javax.jcr.observation.EventIterator的典型用法代码示例。如果您正苦于以下问题:Java EventIterator类的具体用法?Java EventIterator怎么用?Java EventIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



EventIterator类属于javax.jcr.observation包,在下文中一共展示了EventIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
public void onEvent(EventIterator eventIterator) {
	try {
		while (eventIterator.hasNext()) {
			Event event = eventIterator.nextEvent();
			int type = event.getType();
			switch (type) {
				case Event.PROPERTY_CHANGED:
					changedProperties.add(event.getPath());
					break;
				case Event.PROPERTY_ADDED:
					addedProperties.add(event.getPath());
					break;
				case Event.PROPERTY_REMOVED:
					removedProperties.add(event.getPath());
					break;
			}
		}
		eventBundlesProcessed++;
	} catch (RepositoryException e) {
		fail(e.getMessage());
	}
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-launchpad-integration-tests,代码行数:23,代码来源:PostServletPrivilegesUpdateTest.java


示例2: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(EventIterator events) {
    while (events.hasNext()) {
        try {
            Event event = events.nextEvent();
            //Event path is for child node. So parent path is for actual node
            String nodeName = PathUtils.getName(PathUtils.getParentPath(event.getPath()));
            if (!nodeName.equals("original")){
                return;
            }
            //Path like foo.jpg/jcr:content/renditions/original/jcr:content
            String assetPath = PathUtils.getAncestorPath(event.getPath(), 4);
            jobManager.newJobBuilder(
                    Types.jobQueue("org/apache/sling/jobs/assets"),
                    Types.jobType("assets/generate/renditions")) //Defined in RenditionJobConsumer
                    .addProperties(ImmutableMap.<String, Object>of("path", assetPath))
                    .add();
            log.info("Scheduled rendition generation job for path [{}]", assetPath);
        } catch (RepositoryException e) {
            throw new RuntimeException(e);
        }
    }
}
 
开发者ID:bdelacretaz,项目名称:sling-adaptto-2016,代码行数:24,代码来源:AssetChangeListener.java


示例3: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(EventIterator events) {
	
	while( events.hasNext()){
		Event event = events.nextEvent();
		
		try {
			String path = event.getPath();
			CardHolder cardHolder = new CardHolder(path);
			if(cardHolder.isValid()){
				addCardHolder(cardHolder);
			}
		} catch (RepositoryException e) {
			e.printStackTrace();
		}
	}		
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:18,代码来源:CardListener.java


示例4: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
/**
 * Listen for add/update/delete of shared dialog nodes, in order to trigger an update of the
 * map of components that have shared property dialogs.
 *
 * Technically a delete may not be caught if a node higher in the ancestry is deleted (thus
 * deleting its children) but having a stale entry in the map does not cause any problems.
 */
@Override
public void onEvent(EventIterator eventIterator) {
    while (eventIterator.hasNext()) {
        Event event = eventIterator.nextEvent();
        try {
            String[] pathPieces = event.getPath().split("/");
            String nodeName = pathPieces[pathPieces.length - 1];
            switch (nodeName) {
                case "dialogglobal":
                case "dialogshared":
                case "dialog_global":
                case "dialog_shared":
                    scheduleSharedComponentsMapUpdate();
                    break;

                default:
                    break;
            }
        } catch (Exception e) {
            log.error("Error determining if event affects list of components with shared/global properties", e);
        }
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:31,代码来源:SharedComponentPropertiesPageInfoProvider.java


示例5: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(EventIterator itr) {
    while (itr.hasNext()) {
        Event event = itr.nextEvent();
        try {
            if (event.getPath().endsWith("/" + CANCELLED_INHERITANCE_PROPERTY)) {
                Map eventInfo = event.getInfo();

                Set<String> deepPropsBefore = collectDeepProps((Value[]) eventInfo.get("beforeValue"));
                Set<String> deepPropsAfter = collectDeepProps((Value[]) eventInfo.get("afterValue"));

                // De-dupe the lists so we can tell which props are added and which are removed
                for (String propAfter : deepPropsAfter.toArray(new String[deepPropsAfter.size()])) {
                    if (deepPropsBefore.contains(propAfter)) {
                        deepPropsBefore.remove(propAfter);
                        deepPropsAfter.remove(propAfter);
                    }
                }

                if (deepPropsAfter.size() > 0 || deepPropsBefore.size() > 0) {
                    String parentPath = StringUtils.substring(event.getPath(), 0, -1 * (CANCELLED_INHERITANCE_PROPERTY_LEN + 1));
                    session.refresh(true);
                    Node pageContentNode = session.getNode(parentPath);

                    for (String propAdded : deepPropsAfter) {
                        addOrRemoveProp(pageContentNode, propAdded, true);
                    }

                    for (String propRemoved : deepPropsBefore) {
                        addOrRemoveProp(pageContentNode, propRemoved, false);
                    }
                }
            }
        } catch (Exception e) {
            log.error("Error propagating cq:propertyInheritanceCancelled for deep properties to child nodes", e);
        }
    }
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:39,代码来源:PropagatePropertyInheritanceCancelled.java


示例6: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(EventIterator itr) {
  try {
    this.listener.changed(itr.nextEvent().getPath());
  } catch (RepositoryException e) {
    LOG.error("erorr when observing resource", e);
  }
}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:9,代码来源:JcrResourceChangeListener.java


示例7: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
/**
 * Trigger on event
 *
 * @param eventIterator The event iterator object
 */
@Override
public void onEvent(EventIterator eventIterator) {
    ResourceResolver resourceResolver = null;
    try {
        Map<String, Object> authenticationInfo = new HashMap<String, Object>();
        authenticationInfo.put(ResourceResolverFactory.SUBSERVICE, CONFIG_SERVICE);
        resourceResolver = resourceResolverFactory.getServiceResourceResolver(authenticationInfo);

        ComponentManager componentManager = resourceResolver.adaptTo(ComponentManager.class);
        if (resourceResolver != null) {
            while (eventIterator.hasNext()) {
                Event event = eventIterator.nextEvent();
                String path = event.getPath();
                switch (event.getType()) {
                    case Event.PROPERTY_REMOVED:
                    case Event.NODE_REMOVED:
                    case Event.PROPERTY_CHANGED:
                    case Event.PROPERTY_ADDED:
                        path = path.substring(0, path.lastIndexOf('/'));
                        break;
                    case Event.NODE_MOVED:
                        path = event.getInfo().get("srcChildRelPath").toString();
                        break;
                    case Event.NODE_ADDED:
                    default:
                }
                Resource resource = resourceResolver.getResource(path);
                if (resource != null) {
                    com.day.cq.wcm.api.components.Component component = ResourceUtils.findContainingComponent(resource);
                    if (component != null) {
                        configCache.clear();
                    }
                }
            }
        }
    } catch (Exception ew) {
        LOG.error(ERROR, ew);
    } finally {
        if (resourceResolver != null)
            resourceResolver.close();
    }
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:48,代码来源:AEMConfigurationProviderImpl.java


示例8: createExchange

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
private Exchange createExchange(EventIterator events) {
    Exchange exchange = endpoint.createExchange();
    exchange.setIn(new JcrMessage(events));
    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:6,代码来源:EndpointEventListener.java


示例9: JcrMessage

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
public JcrMessage(EventIterator eventIterator) {
    this.eventIterator = eventIterator;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:JcrMessage.java


示例10: getEventIterator

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
public EventIterator getEventIterator() {
    return eventIterator;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:JcrMessage.java


示例11: testJcrConsumer

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Test
public void testJcrConsumer() throws Exception {
    // start consumer thread first
    JcrConsumerThread consumerThread = new JcrConsumerThread();
    consumerThread.start();
    // wait until the consumer thread has tried to receive event at least once
    while (consumerThread.getReceiveTrialTimes() < 1) {
        Thread.sleep(10L);
    }

    // now create a node under the specified event node path

    Session session = openSession();

    try {
        Node folderNode = session.getRootNode();

        for (String folderNodeName : absPath.split("\\/")) {
            if (!"".equals(folderNodeName)) {
                if (folderNode.hasNode(folderNodeName)) {
                    folderNode.getNode(folderNodeName).remove();
                }

                folderNode = folderNode.addNode(folderNodeName, "nt:unstructured");
            }
        }

        folderNode.addNode("node", "nt:unstructured");
        session.save();
    } finally {
        if (session != null && session.isLive()) {
            session.logout();
        }
    }

    // wait until the consumer thread captures an event
    consumerThread.join();

    Exchange exchange = consumerThread.getExchange();
    assertNotNull(exchange);

    Message message = exchange.getIn();
    assertNotNull(message);
    assertTrue(message instanceof JcrMessage);
    EventIterator eventIterator = ((JcrMessage)message).getEventIterator();
    assertNotNull(eventIterator);
    assertEquals(1, eventIterator.getSize());

    List<?> eventList = message.getBody(List.class);
    assertEquals(1, eventList.size());
    Event event = (Event) eventList.get(0);
    assertEquals(Event.NODE_ADDED, event.getType());
    assertNotNull(event.getPath());
    assertTrue(event.getPath().startsWith(absPath));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:56,代码来源:JcrConsumerTest.java


示例12: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(final EventIterator events) {
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:4,代码来源:LongResourceResolverEvenListenerError.java


示例13: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
@Override
public void onEvent(EventIterator events) {
	throw new UnsupportedOperationException("Not supported yet.");
}
 
开发者ID:Cognifide,项目名称:AEM-Rules-for-SonarQube,代码行数:5,代码来源:LongSessionService.java


示例14: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
public void onEvent(final EventIterator events) {
    // Handle events
    while (events.hasNext()) {
        try {
            Event event = events.nextEvent();

            // IMPORTANT!
            //
            // JCR Events are NOT cluster-aware and this event listener will be invoked on every node in the cluster.

            // Check if this event was spawned from the server this event handler is running on or from another
            if (event instanceof JackrabbitEvent && ((JackrabbitEvent) event).isExternal()) {
                // Event did NOT originate from this server

                // Skip, Let only the originator process;

                // This is usual to avoid having the same processing happening for every node in a cluster. This
                // is almost always the case when the EventListener modifies the JCR.

                // A possible use-case for handling the event on EVERY member of a cluster would be clearing out an
                // in memory (Service-level) cache.

                return;
            } else {
                // Event originated from THIS server
                // Continue processing this Event
            }

            final String path = event.getPath();

            if (Event.NODE_ADDED == event.getType()) {
                // Node added!
            } else if (Event.PROPERTY_ADDED == event.getType()) {
                // Property added!
            }

            // Dummy variable; You'd never conditionally pick the approach in real code.
            boolean handleAsJcrEvent = true;

            if (handleAsJcrEvent) {
                // Execute handler logic in this event handler...

                // Make sure you handle this quickly else your event handler may get blacklisted!

                // Get a resourceResolver or JCR Session using the usual ways
                // Always make sure to close them if you open them though!

                // ... do some work
            } else {
                // Alternatively to doing work in the event, you can kick off a new Sling Event OR Job

                // Example of kicking off a Sling Event which will then pick up and do the work via a Sling Event
                // Listener; Generally this can be simply avoided by making a Sling Event Handler directly.

                final Map<String, Object> jobProperties = new HashMap<String, Object>();
                jobProperties.put("resourcePath", path);

                // Kick off a new job based on the event
                jobManager.addJob("com/adobe/acs/samples/sample-job", jobProperties);
            }

        } catch (RepositoryException ex) {
            log.error("Something bad happened!", ex);
        }
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-samples,代码行数:67,代码来源:SampleJcrEventListener.java


示例15: onEvent

import javax.jcr.observation.EventIterator; //导入依赖的package包/类
public void onEvent(EventIterator eventIterator) {

        //TODO when greg internally can track events occured we can put code here what to do on an occurance of an event
    }
 
开发者ID:wso2,项目名称:carbon-registry,代码行数:5,代码来源:RegistryEventListener.java



注:本文中的javax.jcr.observation.EventIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GeneratorType类代码示例发布时间:2022-05-22
下一篇:
Java Quantile类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap