当前位置: 首页>>代码示例>>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;未经允许,请勿转载。