本文整理汇总了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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}