use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.
the class ChainSpecification method flatten.
/**
* @param allChainSpecifications resolves ChainSpecifications from ComponentSpecifications
* as given in the inheritance fields.
* @param path tracks which chains are used in each recursive invocation of flatten, used for detecting cycles.
* @return ChainSpecification directly containing all the component references and phases of the inherited chains.
*/
private ChainSpecification flatten(Resolver<ChainSpecification> allChainSpecifications, Deque<ComponentId> path) {
path.push(componentId);
// if this turns out to be a bottleneck(which I seriously doubt), please add memoization
Map<String, ComponentSpecification> resultingComponents = componentsByName(componentReferences);
Map<String, Phase> resultingPhases = new LinkedHashMap<>(phases);
for (ComponentSpecification inheritedChainSpecification : inheritance.chainSpecifications) {
ChainSpecification inheritedChain = resolveChain(path, allChainSpecifications, inheritedChainSpecification).flatten(allChainSpecifications, path);
mergeInto(resultingComponents, filterByComponentSpecification(filterByName(inheritedChain.componentReferences, names(componentReferences)), inheritance.excludedComponents));
mergeInto(resultingPhases, inheritedChain.phases);
}
path.pop();
return new ChainSpecification(componentId, inheritance.flattened(), resultingPhases.values(), new LinkedHashSet<>(resultingComponents.values()));
}
use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.
the class BundleInstantiationSpecificationBuilder method build.
public static BundleInstantiationSpecification build(Element spec, boolean legacyMode) {
ComponentSpecification id = XmlHelper.getIdRef(spec);
ComponentSpecification classId = getComponentSpecification(spec, "class");
ComponentSpecification bundle = getComponentSpecification(spec, "bundle");
BundleInstantiationSpecification instSpec = new BundleInstantiationSpecification(id, classId, bundle);
if (// TODO: Remove?
!legacyMode)
validate(instSpec);
return bundle == null ? setBundleForKnownClass(instSpec) : instSpec;
}
use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.
the class ContainerServiceBuilder method readServerPortOverrides.
private List<Container.PortOverride> readServerPortOverrides(Element spec) {
List<Container.PortOverride> portOverrides = new ArrayList<>();
for (Element serverPort : XML.getChildren(spec, "server-port")) {
ComponentSpecification serverId = XmlHelper.getIdRef(serverPort);
int port = Integer.parseInt(serverPort.getAttribute("port"));
portOverrides.add(new Container.PortOverride(serverId, port));
}
return portOverrides;
}
use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.
the class ContainerTestBase method complete.
public void complete() {
try {
Container container = new Container(new CloudSubscriberFactory(dirConfigSource().configSource()), dirConfigSource().configId(), new ContainerTest.TestDeconstructor(), new Osgi() {
@SuppressWarnings("unchecked")
@Override
public Class<Object> resolveClass(BundleInstantiationSpecification spec) {
try {
return (Class<Object>) Class.forName(spec.classId.getName());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public BundleClasses getBundleClasses(ComponentSpecification bundle, Set<String> packagesToScan) {
throw new UnsupportedOperationException("getBundleClasses not supported");
}
@Override
public void useBundles(Collection<FileReference> bundles) {
}
@Override
public Bundle getBundle(ComponentSpecification spec) {
throw new UnsupportedOperationException("getBundle not supported.");
}
});
componentGraph = container.runOnce(componentGraph, Guice.createInjector());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.yahoo.component.ComponentSpecification in project vespa by vespa-engine.
the class CompiledQueryProfileRegistry method findQueryProfile.
/**
* <p>Returns a query profile for the given request string, or null if a suitable one is not found.</p>
*
* The request string must be a valid {@link com.yahoo.component.ComponentId} or null.<br>
* If the string is null, the profile named "default" is returned, or null if that does not exists.
*
* <p>
* The version part (if any) is matched used the usual component version patching rules.
* If the name part matches a query profile name perfectly, that profile is returned.
* If not, and the name is a slash-separated path, the profile with the longest matching left sub-path
* which has a type which allows path matching is used. If there is no such profile, null is returned.
*/
public CompiledQueryProfile findQueryProfile(String idString) {
if (idString == null || idString.isEmpty())
return getComponent("default");
ComponentSpecification id = new ComponentSpecification(idString);
CompiledQueryProfile profile = getComponent(id);
if (profile != null)
return profile;
return findPathParentQueryProfile(new ComponentSpecification(idString));
}
Aggregations