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


Java EventConstants类代码示例

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


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

示例1: activate

import org.osgi.service.event.EventConstants; //导入依赖的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: start

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
public void start(BundleContext context) throws Exception {
	System.out.println("{Core Bundle}:Running!...");		
	Activator.bc = context;
	
	//ServiceReference ref = context.getServiceReference(LogConfig.class.getName());        
	//LogConfig conf = (LogConfig) context.getService(ref);				
    //conf.setFile(true);
    //conf.setOut(true);
    
	//method which starts SyMPHOnY Bundles
	//startBundles(bc.getBundles());
	
	//start miniDLNA Server on NEC
	inicialization.startMiniDLNA("minidlna -f /tiny/minidlna.conf");
	
	//set NTP pool for NTP Client on NEC
	inicialization.setDate("0.openwrt.pool.ntp.org");
		
	System.out.println("{Core Bundle}:Registering events...");
	EventHandler eventHandler = new CoreEventHandler(context);
	Dictionary<String, String> d = new Hashtable<String, String>();
	d.put(EventConstants.EVENT_TOPIC, "symphony/event");
	Activator.bc.registerService( EventHandler.class, eventHandler, d);
}
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:25,代码来源:Activator.java

示例3: onMessage

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
public void onMessage(String message) {
	// Parse the subscription request string
	JsonParser parser = new JsonParser();
	JsonObject object = parser.parse(message).getAsJsonObject();
	String functionUID = object.get(FunctionEvent.PROPERTY_FUNCTION_UID).getAsString();
	String propertyName = object.get(FunctionEvent.PROPERTY_FUNCTION_PROPERTY_NAME).getAsString();

	// Prepare properties for event filter to be used with EventAdmin
	Hashtable properties = new Hashtable();
	properties.put(EventConstants.EVENT_TOPIC, FunctionEvent.TOPIC_PROPERTY_CHANGED);
	properties.put(EventConstants.EVENT_FILTER, "(&(" + FunctionEvent.PROPERTY_FUNCTION_UID + "=" + functionUID + ")(" + FunctionEvent.PROPERTY_FUNCTION_PROPERTY_NAME + "="
			+ propertyName + "))");

	// unregister previous event handler
	unregisterEventHandlerService();

	// register event handlers
	registration = this.context.getBundleContext().registerService(EventHandler.class.getName(), this, properties);

}
 
开发者ID:ismb,项目名称:jemma.osgi.dal.web-apis,代码行数:21,代码来源:DALEventWebSocket.java

示例4: onMessage

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
public void onMessage(String message) {
	//Parse the subscription request string
	JsonParser parser=new JsonParser();
	JsonObject object=parser.parse(message).getAsJsonObject();
	String functionUID=object.get(FunctionEvent.PROPERTY_FUNCTION_UID).getAsString();
	String propertyName=object.get(FunctionEvent.PROPERTY_FUNCTION_PROPERTY_NAME).getAsString();
			
	//Prepare properties for event filter to be used with EventAdmin
	Hashtable properties=new Hashtable();
	properties.put(EventConstants.EVENT_TOPIC, FunctionEvent.TOPIC_PROPERTY_CHANGED);
	properties.put(EventConstants.EVENT_FILTER, "(&("+FunctionEvent.PROPERTY_FUNCTION_UID+"="+functionUID+")("+FunctionEvent.PROPERTY_FUNCTION_PROPERTY_NAME+"="+propertyName+"))");
	
	//unregister previous event handler
	unregisterEventHandlerService();
	
	//register event handlers
	registration=this.context.getBundleContext().registerService(EventHandler.class.getName(), this, properties);
	
}
 
开发者ID:ismb,项目名称:it.ismb.pert.osgi.dal.web-apis,代码行数:20,代码来源:DALEventWebSocket.java

示例5: testEventTransferOnWamp

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
@Test
public void testEventTransferOnWamp() {
    WampController controller = createWampControllerAndConnectClient();
    ArrayNode msg = json.newArray();
    msg.add(MessageType.SUBSCRIBE.code());
    msg.add("http://example.com/topic");
    controller.onMessage(CLIENT_ID, msg);

    Map<String, String> map = ImmutableMap.of("k1", "v1", "k2", "v2");
    org.osgi.service.event.Event event = new org.osgi.service.event.Event("top/ic", map);
    controller.handleEvent(event);

    // The event should have been transferred on wamp
    System.out.println(last());
    assertThat(get(0).get(1).asText()).isEqualTo(TestConstants.PREFIX + "/top/ic");
    assertThat(get(0).get(2).get("k1").asText()).isEqualTo("v1");
    assertThat(get(0).get(2).get("k2").asText()).isEqualTo("v2");
    assertThat(get(0).get(2).get(EventConstants.EVENT_TOPIC).asText()).isEqualTo("top/ic");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:20,代码来源:WampControllerEventAdminTest.java

示例6: testEventTransferOnWampUsingEligible

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
@Test
public void testEventTransferOnWampUsingEligible() {
    WampController controller = createWampControllerAndConnectClient();
    ArrayNode msg = json.newArray();
    msg.add(MessageType.SUBSCRIBE.code());
    msg.add("http://example.com/topic");
    controller.onMessage(CLIENT_ID, msg);
    clear();
    Map<String, Object> map = ImmutableMap.<String, Object>of("k1", "v1", "k2", "v2",
            Wamp.WAMP_ELIGIBLE_EVENT_PROPERTY, ImmutableList.of(controller.getClientById(CLIENT_ID).getValue()
            .session()));
    org.osgi.service.event.Event event = new org.osgi.service.event.Event("top/ic", map);
    controller.handleEvent(event);

    // The event should have been transferred on wamp
    System.out.println(last());
    assertThat(get(0).get(1).asText()).isEqualTo(TestConstants.PREFIX + "/top/ic");
    assertThat(get(0).get(2).get("k1").asText()).isEqualTo("v1");
    assertThat(get(0).get(2).get("k2").asText()).isEqualTo("v2");
    assertThat(get(0).get(2).get(EventConstants.EVENT_TOPIC).asText()).isEqualTo("top/ic");
}
 
开发者ID:wisdom-framework,项目名称:wisdom-wamp,代码行数:22,代码来源:WampControllerEventAdminTest.java

示例7: addListener

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
@Override
public void addListener(HubContext ctx, Object listener, EventCallbackInvoker invoker) {
    Hashtable ht = new Hashtable();
    ht.put(EventConstants.EVENT_TOPIC, EventTopics.GLOBAL);

    synchronized (serviceRegMap) {
        if (serviceRegMap.containsKey(listener)) {
            serviceRegMap.get(listener).unregister();
        }
        Bundle bundle = FrameworkUtil.getBundle(getClass());
        if (bundle != null) {
            BundleContext context = bundle.getBundleContext();
            if (context != null) {
                ServiceRegistration sr = context.registerService(EventHandler.class.getName(), new EventHandlerAdapter(eventFactory, listener, invoker), ht);
                if (sr != null) {
                    serviceRegMap.put(listener, sr);
                } else {
                    logger.error("Received null service registration registering listener: " + listener);
                }
            }
        }
    }
}
 
开发者ID:whizzosoftware,项目名称:hobson-hub-core,代码行数:24,代码来源:OSGIEventManager.java

示例8: commonSetUp

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
/**
 * Common test setup.
 */
@Before
public void commonSetUp() {
    super.commonSetUp();
    // Get the interesting bundles
    ipojoBundle = osgiHelper.getBundle(IPOJO);
    testBundle = osgiHelper.getBundle(TEST_BUNDLE_SYMBOLIC_NAME);
    testBundle2 = osgiHelper.getBundle(TEST_BUNDLE_2_SYMBOLIC_NAME);
    // Register an EventHandler for debug
    Dictionary<String, String> props = new Hashtable<String, String>();
    props.put(EventConstants.EVENT_TOPIC, "everest/ipojo/*");
    eventHandlerService = context.registerService(EventHandler.class, new EventHandler() {
        public void handleEvent(Event event) {
            System.out.println("Event " + event.getProperty("eventType") + " on path " + event.getProperty("canonicalPath"));
        }
    }, props);
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:20,代码来源:EverestIpojoTestCommon.java

示例9: registerEventHandler

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
protected void registerEventHandler() {
    Hashtable<String, Object> props = new Hashtable<String, Object>();
    props.put(EventConstants.EVENT_TOPIC, new String[]{"everest/osgi/*", "everest/osgi"});
    osgiHelper.getContext().registerService(EventHandler.class.getName(), new EventHandler() {
        public void handleEvent(Event event) {
            Object eventType = event.getProperty("eventType");
            //System.out.println(eventType + " " + event.getProperty("canonicalPath"));
            if (ResourceEvent.CREATED.toString().equals(eventType)) {
                createdEvents.add(event);
            } else if (ResourceEvent.DELETED.toString().equals(eventType)) {
                deletedEvents.add(event);
            } else if (ResourceEvent.UPDATED.toString().equals(eventType)) {
                updatedEvents.add(event);
            }
        }
    }, props);

}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:19,代码来源:EverestOsgiTest.java

示例10: isServiceUpdated

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
@Override
@SuppressWarnings("squid:S3923")
protected boolean isServiceUpdated(Resource config, ServiceReference reference) {
    boolean updated = false;
    AutomaticPackageReplicatorModel model = new AutomaticPackageReplicatorModel(config);
    String triggerStr = (String) reference.getProperty(TRIGGER_KEY);
    if (model.getTrigger() == TRIGGER.cron && model.getTrigger() == TRIGGER.valueOf(triggerStr) && ObjectUtils
            .equals(reference.getProperty(Scheduler.PROPERTY_SCHEDULER_EXPRESSION), model.getCronTrigger())) {
        updated = true;
    } else if (model.getTrigger() == TRIGGER.event && model.getTrigger() == TRIGGER.valueOf(triggerStr)
            && ObjectUtils.equals(reference.getProperty(EventConstants.EVENT_TOPIC), model.getEventTopic())
            && ObjectUtils.equals(reference.getProperty(EventConstants.EVENT_FILTER), model.getEventFilter())) {
        updated = true;
    }
    return updated;
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:17,代码来源:ConfigurationUpdateListener.java

示例11: registerAsEventHandler

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
@SuppressWarnings("squid:S1149")
private void registerAsEventHandler() {
        final Hashtable filterProps = new Hashtable<String, String>();

        // Listen on Add and Remove under /etc/acs-commons/notifications

        filterProps.put(EventConstants.EVENT_TOPIC,
                new String[]{
                        SlingConstants.TOPIC_RESOURCE_ADDED,
                        SlingConstants.TOPIC_RESOURCE_REMOVED });

        filterProps.put(EventConstants.EVENT_FILTER, "(&"
                + "(" + SlingConstants.PROPERTY_PATH + "=" + SystemNotificationsImpl.PATH_NOTIFICATIONS + "/*)"
                + ")");

        this.eventHandlerRegistration =
                this.osgiComponentContext.getBundleContext().registerService(EventHandler.class.getName(), this,
                        filterProps);

        log.debug("Registered System Notifications as Event Handler");
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:22,代码来源:SystemNotificationsImpl.java

示例12: registerWebResourceGroupListener

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
private void registerWebResourceGroupListener(final String webResourceName,
		final String webResourcePath) throws RepositoryException {
	if (!webResourceServiceRegistration.containsKey(webResourceName)) {
		String[] topics = new String[] {
				SlingConstants.TOPIC_RESOURCE_ADDED,
				SlingConstants.TOPIC_RESOURCE_CHANGED,
				SlingConstants.TOPIC_RESOURCE_REMOVED };

		Dictionary<String, Object> props = new Hashtable<String, Object>();
		props.put(EventConstants.EVENT_TOPIC, topics);
		props.put(EventConstants.EVENT_FILTER, "(path=" + webResourcePath
				+ "/*)");

		this.webResourceServiceRegistration.put(webResourceName,
				bundleContext.registerService(EventHandler.class.getName(),
						new InventoryEventHandler(), props));

		log.info("Registered Inventory Event Handler for "
				+ webResourceName);
	}
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:22,代码来源:WebResourceInventoryManagerImpl.java

示例13: activate

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
protected void activate(ComponentContext context) {
	bundleContext = context.getBundleContext();

	this.executorService = Executors.newFixedThreadPool(4);

	compilePaths(new ArrayList<String>(
			this.webResourceInventoryManager.getAllWebResourcePaths()));
	String[] compileTopics = new String[] {
			WebResourceInventoryManager.COMPILE_EVENT,
			WebResourceInventoryManager.COMPILE_ALL_EVENT };
	Dictionary<String, Object> backgroundCompilerProps = new Hashtable<String, Object>();
	backgroundCompilerProps.put(EventConstants.EVENT_TOPIC, compileTopics);
	bundleContext.registerService(EventHandler.class.getName(), this,
			backgroundCompilerProps);
	log.debug("Background Compiler Activated");
}
 
开发者ID:bobpaulin,项目名称:sling-web-resource,代码行数:17,代码来源:BackgroundCompilerHandler.java

示例14: getHandlerServiceProperties

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
/**
 * 
 * @param topics
 *            Specify the topics to subscribe to - Wilcard * is applicable at the end of a String
 * @param filter
 * @return dictionary object that represents handler service properties.
 */
protected Dictionary<String, Object> getHandlerServiceProperties(
		String[] topics, String filter) {

	String[] topicsToUse = topics;
	if (topicsToUse == null || topicsToUse.length == 0)
		topicsToUse = new String[] { "*" };

	Dictionary<String, Object> result = new Hashtable<String, Object>();
	result.put(EventConstants.EVENT_TOPIC, topicsToUse);

	if (filter != null && filter.length() > 0)
		result.put(EventConstants.EVENT_FILTER, filter);

	return result;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:23,代码来源:EventManager.java

示例15: createViewer

import org.osgi.service.event.EventConstants; //导入依赖的package包/类
private void createViewer(Composite parent) {
	viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.CHECK | SWT.READ_ONLY | SWT.PUSH);
	createColumns(parent, viewer);
	final Table table = viewer.getTable();
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

	viewer.getTable().addListener(SWT.Selection, new Listener() {

		@Override
		public void handleEvent(org.eclipse.swt.widgets.Event event) {
			if (highlightNodes.getSelection())
				highlightNodesOnGraph(highlightNodes.getSelection());
		}
	});

	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setInput(this.units);
	getSite().setSelectionProvider(viewer);

	GridData gridData = new GridData();
	gridData.verticalAlignment = GridData.FILL;
	gridData.horizontalSpan = 2;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.horizontalAlignment = GridData.FILL;
	viewer.getControl().setLayoutData(gridData);

	Hashtable<String, Object> properties = new Hashtable<>();
	String[] topics = new String[] { DataModel.EA_TOPIC_DATA_SELECTION, DataModel.EA_TOPIC_DATA_UNIT_CHANGED, DataModel.EA_TOPIC_DATA_VIEW_REFRESH };
	properties.put(EventConstants.EVENT_TOPIC, topics);
	ServiceUtil.registerService(EventHandler.class, this, properties);

}
 
开发者ID:VisuFlow,项目名称:visuflow-plugin,代码行数:35,代码来源:ResultView.java


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