2 * Copyright 2004 The Apache Software Foundation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 using Document
= Lucene
.Net
.Documents
.Document
;
18 using Term
= Lucene
.Net
.Index
.Term
;
19 namespace Lucene
.Net
.Search
22 /// <summary>A remote searchable implementation. </summary>
24 public class RemoteSearchable
:System
.MarshalByRefObject
, Lucene
.Net
.Search
.Searchable
27 private Lucene
.Net
.Search
.Searchable local
;
29 /// <summary>Constructs and exports a remote searcher. </summary>
30 public RemoteSearchable(Lucene
.Net
.Search
.Searchable local
):base()
35 public virtual void Search(Query query
, Filter filter
, HitCollector results
)
37 local
.Search(query
, filter
, results
);
40 public virtual void Close()
45 public virtual int DocFreq(Term term
)
47 return local
.DocFreq(term
);
50 public virtual int MaxDoc()
52 return local
.MaxDoc();
55 public virtual TopDocs
Search(Query query
, Filter filter
, int n
)
57 return local
.Search(query
, filter
, n
);
60 public virtual TopFieldDocs
Search(Query query
, Filter filter
, int n
, Sort sort
)
62 return local
.Search(query
, filter
, n
, sort
);
65 public virtual Document
Doc(int i
)
70 public virtual Query
Rewrite(Query original
)
72 return local
.Rewrite(original
);
75 public virtual Explanation
Explain(Query query
, int doc
)
77 return local
.Explain(query
, doc
);
80 /// <summary>Exports a searcher for the index in args[0] named
81 /// "//localhost/Searchable".
84 public static void Main(System
.String
[] args
)
86 System
.Runtime
.Remoting
.RemotingConfiguration
.Configure("Lucene.Net.Search.RemoteSearchable.config");
87 System
.Runtime
.Remoting
.Channels
.ChannelServices
.RegisterChannel(new System
.Runtime
.Remoting
.Channels
.Http
.HttpChannel(1099));
88 // FIXED joeshaw@novell.com 10 Jan 2005 - turned off unreachable code
90 // create and install a security manager
91 if (false) //{{}}// if (System.getSecurityManager() == null) // {{Aroush}} >> 'java.lang.System.getSecurityManager()'
93 //{{}}// System.setSecurityManager(new RMISecurityManager()); // {{Aroush}} >> 'java.lang.System.setSecurityManager()' and 'java.rmi.RMISecurityManager.RMISecurityManager()'
97 Lucene
.Net
.Search
.Searchable local
= new IndexSearcher(args
[0]);
98 RemoteSearchable impl
= new RemoteSearchable(local
);
100 // bind the implementation to "Searchable"
101 System
.Runtime
.Remoting
.RemotingServices
.Marshal(impl
, "tcp://localhost:1099/Searchable");
102 System
.Console
.ReadLine();