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