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


Java BundleContext.createFilter方法代碼示例

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


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

示例1: createFilter

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
private static Filter createFilter(BundleContext context, PersistenceUnit punit) {
    String filter;
    if (punit.getPersistenceProviderClassName() != null) {
        filter = String.format("(&(objectClass=%s)(%s=%s))",
                               PersistenceProvider.class.getName(),
                               JAVAX_PERSISTENCE_PROVIDER,
                               punit.getPersistenceProviderClassName());
    } else {
        filter = String.format("(objectClass=%s)", PersistenceProvider.class.getName());
    }

    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:18,代碼來源:PersistenceProviderTracker.java

示例2: start

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
@Override
public void start(BundleContext context) throws Exception {
    String filterString = String.format("(|(objectClass=%s)(objectClass=%s))", RandomNumberGenerator.class.getName(), RandomStringGenerator.class.getName());
    serviceTracker = new ServiceTracker<>(context, context.createFilter(filterString), new ServiceTrackerCustomizer<Object, Object>() {
        @Override
        public Object addingService(ServiceReference<Object> reference) {
            setServiceReference(reference);
            consumeServicesIfPresent(context, randomNumberGeneratorServiceReference, randomStringGeneratorServiceReference);
            return context.getService(reference);
        }

        @Override
        public void modifiedService(ServiceReference<Object> reference, Object service) {

        }

        @Override
        public void removedService(ServiceReference<Object> reference, Object service) {
            unsetServiceReference(reference);
        }
    });
    serviceTracker.open();

    ServiceReference<Object>[] serviceReferences = serviceTracker.getServiceReferences();
    if (serviceReferences != null) {
        Arrays.stream(serviceReferences).forEach(this::setServiceReference);
    } else {
        log.info("serviceReferences is null");
    }

    consumeServicesIfPresent(context, randomNumberGeneratorServiceReference, randomStringGeneratorServiceReference);
}
 
開發者ID:L7R7,項目名稱:magic-bundle,代碼行數:33,代碼來源:Activator.java

示例3: createFilter

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
static Filter createFilter(BundleContext context, String driverClass, String puName) {
    if (driverClass == null) {
        throw new IllegalArgumentException("No javax.persistence.jdbc.driver supplied in persistence.xml");
    }
    String filter = String.format("(&(objectClass=%s)(%s=%s))",
                                  DataSourceFactory.class.getName(),
                                  DataSourceFactory.OSGI_JDBC_DRIVER_CLASS,
                                  driverClass);
    LOGGER.info("Tracking DataSourceFactory for punit " + puName + " with filter " + filter);
    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:16,代碼來源:DSFTracker.java

示例4: createFilter

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
static Filter createFilter(BundleContext context, String dsName, String puName) {
    if (dsName == null) {
        throw new IllegalArgumentException("No DataSource supplied in persistence.xml");
    }
    String subFilter = getSubFilter(dsName);
    String filter = String.format("(&(objectClass=%s)%s)",
                                  DataSource.class.getName(),
                                  subFilter);
    LOGGER.info("Tracking DataSource for punit " + puName + " with filter " + filter);
    try {
        return context.createFilter(filter);
    } catch (InvalidSyntaxException e) {
        throw new IllegalArgumentException(e);
    }
}
 
開發者ID:apache,項目名稱:aries-jpa,代碼行數:16,代碼來源:DataSourceTracker.java

示例5: create

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
/**
 * Creates an instance.
 *
 * @param serviceInterface
 *            the service interface
 * @param context
 *            the BundleContext
 * @param filter
 *            the OSGi service filter
 * @return new WaitingServiceTracker instance
 */
public static <T> WaitingServiceTracker<T> create(@Nonnull final Class<T> serviceInterface,
        @Nonnull final BundleContext context, @Nonnull final String filter) {
    String newFilter = String.format("(&(%s=%s)%s)", Constants.OBJECTCLASS, serviceInterface.getName(), filter);
    try {
        ServiceTracker<T, ?> tracker = new ServiceTracker<>(context, context.createFilter(newFilter), null);
        tracker.open();
        return new WaitingServiceTracker<>(serviceInterface, tracker);
    } catch (final InvalidSyntaxException e) {
        throw new IllegalArgumentException(String.format("Invalid OSGi filter %s", newFilter), e);
    }
}
 
開發者ID:hashsdn,項目名稱:hashsdn-controller,代碼行數:23,代碼來源:WaitingServiceTracker.java

示例6: DataSourceFactoryTracker

import org.osgi.framework.BundleContext; //導入方法依賴的package包/類
public DataSourceFactoryTracker ( final BundleContext context, final String driver, final SingleServiceListener<DataSourceFactory> listener ) throws InvalidSyntaxException
{
    super ( context, context.createFilter ( "(&(objectClass=" + DataSourceFactory.class.getName () + ")(" + DataSourceFactory.OSGI_JDBC_DRIVER_CLASS + "=" + driver + "))" ), listener );
    this.driver = driver;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:6,代碼來源:DataSourceFactoryTracker.java


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