本文整理匯總了Java中org.osgi.framework.ServiceEvent.MODIFIED屬性的典型用法代碼示例。如果您正苦於以下問題:Java ServiceEvent.MODIFIED屬性的具體用法?Java ServiceEvent.MODIFIED怎麽用?Java ServiceEvent.MODIFIED使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.osgi.framework.ServiceEvent
的用法示例。
在下文中一共展示了ServiceEvent.MODIFIED屬性的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: serviceChanged
@Override
public synchronized void serviceChanged ( final ServiceEvent event )
{
switch ( event.getType () )
{
case ServiceEvent.REGISTERED:
addReference ( event.getServiceReference () );
break;
case ServiceEvent.MODIFIED:
update ();
break;
case ServiceEvent.UNREGISTERING:
removeReference ( event.getServiceReference () );
break;
}
}
示例2: serviceChanged
@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;
}
}
示例3: serviceChanged
/**
* Implements ServiceListener.serviceChanged().
* Prints the details of any service event from the framework.
* @param event the fired service event.
**/
public void serviceChanged(ServiceEvent event)
{
String[] objectClass = (String[])
event.getServiceReference().getProperty("objectClass");
if (event.getType() == ServiceEvent.REGISTERED)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " registered.");
}
else if (event.getType() == ServiceEvent.UNREGISTERING)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " unregistered.");
}
else if (event.getType() == ServiceEvent.MODIFIED)
{
System.out.println(
"Ex1: Service of type " + objectClass[0] + " modified.");
}
}
示例4: serviceChanged
/**
* 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;
}
}
示例5: serviceChanged
@Override
public void serviceChanged(final ServiceEvent serviceEvent) {
switch(serviceEvent.getType()) {
case ServiceEvent.REGISTERED:
registerWithOnmsRegistry(serviceEvent.getServiceReference());
break;
case ServiceEvent.MODIFIED:
registerWithOnmsRegistry(serviceEvent.getServiceReference());
break;
case ServiceEvent.MODIFIED_ENDMATCH:
unregisterWithOnmsRegistry(serviceEvent.getServiceReference());
break;
case ServiceEvent.UNREGISTERING:
unregisterWithOnmsRegistry(serviceEvent.getServiceReference());
break;
}
}
示例6: getServiceEventTypeText
private String getServiceEventTypeText(int type) {
switch (type) {
case ServiceEvent.REGISTERED:
return "Registered";
case ServiceEvent.MODIFIED:
return "Modified";
case ServiceEvent.MODIFIED_ENDMATCH:
return "Modified End Match";
case ServiceEvent.UNREGISTERING:
return "Unregistering";
default:
return type + " ???";
}
}
示例7: serviceChanged
@Override
public void serviceChanged(ServiceEvent event) {
final ServiceReference reference = event.getServiceReference();
final ServiceItem ri = new ServiceItem(reference);
EnumSet<RuntimeDataProviderListener.EventType> events = EnumSet.noneOf(RuntimeDataProviderListener.EventType.class);
switch (event.getType()) {
case ServiceEvent.REGISTERED:
synchronized (serviceSet) {
if (serviceSet.contains(ri)) {
serviceSet.add(ri);
events = EnumSet.of(RuntimeDataProviderListener.EventType.ADD);
}
}
break;
case ServiceEvent.UNREGISTERING:
synchronized (serviceSet) {
if (serviceSet.contains(ri)) {
serviceSet.remove(ri);
events = EnumSet.of(RuntimeDataProviderListener.EventType.REMOVE);
}
}
break;
case ServiceEvent.MODIFIED:
default:
events = EnumSet.of(RuntimeDataProviderListener.EventType.CHANGE);
break;
}
fireProviderChangeEvent(events);
}
示例8: serviceChanged
@Override
public void serviceChanged(final ServiceEvent aEvent) {
final ServiceReference<?> svcRef = aEvent.getServiceReference();
switch (aEvent.getType()) {
case ServiceEvent.REGISTERED:
// New service to export
exportService(svcRef);
break;
case ServiceEvent.MODIFIED:
if (pServiceUids.containsKey(svcRef)) {
// Already known service
updateService(svcRef);
} else {
// New match
exportService(svcRef);
}
break;
case ServiceEvent.MODIFIED_ENDMATCH:
case ServiceEvent.UNREGISTERING:
// Service must not be exported
unexportService(svcRef);
break;
default:
break;
}
}
示例9: serviceChanged
public void serviceChanged(ServiceEvent event) {
ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);
ServiceReference ref = event.getServiceReference();
Long serviceId = (Long) ref.getProperty(Constants.SERVICE_ID);
EventResult state = null;
switch (event.getType()) {
case (ServiceEvent.REGISTERED):
case (ServiceEvent.MODIFIED):
// same as ServiceEvent.REGISTERED
state = addService(serviceId, ref);
// inform listeners
if (state.collectionModified) {
OsgiServiceBindingUtils.callListenersBind(state.proxy, ref, listeners);
if (serviceRequiredAtStartup && state.shouldInformStateListeners)
notifySatisfiedStateListeners();
}
break;
case (ServiceEvent.UNREGISTERING):
state = canRemoveService(serviceId, ref);
if (state.collectionModified) {
OsgiServiceBindingUtils.callListenersUnbind(state.proxy, ref, listeners);
state = removeService(serviceId, ref);
if (serviceRequiredAtStartup && state.shouldInformStateListeners)
notifyUnsatisfiedStateListeners();
}
break;
default:
throw new IllegalArgumentException("unsupported event type:" + event);
}
}
// OSGi swallows these exceptions so make sure we get a chance to
// see them.
catch (Throwable re) {
if (log.isWarnEnabled()) {
log.warn("serviceChanged() processing failed", re);
}
} finally {
Thread.currentThread().setContextClassLoader(tccl);
}
}
示例10: validate
@Validate
public void validate() {
// set service listener to check if endpoint port is changed
String wFilter = "(objectclass=" + HttpService.class.getName() + ")";
ServiceListener wListener = new ServiceListener() {
@Override
public void serviceChanged(ServiceEvent aServiceEvent) {
if (aServiceEvent.getType() == ServiceEvent.MODIFIED) {
pLogger.log(LogService.LOG_INFO, "Properties modified! should update Http service port..");
//checkEndpoints(aServiceEvent.getServiceReference().getProperty(HTTP_SERVICE_ENDPOINTS));
// to garanty the synchronization of tests, we call instead the synchronized method:
checkRegisteredHttpService();
}
}
};
try {
pBundleContext.addServiceListener(wListener, wFilter);
} catch (InvalidSyntaxException e) {
pLogger.log(LogService.LOG_ERROR, "Invalid syntax while registering a service listener: "
+ e.getMessage());
pController = false;
pHttpPort = -1;
}
// set a timer to check periodically if endpoint port is set the first time!
// when the port is set, the timer is canceled and we do use only service listener
// to check if port change again.
pTimer = new Timer();
pTimer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
checkRegisteredHttpService();
if (pHttpPort > 0) {
this.cancel();
} else {
// MOD_BD_20170724
if (pHops.incrementAndGet() > MAX_CHECK_HOPS) {
setDefaultHttpServicePort();
}
}
}
}, 1000, 1000);
}
示例11: updateDependencies
private void updateDependencies(ServiceEvent serviceEvent) {
boolean trace = log.isTraceEnabled();
boolean debug = log.isDebugEnabled();
for (Iterator i = dependencies.keySet().iterator(); i.hasNext();) {
MandatoryServiceDependency dependency = (MandatoryServiceDependency) i.next();
// check if there is a match on the service
if (dependency.matches(serviceEvent)) {
switch (serviceEvent.getType()) {
case ServiceEvent.REGISTERED:
case ServiceEvent.MODIFIED:
unsatisfiedDependencies.remove(dependency);
if (debug) {
log.debug("Found service for " + context.getDisplayName() + "; eliminating "
+ dependency + ", remaining [" + unsatisfiedDependencies + "]");
}
sendDependencySatisfiedEvent(dependency);
break;
case ServiceEvent.UNREGISTERING:
unsatisfiedDependencies.put(dependency, dependency.getBeanName());
if (debug) {
log.debug("Service unregistered; adding " + dependency);
}
sendDependencyUnsatisfiedEvent(dependency);
break;
default: // do nothing
if (debug) {
log.debug("Unknown service event type for: " + dependency);
}
break;
}
}
else {
if (trace) {
log.trace(dependency + " does not match: "
+ OsgiStringUtils.nullSafeToString(serviceEvent.getServiceReference()));
}
}
}
}