org.osgi.resource.Wire Java Examples

The following examples show how to use org.osgi.resource.Wire. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Concierge.java    From concierge with Eclipse Public License 1.0 6 votes vote down vote up
public synchronized Map<Resource, List<Wire>> resolve(
		final ResolveContext context) throws ResolutionException {
	if (context == null) {
		throw new IllegalArgumentException("context is null");
	}

	final MultiMap<Resource, Wire> solution = new MultiMap<Resource, Wire>();
	final ArrayList<Requirement> unresolvedRequirements = new ArrayList<Requirement>();
	final ArrayList<Resource> unresolvedResources = new ArrayList<Resource>();

	resolve0(context, solution, unresolvedRequirements,
			unresolvedResources, true);

	if (!unresolvedRequirements.isEmpty()
			|| !unresolvedResources.isEmpty()) {
		throw new ResolutionException("Could not resolve.", null,
				unresolvedRequirements);
	}

	return solution.getFlatMap();
}
 
Example #2
Source File: RepositoryManagerImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Set<Resource> findResolution(List<Resource> resources)
    throws Exception {
  Resolver resolver = resolverTracker.getService();
  if (resolver == null) {
    throw new Exception(
        "Unable to find resolution: No Resolver service available!");
  }

  ResolveContextImpl rc = new ResolveContextImpl(bc, resources,
      new ArrayList<Resource>());
  Map<Resource, List<Wire>> resolution = resolver.resolve(rc);
  return resolution.keySet();
}
 
Example #3
Source File: Concierge.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
private void hostFragment(final ResolveContext context,
		final BundleRevision fragment, final BundleRevision host,
		final MultiMap<Resource, Wire> solution) {
	// host the capabilities
	for (final Capability cap : fragment.getCapabilities(null)) {
		if (!IdentityNamespace.IDENTITY_NAMESPACE
				.equals(cap.getNamespace())) {
			final HostedBundleCapability hostedCap = new HostedBundleCapability(
					host, cap);

			context.insertHostedCapability(
					new ArrayList<Capability>(host.getCapabilities(
							PackageNamespace.PACKAGE_NAMESPACE)),
					hostedCap);
		}
	}

	// create host wire
	final Capability hostCapability = host
			.getCapabilities(HostNamespace.HOST_NAMESPACE).get(0);
	final Requirement hostRequirement = fragment
			.getRequirements(HostNamespace.HOST_NAMESPACE).get(0);

	final Wire wire = Resources.createWire(hostCapability,
			hostRequirement);
	solution.insert(fragment, wire);
	solution.insert(host, wire);
}
 
Example #4
Source File: Resources.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
public boolean equals(final Object o) {
	if (o instanceof AbstractWireImpl) {
		return o == this;
	}
	if (o instanceof Wire) {
		final Wire w = (Wire) o;
		return w.getRequirer().equals(requirement.getResource())
				&& w.getRequirement().equals(requirement)
				&& w.getProvider().equals(capability.getResource())
				&& w.getCapability().equals(capability);
	}
	return false;
}
 
Example #5
Source File: Resources.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
private void addWire(final Wire wire) {
	if (wire.getProvider() == resource) {
		final Capability cap = wire.getCapability();
		capabilities.insertUnique(cap.getNamespace(), cap);
		providedWires.insert(cap.getNamespace(), wire);
	} else {
		final Requirement req = wire.getRequirement();
		requirements.insertUnique(req.getNamespace(), req);
		requiredWires.insert(req.getNamespace(), wire);
	}
}
 
Example #6
Source File: BundleImpl.java    From concierge with Eclipse Public License 1.0 5 votes vote down vote up
ConciergeBundleWiring addAdditionalWires(final List<Wire> wires) {
	for (final Wire wire : wires) {
		wiring.addWire((BundleWire) wire);
	}

	packageImportWires = wiring.getPackageImportWires();
	requireBundleWires = wiring.getRequireBundleWires();
	return wiring;
}
 
Example #7
Source File: ClassLoaderOsgiFramework.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public List<Wire> getProvidedResourceWires(String p1) {
    throw new UnsupportedOperationException();
}
 
Example #8
Source File: BundleWiringImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<Wire> getRequiredResourceWires(String namespace) {
  return (List<Wire>)(List<?>)getRequiredWires(namespace);
}
 
Example #9
Source File: BundleWiringImpl.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public List<Wire> getProvidedResourceWires(String namespace) {
  return (List<Wire>)(List<?>)getProvidedWires(namespace);
}
 
Example #10
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
public List<Wire> getRequiredResourceWires(final String namespace) {
	final List<BundleWire> bwires = getRequiredWires(namespace);
	return bwires == null ? null : new ArrayList<Wire>(bwires);
}
 
Example #11
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
public List<Wire> getProvidedResourceWires(final String namespace) {
	final List<BundleWire> bwires = getProvidedWires(namespace);
	return bwires == null ? null : new ArrayList<Wire>(bwires);
}
 
Example #12
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
public List<Wire> getRequiredResourceWires(final String namespace) {
	return namespace == null ? requiredWires.getAllValues()
			: requiredWires.lookup(namespace);
}
 
Example #13
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
public List<Wire> getProvidedResourceWires(final String namespace) {
	return namespace == null ? providedWires.getAllValues()
			: providedWires.lookup(namespace);
}
 
Example #14
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
ConciergeWiring(final Resource resource, final List<Wire> wires) {
	this.resource = resource;
	for (final Wire wire : wires) {
		addWire(wire);
	}
}
 
Example #15
Source File: Resources.java    From concierge with Eclipse Public License 1.0 4 votes vote down vote up
static Wire createWire(final Capability cap, final Requirement req) {
	return cap instanceof BundleCapability
			&& req instanceof BundleRequirement ? new ConciergeBundleWire(
			(BundleCapability) cap, (BundleRequirement) req)
			: new ConciergeWire(cap, req);
}
 
Example #16
Source File: MockBundle.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public List<Wire> getProvidedResourceWires(String p1) {
    throw new UnsupportedOperationException();
}
 
Example #17
Source File: MockBundle.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public List<Wire> getRequiredResourceWires(String p1) {
    throw new UnsupportedOperationException();
}
 
Example #18
Source File: ClassLoaderOsgiFramework.java    From vespa with Apache License 2.0 4 votes vote down vote up
@Override
public List<Wire> getRequiredResourceWires(String p1) {
    throw new UnsupportedOperationException();
}
 
Example #19
Source File: Resolver.java    From concierge with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Resolve the specified resolve context and return any new resources and
 * wires to the caller.
 * 
 * <p>
 * The resolver considers two groups of resources:
 * <ul>
 * <li>Mandatory - any resource in the
 * {@link ResolveContext#getMandatoryResources() mandatory group} must be
 * resolved. A failure to satisfy any mandatory requirement for these
 * resources will result in throwing a {@link ResolutionException}</li>
 * <li>Optional - any resource in the
 * {@link ResolveContext#getOptionalResources() optional group} may be
 * resolved. A failure to satisfy a mandatory requirement for a resource in
 * this group will not fail the overall resolution but no resources or wires
 * will be returned for that resource.</li>
 * </ul>
 * 
 * <p>
 * The resolve method returns the delta between the start state defined by
 * {@link ResolveContext#getWirings()} and the end resolved state. That is,
 * only new resources and wires are included.
 * 
 * <p>
 * The behavior of the resolver is not defined if the specified resolve
 * context supplies inconsistent information.
 * 
 * @param context The resolve context for the resolve operation. Must not be
 *        {@code null}.
 * @return The new resources and wires required to satisfy the specified
 *         resolve context. The returned map is the property of the caller
 *         and can be modified by the caller.
 * @throws ResolutionException If the resolution cannot be satisfied.
 */
Map<Resource, List<Wire>> resolve(ResolveContext context) throws ResolutionException;
 
Example #20
Source File: BundleWiring.java    From concierge with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the {@link Wire}s to the provided {@link Capability capabilities}
 * of this wiring.
 * 
 * <p>
 * This method returns the same value as {@link #getProvidedWires(String)}.
 * 
 * @param namespace The namespace of the capabilities for which to return
 *        wires or {@code null} to return the wires for the capabilities in
 *        all namespaces.
 * @return A list containing a snapshot of the {@link Wire}s for the
 *         {@link Capability capabilities} of this wiring, or an empty list
 *         if this wiring has no capabilities in the specified namespace.
 *         For a given namespace, the list contains the wires in the order
 *         the capabilities were specified in the manifests of the
 *         {@link #getResource() resource} and the attached fragment
 *         resources of this wiring. There is no ordering defined between
 *         capabilities in different namespaces.
 * @since 1.1
 */
List<Wire> getProvidedResourceWires(String namespace);
 
Example #21
Source File: BundleWiring.java    From concierge with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the {@link Wire}s to the {@link Requirement requirements} in use
 * by this wiring.
 * 
 * <p>
 * This method returns the same value as {@link #getRequiredWires(String)}.
 * 
 * @param namespace The namespace of the requirements for which to return
 *        wires or {@code null} to return the wires for the requirements in
 *        all namespaces.
 * @return A list containing a snapshot of the {@link Wire}s for the
 *         {@link Requirement requirements} of this wiring, or an empty list
 *         if this wiring has no requirements in the specified namespace.
 *         For a given namespace, the list contains the wires in the order
 *         the requirements were specified in the manifests of the
 *         {@link #getResource() resource} and the attached fragment
 *         resources of this wiring. There is no ordering defined between
 *         requirements in different namespaces.
 * @since 1.1
 */
List<Wire> getRequiredResourceWires(String namespace);
 
Example #22
Source File: Resolver.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Resolve the specified resolve context and return any new resources and
 * wires to the caller.
 * 
 * <p>
 * The resolver considers two groups of resources:
 * <ul>
 * <li>Mandatory - any resource in the
 * {@link ResolveContext#getMandatoryResources() mandatory group} must be
 * resolved. A failure to satisfy any mandatory requirement for these
 * resources will result in throwing a {@link ResolutionException}</li>
 * <li>Optional - any resource in the
 * {@link ResolveContext#getOptionalResources() optional group} may be
 * resolved. A failure to satisfy a mandatory requirement for a resource in
 * this group will not fail the overall resolution but no resources or wires
 * will be returned for that resource.</li>
 * </ul>
 * 
 * <p>
 * The resolve method returns the delta between the start state defined by
 * {@link ResolveContext#getWirings()} and the end resolved state. That is,
 * only new resources and wires are included.
 * 
 * <p>
 * The behavior of the resolver is not defined if the specified resolve
 * context supplies inconsistent information.
 * 
 * @param context The resolve context for the resolve operation. Must not be
 *        {@code null}.
 * @return The new resources and wires required to satisfy the specified
 *         resolve context. The returned map is the property of the caller
 *         and can be modified by the caller.
 * @throws ResolutionException If the resolution cannot be satisfied.
 */
Map<Resource, List<Wire>> resolve(ResolveContext context) throws ResolutionException;
 
Example #23
Source File: BundleWiring.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Returns the {@link Wire}s to the provided {@link Capability capabilities}
 * of this wiring.
 * 
 * <p>
 * This method returns the same value as {@link #getProvidedWires(String)}.
 * 
 * @param namespace The namespace of the capabilities for which to return
 *        wires or {@code null} to return the wires for the capabilities in
 *        all namespaces.
 * @return A list containing a snapshot of the {@link Wire}s for the
 *         {@link Capability capabilities} of this wiring, or an empty list
 *         if this wiring has no capabilities in the specified namespace.
 *         For a given namespace, the list contains the wires in the order
 *         the capabilities were specified in the manifests of the
 *         {@link #getResource() resource} and the attached fragment
 *         resources of this wiring. There is no ordering defined between
 *         capabilities in different namespaces.
 * @since 1.1
 */
List<Wire> getProvidedResourceWires(String namespace);
 
Example #24
Source File: BundleWiring.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 2 votes vote down vote up
/**
 * Returns the {@link Wire}s to the {@link Requirement requirements} in use
 * by this wiring.
 * 
 * <p>
 * This method returns the same value as {@link #getRequiredWires(String)}.
 * 
 * @param namespace The namespace of the requirements for which to return
 *        wires or {@code null} to return the wires for the requirements in
 *        all namespaces.
 * @return A list containing a snapshot of the {@link Wire}s for the
 *         {@link Requirement requirements} of this wiring, or an empty list
 *         if this wiring has no requirements in the specified namespace.
 *         For a given namespace, the list contains the wires in the order
 *         the requirements were specified in the manifests of the
 *         {@link #getResource() resource} and the attached fragment
 *         resources of this wiring. There is no ordering defined between
 *         requirements in different namespaces.
 * @since 1.1
 */
List<Wire> getRequiredResourceWires(String namespace);