On 27 Jan 2015 at 12:02:01, Thomas Mortagne
([email protected](mailto:[email protected])) wrote:
> On Tue, Jan 27, 2015 at 11:55 AM, [email protected] 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#HAccessfromScripts).
> >
> > 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().
Indeed by bad, I checked but missed it.. Sorry about that.
I’ve now documented it at:
http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAccessfromScripts
A real pity that issue http://jira.xwiki.org/browse/XWIKI-10352 has put N/A in
the documentation field! That’s bad, it should have been documented at
http://extensions.xwiki.org/xwiki/bin/view/Extension/Component+Module#HAccessfromScripts
We still have broken some pretty important and used API.
Thanks
-Vincent
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>
> /**
> * Retrieves the component manager associated with a specific
> namespace. The namespace is generally of the form
> * prefix:subid where prefix is used to
> find the proper factory. : can be
> * escaped using \ and \ 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
> > ([email protected](mailto:[email protected])) wrote:
> >
> >> I tried to follow the example code given in:
> >> http://extensions.xwiki.org/xwiki/bin/view/Extension/Create+a+component+using+Groovy
> >>
> >> 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
> > [email protected]
> > http://lists.xwiki.org/mailman/listinfo/users
>
>
>
> --
> Thomas Mortagne
> _______________________________________________
> users mailing list
> [email protected]
> http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users