cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Leszek Gawron <lgaw...@mobilebox.pl>
Subject Re: more about properties in cocoon 2.2
Date Mon, 21 Aug 2006 11:48:32 GMT
Carsten Ziegeler wrote:
> Leszek Gawron schrieb:
>> Carsten Ziegeler wrote:
>>> Leszek Gawron wrote:
>>>>> Yes, I like your idea. Just one simple "include-config" and that's it.
>>>>> And the use-default-dirs can then be used to turn off including from
the
>>>>> default location which is on by default (If the directories do not
>>>>> exists this is not concidered an error).
>>>>> If you want I can implement this (I would not disable the possibility
to
>>>>> do a include and include-beans in the sitemap though).
>>>> Would be even better if you described in few words how to do it. Then I 
>>>> would do it myself and learn a lot.
>>>>
>>> Sure. The whole code is in the SitemapLanguage class. Now, there is the
>>> evaluation of the property-dir attribute and the like. You just have to
>>> get all "include-config" children of the Configuration object and pass
>>> that into the method creating the settings objects. There you read all
>>> the property files.
>>> The second thing is to replace the "include-config" statements with
>>> "include" and "include-bean" elements in the Configuration object (ok,
>>> this could be solved differently but that approach works) - this is
>>> already done for the default locations.
>>> And this should be more or less everything.
>> I forgot one thing: what about the same functionality for main 
>> cocoon.xconf? From what I saw there is different code (duplication) that 
>> handles inclusions and property management in cocoon.xconf...
>>
> I think we should not use the functionality for cocoon.xconf and just
> use it in sitemaps. The configuration for cocoon.xconf is imho working
> fine/complete.

It is not (I am writing this without testing, just showing you the steps 
to recreate my problem):

mvn archetype:create -DarchetypeArtifactId=cocoon-22-archetype-block 
-DarchetypeGroupId=org.apache.cocoon 
-DarchetypeVersion=1.0.0-M4-SNAPSHOT -DartifactId=myblock 
-DgroupId=com.mycompany

cd myblock
mkdir src/main/resources/META-INF/properties/
echo "property1=value" > 
src/main/resources/META-INF/properties/some.properties

mvn install cocoon:deploy jetty:run


If locally testing a block the resources from src/ are not copied to 
target folder/

this works well for:
- COB-INF/ (linked directly via map:mount in a sitemap)
- META-INF/legacy/xconf ('include' in cocoon.xconf)
- META-INF/spring ('include-beans' in cocoon.xconf)

but it NOT working for properties as they are only read from 
target/WEB-INF/cocoon/properties.

That is why we need 'include-properties' to load properties from 
src/main/resources/META-INF/properties/



I have been browsing the code for the solution to include properties but 
I have found none. My problem I cannot resolve occurs for both 
cocoon.xconf and sitemap entries. When creating a new CocoonBean factory 
those steps are performed:

1. read settings from default/specified location
2. Apply settings to Configuration holding component information. AFAIU 
this means:

<map:components>
  <map:generators default="file">
    <map:generator logger="${my.generator.logger}" name="mygenerator" 
src="${my.generator.class}"/>
  </map:generators>
</map:compoments>

3. read Configuration using ConfigReader.
4. Create CocoonBeanFactory using ComponentInfo provided by ConfigReader


This procedure cannot be the same if we want to add 'include-properties' 
  instruction.

<map:components>
	<!-- properties visible: default -->
	<map:some-components-declaration/>
	
	<map:include-properties src="abc/"/>

	<!-- properties visible: default, abc -->
	<map:include src="additional.xconf"/>

	<!-- properties visible: default, abc, additional -->
</map:components>

additional.xconf:
<map:components>
	<map:include-properties
		src="${additional.properties.directory}"/>
</map:components>

ConfigReader would have to intruduce side effects of modifying Settings 
when 'include-properties' occurs.

-- 
Leszek Gawron, IT Manager                          MobileBox sp. z o.o.
+48 (61) 855 06 67                              http://www.mobilebox.pl
mobile: +48 (501) 720 812                       fax: +48 (61) 853 29 65

Mime
View raw message