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


Java ServiceEvent.getType方法代碼示例

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


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

示例1: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@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,代碼行數:17,代碼來源:ServiceDiscoverer.java

示例2: testAddServiceListenerBundleContextServiceListenerString

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Test method for
 * {@link org.eclipse.gemini.blueprint.util.OsgiListenerUtils#addServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
 */
public void testAddServiceListenerBundleContextServiceListenerString() {
	final List refs = new ArrayList();

	ServiceListener list = new ServiceListener() {

		public void serviceChanged(ServiceEvent event) {
			if (ServiceEvent.REGISTERED == event.getType())
				refs.add(event.getSource());
		}
	};

	OsgiListenerUtils.addServiceListener(bundleContext, list, (String) null);

	assertFalse(refs.isEmpty());
	assertEquals(3, refs.size());
	assertSame(ref1, refs.get(0));
	assertSame(ref2, refs.get(1));
	assertSame(ref3, refs.get(2));
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:24,代碼來源:OsgiListenerUtilsTest.java

示例3: testAddSingleServiceListenerBundleContextServiceListenerString

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Test method for
 * {@link org.eclipse.gemini.blueprint.util.OsgiListenerUtils#addSingleServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
 */
public void testAddSingleServiceListenerBundleContextServiceListenerString() {
	final List refs = new ArrayList();

	ServiceListener listener = new ServiceListener() {

		public void serviceChanged(ServiceEvent event) {
			if (ServiceEvent.REGISTERED == event.getType())
				refs.add(event.getSource());
		}
	};

	OsgiListenerUtils.addSingleServiceListener(bundleContext, listener, (String) null);

	assertFalse(refs.isEmpty());
	assertEquals(1, refs.size());
	assertSame(ref1, refs.get(0));
}
 
開發者ID:eclipse,項目名稱:gemini.blueprint,代碼行數:22,代碼來源:OsgiListenerUtilsTest.java

示例4: RemoteServiceAdminCore

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public RemoteServiceAdminCore(BundleContext context, BundleContext apiContext, DistributionProvider provider) {
    this.bctx = context;
    this.apictx = apiContext;
    this.eventProducer = new EventProducer(bctx);
    this.provider = provider;
    // listen for exported services being unregistered so we can close the export
    this.exportedServiceListener = new ServiceListener() {
        public void serviceChanged(ServiceEvent event) {
            if (event.getType() == ServiceEvent.UNREGISTERING) {
                removeServiceExports(event.getServiceReference());
            }
        }
    };
    try {
        String filter = "(" + RemoteConstants.SERVICE_EXPORTED_INTERFACES + "=*)";
        context.addServiceListener(exportedServiceListener, filter);
    } catch (InvalidSyntaxException ise) {
        throw new RuntimeException(ise); // can never happen
    }
}
 
開發者ID:apache,項目名稱:aries-rsa,代碼行數:21,代碼來源:RemoteServiceAdminCore.java

示例5: 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

示例6: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
@Override
public void serviceChanged(ServiceEvent event) {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Service {} changed to {}", event, event.getType());
    }
    // look for blueprint container to be registered, and then we can start the CamelContext
    if (event.getType() == ServiceEvent.REGISTERED
            && event.getServiceReference().isAssignableTo(bundleContext.getBundle(), "org.osgi.service.blueprint.container.BlueprintContainer")
            && bundleContext.getBundle().equals(event.getServiceReference().getBundle())) {
        try {
            maybeStart();
        } catch (Exception e) {
            LOG.error("Error occurred during starting Camel: " + this + " due " + e.getMessage(), e);
        }
    }
}
 
開發者ID:HydAu,項目名稱:Camel,代碼行數:17,代碼來源:BlueprintCamelContext.java

示例7: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * 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,代碼行數:27,代碼來源:Activator.java

示例8: 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

示例9: serviceChanged

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

	if (!enabled) return;

	try {
		if (event.getType() != ServiceEvent.REGISTERED) return;
		Object service = context.getService(event.getServiceReference());
		if (service == null) return;
		if (!(service instanceof VaadinConfigurableResourceProviderAdmin)) return;

		log.info("Admin-Service registered");
		refreshAll();
	} catch (Throwable t) {
		t.printStackTrace(); //TODO log
	}
}
 
開發者ID:mhus,項目名稱:mhus-osgi-tools,代碼行數:18,代碼來源:BundleWatchImpl.java

示例10: testAddSingleServiceListenerBundleContextServiceListenerString

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
/**
 * Test method for
 * {@link org.springframework.osgi.util.OsgiListenerUtils#addSingleServiceListener(org.osgi.framework.BundleContext, org.osgi.framework.ServiceListener, java.lang.String)}.
 */
public void testAddSingleServiceListenerBundleContextServiceListenerString() {
	final List refs = new ArrayList();

	ServiceListener listener = new ServiceListener() {

		public void serviceChanged(ServiceEvent event) {
			if (ServiceEvent.REGISTERED == event.getType())
				refs.add(event.getSource());
		}
	};

	OsgiListenerUtils.addSingleServiceListener(bundleContext, listener, (String) null);

	assertFalse(refs.isEmpty());
	assertEquals(1, refs.size());
	assertSame(ref1, refs.get(0));
}
 
開發者ID:BeamFoundry,項目名稱:spring-osgi,代碼行數:22,代碼來源:OsgiListenerUtilsTest.java

示例11: 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

示例12: 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

示例13: 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

示例14: serviceChanged

import org.osgi.framework.ServiceEvent; //導入方法依賴的package包/類
public void serviceChanged(ServiceEvent arg0) {
	
	if (arg0.getType() == ServiceEvent.REGISTERED){
		ServiceReference sr = arg0.getServiceReference();
		String famaType = (String)sr.getProperty("famaType");
		if (famaType.equals("reasoner")){
			consumeReasoner(sr);
		}
		else if(famaType.equals("reader")){
			consumeReader(sr);
		}
		else if (famaType.equals("writer")){
			consumeWriter(sr);
		}
		else if (famaType.equals("selector")){
			consumeSelector(sr);
		}
		else if (famaType.equals("transform")){
			consumeTransform(sr);
		}
		else{
			throw new IllegalArgumentException("famaType value not valid");
		}
	}
	
}
 
開發者ID:isa-group,項目名稱:FaMA,代碼行數:27,代碼來源:Activator.java

示例15: 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


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