当前位置: 首页>>代码示例>>Java>>正文


Java Event.PROPERTY_ADDED属性代码示例

本文整理汇总了Java中javax.jcr.observation.Event.PROPERTY_ADDED属性的典型用法代码示例。如果您正苦于以下问题:Java Event.PROPERTY_ADDED属性的具体用法?Java Event.PROPERTY_ADDED怎么用?Java Event.PROPERTY_ADDED使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.jcr.observation.Event的用法示例。


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

示例1: onEvent

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,代码行数:22,代码来源:PostServletPrivilegesUpdateTest.java

示例2: activate

protected void activate(ComponentContext ctx) {
    try {
        session = repository.loginService("serviceUser", null);
        observationManager = session.getWorkspace().getObservationManager();

        String[] nodeTypes = {"cq:PageContent"};
        int eventTypes = Event.PROPERTY_ADDED | Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
        observationManager.addEventListener(this, eventTypes, "/content", true, null, nodeTypes, true);

        log.info("Activated JCR event listener");
    } catch (LoginException le) {
        log.error("Error activating JCR event listener: {}", le.getMessage());
    } catch (Exception e) {
        log.error("Error activating JCR event listener", e);
    }
}
 
开发者ID:HS2-SOLUTIONS,项目名称:hs2-aem-commons,代码行数:16,代码来源:PropagatePropertyInheritanceCancelled.java

示例3: onEvent

/**
 * 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,代码行数:47,代码来源:AEMConfigurationProviderImpl.java

示例4: onEvent

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,代码行数:66,代码来源:SampleJcrEventListener.java


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