Lucene.Net  3.0.3
Lucene.Net is a port of the Lucene search engine library, written in C# and targeted at .NET runtime users.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Pages
DistributedSearchers.cs
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 using System;
19 using System.Configuration;
20 using System.Xml;
21 
22 namespace Lucene.Net.Distributed.Configuration
23 {
24  /// <summary>
25  /// Definition of a configurable set of search indexes made accessible by the
26  /// LuceneServer windows service for a consuming application. These search indexes
27  /// are defined in the configuration file of an application. The locations defined
28  /// in a DistributedSearcher match the exposed object URIs as defined in the LuceneServer service.
29  ///
30  /// An example configuration would look like the following:
31  /// <code>
32  /// <DistributedSearchers>
33  /// <DistributedSearcher wsid="1" SearchMethod="0" location="c:\localindexes\LocalIndex1" />
34  /// <DistributedSearcher wsid="2" SearchMethod="1" location="tcp://192.168.1.100:1089/RemoteIndex1" />
35  /// <DistributedSearcher wsid="3" SearchMethod="1" location="tcp://192.168.1.101:1089/RemoteIndex2" />
36  /// </DistributedSearchers>
37  /// </code>
38  /// </summary>
39  public class DistributedSearchers
40  {
41  private DistributedSearcher[] _arDistributedSearcherArray;
42 
43  /// <summary>
44  /// Accessor method for the configurable DistributedSearchers.
45  /// </summary>
46  public static DistributedSearchers GetConfig
47  {
48  get { return (DistributedSearchers)ConfigurationManager.GetSection("DistributedSearchers"); }
49  }
50 
51  /// <summary>
52  /// Public constructor for DistributedSearchers. A DistributedSearcher is defined
53  /// in XML configuration and is loaded via a custom configuration handler.
54  /// </summary>
55  /// <param name="xSection">The Xml definition in the configuration file</param>
56  public DistributedSearchers(XmlNode xSection)
57  {
58  this._arDistributedSearcherArray = new DistributedSearcher[xSection.ChildNodes.Count];
59  int x=0;
60 
61  foreach (XmlNode c in xSection.ChildNodes)
62  {
63  if (c.Name.ToLower()=="DistributedSearcher")
64  {
66  this._arDistributedSearcherArray[x] = ws;
67  x++;
68  }
69  }
70  }
71 
72  /// <summary>
73  /// Strongly-typed array of DistributedSearcher objects as defined in
74  /// a configuration section.
75  /// </summary>
76  public DistributedSearcher[] DistributedSearcherArray
77  {
78  get {return this._arDistributedSearcherArray;}
79  }
80 
81  }
82 }