Sylvain Wallez wrote:

Leszek Gawron wrote:

other example that I posted some time ago: if every cocoon uses error2html.xsl by default (along with some other default resources) they should be also packed into jars.



Aha! This is something I wanted to talk about when working on Cocoon stacktraces: standardizing the fact that some blocks provide resources and include them in jars.

The first block to do this is CForms, which provides a lot of runtime resources in org/apache/cocoon/forms/resources: XSLs, js, css, etc. We also have a few items for the core block in webapp/stylesheets/system and webapp/resources (js and css). What we see here is that these are runtime resources targeted both at the server side (XSLs) and the client side (js, css and also XSLs for xsl-aware browsers).

What I propose is that we define a standard layout for resources provided by blocks: they should be stored in resource://org/apache/cocoon/{block-name}/resources/

The nice thing with this propsal is that it is back compatible and follow current (emerging) conventions. OTH with the blocks architecture, using the resource protocol is not such a good idea. In OSGi resources have URLs like bundle://3/org.apache.cocoon.foo e.g. where "3" is the number of the bundle and is deployment order dependent and is therefore not usable in sitemaps. In OSGi one typically puts the resources at the top level of the jar or in directories at top level. There is normally not that much reason for puting resources in the Java package structure, as the bundle poften is an apropriate level of granularity anyway.

We also have the block protocol that allows you to define what block the resource is taken from: block:foo:/bar.xsl. Now the block protocol assumes that everything is exported through the sitemap wich might be appropriate (but maybe inconvenient) for the use cases you have in mind. Maybe we could have an own bundle protocol (through the source mechanism), that works like the OSGi bundle protocol but have symbolic block names instead of bundle numbers.

Additionally, we should have a system-defined URI which allows clients to fetch these resources, implemented in the root sitemap:

<map:match pattern="_cocoon_/*/**">
 <map:read src="resource://org/apache/cocoon/{1}/resources/{2}"/>
</map:match>

By standardizing this URI pattern, we can easily solve cross-referencing problems among resources, e.g. CForms XSLs having to produce <script src="..."/> to load the JS files, etc.

This URI pattern could even be written **_cocoon_/*/** to be location-independent so that we don't have to mess around with {request:contextPath}.

All this is allready solved within the (sitemap) block architecture and there is an implementation of it in trunk. block URIs are used for accessing things and a special URL rewriting transformer absolutizes the block URLs.

WDYT?

Your proposal makes sense and we should make something about the issues you describe. What you describe will not be particulary future proof though.

/Daniel

Reply via email to