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


Java Event类代码示例

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


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

示例1: activate

import javax.jcr.observation.Event; //导入依赖的package包/类
/**
 * Component activator
 *
 * @param componentContext The component context
 * @throws Exception
 */
@Activate
protected void activate(ComponentContext componentContext)
        throws Exception {
    session = repository.loginService(CONFIG_SERVICE, null);
    observationManager = session.getWorkspace().getObservationManager();
    // set up observation listener
    observationManager.addEventListener(
            this,
            Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_CHANGED | Event.PROPERTY_ADDED | Event.PROPERTY_REMOVED,
            APPS_ROOT,
            true /* isDeep */,
            null /* uuid */,
            null /* nodeTypeName */,
            true /* noLocal */
    );
    OSGiUtils.activate(this, componentContext);
}
 
开发者ID:DantaFramework,项目名称:AEM,代码行数:24,代码来源:AEMConfigurationProviderImpl.java

示例2: onEvent

import javax.jcr.observation.Event; //导入依赖的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

示例3: activate

import javax.jcr.observation.Event; //导入依赖的package包/类
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,代码行数:17,代码来源:PropagatePropertyInheritanceCancelled.java

示例4: onEvent

import javax.jcr.observation.Event; //导入依赖的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

示例5: activate

import javax.jcr.observation.Event; //导入依赖的package包/类
public void activate(String[] paths) {
  this.repositoryConnection = this.repositoryConnectionFactory.getConnection(subServiceName);
  try {
    this.observationManager = this.repositoryConnection.getSession().getWorkspace().getObservationManager();

    final String[] types = { "nt:unstructured", "nt:resource" };
    final int eventTypes = Event.PROPERTY_CHANGED;

    for (String path : paths) {
      this.observationManager.addEventListener(this, eventTypes, path, true, null, types, false);

    }
    LOG.info("Observing property changes to nodes under {}", paths);
  } catch (final RepositoryException e) {
    throw new TechnicalException("cannot actiate Preview PreviewReplicationService", e);
  }
}
 
开发者ID:sinnerschrader,项目名称:aem-react,代码行数:18,代码来源:JcrResourceChangeListener.java

示例6: onEvent

import javax.jcr.observation.Event; //导入依赖的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

示例7: onEvent

import javax.jcr.observation.Event; //导入依赖的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

示例8: activate

import javax.jcr.observation.Event; //导入依赖的package包/类
@Activate
public void activate(final Map<String, String> config) throws RepositoryException {
    componentsWithSharedProperties = new HashMap<>();

    // Schedule the initial calculation of components that have shared/global property dialogs.
    scheduleSharedComponentsMapUpdate();

    try {
        // Add an event listener on the /apps directory for component adds/removals to recalculate
        // the set of components that have shared/global property dialogs.
        respositorySession = repository.loginService(SERVICE_NAME, null);
        observationManager = respositorySession.getWorkspace().getObservationManager();

        // Need to listen for "nt:folder" else "nt:unstructured" nodes created/deleted from
        // CRD DE are not captured.
        String[] nodeTypes = {"nt:folder", "nt:unstructured"};
        int eventTypes = Event.NODE_ADDED | Event.NODE_REMOVED;
        observationManager.addEventListener(this, eventTypes, "/apps", true, null, nodeTypes, true);

        log.info("Activated JCR event listener for components with shared/global properties");
    } catch (LoginException le) {
        log.error("Could not get an admin resource resolver to listen for components with shared/global properties");
    } catch (Exception e) {
        log.error("Error activating JCR event listener for components with shared/global properties", e);
    }
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:27,代码来源:SharedComponentPropertiesPageInfoProvider.java

示例9: apply

import javax.jcr.observation.Event; //导入依赖的package包/类
@Override
public Stream<FedoraEvent> apply(final Stream<Event> events) {
    // first, index all the events by path-userID and then flatMap over that list of values
    // each of which returns either a singleton Stream or an empty Stream. The final result
    // will be a concatenated Stream of FedoraEvent objects.
    return events.collect(groupingBy(EXTRACT_NODE_ID)).entrySet().stream().flatMap(entry -> {
        final List<Event> evts = entry.getValue();
        if (!evts.isEmpty()) {
            // build a FedoraEvent from the first JCR Event
            final FedoraEvent fedoraEvent = from(evts.get(0));
            evts.stream().skip(1).forEach(evt -> {
                // add types to the FedoraEvent from the subsequent JCR Events
                fedoraEvent.getTypes().add(FedoraEventImpl.valueOf(evt.getType()));
                fedoraEvent.getResourceTypes().addAll(getResourceTypes(evt).collect(toSet()));
            });
            return of(fedoraEvent);
        }
        return empty();
    });
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:21,代码来源:AllNodeEventsOneEvent.java

示例10: onEvent

import javax.jcr.observation.Event; //导入依赖的package包/类
/**
 * Filter JCR events and transform them into our own FedoraEvents.
 *
 * @param events the JCR events
 */
@Override
public void onEvent(final javax.jcr.observation.EventIterator events) {
    Session lookupSession = null;
    try {
        lookupSession = getJcrSession(repository.login());

        @SuppressWarnings("unchecked")
        final Iterator<Event> filteredEvents = filter(events, eventFilter::test);
        eventMapper.apply(iteratorToStream(filteredEvents))
            .map(filterAndDerefResourceTypes(lookupSession))
            .flatMap(handleMoveEvents(lookupSession))
            .forEach(this::post);
    } finally {
        if (lookupSession != null) {
            lookupSession.logout();
        }
    }
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:24,代码来源:SimpleObserver.java

示例11: getResourceTypes

import javax.jcr.observation.Event; //导入依赖的package包/类
/**
 * Get the RDF Types of the resource corresponding to this JCR Event
 * @param event the JCR event
 * @return the types recorded on the resource associated to this event
 */
public static Stream<String> getResourceTypes(final Event event) {
    if (event instanceof org.modeshape.jcr.api.observation.Event) {
        try {
            final org.modeshape.jcr.api.observation.Event modeEvent =
                    (org.modeshape.jcr.api.observation.Event) event;
            final Stream.Builder<NodeType> types = Stream.builder();
            for (final NodeType type : modeEvent.getMixinNodeTypes()) {
                types.add(type);
            }
            types.add(modeEvent.getPrimaryNodeType());
            return types.build().map(NodeType::getName);
        } catch (final RepositoryException e) {
            throw new RepositoryRuntimeException(e);
        }
    }
    return empty(); // wasn't a ModeShape event, so we have no access to resource types
}
 
开发者ID:fcrepo4,项目名称:fcrepo4,代码行数:23,代码来源:FedoraEventImpl.java

示例12: onEvent

import javax.jcr.observation.Event; //导入依赖的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

示例13: activate

import javax.jcr.observation.Event; //导入依赖的package包/类
@Activate
private void activate() throws RepositoryException {
    session = newSession();
    session.getWorkspace().getObservationManager().addEventListener(this, Event.NODE_ADDED, "/content",
            true,
            null, new String[]{"nt:file"}, true);
}
 
开发者ID:bdelacretaz,项目名称:sling-adaptto-2016,代码行数:8,代码来源:AssetChangeListener.java

示例14: createBody

import javax.jcr.observation.Event; //导入依赖的package包/类
@Override
protected Object createBody() {
    if (eventList == null) {
        eventList = new LinkedList<Event>();

        if (eventIterator != null) {
            while (eventIterator.hasNext()) {
                eventList.add(eventIterator.nextEvent());
            }
        }
    }

    return eventList;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:JcrMessage.java

示例15: postProcess

import javax.jcr.observation.Event; //导入依赖的package包/类
@Override
protected void postProcess(BeanDefinitionBuilder definitionBuilder, Element element) {
    List<Element> eventTypes = DomUtils.getChildElementsByTagName(element, EVENT_TYPE);
    if (eventTypes != null && eventTypes.size() > 0) {
        // compute event type
        int eventType = 0;
        Constants types = new Constants(Event.class);
        for (Iterator<Element> iter = eventTypes.iterator(); iter.hasNext();) {
            Element evenTypeElement = iter.next();
            eventType |= types.asNumber(DomUtils.getTextValue(evenTypeElement)).intValue();
        }
        definitionBuilder.addPropertyValue("eventTypes", Integer.valueOf(eventType));
    }

    List<Element> nodeTypeNames = DomUtils.getChildElementsByTagName(element, NODE_TYPE_NAME);
    String[] nodeTypeValues = new String[nodeTypeNames.size()];

    for (int i = 0; i < nodeTypeValues.length; i++) {
        nodeTypeValues[i] = DomUtils.getTextValue(nodeTypeNames.get(i));
    }
    definitionBuilder.addPropertyValue(NODE_TYPE_NAME, nodeTypeValues);
    List<Element> uuids = DomUtils.getChildElementsByTagName(element, UUID);

    String[] uuidsValues = new String[uuids.size()];

    for (int i = 0; i < uuidsValues.length; i++) {
        uuidsValues[i] = DomUtils.getTextValue(uuids.get(i));
    }

    definitionBuilder.addPropertyValue(UUID, uuidsValues);
    //TODO, reference a listenerBean, it is not a propertyReference
    Element eventListner = DomUtils.getChildElementByTagName(element, "listener");
    String listenerBeanRefName = DomUtils.getTextValue(eventListner);

    definitionBuilder.addPropertyReference("listener", listenerBeanRefName);
}
 
开发者ID:MyCollab,项目名称:mycollab,代码行数:37,代码来源:JcrNamespaceHandler.java


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