/** Returns a copy of this spec with namespace set to null **/ public ComponentSpecification withoutNamespace() { return new ComponentSpecification(getName(), getVersionSpecification(), null); }
public static Bundle getBundle(Osgi osgi, String bundleSpec) { Bundle bundle = osgi.getBundle(ComponentSpecification.fromString(bundleSpec)); if (bundle == null) { throw new IllegalArgumentException("Bundle not found: " + bundleSpec); } return bundle; }
public BundleInstantiationSpecification(ComponentSpecification id, ComponentSpecification classId, ComponentSpecification bundle) { this.id = id.toId(); this.classId = (classId != null) ? classId : id.withoutNamespace(); this.bundle = (bundle != null) ? bundle : this.classId; }
private boolean hasOnlyName(ComponentSpecification sourceSpec) { return new ComponentSpecification(sourceSpec.getName()).equals(sourceSpec); }
private static BundleInstantiationSpecification getInternalSpecificationFromString(String idSpec, String classSpec) { return new BundleInstantiationSpecification( new ComponentSpecification(idSpec), (classSpec == null || classSpec.isEmpty())? null : new ComponentSpecification(classSpec), new ComponentSpecification(defaultInternalBundle)); }
public ComponentSpecification nestInNamespace(ComponentId namespace) { ComponentId newNameSpace = (getNamespace() == null) ? namespace : getNamespace().nestInNamespace(namespace); return new ComponentSpecification(getName(), getVersionSpecification(), newNameSpace); }
public String getClassName() { return classId.getName(); }
public void fillQueryProfileTypes(List<Element> queryProfileTypeElements, QueryProfileTypeRegistry registry) { for (Element element : queryProfileTypeElements) { QueryProfileType type = registry.getComponent(new ComponentSpecification(element.getAttribute("id")).toId()); try { readInheritedTypes(element, type, registry); readFieldDefinitions(element, type, registry); } catch (RuntimeException e) { throw new IllegalArgumentException("Error reading " + type, e); } } }
/** Converts the specification to an id */ public ComponentId toId() { Version version = (getVersionSpecification() == VersionSpecification.emptyVersionSpecification) ? Version.emptyVersion : getVersionSpecification().lowestMatchingVersion(); return new ComponentId(getName(), version, getNamespace()); }
/** * Checks if a componentId matches a given spec */ public boolean matches(ComponentId id) { boolean versionMatch = getVersionSpecification().matches(id.getVersion()); return getName().equals(id.getName()) && versionMatch && namespaceMatch(id.getNamespace()); }
/** * Returns the bundle of a given name having the highest matching version * * @param id the id of the component to return. May not include a version, or include * an underspecified version, in which case the highest (mathcing) version which * does not contain a qualifier is returned * @return the bundle match having the highest version, or null if there was no matches */ public Bundle getBundle(ComponentSpecification id) { Bundle highestMatch=null; for (Bundle bundle : getBundles()) { assert bundle.getSymbolicName() != null : "ensureHasBundleSymbolicName not called during installation"; if ( ! bundle.getSymbolicName().equals(id.getName())) continue; if ( ! id.getVersionSpecification().matches(versionOf(bundle))) continue; if (highestMatch==null || versionOf(highestMatch).compareTo(versionOf(bundle))<0) highestMatch=bundle; } return highestMatch; }
private static void mergeInto(Map<String, ComponentSpecification> resultingComponents, Set<ComponentSpecification> components) { for (ComponentSpecification component : components) { String name = component.getName(); if (resultingComponents.containsKey(name)) { resultingComponents.put(name, component.intersect(resultingComponents.get(name))); } else { resultingComponents.put(name, component); } } }
public boolean equals(Object o) { if (o==this) return true; if ( ! (o instanceof ComponentSpecification)) return false; ComponentSpecification c = (ComponentSpecification) o; return c.stringValue.equals(this.stringValue()); }
static ComponentModel providerComponentModel(final ComponentId parentId, String className) { final ComponentSpecification classNameSpec = new ComponentSpecification( className); return new ComponentModel(new BundleInstantiationSpecification( classNameSpec.nestInNamespace(parentId), classNameSpec, null)); }
@Override public String toString() { return toId().toString(); }
private void assertNoInnerComponents(ChainSpecification specWithoutInnerComponents) { for (ComponentSpecification component : specWithoutInnerComponents.componentReferences) { assert (component.getNamespace() == null); } }
private int getPort(ConnectorFactory connectorFactory, List<PortOverride> portOverrides) { ComponentId id = ComponentId.fromString(connectorFactory.getName()); for (PortOverride override : portOverrides) { if (override.serverId.matches(id)) { return override.port; } } return connectorFactory.getListenPort(); }
public ClusterControllerComponent() { super(new ComponentModel(new BundleInstantiationSpecification( new ComponentSpecification("clustercontroller"), new ComponentSpecification("com.yahoo.vespa.clustercontroller.apps.clustercontroller.ClusterController"), new ComponentSpecification("clustercontroller-apps")))); } }
public ComponentSpecification intersect(ComponentSpecification other) { if (!getName().equals(other.getName())) { throw new RuntimeException("The names of the component specifications does not match(" + getName() + "!=" + other.getName() + ")."); } if (!namespaceMatch(other.getNamespace())) { throw new RuntimeException("The namespaces of the component specifications does not match(" + this + ", " + other +")"); } return new ComponentSpecification(getName(), getVersionSpecification().intersect(other.getVersionSpecification()), getNamespace()); }