private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static void writeWire(ModuleWire wire, DataOutputStream out, Map<Object, Integer> objectTable) throws IOException { Wire w = wire; Integer capability = objectTable.get(w.getCapability()); Integer provider = objectTable.get(w.getProvider()); Integer requirement = objectTable.get(w.getRequirement()); Integer requirer = objectTable.get(w.getRequirer()); if (capability == null || provider == null || requirement == null || requirer == null) throw new NullPointerException("Could not find the expected indexes"); //$NON-NLS-1$ out.writeInt(addToWriteTable(wire, objectTable)); out.writeInt(capability); out.writeInt(provider); out.writeInt(requirement); out.writeInt(requirer); }
private static Object toJson(Map<Resource, List<Wire>> wiring) { Map<String, List<Map<String, Object>>> wires = new HashMap<>(); for (Map.Entry<Resource, List<Wire>> reswiring : wiring.entrySet()) { Resource resource = reswiring.getKey(); String id = toString(resource); List<Map<String, Object>> reswires = new ArrayList<>(); for (Wire w : reswiring.getValue()) { Map<String, Object> rw = new LinkedHashMap<>(); rw.put("requirement", toString(w.getRequirement())); rw.put("capability", toString(w.getCapability())); rw.put("requirer", toString(w.getRequirer())); rw.put("provider", toString(w.getProvider())); reswires.add(rw); } wires.put(id, reswires); } return wires; }
private void addWiredBundle(Map<Resource, List<Wire>> wirings, Resource resource, List<Resource> result) { List<Requirement> reqs = resource.getRequirements(BUNDLE_NAMESPACE); for (Requirement req : reqs) { List<Wire> wrs = wirings.get(resource); for (Wire w : wrs) { if (w.getRequirement() .equals(req)) { Resource res = w.getProvider(); if (res != null) { if (!result.contains(res)) { result.add(res); addWiredBundle(wirings, res, result); } } } } } }
private void addWiredBundle(Map<Resource, List<Wire>> wirings, Resource resource, List<Resource> result) { List<Requirement> reqs = resource.getRequirements(BUNDLE_NAMESPACE); for (Requirement req : reqs) { List<Wire> wrs = wirings.get(resource); for (Wire w : wrs) { if (w.getRequirement() .equals(req)) { Resource res = w.getProvider(); if (res != null) { if (!result.contains(res)) { result.add(res); addWiredBundle(wirings, res, result); } } } } } }
private static Resource findResolvedProvider(Wire wire, Set<Resource> resources, AbstractResolveContext rc) { // Make sure not to add new resources into the result. The resolver // already created the closure of all the needed resources. We need to // find the key in the result that already provides the capability // defined by this wire. Capability capability = wire.getCapability(); Resource resource = capability.getResource(); if (rc.isSystemResource(resource) || (ResourceUtils.isFragment(resource) && resources.contains(resource))) { return resource; } for (Resource resolved : resources) { for (Capability resolvedCap : resolved.getCapabilities(capability.getNamespace())) { if (ResourceUtils.matches(wire.getRequirement(), resolvedCap)) { return resolved; } } } // It shouldn't be possible to arrive here! throw new IllegalStateException( Strings.format("The capability for wire %s was not associated with a resource in the resolution", wire)); }
private static Resource findResolvedProvider(Wire wire, Set<Resource> resources, AbstractResolveContext rc) { // Make sure not to add new resources into the result. The resolver // already created the closure of all the needed resources. We need to // find the key in the result that already provides the capability // defined by this wire. Capability capability = wire.getCapability(); Resource resource = capability.getResource(); if (rc.isSystemResource(resource) || (ResourceUtils.isFragment(resource) && resources.contains(resource))) { return resource; } for (Resource resolved : resources) { for (Capability resolvedCap : resolved.getCapabilities(capability.getNamespace())) { if (ResourceUtils.matches(wire.getRequirement(), resolvedCap)) { return resolved; } } } // It shouldn't be possible to arrive here! throw new IllegalStateException( Strings.format("The capability for wire %s was not associated with a resource in the resolution", wire)); }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; } }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; } }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; }
private Capability getSatisfyingCapability(Requirement req) { // If the requiring revision is not resolved, then check in the // candidate map for its matching candidate. Capability cap = m_allCandidates.getFirstCandidate(req); // Otherwise, if the requiring revision is resolved then check // in its wires for the capability satisfying the requirement. if (cap == null && m_context.getWirings().containsKey(req.getResource())) { List<Wire> wires = m_context.getWirings().get(req.getResource()).getRequiredResourceWires(null); req = getDeclaredRequirement(req); for (Wire w : wires) { if (w.getRequirement().equals(req)) { // TODO: RESOLVER - This is not 100% correct, since requirements for // dynamic imports with wildcards will reside on many wires and // this code only finds the first one, not necessarily the correct // one. This is only used for the diagnostic message, but it still // could confuse the user. cap = w.getCapability(); break; } } } return cap; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Wire) { Wire w = (Wire) obj; if (capability.equals(w.getCapability()) && requirement.equals(w.getRequirement())) { Resource provider = getProvider(); Resource requirer = getRequirer(); return (provider == null ? w.getProvider() == null : provider.equals(w.getProvider())) && (requirer == null ? w.getRequirer() == null : requirer.equals(w.getRequirer())); } } return false; }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj instanceof Wire) { Wire w = (Wire) obj; if (capability.equals(w.getCapability()) && requirement.equals(w.getRequirement())) { Resource provider = getProvider(); Resource requirer = getRequirer(); return (provider == null ? w.getProvider() == null : provider.equals(w.getProvider())) && (requirer == null ? w.getRequirer() == null : requirer.equals(w.getRequirer())); } } return false; }
private static BundleWireDTO createBundleWireDTO(Wire wire, Set<BundleRevisionDTO> resources, Set<NodeDTO> nodes) { BundleWireDTO wdto = new BundleWireDTO(); if (wire instanceof BundleWire) { BundleWire w = (BundleWire) wire; BundleWiring pw = w.getProviderWiring(); addWiringNodeIfNotPresent(pw, resources, nodes); wdto.providerWiring = getWiringID(pw); BundleWiring rw = w.getRequirerWiring(); addWiringNodeIfNotPresent(rw, resources, nodes); wdto.requirerWiring = getWiringID(rw); } wdto.provider = getResourceIDAndAdd(wire.getProvider(), resources); wdto.requirer = getResourceIDAndAdd(wire.getRequirer(), resources); wdto.capability = new CapabilityRefDTO(); wdto.capability.capability = getCapabilityID(wire.getCapability()); wdto.capability.resource = getResourceIDAndAdd(wire.getCapability().getResource(), resources); wdto.requirement = new RequirementRefDTO(); wdto.requirement.requirement = getRequirementID(wire.getRequirement()); wdto.requirement.resource = getResourceIDAndAdd(wire.getRequirement().getResource(), resources); return wdto; }