Using StructureMap with Solrnet – updated
Posted: August 12, 2010 Filed under: Development | Tags: c#, Solr, SolrNet 9 CommentsThe implementation has now been updated to allow for multi-core instances. Which can be set up in your Bootstrapper like this:
var solr = (SolrConfigurationSection)ConfigurationManager.GetSection(“solr”); var solrServers = solr.SolrServers; ObjectFactory.Initialize(
x => x.AddRegistry(new SolrNetRegistry(solrServers))
);
You’re app config should look like the the following:
<configuration>
<configSections>
<section name="solr"
type="StructureMap.SolrNetIntegration.Config.SolrConfigurationSection, SolrNet" />
</configSections>
<solr>
<server id="myobject" url="http://localhost:8080/solr/"
documentType="Your.Objects.Name, Your.Objects.Namespace" />
</solr>
</configuration>
I really object to having to use app.config to drive my StructureMap configuration.
It is for this reason I’m still not using this in our projects!
Sorry, that wasn’t very constructive, what I meant to say is really I’d prefer if the registry took in some bespoke configuration object that I could generate myself (basically by convention based on all of our cores/customers, as that is how we do most things), and then you could also generate that configuration object from app.config to allow that sort of thing as well.
If that makes sense. Give us the choice at least 🙂
[…] The structuremap adapter now allows for multicore configuration Possibly related posts: (automatically generated)StructureMap RegistryThe IOC and (the Lack Of) […]
Rob
I’m pretty sure app.config has nothing to do with how StructureMap is configured (both in that example and in general).
In fact that only line that has anything to do with it is this section:
ObjectFactory.Initialize(
x => x.AddRegistry(new SolrNetRegistry(solrServers))
);
The documentation recommends using the fluent DSL for type registration and has done for about the past 2 years. You can find it here:
http://structuremap.github.com/structuremap/RegistryDSL.htm
Regards
Matt
That is not what I meant.
var solr = (SolrConfigurationSection)ConfigurationManager.GetSection(“solr”);
Is my problem, it’s not easy to construct those configuration objects manually, I don’t want to be storing my solr config in app.config
We generate *nearly all* of our StructureMap mappings via conventions, filling in the holes with some manual fluent config.
I am not a simpleton who needs that explaining to me.
What I want to do is construct the configuration for Solr via convention too, because we have 100 customers, each with their own core(s), and they’re all named/setup via conventions. Sticking 100 cores in app.config is a faff.
The fact that Mark has chosen to use the app.config to hydrate his SolrConfigurationSection has nothing to do with SolrNet *or* StructureMap.
There’s nothing to stop you from writing your own convention based mechanism to achieve this.
Otherwise, I’m not sure what the point of your rant at Mark is…
logging works without structuremap, but with structuremap how do we enable logging.