本文整理了Java中org.osgi.service.event.Event.getTopic()
方法的一些代码示例,展示了Event.getTopic()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Event.getTopic()
方法的具体详情如下:
包路径:org.osgi.service.event.Event
类名称:Event
方法名:getTopic
[英]Returns the topic of this event.
[中]返回此事件的主题。
代码示例来源:origin: openhab/openhab1-addons
@Override
public void handleEvent(Event event) {
String itemName = (String) event.getProperty("item");
String topic = event.getTopic();
String[] topicParts = topic.split(TOPIC_SEPERATOR);
if (!(topicParts.length > 2) || !topicParts[0].equals(TOPIC_PREFIX)) {
return; // we have received an event with an invalid topic
}
String operation = topicParts[1];
if (operation.equals(EventType.UPDATE.toString())) {
State newState = (State) event.getProperty("state");
if (newState != null) {
receiveUpdate(itemName, newState);
}
}
if (operation.equals(EventType.COMMAND.toString())) {
Command command = (Command) event.getProperty("command");
if (command != null) {
receiveCommand(itemName, command);
}
}
}
代码示例来源:origin: osgi/osgi.enroute.examples
@Override
public void handleEvent(Event event) {
System.out.println("Event: " + event.getTopic());
}
}
代码示例来源:origin: apache/karaf
@Override
public boolean test(Event event) {
return pattern.matcher(event.getTopic()).matches();
}
代码示例来源:origin: org.apache.sling/org.apache.sling.event
/**
* @see org.osgi.service.event.EventHandler#handleEvent(org.osgi.service.event.Event)
*/
public void handleEvent(final Event event) {
if ( ResourceHelper.BUNDLE_EVENT_STARTED.equals(event.getTopic())
|| ResourceHelper.BUNDLE_EVENT_UPDATED.equals(event.getTopic()) ) {
this.scheduledJobHandler.bundleEvent();
}
}
代码示例来源:origin: joerghoh/cq5-healthcheck
public void handleEvent(Event event) {
totalCounter++;
String topic = event.getTopic();
if (topic.startsWith(SLING_RESOURCE_EVENTS)) {
resourceCounter++;
}
if (topic.startsWith(REPLICATION_EVENTS)) {
replicationEventCounter++;
}
if (topic.startsWith(OSGI_EVENTS)) {
osgiEventCounter++;
}
}
代码示例来源:origin: apache/karaf
private String _subtype() {
String topic = event.getTopic();
String subtype = topic.substring(topic.lastIndexOf('/') + 1).toLowerCase(Locale.ENGLISH);
if (subtype.startsWith("log_")) {
subtype = subtype.substring("log_".length());
}
return subtype;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.launchpad.test-services
public synchronized void handleEvent(Event event) {
final String topic = event.getTopic();
AtomicInteger counter = counters.get(topic);
if(counter == null) {
counter = new AtomicInteger();
counters.put(topic, counter);
}
counter.incrementAndGet();
log.debug("{} counter is now {}", topic, counter.get());
}
代码示例来源:origin: apache/karaf
@Override
public void accept(Event event) {
out.println(getTimeStamp(event) + " - " + event.getTopic());
if (verbose) {
for (String key : event.getPropertyNames()) {
if (!key.equals("event.topics") && !key.equals("timestamp")) {
out.println(key + ": " + getPrintValue(event, key));
}
}
out.println();
out.flush();
}
}
代码示例来源:origin: org.opendaylight.controller/blueprint
@Override
public void handleEvent(Event event) {
LOG.debug("handleEvent {} for bundle {}", event.getTopic(), event.getProperty(EventConstants.BUNDLE));
if(containerBundles.contains(event.getProperty(EventConstants.BUNDLE))) {
containerCreationComplete.countDown();
}
}
});
代码示例来源:origin: io.wcm/io.wcm.dam.asset-service
@Override
public void handleEvent(Event event) {
if (!StringUtils.equals(event.getTopic(), DamEvent.EVENT_TOPIC)) {
return;
}
DamEvent damEvent = DamEvent.fromEvent(event);
damPathHandler.handleDamEvent(damEvent);
}
代码示例来源:origin: io.wcm/io.wcm.handler.media
@Override
public void handleEvent(Event event) {
if (!enabled || !StringUtils.equals(event.getTopic(), DamEvent.EVENT_TOPIC)) {
return;
}
DamEvent damEvent = DamEvent.fromEvent(event);
if (SUPPORTED_EVENT_TYPES.contains(damEvent.getType())) {
handleDamEvent(damEvent);
}
}
代码示例来源:origin: org.apache.felix/org.apache.felix.eventadmin
/**
* This method checks whether the given (i.e., calling) bundle has
* appropriate permissions to send an event to the targeted topic. A
* <tt>SecurityException</tt> is thrown in case it has not. Otherwise,
* the event is posted using this decorator's service instance.
*
* @param event The event that should be send
*
* @see org.osgi.service.event.EventAdmin#sendEvent(org.osgi.service.event.Event)
*/
public void sendEvent(final Event event)
{
checkPermission(event.getTopic());
m_admin.sendEvent(event);
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-tools
public void handleEvent(Event event) {
String topic = event.getTopic();
if (topic.equals(SlingConstants.TOPIC_RESOURCE_CHANGED)) {
try {
String path = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
log.debug("script reload {}", path);
server.triggerReload(path);
} catch (JSONException e) {
log.error("unable to reload from jsp", e);
}
} else if (scriptChangeListenerRegistration != null) {
registerOrUpdate(getProperties());
}
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/org.eclipse.equinox.app
private Map getArguments(Event trigger) {
Map result = args == null ? new HashMap() : getArguments();
result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic())));
return result;
}
代码示例来源:origin: com.adobe.acs/acs-aem-tools-bundle-livereload
public void handleEvent(Event event) {
String topic = event.getTopic();
if (topic.equals(SlingConstants.TOPIC_RESOURCE_CHANGED)) {
try {
String path = (String) event.getProperty(SlingConstants.PROPERTY_PATH);
log.debug("script reload {}", path);
server.triggerReload(path);
} catch (JSONException e) {
log.error("unable to reload from jsp", e);
}
} else if (scriptChangeListenerRegistration != null) {
registerOrUpdate(getProperties());
}
}
代码示例来源:origin: org.eclipse.platform/org.eclipse.equinox.app
private Map getArguments(Event trigger) {
Map result = args == null ? new HashMap() : getArguments();
result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic())));
return result;
}
代码示例来源:origin: com.github.veithen.cosmos.bootstrap/org.eclipse.equinox.app
private Map getArguments(Event trigger) {
Map result = args == null ? new HashMap() : getArguments();
result.put(TRIGGERING_EVENT, new GuardedObject(trigger, new TriggerGuard(trigger.getTopic())));
return result;
}
代码示例来源:origin: org.apache.sling/org.apache.sling.distribution.core
public void handleEvent(Event event) {
DistributionRequestType action = SlingConstants.TOPIC_RESOURCE_REMOVED.equals(event.getTopic()) ?
DistributionRequestType.DELETE : DistributionRequestType.ADD;
log.info("triggering distribution from event {}", event);
for (String pn : event.getPropertyNames()) {
log.info("property {} : {}", pn, event.getProperty(pn));
}
Object pathProperty = event.getProperty("path");
if (pathProperty != null) {
String distributingPath = String.valueOf(pathProperty);
requestHandler.handle(null, new SimpleDistributionRequest(action, distributingPath));
}
}
}
代码示例来源:origin: apache/ace
@Override
public void sendEvent(Event event) {
getEventsHandler().sendEvent(event.getTopic(), getPayload(event));
invokeExternalEventAdmin("sendEvent", event);
}
代码示例来源:origin: apache/ace
@Override
public void postEvent(Event event) {
getEventsHandler().postEvent(event.getTopic(), getPayload(event));
invokeExternalEventAdmin("postEvent", event);
}
内容来源于网络,如有侵权,请联系作者删除!