List Info

Thread: weird code in ExistingUsecaseResolver.java - can anyone explain?




weird code in ExistingUsecaseResolver.java - can anyone explain?
country flaguser name
Germany
2007-02-24 09:53:38
hi *!

in 
src/java/org/apache/lenya/cms/publication/templating/Existin
gUsecaseResolver.java 
  , i see this:

protected static final String ELEMENT_USECASES =
"usecases";
protected static final String ELEMENT_USECASE =
"usecase";
protected static final String ATTRIBUTE_NAME =
"name";
protected static String CONFIGURATION_PATH =
"config";
protected static final String CONFIGURATION_FILE =
       CONFIGURATION_PATH + File.separator +
"publication.xconf";


public void visit(Publication _publication) {

if (this.publication == null) {
   File configFile = new File(_publication.getDirectory(),
        CONFIGURATION_FILE);
   DefaultConfigurationBuilder builder = new
        DefaultConfigurationBuilder();

   try {
     Configuration config =
builder.buildFromFile(configFile);
     Configuration usecasesConfig =
config.getChild(ELEMENT_USECASES);
     if (usecasesConfig != null) {
       Configuration[] usecaseConfigs =
            usecasesConfig.getChildren(ELEMENT_USECASE);
       for (int i = 0; i < usecaseConfigs.length; i++) {
         String usecaseName =
              
usecaseConfigs[i].getAttribute(ATTRIBUTE_NAME);
         if (usecaseName.equals(this.usecase)) {
           this.publication = _publication;
         }
       }
     }
   } catch (Exception e) {
     throw new RuntimeException("Resolving usecases
failed: ", e);
   }
}
}


i wonder:

a) does this code ever do anything? iiuc we don't have
<usecases/> or 
<usecase> elements in publication.xconf.

b) is it ok to parse publication.xconf in more than one java
class, or 
had we better handle everything in PublicationConfiguration
?


thanks,

jörn


------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


Re: weird code in ExistingUsecaseResolver.java - can anyone explain?
country flaguser name
Germany
2007-02-26 04:11:55
Andreas Hartmann wrote:
> Jörn Nettingsmeier schrieb:
>> b) is it ok to parse publication.xconf in more than
one java class, or
>> had we better handle everything in
PublicationConfiguration ?
> 
> Basically everything should be done in
PublicationConfiguration.

ok.

> An exception would be composition, then it would make
sense to pass
> a configuration snippet to a different component (e.g.
the path mapper).

can you explain what "composition" means?

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


publication.xconf parsing..
country flaguser name
Germany
2007-02-26 05:11:27
Andreas Hartmann wrote:
> Joern Nettingsmeier schrieb:
>> Andreas Hartmann wrote:
>>> Jörn Nettingsmeier schrieb:
>>>> b) is it ok to parse publication.xconf in
more than one java class, or
>>>> had we better handle everything in
PublicationConfiguration ?
>>> Basically everything should be done in
PublicationConfiguration.
>> ok.
>>
>>> An exception would be composition, then it
would make sense to pass
>>> a configuration snippet to a different
component (e.g. the path mapper).
>> can you explain what "composition"
means?
> 
> http:
//en.wikipedia.org/wiki/Object_composition

ok. i thought you were talking about some new lenya concept
i had missed.

another thing: do you think it would make sense to validate
a 
publication.xconf before parsing it? i'm always for it,
because it 
forces us to keep the rng up-to-date and all implementations
in sync... 
wdot?



------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


Re: publication.xconf parsing..
country flaguser name
Germany
2007-02-26 05:50:28
Andreas Hartmann wrote:
> Joern Nettingsmeier schrieb:
>> Andreas Hartmann wrote:
>>> Joern Nettingsmeier schrieb:
>>>> Andreas Hartmann wrote:
>>>>> Jörn Nettingsmeier schrieb:
>>>>>> b) is it ok to parse
publication.xconf in more than one java class, or
>>>>>> had we better handle everything in
PublicationConfiguration ?
>>>>> Basically everything should be done in
PublicationConfiguration.
>>>> ok.
>>>>
>>>>> An exception would be composition, then
it would make sense to pass
>>>>> a configuration snippet to a different
component (e.g. the path
>>>>> mapper).
>>>> can you explain what
"composition" means?
>>> http:
//en.wikipedia.org/wiki/Object_composition
>> ok. i thought you were talking about some new lenya
concept i had missed.
>>
>> another thing: do you think it would make sense to
validate a
>> publication.xconf before parsing it? i'm always for
it,
> 
> +1, that should be quite easy using the
ValidationUtil.

ok, i'll try to hack it in.

------------------------------------------------------------
---------
To unsubscribe, e-mail: dev-unsubscribelenya.apache.org
For additional commands, e-mail: dev-helplenya.apache.org


[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )