I use Windsor container in purpose of SolrNet multicore access, but my Solr cores requires basic authentication. Is it possible use SolrNet Windsor intergation with authentication?
I'm tried next:
static SolrInteractServer()
{
container.Register(Component.For<ISolrConnection>().ImplementedBy<SolrConnection>().DependsOn(Property.ForKey<IHttpWebRequestFactory>().Eq(new WebAuthentication("login", "password"))));
}
private static WindsorContainer container = new WindsorContainer();
public static void RegisterFacility<T>(IEnumerable<string> coreUrls, string baseHttpUrl = null)
{
SolrNetFacility facility = null;
if (baseHttpUrl != null)
{
facility = new SolrNetFacility(baseHttpUrl);
}
else
{
facility = new SolrNetFacility();
}
foreach (var httpUrl in coreUrls)
{
var coreName = "core_" + Guid.NewGuid();
facility.AddCore(coreName, typeof(T), httpUrl);
RegisteredCores.Add(coreName, new KeyValuePair<Type, string>(typeof(T), httpUrl));
}
container.AddFacility("solr", facility);
}
public static Dictionary<string, KeyValuePair<Type, string>> RegisteredCores = new Dictionary<string, KeyValuePair<Type, string>>();
When I run container.AddFacility throws:
Component SolrNet.Impl.SolrConnection could not be registered. There is already a component with that name. Did you want to modify the existing component instead? If not, make sure you specify a unique name.
and stack trace:
at Castle.MicroKernel.SubSystems.Naming.DefaultNamingSubSystem.Register(IHandler handler) at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.RegisterHandler(String name, IHandler handler, Boolean skipRegistration) at Castle.MicroKernel.Handlers.DefaultHandlerFactory.Create(ComponentModel model, Boolean isMetaHandler) at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model, Boolean isMetaHandler) at Castle.MicroKernel.DefaultKernel.AddCustomComponent(ComponentModel model) at Castle.MicroKernel.Registration.ComponentRegistration
1.Castle.MicroKernel.Registration.IRegistration.Register(IKernelInternal kernel) at Castle.MicroKernel.DefaultKernel.Register(IRegistration[] registrations) at Castle.Facilities.SolrNetIntegration.SolrNetFacility.Init() in g:\prg\SolrNet\Castle.Facilities.SolrNetIntegration\SolrNetFacility.cs:line 80 at Castle.MicroKernel.Facilities.AbstractFacility.Castle.MicroKernel.IFacility.Init(IKernel kernel, IConfiguration facilityConfig) at Castle.MicroKernel.DefaultKernel.AddFacility(IFacility facility) at Castle.MicroKernel.DefaultKernel.AddFacility(String key, IFacility facility) at Castle.Windsor.WindsorContainer.AddFacility(String idInConfiguration, IFacility facility) at SolrInteractionLogic.Core.SolrInteractServer
1.RegisterFacility[T](IEnumerable`1 coreUrls, String baseHttpUrl) in D:\1. Job projects\1. In Progress\Semantic Force\Reporting\SFDigestGenerator\SolrInteractionLogic\Core\SolrInteractServer.cs:line 58 at SolrInteractionTest.Program.Main(String[] args) in D:\1. Job projects\1. In Progress\Semantic Force\Reporting\SFDigestGenerator\SolrInteractionTest\Program.cs:line 26 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()
You have to register IHttpWebRequestFactory
in the container, not ISolrConnection
.