Hi Sergiu,
On Fri, Oct 10, 2008 at 5:25 AM, Sergiu Dumitriu <sergiu(a)xwiki.com> wrote:
Asiri Rathnayake wrote:
---------- Forwarded message ----------
From: Asiri Rathnayake <asiri.rathnayake(a)gmail.com>
Date: Thu, Oct 9, 2008 at 2:09 PM
Subject: Re: [xwiki-notifications] r13428 - in sandbox/xwiki-webdav/src:
main/java/com/xpn/xwiki/plugin/webdav/resources/views
main/java/com/xpn/xwiki/plugin/webdav/resources/views/pages
test/java/com/xpn/xwiki/plugin/webdav/tests
To: XWiki Notifications <notifications(a)xwiki.org>
Hi Vincent, Sergiu and all,
I will try to explain the need to componetize xwiki-webdav. May be we
shouldn't componetize xwiki-webdav after all ;)
Following is the way we lookup for a base-view (a particular view of an
xwiki-repository). Basically, when a request comes for a particular url,
we
take the corresponding segment of the url
(nextToken here), append
"-baseview" and lookup for a component with that ROLE_HINT. If found,
we'll
handover the job to that component.
+ XWikiDavResource resource = null;
+ try {
+ resource =
+ (XWikiDavResource) getComponentManager()
+ .lookup(ROLE, nextToken + "-baseview");
+ resource.init(this, nextToken, "/" + nextToken);
+ stack.push(resource);
+ resource.decode(stack, tokens, next + 1);
+ } catch (ComponentLookupException e) {
+ throw new
DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e);
Bellow is where we list the set of possible views. for this i need to
filter
out only those views which has the
"-baseview" id appended to their role
hint. This is why i added the getRoleHint() method into the component
interface.
The use of this approach is, if someone need to add a new view, he simply
have to extend the XWikiDavResource interface and have the ROLE_HINT
ending
like "-baseview", nothing else.
The other approach is to manually load each base view using
lookup("role",
"role-hint") but in this case, the
developer of the new view will have to
change the RootView's code to load his view along with the rest of base
views.
+ List<XWikiDavResource>
viewsList =
getComponentManager().lookupList(ROLE);
+ for (XWikiDavResource view : viewsList) {
+ String componentHint = view.getRoleHint();
+ int dash = componentHint.lastIndexOf('-');
+ if (componentHint.endsWith("-baseview")) {
+ String name = componentHint.substring(0, dash);
+ view.init(this, name, "/" + name);
+ children.add(view);
+ }
+ }
+ } catch (ComponentLookupException e) {
+ LOG.error("Unexpected Error : ", e);
May be this is a wrong approach. And yes, XWikiDavResource is not a
business
interface. But I think this increases the
extensibility / flexibility of
xwiki-webdav. To add a new view, (as i said before) extend
XWikiDavResourve
and end your ROLE_HINT with
"-baseview". To remove an existing view,
simply
remove the "-baseview" part from your
components.xml configuration file,
that's it.
I would like to know your thoughts. And i can revert these changes if
necessary.
I don't understand why is the -baseview needed. What does it do? How are
implementations with baseview different than the others? What other
types of views are there?
You could do something different: add a new component type that extends
the XWikiDavResource component, let's say XWikiDavBaseview, and declare
your baseviews to implement this component. Is this OK for you?
Yes, I figured out this was bad practice. Already started to what you
proposed. Thanks :)
- Asiri
--
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs