本文整理匯總了Java中org.osgi.service.event.Event類的典型用法代碼示例。如果您正苦於以下問題:Java Event類的具體用法?Java Event怎麽用?Java Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Event類屬於org.osgi.service.event包,在下文中一共展示了Event類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: activate
import org.osgi.service.event.Event; //導入依賴的package包/類
@Activate
public void activate(ComponentContext context) {
Dictionary<String, Object> config = context.getProperties();
this.topic = (String)config.get("topic");
if (topic == null) {
throw new IllegalArgumentException("Config property topic must be present.");
}
String eventTopics = (String)config.get(EventConstants.EVENT_TOPIC);
Publisher<Event> fromEventAdmin = eventAdmin.from(eventTopics, Event.class);
toKafka = kafka.to(topic, ProducerRecord.class);
org.slf4j.MDC.put("inLogAppender", "true");
Flux.from(fromEventAdmin)
.doOnEach(event -> org.slf4j.MDC.put("inLogAppender", "true"))
//.log()
.map(event->toRecord(event))
.doOnError(ex -> LOGGER.error(ex.getMessage(), ex))
.subscribe(toKafka);
LOGGER.info("Kafka appender started. Listening on topic " + topic);
}
示例2: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
String[] propertyNames = event.getPropertyNames();
//System.out.println(event.getProperty(propertyNames[0]));
IStyledTextGazeResponse response = (IStyledTextGazeResponse)event.getProperty(propertyNames[0]);
Rectangle mBounds = ITrace.getDefault().getRootShell().getBounds();
int screenX = (int) (response.getGaze().getX() * mBounds.width);
int screenY = (int) (response.getGaze().getY() * mBounds.height);
//Rectangle monitorBounds = ITrace.getDefault().monitorBounds;
if(styledText.isDisposed()) return;
Rectangle editorBounds = styledText.getBounds();
Point screenPos = styledText.toDisplay(0, 0);
editorBounds.x = screenPos.x - mBounds.x;
editorBounds.y = screenPos.y - mBounds.y;
if(editorBounds.contains(screenX, screenY)){
int relativeX = screenX-editorBounds.x;
int relativeY = screenY-editorBounds.y;
update(response.getLine()-1,response.getCol(), relativeX, relativeY);
}
}
示例3: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
/**
* Implemented from EventHandler to listen for blueprint events.
*
* @param event the event to handle
*/
@Override
public void handleEvent(final Event event) {
if (EventConstants.TOPIC_CREATED.equals(event.getTopic())) {
LOG.info("Blueprint container for bundle {} was successfully created",
event.getProperty(EventConstants.BUNDLE));
return;
}
// If the container timed out waiting for dependencies, we'll destroy it and start it again. This
// is indicated via a non-null DEPENDENCIES property containing the missing dependencies. The
// default timeout is 5 min and ideally we would set this to infinite but the timeout can only
// be set at the bundle level in the manifest - there's no way to set it globally.
if (EventConstants.TOPIC_FAILURE.equals(event.getTopic())
&& event.getProperty(EventConstants.DEPENDENCIES) != null) {
Bundle bundle = (Bundle) event.getProperty(EventConstants.BUNDLE);
List<Object> paths = findBlueprintPaths(bundle);
if (!paths.isEmpty()) {
LOG.warn("Blueprint container for bundle {} timed out waiting for dependencies - restarting it",
event.getProperty(EventConstants.BUNDLE));
restartService.restartContainer(bundle, paths);
}
}
}
示例4: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
String topic = event.getTopic();
Object target = event.getProperty(MafiaBossConstants.PROPERTY_KEY_TARGET);
switch (topic) {
case MafiaBossConstants.TOPIC_CONVINCE:
System.out.println("Ray: I helped in punching the shit out of" + target);
break;
case MafiaBossConstants.TOPIC_ENCASH:
System.out.println("Ray: I helped getting the money from " + target);
break;
case MafiaBossConstants.TOPIC_SOLVE:
System.out.println("Ray: I helped killing " + target);
break;
default: System.out.println("Ray: I helped with whatever was requested!");
}
}
示例5: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
logger.debug("Started handling task status.");
ITaskStatusMessage message = (ITaskStatusMessage) event.getProperty("message");
ICommandExecutionResult result = (ICommandExecutionResult) event.getProperty("result");
logger.info("Sending task status message to plugins. Task: {} Status: {}",
new Object[] { message.getTaskId(), message.getResponseCode() });
ITask task = result.getCommandExecution().getCommand().getTask();
String key = buildKey(task.getPlugin().getName(), task.getPlugin().getVersion(), task.getCommandClsId());
ITaskAwareCommand subscriber = subscribers != null ? subscribers.get(key.toUpperCase(Locale.ENGLISH)) : null;
if (subscriber != null) {
try {
subscriber.onTaskUpdate(result);
logger.debug("Notified subscriber: {} with task status: {}", new Object[] { subscriber, message });
} catch (Throwable e) {
logger.error(e.getMessage(), e);
}
}
logger.info("Handled task status.");
}
示例6: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
logger.debug("Started handling task status.");
ITaskStatusMessage message = (ITaskStatusMessage) event.getProperty("message");
ICommandExecutionResult result = (ICommandExecutionResult) event.getProperty("result");
String recipient = result.getCommandExecution().getCommand().getCommandOwnerUid();
logger.info("Sending task status message to Lider Console. Task: {} Status: {} JID: {}",
new Object[] { message.getTaskId(), message.getResponseCode(), recipient });
try {
ITaskStatusNotification notification = messageFactory.createTaskStatusNotification(recipient, result);
messagingService.sendNotification(notification);
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
logger.info("Handled task status.");
}
示例7: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
LOGGER.info("Exiting application");
stopFramework();
if ("true".equals(System.getProperty("lolixl.forciblyExit"))) {
Thread t = new Thread(() -> {
try {
Thread.sleep(stopWaitTime);
} catch (InterruptedException e) {
// ignore
}
LOGGER.warning("Application hasn't exited during last " + stopWaitTime + "ms, invoking Systen.exit()");
System.exit(0);
});
t.setName("Application Killer");
t.setDaemon(true);
t.start();
}
}
示例8: notifyEventAdmins
import org.osgi.service.event.Event; //導入依賴的package包/類
@SuppressWarnings({
"rawtypes", "unchecked"
})
private void notifyEventAdmins(String topic, Event event) {
ServiceReference[] refs = null;
try {
refs = bctx.getAllServiceReferences(EventAdmin.class.getName(), null);
} catch (InvalidSyntaxException e) {
LOG.error("Failed to get EventAdmin: " + e.getMessage(), e);
}
if (refs != null) {
LOG.debug("Publishing event to {} EventAdmins; Topic:[{}]", refs.length, topic);
for (ServiceReference serviceReference : refs) {
EventAdmin eventAdmin = (EventAdmin) bctx.getService(serviceReference);
try {
eventAdmin.postEvent(event);
} finally {
if (eventAdmin != null) {
bctx.ungetService(serviceReference);
}
}
}
}
}
示例9: toEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
private Event toEvent(RemoteServiceAdminEvent rsaEvent) {
String topic = getTopic(rsaEvent);
Map<String, Object> props = new HashMap<>();
props.put("bundle", rsaEvent.getSource());
props.put("bundle.id", rsaEvent.getSource().getBundleId());
props.put("bundle.symbolicname", rsaEvent.getSource().getSymbolicName());
props.put("bundle.version", rsaEvent.getSource().getVersion());
props.put("bundle.signer", ""); // TODO What to put here
if (rsaEvent.getException() != null) {
props.put("exception", rsaEvent.getException());
props.put("exception.class", rsaEvent.getException().getClass());
props.put("exception.class", rsaEvent.getException().getMessage());
}
if (rsaEvent.getExportReference() != null) {
EndpointDescription endpoint = rsaEvent.getExportReference().getExportedEndpoint();
props.put("endpoint.framework.uuid", endpoint.getFrameworkUUID());
props.put("endpoint.id", endpoint.getId());
props.put("objectClass", endpoint.getInterfaces());
}
if (rsaEvent.getImportReference() != null && rsaEvent.getImportReference().getImportedEndpoint() != null) {
props.put("service.imported.configs", rsaEvent.getImportReference().getImportedEndpoint().getConfigurationTypes());
}
props.put("timestamp", System.currentTimeMillis());
props.put("event", rsaEvent);
return new Event(topic, props);
}
示例10: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void handleEvent(Event event) {
final BookmarkId bookmarkFolderId = new BookmarkId((String) event.getProperty(PROP_BOOKMARK_FOLDER_ID));
new Job("Updating remote bookmark folder") {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
refreshRemoteFolderOperation.refresh(bookmarkFolderId, monitor);
return Status.OK_STATUS;
} catch (BookmarksException e) {
return e.getStatus();
}
}
}.schedule();
}
示例11: handleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
public void handleEvent(Event event) {
Exchange exchange = endpoint.createExchange();
// TODO: populate exchange headers
exchange.getIn().setBody(event);
LOG.trace("EventAdmin {} is firing", endpoint.getTopic());
try {
getProcessor().process(exchange);
// log exception if an exception occurred and was not handled
if (exchange.getException() != null) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
} catch (Exception e) {
getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
}
}
示例12: notify
import org.osgi.service.event.Event; //導入依賴的package包/類
public void notify(EventObject event) throws Exception {
EventAdmin eventAdmin = tracker.getService();
if (eventAdmin == null) {
return;
}
Dictionary<String, Object> props = new Hashtable<String, Object>();
props.put(TYPE, getType(event));
props.put(EVENT, event);
props.put(TIMESTAMP, System.currentTimeMillis());
props.put(BUNDLE, bundleContext.getBundle());
props.put(BUNDLE_SYMBOLICNAME, bundleContext.getBundle().getSymbolicName());
props.put(BUNDLE_ID, bundleContext.getBundle().getBundleId());
props.put(BUNDLE_VERSION, getBundleVersion(bundleContext.getBundle()));
try {
props.put(CAUSE, event.getClass().getMethod("getCause").invoke(event));
} catch (Throwable t) {
// ignore
}
eventAdmin.postEvent(new Event(getTopic(event), props));
}
示例13: remoteDeviceRemoved
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
System.out.println("{UPNP Discovery}:Registry: Remote device removed: "+ device.getDisplayString());
//posting event
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("UpnpEvent", "Device_Removed");
properties.put("UDN", ""+device.getIdentity().getUdn().getIdentifierString());
properties.put("Name", ""+device.getDisplayString());
properties.put("Type", ""+device.getType().getType());
Activator.event = new Event("symphony/event", properties);
//System.out.println("Posting event");
Activator.admin.postEvent(Activator.event);
//removing device from list
deviceArrayList.remove(device);
}
示例14: doPost
import org.osgi.service.event.Event; //導入依賴的package包/類
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/html");
HashMap<String, String> properties = new HashMap<String, String>();
/*properties.put("UpnpEvent", "Device_Removed");
properties.put("UDN", "19a14780-00ae-1000-a3f9-4844f761ff04");
properties.put("Name", "Samsung Electronics UE46ES8080 1.0");
properties.put("Type", "MediaRenderer");
Activator.event = new Event("symphony/event", properties);
//System.out.println("Posting event");
Activator.admin.postEvent(Activator.event);*/
//properties.clear();
properties.put("UpnpEvent", "Device_Added");
properties.put("UDN", "2c3f5fdc-1dd2-11b2-98ae-000982195dd8");
properties.put("Name", "Samsung Electronics UE46ES8080 1.0");
properties.put("Type", "MediaRenderer");
Activator.event = new Event("symphony/event", properties);
//System.out.println("Posting event");
Activator.admin.postEvent(Activator.event);
resp.getOutputStream().println("<style type=\"text/css\">body{background-color: black;}input#play{width: 100%;height: 100%; font-size: 100px; color: white; background-color: black; border: none;}</style><form method=\"post\"><input type=\"submit\" id=\"play\" value=\"Play\"></form>");
}
示例15: GwBundleEvent
import org.osgi.service.event.Event; //導入依賴的package包/類
static public void GwBundleEvent(WmbusPacket gwPacket) {
//gwPacket.print();
HashMap<String, String> properties = new HashMap<String, String>();
properties.put("WMBus-incomming-packet", gwPacket.getManufacturer());
properties.put("SERIAL", gwPacket.getSerialNumber());
if (gwPacket.getManufacturer().equals("WEPTECH")) {
properties.put("TEMP", gwPacket.getPhenomenaList().get(0));
properties.put("HUM", gwPacket.getPhenomenaList().get(1));
}
if (gwPacket.getManufacturer().equals("PIKKERTON")) {
properties.put("WORK", gwPacket.getPhenomenaList().get(0));
}
if (gwPacket.getManufacturer().equals("BONEGA")) {
properties.put("TYPE", gwPacket.getPhenomenaList().get(0));
properties.put("VALUE", gwPacket.getPhenomenaList().get(1));
}
Activator.event = new Event("symphony/event", properties);
Activator.admin.postEvent(Activator.event);
}