public boolean equals(Object o) { if (o==this) return true; if ( ! (o instanceof ComponentId)) return false; ComponentId c = (ComponentId) o; if (isAnonymous() || c.isAnonymous()) return false; return c.stringValue().equals(stringValue); }
private static boolean equalNodes(Object a, Object b) { if (a instanceof Node && b instanceof Node) { Node l = (Node) a; Node r = (Node) b; return l.componentId.equals(r.componentId); } else { return a.equals(b); } }
public ComponentId nestInNamespace(ComponentId namespace) { if (namespace == null) { return this; } else { ComponentId newNamespace = getNamespace() == null ? namespace : getNamespace().nestInNamespace(namespace); return new ComponentId(getName(), getVersion(), newNamespace); } }
private static ComponentId createId(String sessionName) { return ComponentId.fromString(sessionName).nestInNamespace( ComponentId.fromString("MbusClient")); }
/** Returns a copy of this id with namespace set to null **/ public ComponentId withoutNamespace() { return new ComponentId(getName(), getVersion(), null); }
static JSONArray renderRequestHandlers(JdiscBindingsConfig bindingsConfig, Map<ComponentId, ? extends RequestHandler> handlersById) { JSONArray ret = new JSONArray(); for (Map.Entry<ComponentId, ? extends RequestHandler> handlerEntry : handlersById.entrySet()) { String id = handlerEntry.getKey().stringValue(); RequestHandler handler = handlerEntry.getValue(); JSONObject handlerJson = renderComponent(handler, handlerEntry.getKey()); addBindings(bindingsConfig, id, handlerJson); ret.put(handlerJson); } return ret; }
/** * Creates a componentId that is unique for this run-time instance */ // TODO: Check if we really need this. -JB public static ComponentId createAnonymousComponentId(String baseName) { return new ComponentId(baseName, null, null, true); }
private Resolver createNativeRandomResolver() { RandomResolver resolver = new RandomResolver(); resolver.initId(ComponentId.fromString(RandomResolver.nativeId)); return resolver; }
/** * Registers a component unless this registry is frozen. * This will succeed even if this component name and version is already registered. * * @throws IllegalStateException if this chain is frozen */ public void register(ComponentId id, COMPONENT component) { if (frozen) throw new IllegalStateException("Cannot modify a frozen component registry"); Map<String, Map<Version, COMPONENT>> componentVersionsByName = componentsByNameByNamespace.get(id.getNamespace()); if (componentVersionsByName == null) { componentVersionsByName = new LinkedHashMap<>(); componentsByNameByNamespace.put(id.getNamespace(), componentVersionsByName); } Map<Version, COMPONENT> componentVersions = componentVersionsByName.get(id.getName()); if (componentVersions == null) { componentVersions = new LinkedHashMap<>(); componentVersionsByName.put(id.getName(), componentVersions); } componentVersions.put(id.getVersion(), component); componentsById.put(id, component); }
if (at>0) { String newId=id.substring(0,at); namespace=ComponentId.fromString(id.substring(at+1)); id=newId; return new ComponentId(id,version,namespace);
public ComponentSpecification toSpecification() { if (isAnonymous()) throw new RuntimeException("Can't generate a specification for an anonymous component id."); return new ComponentSpecification(getName(), getVersion().toSpecification(), getNamespace()); }
private Set<ComponentSpecification> disableStemmingIfStreaming(Set<ComponentSpecification> searcherReferences) { if (!searchCluster.isStreaming()) { return searcherReferences; } else { Set<ComponentSpecification> filteredSearcherReferences = new LinkedHashSet<>(searcherReferences); filteredSearcherReferences.remove( toGlobalComponentId( new ComponentId("com.yahoo.prelude.querytransform.StemmingSearcher")). toSpecification()); return filteredSearcherReferences; } }
private void configureLegacyFilters(ComponentId id, ComponentRegistry<SecurityRequestFilter> legacyRequestFilters) { ComponentId serverName = id.getNamespace(); if (SEARCH_SERVER_COMPONENT_ID.equals(serverName) && !legacyRequestFilters.allComponents().isEmpty()) { requestFilters.bind("http://*/*", SecurityRequestFilterChain.newInstance(legacyRequestFilters.allComponents())); } }
public BundleInstantiationSpecification(ComponentId id, ComponentSpecification classId, ComponentSpecification bundle) { this(id.toSpecification(), classId, bundle); assert (classId!= null); }
@Override public String searchRefDescription() { return localId.toString(); }
public void register(ComponentId globalComponentId, ChainedComponentModel componentModel) { assert (componentModel.getComponentId().withoutNamespace().equals( globalComponentId.withoutNamespace())); componentModels.register(globalComponentId, ComponentAdaptor.create(globalComponentId, componentModel)); }
/** * Creates a new query profile from an id. * The query profile can be modified freely (but not accessed) until it is {@link #freeze frozen}. * At that point it becomes readable but unmodifiable, which it stays until it goes out of reference. */ public QueryProfile(ComponentId id) { super(id); if ( ! id.isAnonymous()) validateName(id.getName()); }
private Query createFederationQuery(Query query, Query outgoing, Window window, long timeout, Target target) { ComponentId chainId = target.getChain().getId(); String sourceName = chainId.getName(); outgoing.properties().set(SOURCENAME, sourceName); String providerName = chainId.getName(); if (chainId.getNamespace() != null) providerName = chainId.getNamespace().getName(); outgoing.properties().set(PROVIDERNAME, providerName); outgoing.setTimeout(timeout); switch (propagateSourceProperties) { case ALL: propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, Query.nativeProperties); break; case OFFSET_HITS: propagatePerSourceQueryProperties(query, outgoing, window, sourceName, providerName, queryAndHits); break; } //TODO: FederationTarget //TODO: only for target produced by this, not others target.modifyTargetQuery(outgoing); return outgoing; }
/** Creates an unbacked overridable query profile */ protected OverridableQueryProfile() { super(ComponentId.createAnonymousComponentId(simpleClassName)); }