Package org.osgi.framework

Examples of org.osgi.framework.Filter


     * @param f The filter for the listener; may be null.
    **/
    void addServiceListener(BundleImpl bundle, ServiceListener l, String f)
        throws InvalidSyntaxException
    {
        Filter oldFilter;
        Filter newFilter = (f == null) ? null : FrameworkUtil.createFilter(f);

        oldFilter = m_dispatcher.addListener(
            bundle._getBundleContext(), ServiceListener.class, l, newFilter);

        // Invoke ListenerHook.removed() if filter updated.
View Full Code Here


                                            + this.reference.getBundle() + ")]");
            this.topics = null;
            valid = false;
        }
        // Second check filter (but only if topics is valid)
        Filter handlerFilter = null;
        if ( valid )
        {
            final Object filterObj = reference.getProperty(EventConstants.EVENT_FILTER);
            if (filterObj instanceof String)
            {
View Full Code Here

        {
            return false;
        }

        // filter match
        final Filter eventFilter = this.filter;
        if ( eventFilter != null && !event.matches(eventFilter) )
        {
            return false;
        }
View Full Code Here

    /* (non-Javadoc)
     * @see org.osgi.framework.BundleContext#createFilter(java.lang.String)
     */
    public Filter createFilter( String arg0 )
    {
        return new Filter()
        {

            public boolean match( ServiceReference arg0 )
            {
                return true;
View Full Code Here

        return optionsFactory;
    }

    private void addMetaTypeNames( final Map pidMap, final Map ocdCollection, final String filterSpec, final String type )
    {
        Filter filter = null;
        if ( filterSpec != null )
        {
            try
            {
                filter = getBundleContext().createFilter( filterSpec );
            }
            catch ( InvalidSyntaxException not_expected )
            {
                /* filter is correct */
            }
        }

        for ( Iterator ei = ocdCollection.entrySet().iterator(); ei.hasNext(); )
        {
            Entry ociEntry = ( Entry ) ei.next();
            final String pid = ( String ) ociEntry.getKey();
            final ObjectClassDefinition ocd = ( ObjectClassDefinition ) ociEntry.getValue();
            if ( filter == null )
            {
                pidMap.put( pid, ocd.getName() );
            }
            else
            {
                final Dictionary props = new Hashtable();
                props.put( type, pid );
                if ( filter.match( props ) )
                {
                    pidMap.put( pid, ocd.getName() );
                }
            }
        }
View Full Code Here

            {
                try
                {
                    final String filterString = "(&(" + Constants.OBJECTCLASS + "=" //$NON-NLS-1$ //$NON-NLS-2$
                        + HTTP_SERVICE + ")(" + httpServiceSelector + "))"; //$NON-NLS-1$ //$NON-NLS-2$
                    Filter filter = osgiManager.getBundleContext().createFilter(
                        filterString);
                    return new HttpServiceTracker(osgiManager, httpServiceSelector,
                        filter);
                }
                catch (InvalidSyntaxException ise)
View Full Code Here

    public synchronized Resource[] discoverResources(String filterExpr) throws InvalidSyntaxException
    {
        initialize();

        Filter filter = filterExpr != null ? m_helper.filter(filterExpr) : null;
        Resource[] resources;
        MapToDictionary dict = new MapToDictionary(null);
        Repository[] repos = listRepositories();
        List matchList = new ArrayList();
        for (int repoIdx = 0; (repos != null) && (repoIdx < repos.length); repoIdx++)
        {
            resources = repos[repoIdx].getResources();
            for (int resIdx = 0; (resources != null) && (resIdx < resources.length); resIdx++)
            {
                dict.setSourceMap(resources[resIdx].getProperties());
                if (filter == null || filter.match(dict))
                {
                    matchList.add(resources[resIdx]);
                }
            }
        }
View Full Code Here

    @Override
    public Role[] getRoles(String filterValue) throws InvalidSyntaxException, MongoException {
        List<Role> roles = new ArrayList<Role>();

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

        DBCollection coll = getCollection();

        DBCursor cursor = coll.find();
        try {
            while (cursor.hasNext()) {
                // Hmm, there might be a more clever way of doing this...
                Role role = m_helper.deserialize(cursor.next());
                if ((filter == null) || filter.match(role.getProperties())) {
                    roles.add(role);
                }
            }
        } finally {
            cursor.close();
View Full Code Here

    public static boolean isDevice( ServiceReference ref )
    {
        try
        {
            Filter device = createFilter( "(|(%s=%s)(%s=%s))", new Object[]
                {
                Constants.OBJECTCLASS, Device.class.getName(),
                org.osgi.service.device.Constants.DEVICE_CATEGORY, "*"
                }
            );
            return device.match( ref );
        }
        catch ( Exception e )
        {
            e.printStackTrace();
        }
View Full Code Here

   
    public static boolean isDeviceInstance( ServiceReference ref )
    {
        try
        {
            Filter device = createFilter( "(%s=%s)", new Object[]
                { Constants.OBJECTCLASS, Device.class.getName() } );
            return device.match( ref );
        }
        catch ( Exception e )
        {
            e.printStackTrace();
        }
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.