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


Java EventHandler类代码示例

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


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

示例1: start

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

示例2: onMessage

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

示例3: onMessage

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

示例4: postContextCreate

import org.osgi.service.event.EventHandler; //导入依赖的package包/类
@PostContextCreate
void postContextCreate(final IEventBroker eventBroker, IApplicationContext context) {
	// configure log4j
	BasicConfigurator.configure();
	Logger.getRootLogger().setLevel(Level.INFO);
	// register for startup completed event
	eventBroker.subscribe(UIEvents.UILifeCycle.APP_STARTUP_COMPLETE, new EventHandler() {
		@Override
		public void handleEvent(Event event) {
			// close dynamic splash screen
			Loading.close();
			eventBroker.unsubscribe(this);
		}
	});
	// close static splash screen
	context.applicationRunning();
	// open dynamic splash screen
	Loading.open();
}
 
开发者ID:DaveVoorhis,项目名称:Rel,代码行数:20,代码来源:E4LifeCycle.java

示例5: addListener

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

示例6: commonSetUp

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

示例7: registerEventHandler

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

示例8: onExecute

import org.osgi.service.event.EventHandler; //导入依赖的package包/类
@Execute
public void onExecute() {
  eventBroker.subscribe(IThemeEngine.Events.THEME_CHANGED,
      new EventHandler() {
        public void handleEvent(Event event) {
          ITheme currentTheme = (ITheme) event
              .getProperty(IThemeEngine.Events.THEME);
          // if (!prefDarker.getBoolean(
          // THEME_DARKER_PREF_THEMEENABLED, false))
          if (currentTheme.getId().equals(THEME_DARKER_ID)) {
            setupPreferences();
            isLastThemeDarker = true;
            DarkerWeavingHook.enableWeaving();
            hookDarkerCore();
          } else if (isLastThemeDarker) {
            DarkerWeavingHook.disableWeaving();
            setToDefaultPreferences();
          }

        }
      });
}
 
开发者ID:jvanzyl,项目名称:eclipse.darker.theme,代码行数:23,代码来源:DarkerThemer.java

示例9: setup

import org.osgi.service.event.EventHandler; //导入依赖的package包/类
@PostConstruct
public void setup(IEventBroker eventBroker){
	partStack = (MPartStack)modelService.find("linguine.partstack.advanced."
			+ "dataEditorPartStack", application);
	
	eventBroker.subscribe(LinGUIneEvents.UILifeCycle.OPEN_PROJECT_DATA,
			new EventHandler(){
		@Override
		public void handleEvent(Event event) {
			if(event != null){
				for(String propName: event.getPropertyNames()){
					//Does nothing, but I'm afraid to get rid of it
				}
			}
		}
	});
}
 
开发者ID:Pro-Nouns,项目名称:LinGUIne,代码行数:18,代码来源:DataEditorManager.java

示例10: registerAsEventHandler

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

示例11: testOnAuthorEmptyNotificationsFolder

import org.osgi.service.event.EventHandler; //导入依赖的package包/类
@Test
public void testOnAuthorEmptyNotificationsFolder() throws Exception {
    setAuthorRunmode();
    aemContext.build().
            resource("/etc/acs-commons/notifications", JCR_PRIMARYTYPE, NT_PAGE).
            resource("jcr:content", JCR_PRIMARYTYPE, NT_UNSTRUCTURED);
    commit();
    aemContext.registerInjectActivateService(notifications);
    assertEquals(1, aemContext.getServices(EventHandler.class, null).length);
    assertEquals(0, aemContext.getServices(Filter.class, null).length);

    aemContext.create().resource("/etc/acs-commons/notifications/first");
    commit();
    sendEvent();
    assertEquals(1, aemContext.getServices(Filter.class, null).length);

    notifications.deactivate(aemContext.componentContext());
    assertEquals(0, aemContext.getServices(Filter.class, null).length);
    assertEquals(0, aemContext.getServices(EventHandler.class, null).length);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:21,代码来源:SystemNotificationsImplTest.java

示例12: testOnAuthorPopulatedNotificationsFolder

import org.osgi.service.event.EventHandler; //导入依赖的package包/类
@Test
public void testOnAuthorPopulatedNotificationsFolder() throws Exception  {
    setAuthorRunmode();
    createEnabledNotification();
    aemContext.registerInjectActivateService(notifications);
    assertEquals(1, aemContext.getServices(EventHandler.class, null).length);
    assertEquals(1, aemContext.getServices(Filter.class, null).length);

    // then remove the resource
    delete("/etc/acs-commons/notifications/enabled");
    commit();
    sendEvent();
    assertEquals(0, aemContext.getServices(Filter.class, null).length);

    notifications.deactivate(aemContext.componentContext());
    assertEquals(0, aemContext.getServices(Filter.class, null).length);
    assertEquals(0, aemContext.getServices(EventHandler.class, null).length);
}
 
开发者ID:Adobe-Consulting-Services,项目名称:acs-aem-commons,代码行数:19,代码来源:SystemNotificationsImplTest.java

示例13: registerWebResourceGroupListener

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

示例14: activate

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

示例15: createViewer

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