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


Java Event类代码示例

本文整理汇总了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);
}
 
开发者ID:cschneider,项目名称:reactive-components,代码行数:20,代码来源:KafkaAppender.java

示例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);
       }
	
}
 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:22,代码来源:TokenHighlighter.java

示例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);
        }
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:31,代码来源:BlueprintBundleTracker.java

示例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!");
    }
}
 
开发者ID:fipro78,项目名称:osgi-ds-getting-started-pde,代码行数:19,代码来源:Ray.java

示例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.");

}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:27,代码来源:PluginNotifier.java

示例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.");
}
 
开发者ID:Pardus-LiderAhenk,项目名称:lider,代码行数:21,代码来源:LiderConsoleNotifier.java

示例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();
	}
}
 
开发者ID:to2mbn,项目名称:LoliXL,代码行数:22,代码来源:ApplicationExitHandler.java

示例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);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:26,代码来源:EventAdminHelper.java

示例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);
}
 
开发者ID:apache,项目名称:aries-rsa,代码行数:27,代码来源:EventAdminSender.java

示例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();
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:18,代码来源:RemoteBookmarksTreeChangeEventHandler.java

示例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());
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:EventAdminConsumer.java

示例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));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:OsgiEventAdminNotifier.java

示例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);	
}
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:18,代码来源:UpnpServiceHandler.java

示例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>");

	  }
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:25,代码来源:ButtonServlet.java

示例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);
}
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:21,代码来源:GwMain.java


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