On Tue, Jan 27, 2015 at 11:55 AM, vincent(a)massol.net <vincent(a)massol.net> wrote:
Hi Bryn,
Apparently we broke backward compat and this is bad… We used to return the root Component
Manager when calling Utils.getComponentManager()
But it’s been modified and deprecated in XWiki 6.1M1
(
http://jira.xwiki.org/browse/XWIKI-10352) to return the Context Component Manager.
Now, the new way of registering components has been to use the Component Manager script
service introduced in XWiki 4.1M2 (see
http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAcce…).
However I’ve just noticed that it’s also been modified to return the Context CM instead
of the Root CM.
This means there’s now no way to dynamically register a new component from Groovy without
using a deprecated API…
You should look at the whole script service not only getComponentManager().
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/**
* Retrieves the component manager associated with a specific
namespace. The namespace is generally of the form
* <code>prefix:subid</code> where <code>prefix</code> is used
to
find the proper factory. <code>:</code> can be
* escaped using <code>\</code> and <code>\</code> need to be
escaped as well. There is a namespace for each
* document, space, wiki and user. E.g. 'wiki:drafts' is the
namespace corresponding to the 'drafts' wiki.
* Namespaces can be nested in which case they inherit from the
parent namespace. E.g. the component manager for a
* specific document has access to the components registered
specifically for that document or for any of its
* namespace ancestors (space, wiki, root). The root (top level)
component manager is returned if you pass
* {@code null}.
*
* @param namespace a namespace or {@code null} for the root
{@link ComponentManager}
* @return the component manager associated with the specified
namespace, if any, {@code null otherwise}
*/
public ComponentManager getComponentManager(String namespace)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
I.e. enforcing the best practice to explicitly indicate where exactly
you want to register your component since most of the time you don't
really want or need to register it from the whole farm.
So right now the only workaround is to use the deprecated method:
Utils.getRootComponentManager()
I’ve created
http://jira.xwiki.org/browse/XWIKI-11716
Thanks
-Vincent
On 27 Jan 2015 at 11:34:04, Bryn Jeffries
(bryn.jeffries@sydney.edu.au(mailto:bryn.jeffries@sydney.edu.au)) wrote:
I tried to follow the example code given in:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+usi…
Saving and Viewing a page with the code without changes, I got a Groovy macro error with
the following exception in the stack trace:
java.lang.RuntimeException: The Context Component Manager should only be used for read
access. Write operations should be done against specific Component Managers.
Could anyone explain what this means, and why this error now appears? I'm using 6.3.
I notice that the same error also currently shows up at
http://platform.xwiki.org/xwiki/bin/view/SRD/ running 6.2.2
Thanks,
Bryn
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
--
Thomas Mortagne