/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#getNamespaces() */ public Set<Namespace> getNamespaces() { // Do not include the aliases in the namespaces ... return delegate.getNamespaces(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.NamespaceRegistry#getNamespaces() */ public Set<Namespace> getNamespaces() { Lock lock = this.registryLock.readLock(); try { lock.lock(); return delegate.getNamespaces(); } finally { lock.unlock(); } }
/** * {@inheritDoc} * * @see org.modeshape.graph.property.basic.SimpleNamespaceRegistry#getNamespaces() */ @Override public Set<Namespace> getNamespaces() { Set<Namespace> delegateNamespaces = this.delegate.getNamespaces(); Set<Namespace> localNamespaces = super.getNamespaces(); if (localNamespaces.isEmpty()) return delegateNamespaces; // Load the local namespaces first ... Set<Namespace> namespaces = new HashSet<Namespace>(localNamespaces); // Now build a map of the local prefixes so we can check for prefixes Map<String, Namespace> localNamespacesByPrefix = new HashMap<String, Namespace>(); for (Namespace ns : localNamespaces) localNamespacesByPrefix.put(ns.getPrefix(), ns); // Now iterate over the local namespaces, removing any existing namespace with the same prefix for (Namespace ns : delegateNamespaces) { if (localNamespacesByPrefix.get(ns.getPrefix()) != null) continue; // Try to add the delegate namespace, which won't work if a local with the same URI was already added... namespaces.add(ns); } return Collections.unmodifiableSet(namespaces); }
/** * Traverse the saved configuration graph treating it as an XML document and calling the corresponding SAX event on the * provided {@link ContentHandler}. Changes made without calling {@link #save()} will not be written to the stream. * * @param handler the content handler that will receive the SAX events * @throws SAXException if there is an error saving the configuration */ public void storeTo( ContentHandler handler ) throws SAXException { Subgraph allContent = configurationGraph().getSubgraphOfDepth(ReadBranchRequest.NO_MAXIMUM_DEPTH).at("/"); Set<NamespaceRegistry.Namespace> namespaces = this.context.getNamespaceRegistry().getNamespaces(); Stack<String> mappedNamespacePrefixes = new Stack<String>(); handler.startDocument(); for (NamespaceRegistry.Namespace namespace : namespaces) { handler.startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceUri()); mappedNamespacePrefixes.push(namespace.getPrefix()); } exportNode(handler, allContent, allContent.getRoot()); while (!mappedNamespacePrefixes.isEmpty()) { handler.endPrefixMapping(mappedNamespacePrefixes.pop()); } handler.endDocument(); }
for (NamespaceRegistry.Namespace actual : registry.getNamespaces()) { String expectedUri = expected.remove(actual.getPrefix()); assertThat("namespace URIs differ", actual.getNamespaceUri(), is(expectedUri)); msg.append(entry.getKey()).append("=").append(entry.getValue()); assertThat(msg.toString(), registry.getNamespaces().isEmpty(), is(true));
protected void initializeCacheFromStore( NamespaceRegistry cache ) { Set<Namespace> toRegister = new HashSet<Namespace>(store.getContext().getNamespaceRegistry().getNamespaces());