Package org.osgi.framework

Examples of org.osgi.framework.Filter.match()


      throw new RuntimeException("Invalid filter: " + e.getFilter(), e);
    }
    Dictionary<String, String> matchProps = new Hashtable<String, String>(2);
    matchProps.put("location", bundleLocation);
    boolean negate = (args.length == 2) ? "!".equals(args[1]) : false;
    return (negate ^ filter.match(matchProps)) ? Condition.TRUE
        : Condition.FALSE;
  }

  private BundleLocationCondition() {
    // private constructor to prevent objects of this type
View Full Code Here


      throw new RuntimeException("Invalid filter: " + e.getFilter(), e);
    }
    Hashtable matchProps = new Hashtable(2);
    matchProps.put("location", bundleLocation);
    boolean negate = (args.length == 2) ? "!".equals(args[1]) : false;
    return (negate ^ filter.match(matchProps)) ? Condition.TRUE
        : Condition.FALSE;
  }

  private BundleLocationCondition() {
    // private constructor to prevent objects of this type
View Full Code Here

            while (matchedFilters.hasNext() && !matched) {
                String filterString = (String)matchedFilters.next();
                try {
                    Filter filter = context.createFilter(filterString);
                    matched =
                        filter.match(getProperties(notification, currInterface));
                } catch (InvalidSyntaxException ise) {
                    LOG.warning("invalid filter syntax: " + filterString);
                }
                if (matched) {
                    matches.add(currInterface);
View Full Code Here

            // set up the mock filter behaviour
            Dictionary<String, Object> d1 = new Hashtable<String, Object>();
            d1.put("blah", "5");
            d1.put("osgi.remote.service.interfaces",
                    Arrays.asList("SomeOtherService", "WithSomeSecondInterface"));
            EasyMock.expect(mockFilter.match(d1)).andReturn(true).anyTimes();
            Dictionary<String, Object> d2 = new Hashtable<String, Object>();
            d2.put("blah", "3");
            d2.put("boo", "hello");
            d2.put("osgi.remote.service.interfaces",
                    Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService"));
View Full Code Here

            Dictionary<String, Object> d2 = new Hashtable<String, Object>();
            d2.put("blah", "3");
            d2.put("boo", "hello");
            d2.put("osgi.remote.service.interfaces",
                    Arrays.asList("org.example.SomeRelatedService", "org.example.SomeService"));
            EasyMock.expect(mockFilter.match(d2)).andReturn(true).anyTimes();
           
            control.replay();
   
            // create the local discovery service
            LocalDiscoveryService lds = new LocalDiscoveryService(bc);
View Full Code Here

        String filter = "(|(osgi.remote.service.interfaces=org.acme.A)(osgi.remote.service.interfaces=org.acme.B))";

        Filter mockFilter = EasyMock.createMock(Filter.class);
        Dictionary<String, Object> map = new Hashtable<String, Object>();
        map.put("osgi.remote.service.interfaces", Arrays.asList("org.acme.B"));
        EasyMock.expect(mockFilter.match(map)).andReturn(true).anyTimes();
        EasyMock.replay(mockFilter);

        BundleContext bc = EasyMock.createNiceMock(BundleContext.class);
        EasyMock.expect(bc.createFilter(filter)).andReturn(mockFilter).anyTimes();
        EasyMock.replay(bc);
View Full Code Here

    private boolean filterMatches(String filterValue,
                                  ServiceEndpointDescription sd) {
        Filter filter = createFilter(filterValue);
        return filter != null
               ? filter.match(getServiceProperties(null, sd))
               : false;
    }

    @SuppressWarnings("unchecked")
    private Dictionary<String, Object> getServiceProperties(String interfaceName,
View Full Code Here

        if (matchingInterfaces.size() == 0 && matchingFilters.size() > 0) {
            Iterator filters = matchingFilters.iterator();
            while (filters.hasNext()) {
                Filter f = control.createMock(Filter.class);
                dswContext.addFilter((String)filters.next(), f);
                f.match(EasyMock.isA(Dictionary.class));
                EasyMock.expectLastCall().andReturn(true);
            }
        }

        control.replay();
View Full Code Here

        int level = d.getLevel();
        for (Map.Entry<String, Dictionary<String, String>> e : manifestEntries
            .entrySet()) {
          String otherLocation = e.getKey();
          if (!otherLocation.equals(location)
              && f.match(e.getValue())) {
            IsolationConstraint c = new IsolationConstraint(
                location, otherLocation, level);
            registry.add(c);
          }
        }
View Full Code Here

      String otherLocation = e.getKey();
      if (otherLocation.equals(location))
        continue;
      for (IsolationDirective d : e.getValue()) {
        Filter f = d.getFilter();
        if (f.match(props)) {
          int level = d.getLevel();
          IsolationConstraint c = new IsolationConstraint(
              otherLocation, location, level);
          registry.add(c);
        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.