本文整理汇总了Java中org.osgi.framework.Filter.match方法的典型用法代码示例。如果您正苦于以下问题:Java Filter.match方法的具体用法?Java Filter.match怎么用?Java Filter.match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.osgi.framework.Filter
的用法示例。
在下文中一共展示了Filter.match方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test
import org.osgi.framework.Filter; //导入方法依赖的package包/类
@Override
public boolean test(CachingServiceReference<T> ref) {
String target = (String)ref.getProperty(JAX_RS_WHITEBOARD_TARGET);
if (target == null) {
return true;
}
Filter filter;
try {
filter = FrameworkUtil.createFilter(target);
}
catch (InvalidSyntaxException ise) {
if (_log.isErrorEnabled()) {
_log.error("Invalid '{}' filter syntax in {}", JAX_RS_WHITEBOARD_TARGET, ref);
}
return false;
}
return filter.match(_serviceRuntimeReference);
}
示例2: findServices
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public Collection<RegistryServiceReference> findServices(String clazz, String filter) {
ArrayList<RegistryServiceReference> refs = new ArrayList<RegistryServiceReference>();
try {
Filter f = filter == null ? null : ctx.createFilter(filter);
for ( RegistryServiceReference ref : references.values() ) {
if ( clazz == null || clazz.equals( ref.getInterface() ) ) {
if ( f == null || f.match( new Hashtable(ref.getProperties()) ) ) {
refs.add( ref );
}
}
}
} catch (InvalidSyntaxException e) {
throw new IllegalStateException(e);
}
return refs;
}
示例3: getServiceReferences
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public ServiceReference[] getServiceReferences(String str, String str2) throws InvalidSyntaxException {
Collection collection;
checkValid();
Filter fromString = RFC1960Filter.fromString(str2);
if (str == null) {
collection = Framework.services;
} else {
List list = (List) Framework.classes_services.get(str);
if (list == null) {
return null;
}
}
List arrayList = new ArrayList();
ServiceReferenceImpl[] serviceReferenceImplArr = (ServiceReferenceImpl[]) collection.toArray(new ServiceReferenceImpl[collection.size()]);
for (int i = 0; i < serviceReferenceImplArr.length; i++) {
if (fromString.match(serviceReferenceImplArr[i])) {
arrayList.add(serviceReferenceImplArr[i]);
}
}
if (Framework.DEBUG_SERVICES && log.isInfoEnabled()) {
log.info("Framework: REQUESTED SERVICES " + str + " " + str2);
log.info("\tRETURNED " + arrayList);
}
return arrayList.size() == 0 ? null : (ServiceReference[]) arrayList.toArray(new ServiceReference[arrayList.size()]);
}
示例4: matches
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public boolean matches(ServiceReference sr, BundleContext bc) throws Exception {
if (getBSN() != null) {
if (!bc.getBundle().getSymbolicName().matches(getBSN())) {
return false;
}
}
if (getBundleVersion() != null) {
if (!bc.getBundle().getVersion().equals(getBundleVersion())) {
return false;
}
}
if (getServiceFilter() != null) {
Filter f = bc.createFilter(getServiceFilter());
return f.match(sr);
} else {
return false;
}
}
示例5: indexFile
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public IndexResult indexFile(File file) throws Exception {
IndexResult result = new IndexResult();
result.resource = new JarResource(file);
result.signature = getSignature();
synchronized (analyzers) {
for (Pair<ResourceAnalyzer, Filter> entry : analyzers) {
ResourceAnalyzer analyzer = entry.getFirst();
Filter filter = entry.getSecond();
if (filter == null || filter.match(result.resource.getProperties())) {
analyzer.analyzeResource(result.resource, result.capabilities, result.requirements);
}
}
}
return result;
}
示例6: getMatchingFilters
import org.osgi.framework.Filter; //导入方法依赖的package包/类
private static Set<Filter> getMatchingFilters(Set<Filter> filters, EndpointDescription endpoint) {
Set<Filter> matchingFilters = new HashSet<Filter>();
Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
for (Filter filter : filters) {
if (filter.match(dict)) {
LOG.debug("Filter {} matches endpoint {}", filter, dict);
matchingFilters.add(filter);
} else {
LOG.trace("Filter {} does not match endpoint {}", filter, dict);
}
}
return matchingFilters;
}
示例7: matchFilter
import org.osgi.framework.Filter; //导入方法依赖的package包/类
private static boolean matchFilter(String filter, EndpointDescription endpoint) {
if (filter == null) {
return false;
}
try {
Filter f = FrameworkUtil.createFilter(filter);
Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
}
}
示例8: matchFilter
import org.osgi.framework.Filter; //导入方法依赖的package包/类
private static boolean matchFilter(BundleContext bctx, String filter, EndpointDescription endpoint) {
if (filter == null) {
return false;
}
try {
Filter f = bctx.createFilter(filter);
Dictionary<String, Object> dict = new Hashtable<String, Object>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
}
}
示例9: matchFilter
import org.osgi.framework.Filter; //导入方法依赖的package包/类
private static boolean matchFilter(String filter, EndpointDescription endpoint) {
if (filter == null) {
return false;
}
try {
Filter f = FrameworkUtil.createFilter(filter);
Dictionary<String, Object> dict = new Hashtable<>(endpoint.getProperties());
return f.match(dict);
} catch (Exception e) {
return false;
}
}
示例10: getWires
import org.osgi.framework.Filter; //导入方法依赖的package包/类
/**
* Return a list of wires that matches the given filter
*
* The internal list of wires is matched against a filter. The wires that match the
* filter are added to a new wire array that is return as result.
* The filter is built from a string that express RFC1960 syntax. The matching is
* done on each wire properties dictionnary.
* If the provided filter string is null, the array return contains all wires.
* If the no wires are matched on the filter criteria, null is returned.
*
* @param filter An RFC1960 filter string.
* @throws org.osgi.framework.InvaalidSyntaxException if the filter has an invalid syntax.
* @return An array of wires, null if no wires are matched
*/
public Wire[] getWires(String filter) throws InvalidSyntaxException {
Wire[] wireArray = null;
synchronized( wires ) {
// if filter is null
if( filter == null ) {
// return all wires in the list
wireArray = (Wire[]) wires.toArray(new Wire[wires.size()]);
} else {
Filter wireFilter = Activator.bc.createFilter(filter);
List<Wire> result = new ArrayList<Wire>();
// try to match each wire in the list afainst the filter
for( int i = 0; i < wires.size(); i++ ){
WireImpl wire = wires.get(i);
if( wireFilter.match(wire.getProperties())){
// if matches, add it to the new list
result.add( wire );
}
}
// return results.
if( result.size() > 0 ) {
wireArray = (Wire[]) result.toArray(new Wire[result.size()]);
}
}
}
return wireArray;
}
示例11: hideService
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public boolean hideService(ServiceReference sr, BundleContext requestingBC) {
try {
for (RestrictRule r : restrictRules) {
if (r.matches(sr, requestingBC)) {
String s = r.getExtraFilter();
Filter f = requestingBC.createFilter(s);
return !f.match(sr);
}
}
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例12: isReferenceSuitable
import org.osgi.framework.Filter; //导入方法依赖的package包/类
@Override
protected boolean isReferenceSuitable(ParsedPersistenceUnit dependentObject, ServiceReference reference) {
Filter filter = dataSourceFiltersByPPUs.get(dependentObject);
if (filter == null) {
return true;
}
return filter.match(reference);
}
示例13: waitForExtensionDependencies
import org.osgi.framework.Filter; //导入方法依赖的package包/类
private OSGi<?> waitForExtensionDependencies(
CachingServiceReference<?> serviceReference,
CachingServiceReference<CXFJaxRsServiceRegistrator>
applicationRegistratorReference,
Consumer<CachingServiceReference<?>> onAddingDependent,
Consumer<CachingServiceReference<?>> onRemovingDependent) {
String applicationName = getApplicationName(
applicationRegistratorReference::getProperty);
String[] extensionDependencies = canonicalize(
serviceReference.getProperty(JAX_RS_EXTENSION_SELECT));
OSGi<CachingServiceReference<?>> program = just(serviceReference);
if (extensionDependencies.length > 0) {
onAddingDependent.accept(serviceReference);
}
else {
return program;
}
for (String extensionDependency : extensionDependencies) {
try {
extensionDependency = extensionDependency.replace(
"(objectClass=", "(original.objectClass=");
Filter extensionFilter = _bundleContext.createFilter(
extensionDependency);
if (
extensionFilter.match(_runtimeReference) ||
extensionFilter.match(
applicationRegistratorReference.getServiceReference())) {
continue;
}
program =
once(serviceReferences(ApplicationExtensionRegistration.class).
filter(
sr -> getApplicationName(sr::getProperty).equals(
applicationName)
).map(
CachingServiceReference::getServiceReference
).filter(
extensionFilter::match
)
).effects(
__ -> {},
__ -> onAddingDependent.accept(serviceReference)
).
then(program);
}
catch (InvalidSyntaxException e) {
}
}
program = onClose(
() -> onRemovingDependent.accept(serviceReference)).
then(program);
program = program.effects(
__ -> onRemovingDependent.accept(serviceReference),
__ -> {}
);
return program;
}
示例14: getServiceReferences
import org.osgi.framework.Filter; //导入方法依赖的package包/类
public Collection<ServiceReference> getServiceReferences(
BundleImpl origin,
Class<?> clazz,
String className,
Filter filter,
boolean checkAssignable)
throws InvalidSyntaxException
{
Filter classNameFilter
= FrameworkUtil.createFilter(
'('
+ Constants.OBJECTCLASS
+ '='
+ ((className == null) ? '*' : className)
+ ')');
List<ServiceReference> serviceReferences
= new LinkedList<ServiceReference>();
synchronized (serviceRegistrations)
{
for (ServiceRegistrationImpl serviceRegistration
: serviceRegistrations)
{
ServiceReference<?> serviceReference
= serviceRegistration.getReference();
if (classNameFilter.match(serviceReference)
&& ((filter == null)
|| (filter.match(serviceReference))))
{
ServiceReference serviceReferenceS
= serviceRegistration.getReference(clazz);
if (serviceReferenceS != null)
serviceReferences.add(serviceReferenceS);
}
}
}
return serviceReferences;
}
示例15: matches
import org.osgi.framework.Filter; //导入方法依赖的package包/类
@Override
protected boolean matches(final ServiceReference<S> capability, final Filter filter) {
return (filter == null) || filter.match(capability);
}