On Mon, Oct 5, 2009 at 12:01, Uwe Schindler <u...@thetaphi.de> wrote:
> Hi Marvin,
>
>> > Property names are always String, values any type (therefore
>> Map<String,?>).
>> > With Java 5, integer props and so on are no "bad syntax" problem because
>> of
>> > autoboxing (no need to pass new Integer() or Integer.valueOf()).
>>
>> Argument validation gets to be a headache when you pass around complex
>> data
>> structures.  It's doable, but messy and hard to grok.  Going through
>> dedicated
>> methods is cleaner and safer.
>>
>> > Another good thing is, that implementors of e.g. XML config files like
>> in
>> > Solr, can simple pass all elements in config to this map.
>>
>> I go back and forth on this.  At some point, the volume of data becomes
>> overwhelming and it becomes easier to swap in the name of a class where
>> most
>> of the data can reside in nice, reliable, structured code.
>
> See my second mail. The recently introduced Attributes and AttributeSource
> would solve this. Each component just defines its attribute interface and
> impl class and you pass in an AttributeSource as configuration. Then you can
> do:
>
> AttributeSource cfg = new AttributeSource();
>
> ComponentAttribute compCfg = cfg.addAttribute(ComponentAttribute.class);
> compCfg.setMergeScheduler(FooScheduler.class);
>
> MergeBarAttribute mergeCfg = cfg.addAttribute(MergeBarAttribute.class);
> mergeCfg.setWhateverProp(1234);
> ...
> IndexWriter iw = new IndexWriter(dir, cfg);
>
> (this is just brainstorming not yet thoroughly thought about).

This approach suggests IW creates its components, and while doing so
provides them your AS instance.
I personally prefer creating all these components myself, configuring
them (at the moment of creation) and passing them to IW in one way or
another.
This requires way less code, you don't have to invent elaborate
schemes of passing through your custom per-component settings and
selecting which exact component types IW should use, you don't risk
construct/postConstruct/postpostConstruct-style things.

-- 
Kirill Zakharenko/Кирилл Захаренко (ear...@gmail.com)
Home / Mobile: +7 (495) 683-567-4 / +7 (903) 5-888-423
ICQ: 104465785

---------------------------------------------------------------------
To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to