Thanks everyone for your help. 
The chain of the symbol sources wasn´t correct.
This way it works fine:

<contribution configuration-id="hivemind.SymbolSources">
                <source name="PropertiesSymbolSource"
class="my.test.PropertiesSymbolSource"
before="hivemind.ApplicationDefaults"/>
        </contribution>


I decided to put the default value in the ApplicationDefaults, because I
don´t expect that this value has to be changed by an individual application.

<contribution configuration-id="hivemind.ApplicationDefaults">
    <default symbol="my.new.symbol" value="DEFAULT" />
</contribution>

Thanks again.

Regards,
Sebastian



James Carman wrote:
> 
> Yes, that's what I'm saying.  Typically, "framework" authors will use
> factory defaults if there are reasonable defaults for their symbols.
> Then, individual applications that use that framework are free to
> override those symbols using application defaults.  For example, in my
> HiveMind/Acegi library, I set a factory default to say that the
> affirmative-based decision manager should be used by default:
> 
> <contribution configuration-id="hivemind.FactoryDefaults">
>   <default symbol="hivemind.acegi.decisionManagerClass"
>                value="org.acegisecurity.vote.AffirmativeBased"/>
> </contribution>
> 
> However, any other application can override that by doing:
> 
> <contribution configuration-id="hivemind.ApplicationDefaults">
>   <default symbol="hivemind.acegi.decisionManagerClass"
>                value="someOtherDecisionManagerClass" />
> </contribution>
> 
> On 10/17/07, Johan Maasing <[EMAIL PROTECTED]> wrote:
>> As both Davor and james said, chain needs to be set up correctly so that
>> propertiesfile->appdefaults->factorydefaults
>> This is done with before and after attributes.
>>
>> But I guess what James is saying is that the default value should
>> belong in factory-defaults since you might want to override it in an
>> application default even if the properties-file does not exists. Is
>> that correct?
>>
>>
>> On 10/17/07, James Carman <[EMAIL PROTECTED]> wrote:
>> > I see what you mean, but the way the situation should be handled would
>> > be with a factory default.
>> >
>> > On 10/17/07, Davor Hrg <[EMAIL PROTECTED]> wrote:
>> > > I understood that another symbol source is used...
>> > >
>> > > quote:
>> > > >To fill this symbol with data at runtime, there is a properties file
>> > > >(myProps.properties)
>> > > >my.new.symbol=The value
>> > >
>> > > and that value contributed to ApplicationDefaults was not overriden
>> > > with one from that source.
>> > >
>> > > Davor Hrg
>> > >
>> > >
>> > > On 10/17/07, James Carman <[EMAIL PROTECTED]> wrote:
>> > > > Actually, you don't need to define your own source.  You need to
>> > > > provide a factory default.  Then, if that needs to be overridden,
>> it
>> > > > would be overridden with an application default.
>> > > >
>> > > > On 10/17/07, Davor Hrg < [EMAIL PROTECTED]> wrote:
>> > > > > contributing to ApplicationDefaults is the way to go,
>> > > > > you just need to make sure your symbolSource is called before
>> > > > > ApplicationDefaults
>> > > > >
>> > > > > for example
>> > > > > look at :
>> > > > >
>> > >
>> http://hivemind.apache.org/hivemind1/hivedocs/config/hivemind.SymbolSources.html
>> > > > >
>> > > > >  <source before="hivemind.FactoryDefaults"
>> > > > > name="hivemind.ApplicationDefaults"
>> > > > > service-id="ApplicationDefaultsSymbolSource" />
>> > > > >  <source name=" hivemind.FactoryDefaults"
>> > > > > service-id="FactoryDefaultsSymbolSource" />
>> > > > >
>> > > > >
>> > > > > add your symbol source like this
>> > > > >  <source before="hivemind.ApplicationDefaults" name="MySource"
>> > > > > service-id="MySymbolSource" />
>> > > > >
>> > > > >
>> > > > > Hrg
>> > > > >
>> > > > >
>> > > > > On 10/17/07, locutuz
>> > > <[EMAIL PROTECTED] >
>> > > > > wrote:
>> > > > > >
>> > > > > > Hi everyone,
>> > > > > >
>> > > > > > I have a contribution where an attribute is defined with a
>> symbol, see
>> > > > > > below:
>> > > > > >
>> > > > > > <config myNewAttribute="${ my.new.symbol}" ...
>> > > > > >
>> > > > > >
>> > > > > > To fill this symbol with data at runtime, there is a properties
>> file
>> > > > > > (myProps.properties)
>> > > > > > my.new.symbol=The value
>> > > > > >
>> > > > > > So far this works fine.
>> > > > > > But there are some cases, where this properties file doesn´t
>> exist
>> > > > > already,
>> > > > > > so at runtime an error message appears, telling me that there
>> is no
>> > > value
>> > > > > > for that symbol
>> > > > > > ( org.apache.hivemind.impl.SymbolExpander    : Error
>> > > > > > at...META-INF/hivemodule.xml, line 146, column 7: No value
>> available
>> > > for
>> > > > > > symbol 'my.new.symbol'.).
>> > > > > >
>> > > > > > Off course not, because the properties file doesn´t exist where
>> the
>> > > value
>> > > > > is
>> > > > > > get from.
>> > > > > > My question is, if there is a possibility to set a
>> default-value for a
>> > > > > > symbol, if it can´t be expanded by the SymbolExpander?
>> > > > > >
>> > > > > > I tried to set the value with the <default> element.
>> > > > > >       <contribution
>> configuration-id="hivemind.ApplicationDefaults">
>> > > > > >                 <default symbol=" my.new.symbol"
>> value="DEFAULT" />
>> > > > > >         </contribution>
>> > > > > >
>> > > > > > The problem here is, that at runtime the value for
>> 'myNewAttribute' is
>> > > > > > 'DEFAULT' in any case, regardless if the value can be read from
>> the
>> > > > > > properties file. i.e. if the symbol should be expanded by the
>> > > > > > SymbolExpander.
>> > > > > >
>> > > > > > Thanks for your help in advance!
>> > > > > >
>> > > > > > Regards,
>> > > > > > Sebastian
>> > > > > >
>> > > > > > --
>> > > > > > View this message in context:
>> > > > >
>> > >
>> http://www.nabble.com/Default-value-for-symbol-tf4639273.html#a13250295
>> > > > > > Sent from the Hivemind - User mailing list archive at
>> Nabble.com.
>> > > > > >
>> > > > > >
>> > > > >
>> > > > >
>> > > >
>> > >
>> > >
>> >
>>
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Default-value-for-symbol-tf4639273.html#a13272641
Sent from the Hivemind - User mailing list archive at Nabble.com.

Reply via email to