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


Java ServiceTracker.getService方法代碼示例

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


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

示例1: getRegions

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static List<Region> getRegions() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJNDI.class).getBundleContext();

	ServiceTracker<RegionLocalService, RegionLocalService> tracker =
		new ServiceTracker<>(bundleContext, RegionLocalService.class, null);

	tracker.open();

	RegionLocalService regionLocalService = tracker.getService();

	try {
		List<Region> regions = regionLocalService.getRegions(
			0, getRegionsCount());

		return regions;
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();

	return null;
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:26,代碼來源:UseJNDI.java

示例2: useJNDI

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static void useJNDI() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJNDI.class).getBundleContext();

	ServiceTracker<RegionLocalService, RegionLocalService> tracker =
		new ServiceTracker<>(bundleContext, RegionLocalService.class, null);

	tracker.open();

	RegionLocalService regionLocalService = tracker.getService();

	try {
		regionLocalService.useJNDI();
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:21,代碼來源:UseJNDI.java

示例3: getCountries

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static List<Country> getCountries() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJDBC.class).getBundleContext();

	ServiceTracker<CountryLocalService, CountryLocalService> tracker =
		new ServiceTracker<>(
			bundleContext, CountryLocalService.class, null);

	tracker.open();

	CountryLocalService countryLocalService = tracker.getService();

	try {
		List<Country> countries = countryLocalService.getCountries(
			0, getCountriesCount());

		return countries;
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();

	return null;
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:27,代碼來源:UseJDBC.java

示例4: getHTTPClientFactory

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
@Override
public HTTPClientFactory getHTTPClientFactory(final ConnectionInstanceData instanceData) {
    final ServiceTracker proxyServiceTracker = TFSCommonUIClientPlugin.getDefault().getProxyServiceTracker();

    if (proxyServiceTracker.getService() != null) {
        if (log.isDebugEnabled()) {
            log.debug("IProxyService is available, returning an EclipseHttpClientFactory"); //$NON-NLS-1$
        }

        return new ProxyServiceHTTPClientFactory(instanceData, proxyServiceTracker);
    }

    if (log.isDebugEnabled()) {
        log.debug("IProxyService is not available, returning a LegacyHttpClientFactory"); //$NON-NLS-1$
    }

    return new LegacyHTTPClientFactory(instanceData);
}
 
開發者ID:Microsoft,項目名稱:team-explorer-everywhere,代碼行數:19,代碼來源:UIClientConnectionAdvisor.java

示例5: useJDBC

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static void useJDBC() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJDBC.class).getBundleContext();

	ServiceTracker<CountryLocalService, CountryLocalService> tracker =
		new ServiceTracker<>(
			bundleContext, CountryLocalService.class, null);

	tracker.open();

	CountryLocalService countryLocalService = tracker.getService();

	try {
		countryLocalService.useJDBC();
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:22,代碼來源:UseJDBC.java

示例6: getRegionsCount

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static int getRegionsCount() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJNDI.class).getBundleContext();

	ServiceTracker<RegionLocalService, RegionLocalService> tracker =
		new ServiceTracker<>(bundleContext, RegionLocalService.class, null);

	tracker.open();

	RegionLocalService regionLocalService = tracker.getService();

	try {
		int regionsCount = regionLocalService.getRegionsCount();

		return regionsCount;
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();

	return 0;
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:25,代碼來源:UseJNDI.java

示例7: getCountriesCount

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static int getCountriesCount() {
	BundleContext bundleContext = FrameworkUtil.getBundle(
		UseJDBC.class).getBundleContext();

	ServiceTracker<CountryLocalService, CountryLocalService> tracker =
		new ServiceTracker<>(
			bundleContext, CountryLocalService.class, null);

	tracker.open();

	CountryLocalService countryLocalService = tracker.getService();

	try {
		int regionsCount = countryLocalService.getCountriesCount();

		return regionsCount;
	}
	catch (Exception e) {
		e.printStackTrace();
	}

	tracker.close();

	return 0;
}
 
開發者ID:liferay,項目名稱:liferay-blade-samples,代碼行數:26,代碼來源:UseJDBC.java

示例8: createServiceTracker

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public synchronized ServiceTracker createServiceTracker(final Class<?> c) {
    ServiceTracker serviceTracker = new ServiceTracker(context, c.getName(), null);
    serviceTracker.open();
    long s = System.currentTimeMillis();
    while (serviceTracker.getService() == null) {
        try {
            Thread.sleep(50);
        } catch (InterruptedException e) {}

        if (System.currentTimeMillis() - s > 5000) {
            if (serviceTracker.getService() == null) {
                System.err.println(c.getName() + " 서비스를 사용 할 수 없습니다.");
            }
            break;
        }
    }

    return serviceTracker;
}
 
開發者ID:SK-HOLDINGS-CC,項目名稱:NEXCORE-UML-Modeler,代碼行數:20,代碼來源:Activator.java

示例9: testExtendedLogReaderServiceAvailable

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public void testExtendedLogReaderServiceAvailable() throws Exception {
    Framework f = IntegrationTest.findFramework();
    BundleContext bc = f.getBundleContext();
    
    ServiceTracker logReaderTracker = new ServiceTracker(bc, ExtendedLogReaderService.class.getName(), null);
    logReaderTracker.open();
            
    LogReaderService logReader = (ExtendedLogReaderService) logReaderTracker.getService();
    assertNotNull(logReader);
        
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:LogReaderServiceTest.java

示例10: logInternal

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
private static void logInternal(int level, String msg, Throwable ex) {
    boolean failedToGetLog = false;
    try {
        ServiceTracker<ExtendedLogService, ExtendedLogService> logTracker
        = Activator.getLogTracker();
        if (logTracker == null) {
            failedToGetLog = true;
            throw new IllegalStateException("logTracker is null");
        }

        ExtendedLogService logService = logTracker.getService();
        if (logService == null) {
            failedToGetLog = true;
            throw new IllegalStateException("logService is null");
        }

        Logger logger = logService.getLogger(EQUINOX_LOGGER);
        if (logger == null) {
            failedToGetLog = true;
            throw new IllegalStateException("logger is null");
        }
        logger.log(level, msg, ex);
    } catch (Exception exLog) {
        if (failedToGetLog) {
            System.err.println("LogService not found! Logging to stdout.");
        } else {
            System.err.println("ERROR while trying to log!");
            exLog.printStackTrace(System.err);
        }

        System.err.println("Attempted to log:");
        System.err.println("Message: " + msg);
        System.err.println("Exception: ");
        if (ex != null) {
            ex.printStackTrace(System.err);
        }
        System.err.println();
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:40,代碼來源:Log.java

示例11: activate

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
@Activate
void activate(BundleContext bundleContext) {
	ServiceTracker logServiceTracker = new ServiceTracker(bundleContext, LogService.class.getName(), null);
	logServiceTracker.open();
	
	LogService logService = (LogService) logServiceTracker.getService();
	
	if(logService != null)
        logService.log(LogService.LOG_INFO, "[" + this.getClass().getName() + "] Testing the logServiceWritter!");

}
 
開發者ID:maldiny,項目名稱:OSGI-en-Castellano,代碼行數:12,代碼來源:LogServiceWritter.java

示例12: activate

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
@Activate
void activate(BundleContext bundleContext) {
	ServiceTracker logServiceTracker = new ServiceTracker(bundleContext, LogService.class.getName(), null);
	logServiceTracker.open();
	
	LogService logService = (LogService) logServiceTracker.getService();
	
	ServiceReference ref = bundleContext.getServiceReference(org.osgi.service.log.LogReaderService.class.getName());
    if (ref != null)
    {
      org.osgi.service.log.LogReaderService reader = (org.osgi.service.log.LogReaderService)bundleContext.getService(ref);
      reader.addLogListener(new LogListenerImpl(logService));
    }
}
 
開發者ID:maldiny,項目名稱:OSGI-en-Castellano,代碼行數:15,代碼來源:LogServiceReader.java

示例13: trackService

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
private void trackService(BundleContext bc) {
ServiceTracker serviceTracker = new ServiceTracker(bc, "oog.common.OGraphFacade", null);
// Be sure to call open() before getService()
serviceTracker.open();

Object service = serviceTracker.getService();
if(service instanceof OGraphFacade) {
	facade = (OGraphFacade) service;
}		
  }
 
開發者ID:aroog,項目名稱:code,代碼行數:11,代碼來源:Activator.java

示例14: trackService

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
private void trackService(BundleContext bc) {
	ServiceTracker serviceTracker = new ServiceTracker(bc, "oog.common.OGraphFacade", null);
	// Be sure to call open() before getService()
	serviceTracker.open();

	Object service = serviceTracker.getService();
	if (service instanceof OGraphFacade) {
	// MotherFacade.setInstance((OGraphFacade) service);
	}
}
 
開發者ID:aroog,項目名稱:code,代碼行數:11,代碼來源:Activator.java

示例15: getNotNull

import org.osgi.util.tracker.ServiceTracker; //導入方法依賴的package包/類
public static <S, T> T getNotNull(ServiceTracker<S, T> serviceTracker) {
    T service = serviceTracker.getService();
    if (service == null)
        throw new IllegalStateException("Service is null");

    return service;
}
 
開發者ID:headwirecom,項目名稱:aem-ide-tooling-4-intellij,代碼行數:8,代碼來源:ServiceUtil.java


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