Package org.osgi.framework

Examples of org.osgi.framework.Filter


        m_devA = new DeviceAnalyzer( m_context );
        Utils.inject( m_devA, LogService.class, m_log );
       
       
        String f1 = "(objectClass=org.osgi.service.device.Device)";
        Filter deviceFilter = FrameworkUtil.createFilter(f1);
        Mockito.when(m_context.createFilter(Mockito.eq(f1))).thenReturn(deviceFilter);
       
        String f2 = "(DEVICE_CATEGORY=*)";
        Filter driverFilter = FrameworkUtil.createFilter(f2);
        Mockito.when(m_context.createFilter(f2)).thenReturn(driverFilter);
       

        Utils.invoke( m_devA, "start" );
    }
View Full Code Here


    @Test
    public void VerifyValidFilterCreation() throws InvalidSyntaxException {
     
      Object[] data = new Object[]{Constants.DEVICE_CATEGORY, "dummy"};
      Filter filter = Util.createFilter("(%s=%s)", data);
     
     
      Properties matching = new Properties();
      matching.put(Constants.DEVICE_CATEGORY, new String[]{"dummy", "nonsense"});
      Assert.assertTrue("matching filter does not match", filter.match(matching));
     
      Properties notmatching = new Properties();
      notmatching.put(Constants.DEVICE_CATEGORY, new String[]{"lummy", "nonsense"});
      Assert.assertFalse("notmatching filter does match", filter.match(notmatching));

     
    }
View Full Code Here

    private ServiceTracker<RepositoryAdmin, RepositoryAdmin> repoTracker;

    public void start(BundleContext context) throws Exception
    {
        bundleContext = context;
        Filter f = context.createFilter("(&(objectClass=java.lang.String)(repository-xml=*))");
        repoXMLTracker = new ServiceTracker<String, String>(context, f, null) {
            @Override
            public String addingService(ServiceReference<String> reference)
            {
                try
View Full Code Here

        EasyMock.expect(systemBundleRevision.getCapabilities(null)).andReturn(Collections.<Capability>emptyList());
        EasyMock.expect(systemBundle.adapt(BundleRevision.class)).andReturn(systemBundleRevision);
        bundleContext.addBundleListener((BundleListener) EasyMock.anyObject());
        bundleContext.addServiceListener((ServiceListener) EasyMock.anyObject());
        EasyMock.expect(bundleContext.getBundles()).andReturn(new Bundle[] { systemBundle });
        EasyMock.expect(bundleContext.createFilter(null)).andReturn(new Filter() {
            public boolean match(ServiceReference reference) {
                return true;
            }
            public boolean match(Dictionary dictionary) {
                return true;
View Full Code Here

   
  @Validate
  private synchronized void start() {
    ApamManagers.addDynamicManager(this);
   
      Filter filter;
    try {
      filter = context.createFilter("(" + Constants.OBJECTCLASS + "=*)");
          instancesServiceTracker = new ServiceTracker(context,filter, this);
          instancesServiceTracker.open(true);
    } catch (InvalidSyntaxException ignored) {
View Full Code Here

    @Validate
    public void start() {
    ApamManagers.addDynamicManager(this);

        try {
            Filter filter = context.createFilter("(instance.name=*)");
            instancesServiceTracker = new ServiceTracker(context, filter, this);
            instancesServiceTracker.open();


        } catch (InvalidSyntaxException e) {
View Full Code Here

        {
            bundles = new Bundle[] { bundle };
        }
        else if (filter != null)
        {
            Filter f = getBundleContext().createFilter(filter);
            ArrayList list = new ArrayList(allBundles.length);
            final String localeString = locale.toString();
            for (int i = 0, size = allBundles.length; i < size; i++)
            {
                if (f.match(allBundles[i].getHeaders(localeString)))
                {
                    list.add(allBundles[i]);
                }
            }
            bundles = new Bundle[list.size()];
View Full Code Here

    }

    public Role[] getRoles(String filterValue) throws InvalidSyntaxException {
        Collection roles = m_entries.values();

        Filter filter = null;
        if (filterValue != null) {
            filter = FrameworkUtil.createFilter(filterValue);
        }

        List matchingRoles = new ArrayList();
        Iterator rolesIter = roles.iterator();
        while (rolesIter.hasNext()) {
            Role role = (Role) rolesIter.next();
            if ((filter == null) || filter.match(role.getProperties())) {
                matchingRoles.add(role);
            }
        }

        Role[] result = new Role[matchingRoles.size()];
View Full Code Here

            }

            try
            {
                BundleContext bundleContext = (BundleContext) bundleContextAttr;
                Filter filter = createFilter(bundleContext, null);
                this.eventDispatcherTracker = new ServiceTracker(bundleContext, filter, null)
                {
                    public void removedService(ServiceReference reference, Object service)
                    {
                        ProxyListener.this.sessionDispatcher = null;
View Full Code Here

    }

    private ServiceTracker trackOSGiCommands(final BundleContext context)
        throws InvalidSyntaxException
    {
        Filter filter = context.createFilter(String.format("(&(%s=*)(%s=*))",
            CommandProcessor.COMMAND_SCOPE, CommandProcessor.COMMAND_FUNCTION));

        return new ServiceTracker(context, filter, null)
        {
            private final ConcurrentMap<ServiceReference, Map<String, CommandProxy>> proxies
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.