當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceEvent.getServiceReference方法代碼示例

本文整理匯總了Java中org.osgi.framework.ServiceEvent.getServiceReference方法的典型用法代碼示例。如果您正苦於以下問題:Java ServiceEvent.getServiceReference方法的具體用法?Java ServiceEvent.getServiceReference怎麽用?Java ServiceEvent.getServiceReference使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osgi.framework.ServiceEvent的用法示例。


在下文中一共展示了ServiceEvent.getServiceReference方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
    if (closed) {
        return;
    }

    ServiceReference<?> sr = event.getServiceReference();

    switch (event.getType()) {
    case ServiceEvent.REGISTERED:
        onServiceRegistration(sr);
        break;

    case ServiceEvent.MODIFIED:
        onServiceUpdate(sr);
        break;

    case ServiceEvent.MODIFIED_ENDMATCH:
    case ServiceEvent.UNREGISTERING:
        onServiceDeparture(sr);
        break;
    }
}
 
開發者ID:primeval-io,項目名稱:aspecio,代碼行數:24,代碼來源:ServiceWeavingManager.java

示例2: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Receives notification that the context of the entities bundle has had a lifecycle change and
 * checks it current status.
 *
 * @param event The {@code ServiceEvent} object.
 */
@Override
public void serviceChanged(ServiceEvent event) {
    ServiceReference<?> reference = event.getServiceReference();

    if (isEntities(reference.getBundle())) {
        Object service = bundleContext.getService(reference);

        if (service instanceof ApplicationContext) {
            LOGGER.trace(
                    "The Entities Bundle Application Context Status: {}",
                    nullSafeToString(event)
            );

            synchronized (lock) {
                contextInitialized = event.getType() != ServiceEvent.UNREGISTERING;

                if (contextInitialized) {
                    LOGGER.info("The entities bundle context has been initialized");
                } else {
                    LOGGER.info("The entities bundle context has been unregistered");
                }
            }
        }
    }
}
 
開發者ID:motech,項目名稱:motech,代碼行數:32,代碼來源:EntitiesBundleMonitor.java

示例3: handleRegisteredEvent

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
private void handleRegisteredEvent(ServiceEvent event) {
	ServiceReference ref = event.getServiceReference();
	ModelFactory factory = (ModelFactory)this.bc.getService(ref);
	String currClass = getCurrentFactoryClassName();
	String newClass = factory.getClass().getName();
	if(this.currentFactorySR == null) {
		log.debug("Registering " + factory.getClass().getName() + " as default ModelFactory");
		this.currentFactorySR = ref;
		RDF2Go.register(factory);
	} else if(this.defaultFactoryClassName != null
	        && !currClass.equals(this.defaultFactoryClassName)
	        && newClass.equals(this.defaultFactoryClassName)) {
		RDF2Go.register((ModelFactory)null);
		this.bc.ungetService(this.currentFactorySR);
		
		factory = (ModelFactory)this.bc.getService(ref);
		this.currentFactorySR = ref;
		RDF2Go.register(factory);
		log.debug("RDF2Go uses " + newClass + " as default ModelFactory");
	} else {
		this.bc.ungetService(ref);
	}
}
 
開發者ID:semweb4j,項目名稱:semweb4j,代碼行數:24,代碼來源:RDF2GoActivator.java

示例4: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
	if (event.getType() == ServiceEvent.REGISTERED) {
		if (serviceReference == null) {
			serviceReference = event.getServiceReference();
			serviceManager = (ModulesManager) context.getService(serviceReference);
			registerAddons();
		}
	} else if (event.getType() == ServiceEvent.UNREGISTERING) {
		if (serviceReference == event.getServiceReference()) {
			unregisterAddons();
			context.ungetService(serviceReference);
			serviceManager = null;
			serviceReference = null;
		}
	}
}
 
開發者ID:kontalk,項目名稱:tigase-server,代碼行數:18,代碼來源:Activator.java

示例5: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Handle notifications of new/removed GenericDeviceEventListeners
 *
 * @param event
 */
@Override
public void serviceChanged(ServiceEvent event) {
    ServiceReference reference = event.getServiceReference();
    GDEventListener listener = (GDEventListener) context.getService(reference);
    switch (event.getType()) {
        case ServiceEvent.REGISTERED:
            Object filter = reference.getProperty(GENERICDEVICE_FILTER);
            listeners.put(listener, getFilter(filter));
            break;
        case ServiceEvent.MODIFIED:
            break;
        case ServiceEvent.UNREGISTERING:
            listeners.remove(listener);
            break;
    }
}
 
開發者ID:Ericsson-LMF,項目名稱:IoT-Gateway,代碼行數:22,代碼來源:EventManager.java

示例6: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
	ServiceReference sr = event.getServiceReference();
	switch(event.getType()) {
		case ServiceEvent.REGISTERED: {
			dataSourceFactory = ((DataSourceFactory) bc.getService(sr));
			if( getDataSourceFactory() != null && logSer != null ){
				dataSourceDriverName = (String)sr.getProperty(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS);
				registerService();
			}
		}
		break;
		case ServiceEvent.UNREGISTERING: {
			dataSourceFactory = null;
			dataSourceDriverName = null;
		}
		break;
	}
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:20,代碼來源:Activator.java

示例7: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public void serviceChanged(ServiceEvent event) {
	ServiceReference sr = event.getServiceReference();
	switch (event.getType()) {
	case ServiceEvent.REGISTERED: {
		httpHandler.setHttpService((HttpService) Activator.bc.getService(sr));
		Activator.log(LogService.LOG_INFO,
				"Getting instance of service: "
						+ HttpService.class.getName() + "," + Constants.SERVICE_PID + "=" + (String) sr.getProperty(Constants.SERVICE_PID)
						+ " from " + sr.getBundle().getSymbolicName());
	}
		break;
	case ServiceEvent.UNREGISTERING: {
		Activator.log(LogService.LOG_INFO, "Releasing service: "
				+ HttpService.class.getName() + ","
				+ Constants.SERVICE_PID + "="
				+ (String) sr.getProperty(Constants.SERVICE_PID));

		// httpService.unregister(obixServletPath);
		httpHandler.setHttpService(null);
	}
		break;
	}
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:24,代碼來源:Activator.java

示例8: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Unique method of the ServiceListener interface. The framework invoke this method when
 * a event has been posted. Since we registered this listener for registered and unregistered
 * event from the sensor node driver service, we will receive notification of theses here.
 *
 */
public void serviceChanged(ServiceEvent event) {
	ServiceReference sr = event.getServiceReference();
	switch(event.getType()) {
		case ServiceEvent.REGISTERED: {
			sensorNodeDriver = (SensorNodeDriver) Activator.bc.getService(sr);
			poolThread = new Thread(this);
			poolThread.start();
			Activator.log( LogService.LOG_INFO, "Getting instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
				+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString() );
		}
		break;
		case ServiceEvent.UNREGISTERING: {
			Activator.log( LogService.LOG_INFO, "Releasing instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
				+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString());
			sensorNodeDriver = null;
			poolThread.interrupt();
		}
		break;
	}
	
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:28,代碼來源:SensorNode.java

示例9: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Unique method of the ServiceListener interface. The framework invoke this method when
 * a event has been posted. Since we registered this listener for registered and unregistered
 * event from the modbus driver service, we will receive notification of theses here.
 *
 */
public void serviceChanged( ServiceEvent event ) {
	
		ServiceReference sr = event.getServiceReference();
		switch(event.getType()) {
			case ServiceEvent.REGISTERED: {
				modbusDr = (ModbusDriver) Activator.bc.getService(sr);
				myThread = new Thread(this);
				myThread.start();
				Activator.log( LogService.LOG_INFO, "Getting instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
					+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString() );
			}
			break;
			case ServiceEvent.UNREGISTERING: {
				Activator.log( LogService.LOG_INFO, "Releasing instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
					+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString());
				modbusDr = null;
				myThread.interrupt();
			}
			break;
		}
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:28,代碼來源:ModbusDeviceImpl.java

示例10: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Receives notification that a service has had a life cycle change.
 *
 * We are interested in receiving notification of WireAdminListener services that register
 * an unregister to and from the framework. This allows us to build dynamically a list of
 * services to which to send WireAdminEvent(s) as they are produces by thi bundle.
 *
 * @param event The ServiceEvent describing the type of life cycle change.
 */
public void serviceChanged( ServiceEvent event ) {
	
	ServiceReference sr = event.getServiceReference();
	switch(event.getType()) {
		case ServiceEvent.REGISTERED: {
				synchronized( wireAdminEventListeners ){
					if( !wireAdminEventListeners.containsKey( sr)) {
						wireAdminEventListeners.put( sr,(WireAdminListener) Activator.bc.getService( sr ));
					}
				}
			}
			break;
		case ServiceEvent.UNREGISTERING: {
				synchronized( wireAdminEventListeners ){
					if( wireAdminEventListeners.containsKey( sr )) {
						Activator.bc.ungetService( sr );
						wireAdminEventListeners.remove( sr );
					}
				}
			}
			break;
		}
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:33,代碼來源:WireAdminImpl.java

示例11: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Unique method of the ServiceListener interface.
 * 
 */
public void serviceChanged(ServiceEvent event) {

    ServiceReference sr = event.getServiceReference();
    switch (event.getType()) {
    case ServiceEvent.REGISTERED: {
	logSer = (LogService) bc.getService(sr);

    }
	break;
    case ServiceEvent.UNREGISTERING: {
	logSer = null;
    }
	break;
    }
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:20,代碼來源:Activator.java

示例12: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
	ServiceReference sr = event.getServiceReference();
	switch(event.getType()) {
		case ServiceEvent.REGISTERED: {
			mqttMessageFormatter = (IMqttMessageFomatter) Activator.bc.getService(sr);
			Activator.log( LogService.LOG_INFO, "Getting instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
				+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString() );
			start();
		}
		break;
		case ServiceEvent.UNREGISTERING: {
			Activator.log( LogService.LOG_INFO, "Releasing instance of service: " + (String) sr.getProperty( Constants.SERVICE_PID)
				+ ", " + Constants.SERVICE_ID + "=" + ((Long)sr.getProperty(Constants.SERVICE_ID)).toString());
			mqttMessageFormatter = null;
			stop();
		}
		break;
	}
	
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:22,代碼來源:MqttClientWrapper.java

示例13: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public void serviceChanged(ServiceEvent event) {
    ServiceReference sr = event.getServiceReference();
    switch (event.getType()) {
    case ServiceEvent.REGISTERED: {
	ObixDataHandler.getInstance().setDataDevice((JdbcDevice) Activator.bc.getService(sr));
	Activator.log(LogService.LOG_INFO, "Getting instance of service: " + JdbcDevice.class.getName() + ","
		+ Constants.SERVICE_PID + "=" + (String) sr.getProperty(Constants.SERVICE_PID));
	startDatabase();
    }
	break;
    case ServiceEvent.UNREGISTERING: {
	Activator.log(LogService.LOG_INFO, "Releasing service: " + JdbcDevice.class.getName() + ","
		+ Constants.SERVICE_PID + "=" + (String) sr.getProperty(Constants.SERVICE_PID));

	// httpService.unregister(obixServletPath);
	ObixDataHandler.getInstance().setDataDevice(null);
	databaseInitialised = false;
    }
	break;
    }
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:22,代碼來源:ObixServiceImpl.java

示例14: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Unique method of the ServiceListener interface.
 * 
 * @param event the service event
 *
 */
public void serviceChanged( final ServiceEvent event ) {
	
		ServiceReference sr = event.getServiceReference();
		switch(event.getType()) {
			case ServiceEvent.REGISTERED: {
				logSer = (LogService) bc.getService(sr);
				registerService();
			}
			break;
			case ServiceEvent.UNREGISTERING: {
				logSer = null;
			}
			break;
		}
}
 
開發者ID:lathil,項目名稱:Ptoceti,代碼行數:22,代碼來源:Activator.java

示例15: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
        if (event.getType() == ServiceEvent.REGISTERED) {
                if (serviceReference == null) {
                        serviceReference = event.getServiceReference();
                        serviceManager = (ModulesManager) context.getService(serviceReference);
                        registerAddons();
                }
        }
        else if (event.getType() == ServiceEvent.UNREGISTERING) {
                if (serviceReference == event.getServiceReference()) {
                        unregisterAddons();
                        context.ungetService(serviceReference);
                        serviceManager = null;
                        serviceReference = null;
                }
        }
}
 
開發者ID:Smartupz,項目名稱:tigase-muc,代碼行數:19,代碼來源:Activator.java


注:本文中的org.osgi.framework.ServiceEvent.getServiceReference方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。