本文整理匯總了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;
}
}
示例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");
}
}
}
}
}
示例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);
}
}
示例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;
}
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
}