All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.felix.framework.ResolveContextImpl Maven / Gradle / Ivy

There is a newer version: 0.40.13
Show newest version
/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */
package org.apache.felix.framework;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.apache.felix.framework.StatefulResolver.ResolverHookRecord;
import org.apache.felix.framework.resolver.CandidateComparator;
import org.apache.felix.framework.resolver.HostedCapability;
import org.apache.felix.framework.resolver.ResolveContext;
import org.apache.felix.framework.resolver.ResolveException;
import org.osgi.framework.wiring.BundleCapability;
import org.osgi.framework.wiring.BundleRequirement;
import org.osgi.framework.wiring.BundleRevision;
import org.osgi.framework.wiring.BundleWiring;

/**
 *
 * @author rickhall
 */
public class ResolveContextImpl extends ResolveContext
{
    private final StatefulResolver m_state;
    private final Map m_wirings;
    private final ResolverHookRecord m_resolverHookrecord;
    private final Collection m_mandatory;
    private final Collection m_optional;
    private final Collection m_ondemand;

    ResolveContextImpl(
        StatefulResolver state, Map wirings,
        ResolverHookRecord resolverHookRecord, Collection mandatory,
        Collection optional, Collection ondemand)
    {
        m_state = state;
        m_wirings = wirings;
        m_resolverHookrecord = resolverHookRecord;
        m_mandatory = mandatory;
        m_optional = optional;
        m_ondemand = ondemand;
    }

    @Override
    public Collection getMandatoryRevisions()
    {
        return new ArrayList(m_mandatory);
    }

    @Override
    public Collection getOptionalRevisions()
    {
        return new ArrayList(m_optional);
    }

    public Collection getOndemandRevisions()
    {
        return new ArrayList(m_ondemand);
    }

    public List findProviders(BundleRequirement br, boolean obeyMandatory)
    {
        return m_state.findProvidersInternal(m_resolverHookrecord, br, obeyMandatory);
    }

    public int insertHostedCapability(List caps, HostedCapability hc)
    {
        int idx = Collections.binarySearch(caps, hc, new CandidateComparator());
        if (idx < 0)
        {
            idx = Math.abs(idx + 1);
        }
        caps.add(idx, hc);
        return idx;
    }

    public boolean isEffective(BundleRequirement br)
    {
        return m_state.isEffective(br);
    }

    public Map getWirings()
    {
        return m_wirings;
    }

    public void checkNativeLibraries(BundleRevision rev) throws ResolveException
    {
        m_state.checkNativeLibraries(rev);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy