use of org.xwiki.component.manager.NamespacedComponentManager in project xwiki-platform by xwiki.
the class ContextComponentManagerTest method testCreateDocumentComponentManager.
@Test
public void testCreateDocumentComponentManager() throws Exception {
ComponentManagerManager manager = getComponentManager().getInstance(ComponentManagerManager.class);
NamespacedComponentManager componentManager = (NamespacedComponentManager) manager.getComponentManager("document:wiki1:space1.space2.document1", true);
assertNotNull(componentManager);
assertEquals("document:wiki1:space1.space2.document1", componentManager.getNamespace());
assertEquals("space:wiki1:space1.space2", ((NamespacedComponentManager) componentManager.getParent()).getNamespace());
assertEquals("space:wiki1:space1", ((NamespacedComponentManager) componentManager.getParent().getParent()).getNamespace());
assertEquals("wiki:wiki1", ((NamespacedComponentManager) componentManager.getParent().getParent().getParent()).getNamespace());
}
use of org.xwiki.component.manager.NamespacedComponentManager in project xwiki-platform by xwiki.
the class XWiki method onMandatoryDocumentInitializerAdded.
private void onMandatoryDocumentInitializerAdded(ComponentDescriptorAddedEvent event, ComponentManager componentManager) {
String namespace;
if (componentManager instanceof NamespacedComponentManager) {
namespace = ((NamespacedComponentManager) componentManager).getNamespace();
} else {
namespace = null;
}
MandatoryDocumentInitializer initializer;
try {
initializer = componentManager.getInstance(MandatoryDocumentInitializer.class, event.getRoleHint());
XWikiContext context = getXWikiContext();
if (namespace == null) {
// Initialize in main wiki
initializeMandatoryDocument(context.getMainXWiki(), initializer, context);
// Initialize in already initialized sub wikis (will be initialized in others when they are initialized)
for (String wiki : this.initializedWikis.keySet()) {
initializeMandatoryDocument(wiki, initializer, context);
}
} else if (namespace.startsWith("wiki:")) {
// Initialize in the wiki where the extension is installed
initializeMandatoryDocument(namespace.substring("wiki:".length()), initializer, context);
}
} catch (ComponentLookupException e) {
LOGGER.error("Failed to lookup mandatory document initializer", e);
}
}
Aggregations