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


Java ServiceEvent.MODIFIED屬性代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:ServiceDiscoverer.java

示例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;
    }
}
 
開發者ID:primeval-io,項目名稱:aspecio,代碼行數:23,代碼來源:ServiceWeavingManager.java

示例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.");
    }
}
 
開發者ID:luoqii,項目名稱:ApkLauncher,代碼行數:26,代碼來源:Activator.java

示例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;
    }
}
 
開發者ID:Ericsson-LMF,項目名稱:IoT-Gateway,代碼行數:21,代碼來源:EventManager.java

示例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;
    }
}
 
開發者ID:qoswork,項目名稱:opennmszh,代碼行數:17,代碼來源:OnmsOSGiBridgeActivator.java

示例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 + " ???";
    }
}
 
開發者ID:vorburger,項目名稱:ch.vorburger.minecraft.osgi,代碼行數:14,代碼來源:LoggingServiceListener.java

示例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);
}
 
開發者ID:apache,項目名稱:karaf-eik,代碼行數:33,代碼來源:EclipseRuntimeDataProvider.java

示例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;
	}
}
 
開發者ID:cohorte,項目名稱:cohorte-remote-services,代碼行數:32,代碼來源:ExportDispatcher.java

示例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);
	}
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:53,代碼來源:OsgiServiceCollection.java

示例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);						
}
 
開發者ID:cohorte,項目名稱:cohorte-herald,代碼行數:44,代碼來源:CHttpServiceAvailabilityChecker.java

示例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()));
			}
		}
	}
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:44,代碼來源:DependencyServiceManager.java


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