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


Java FrameworkUtil.getBundle方法代碼示例

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


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

示例1: MailEventHandler

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
public MailEventHandler ( final String id, final MailSender sender, final PipeService pipeService, final int retries ) throws Exception
{
    this.bundle = FrameworkUtil.getBundle ( MailHandlerFactory.class );
    this.sender = sender;
    this.retries = retries;

    final String pipeName = "mail." + id;

    try
    {
        this.producer = pipeService.createProducer ( pipeName );
        this.workerHandle = pipeService.createWorker ( pipeName, this.mailWorker );
    }
    catch ( final Exception e )
    {
        if ( this.sender != null )
        {
            this.sender.dispose ();
            this.sender = null;
        }
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:23,代碼來源:MailEventHandler.java

示例2: emit

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
protected void emit(
	ServiceReference<NestedCollectionRouter> serviceReference,
	Emitter<String> emitter) {

	Bundle bundle = FrameworkUtil.getBundle(
		NestedCollectionRouterManagerImpl.class);

	BundleContext bundleContext = bundle.getBundleContext();

	CustomServiceReferenceMapper<NestedCollectionRouter>
		customServiceReferenceMapper = new CustomServiceReferenceMapper<>(
			bundleContext, NestedCollectionRouter.class);

	NestedCollectionRouter nestedCollectionRouter =
		bundleContext.getService(serviceReference);

	Class<?> genericClass = getGenericClassFromPropertyOrElse(
		serviceReference, PARENT_MODEL_CLASS,
		() -> getTypeParamOrFail(
			nestedCollectionRouter, NestedCollectionRouter.class, 1));

	customServiceReferenceMapper.map(
		serviceReference,
		key -> emitter.emit(key + "-" + genericClass.getName()));
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:27,代碼來源:NestedCollectionRouterManagerImpl.java

示例3: execute

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
public Object execute() throws Exception {

    ShellTable table = new ShellTable();
    table.column("Path");
    table.column("Bundle Id");
    table.column("Bundle");
    table.column("UI Class");
    table.column("Production Mode");
    //table.column("Bundle Id");
    //table.column("State");

    for (VaadinProvider vaadinProvider : vaadinManager.getProviders()) {
        Bundle bundle = FrameworkUtil.getBundle(vaadinProvider.getClass());
        table.addRow().addContent(vaadinProvider.getPath(), bundle.getBundleId(), bundle.getSymbolicName(), vaadinProvider.getUIClass().getSimpleName(), vaadinProvider.productionMode());
    }

    table.print(System.out);

    return null;
}
 
開發者ID:andyphillips404,項目名稱:awplab-core,代碼行數:22,代碼來源:ProvidersCommand.java

示例4: getBundleId

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
private static String getBundleId(Object origin) {
  Class<?> clazz = null;
  if (origin == null) {
    clazz = StatusUtil.class;
  } else if (origin instanceof Class<?>) {
    clazz = (Class<?>) origin;
  } else {
    clazz = origin.getClass();
  }

  Bundle bundle = FrameworkUtil.getBundle(clazz);
  if (bundle == null) {
    return clazz.getName(); // what else can we do?
  }
  return bundle.getSymbolicName();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:17,代碼來源:StatusUtil.java

示例5: ensureInitialized

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
private static void ensureInitialized() {
    boolean startTracker = false;
    synchronized (HibernateUtil.class) {
        if(tracker == null) {
            Bundle bundle = FrameworkUtil.getBundle(HibernateUtil.class);
            tracker = new ServiceTracker<>(bundle.getBundleContext(),
                    DBConnectionManager.class, null);
            startTracker = true;
        }
    }

    if (startTracker) {
        tracker.open();
    }
}
 
開發者ID:opensecuritycontroller,項目名稱:osc-core,代碼行數:16,代碼來源:HibernateUtil.java

示例6: emit

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
/**
 * Emits a the key of a service using an {@link Emitter<String>}.
 *
 * @param  serviceReference the service reference
 * @param  emitter the emitter
 * @review
 */
protected void emit(
	ServiceReference<T> serviceReference, Emitter<String> emitter) {

	Bundle bundle = FrameworkUtil.getBundle(BaseManager.class);

	BundleContext bundleContext = bundle.getBundleContext();

	CustomServiceReferenceMapper<T> customServiceReferenceMapper =
		new CustomServiceReferenceMapper<>(
			bundleContext, getManagedClass());

	customServiceReferenceMapper.map(serviceReference, emitter);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:21,代碼來源:BaseManager.java

示例7: emit

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
protected void emit(
	ServiceReference<Representable> serviceReference,
	Emitter<String> emitter) {

	Bundle bundle = FrameworkUtil.getBundle(
		NestedCollectionRouterManagerImpl.class);

	BundleContext bundleContext = bundle.getBundleContext();

	Representable representable = bundleContext.getService(
		serviceReference);

	emitter.emit(representable.getName());
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:16,代碼來源:ModelClassManagerImpl.java

示例8: removedService

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
public default void removedService(
	ServiceReference<T> serviceReference,
	ServiceRegistration<?> serviceRegistration) {

	Bundle bundle = FrameworkUtil.getBundle(
		ServiceRegistrationServiceTrackerCustomizer.class);

	BundleContext bundleContext = bundle.getBundleContext();

	bundleContext.ungetService(serviceReference);

	serviceRegistration.unregister();
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:15,代碼來源:ServiceRegistrationServiceTrackerCustomizer.java

示例9: addingService

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
public U addingService(ServiceReference<T> serviceReference) {
	Bundle bundle = FrameworkUtil.getBundle(
		TransformServiceTrackerCustomizer.class);

	BundleContext bundleContext = bundle.getBundleContext();

	T t = bundleContext.getService(serviceReference);

	Class<?> modelClass = getGenericClassFromPropertyOrElse(
		serviceReference, MODEL_CLASS,
		() -> getTypeParamOrFail(t, _managedClass, 0));

	return map(t, serviceReference, modelClass);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:16,代碼來源:TransformServiceTrackerCustomizer.java

示例10: removedService

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
public void removedService(ServiceReference<T> serviceReference, U u) {
	Bundle bundle = FrameworkUtil.getBundle(
		TransformServiceTrackerCustomizer.class);

	BundleContext bundleContext = bundle.getBundleContext();

	bundleContext.ungetService(serviceReference);

	onRemovedService(serviceReference, u);
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:12,代碼來源:TransformServiceTrackerCustomizer.java

示例11: load

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Override
public Image load(String fullPath) throws Exception {
	Bundle bundle = FrameworkUtil.getBundle(ViewLabelProvider.class);
	URL url = FileLocator.find(bundle, new Path(fullPath), null);
	ImageDescriptor imageDcr = ImageDescriptor.createFromURL(url);
	return imageDcr.createImage();
}
 
開發者ID:termsuite,項目名稱:termsuite-ui,代碼行數:8,代碼來源:TermsuiteImg.java

示例12: getImageDescriptor

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
public static ImageDescriptor getImageDescriptor(String path){
	Bundle bundle = FrameworkUtil.getBundle(IconUtils.class);
    URL url = FileLocator.find(bundle, new Path(path), null);
    if(url!=null){
    	return ImageDescriptor.createFromURL(url);
    }
    return null;
}
 
開發者ID:aroog,項目名稱:code,代碼行數:9,代碼來源:IconUtils.java

示例13: loadResource

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
/** {@inheritDoc}} */
@Override
public <T> T loadResource(final Class<?> bundleClazz, final Class<T> resourceTypeclazz, final String pathToFile)
		throws IOException {
	final Bundle bundle = FrameworkUtil.getBundle(bundleClazz);
	final InputStream stream = FileLocator.openStream(bundle, new Path(pathToFile), false);

	if (resourceTypeclazz.isInstance(InputStream.class)) {
		return resourceTypeclazz.cast(stream);
	}

	return null;
}
 
開發者ID:amitjoy,項目名稱:Kura-MQTT-Client-Utility,代碼行數:14,代碼來源:BundleResourceLoaderImpl.java

示例14: getDataFile

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
private static InputStream getDataFile(String fileName) throws IOException {
  Bundle bundle = FrameworkUtil.getBundle(TemplatesTest.class);
  URL expectedFileUrl = bundle.getResource("/testData/templates/appengine/" + fileName);
  if (expectedFileUrl == null) {
    throw new IOException("Could not find comparison file " + fileName);
  }
  return expectedFileUrl.openStream();
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:9,代碼來源:TemplatesTest.java

示例15: testConvertJobClassName

import org.osgi.framework.FrameworkUtil; //導入方法依賴的package包/類
@Test
public void testConvertJobClassName() {
  String convertJobClass =
      ConvertJobSuspender.CONVERT_JOB_CLASS_NAME.replace(".", "/") + ".class";
  Bundle jsdtWebCoreBundle = FrameworkUtil.getBundle(JsNameManglerUtil.class);
  assertNotNull(jsdtWebCoreBundle.getResource(convertJobClass));
}
 
開發者ID:GoogleCloudPlatform,項目名稱:google-cloud-eclipse,代碼行數:8,代碼來源:ConvertJobSuspenderTest.java


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