JBoss.orgCommunity Documentation

Chapter 11. Namespace altering

11.1. Adding new namespace
11.2. Changing existing namespace
11.3. Removing existing namespace

eXo JCR implementation since 1.11 version have support of altering namespaces.

ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");
ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");
namespaceRegistry.registerNamespace("newMapping2", "http://dumb.uri/jcr");
try {
    assertNull(namespaceRegistry.getURI("newMapping"));
    fail("exception should have been thrown");
} catch (NamespaceException e) {
}
assertNotNull(namespaceRegistry.getURI("newMapping2"));
assertEquals("http://dumb.uri/jcr", namespaceRegistry.getURI("newMapping2"));
ExtendedNamespaceRegistry namespaceRegistry = (ExtendedNamespaceRegistry) workspace.getNamespaceRegistry();
namespaceRegistry.registerNamespace("newMapping", "http://dumb.uri/jcr");
namespaceRegistry.unregisterNamespace("newMapping");