Package org.osgi.framework

Examples of org.osgi.framework.Filter


      String resolution = c.getDirective("resolution");

      boolean optional = Boolean.valueOf(resolution);
     
      String f = ManifestHeaderProcessor.generateFilter(Resource.SYMBOLIC_NAME, c.getContentName(), c.getAttributes());
      Filter filter;
      try {
        filter = FrameworkUtil.createFilter(f);
        _requirements[i] = new RequirementImpl("bundle", new FilterWrapper(filter), false, optional, false, comment);
      } catch (InvalidSyntaxException e) {
        // TODO work out what to do if his happens. If it does our filter generation code is bust.
View Full Code Here


    State containingState = getBundle().getContainingState();
    if (containingState == null)
      return false;
    Dictionary[] platformProps = containingState.getPlatformProperties();
    NativeCodeDescription nativeSupplier = (NativeCodeDescription) supplier;
    Filter filter = nativeSupplier.getFilter();
    boolean match = false;
    for (int i = 0; i < platformProps.length && !match; i++) {
      if (filter != null && !filter.matchCase(platformProps[i]))
        continue;
      String[] osNames = nativeSupplier.getOSNames();
      if (osNames.length == 0)
        match = true;
      else {
View Full Code Here

     *         <code>false</code> otherwise.
     * @throws IllegalArgumentException If <code>filter</code> contains an
     *                                  invalid filter string that cannot be parsed.
     */
    public boolean matches(String filter) {
        Filter f;
        try {
            f = FrameworkUtil.createFilter(filter);
        } catch (InvalidSyntaxException e) {
            IllegalArgumentException iae = new IllegalArgumentException(e.getMessage());
            iae.initCause(e);
            throw iae;
        }

        Dictionary dictionary = new Properties();
        for (Map.Entry<String, Object> entry : properties.entrySet()) {
            String key = entry.getKey();
            Object value = entry.getValue();
            dictionary.put(key, value);
        }
        /*
           * we can use matchCase here since properties already supports case
           * insensitive key lookup.
           */
        return f.matchCase(dictionary);
    }
View Full Code Here

            }
            else
            {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter( flt );
            tracker = new ServiceTracker( bundleContext, osgiFilter, null );
            tracker.open( true );

            Object svc = type.cast( tracker.waitForService( timeout ) );
            if ( svc == null )
View Full Code Here

  public void start(BundleContext context) throws Exception
  {
    ctx = context;
    logger = new Logger(ctx);

    Filter filter = getFilter(context, PACKAGE_ADMIN, START_LEVEL,
        PERMISSION_ADMIN, CONFIG_ADMIN, USER_ADMIN,
        PROVISIONING_SERVICE);

    tracker = new ServiceTracker(context, filter, this);
    tracker.open();
View Full Code Here

              + filter + "))";
        }
      } else {
        flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
      }
      Filter osgiFilter = FrameworkUtil.createFilter(flt);
      tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter,
          null);
      tracker.open();
     
      // add tracker to the list of trackers we close at tear down
View Full Code Here

                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
                }
            } else {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter(flt);
            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
            tracker.open();
           
            // add tracker to the list of trackers we close at tear down
            srs.add(tracker);
View Full Code Here

                    flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
                }
            } else {
                flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
            }
            Filter osgiFilter = FrameworkUtil.createFilter(flt);
            tracker = new ServiceTracker(bc == null ? bundleContext : bc, osgiFilter, null);
            tracker.open();
           
            // add tracker to the list of trackers we close at tear down
            srs.add(tracker);
View Full Code Here

            }
        }

        public void add(ServiceReference ref, ResourceHandler handler) {
            String filterString = (String) ref.getProperty("filter");
            Filter filter = null;
            if (filterString != null) {
                try {
                    filter = m_context.createFilter(filterString);
                }
                catch (InvalidSyntaxException e) {
                    Assert.fail("Could not create filter for resource handler: " + e);
                    return;
                }
            }
            synchronized (m_handlers) {
                m_handlers.put(handler, filter);
            }
            for (int i = 0; i < m_resources.length; i++) {
                if (filter == null || filter.match(ResourceUtil.createProperties(m_resources[i]))) {
                    handler.added(m_resources[i]);
                }
            }
        }
View Full Code Here

                }
            }
        }

        public void remove(ServiceReference ref, ResourceHandler handler) {
            Filter filter;
            synchronized (m_handlers) {
                filter = (Filter) m_handlers.remove(handler);
            }
            removeResources(handler, filter);
        }
View Full Code Here

TOP

Related Classes of org.osgi.framework.Filter

Copyright © 2018 www.massapicom. 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.