1 package org.apache.lucene.search; 2 3 18 19 import java.io.IOException ; 20 21 import java.rmi.Naming ; 22 import java.rmi.RemoteException ; 23 import java.rmi.RMISecurityManager ; 24 import java.rmi.server.UnicastRemoteObject ; 25 26 import org.apache.lucene.document.Document; 27 import org.apache.lucene.index.Term; 28 29 34 public class RemoteSearchable 35 extends UnicastRemoteObject 36 implements Searchable { 37 38 private Searchable local; 39 40 41 public RemoteSearchable(Searchable local) throws RemoteException { 42 super(); 43 this.local = local; 44 } 45 46 public void search(Query query, Filter filter, HitCollector results) 49 throws IOException { 50 local.search(query, filter, results); 51 } 52 53 public void search(Weight weight, Filter filter, HitCollector results) 54 throws IOException { 55 local.search(weight, filter, results); 56 } 57 58 public void close() throws IOException { 59 local.close(); 60 } 61 62 public int docFreq(Term term) throws IOException { 63 return local.docFreq(term); 64 } 65 66 67 public int[] docFreqs(Term[] terms) throws IOException { 68 return local.docFreqs(terms); 69 } 70 71 public int maxDoc() throws IOException { 72 return local.maxDoc(); 73 } 74 75 public TopDocs search(Query query, Filter filter, int n) throws IOException { 78 return local.search(query, filter, n); 79 } 80 81 public TopDocs search(Weight weight, Filter filter, int n) throws IOException { 82 return local.search(weight, filter, n); 83 } 84 85 public TopFieldDocs search (Query query, Filter filter, int n, Sort sort) 88 throws IOException { 89 return local.search (query, filter, n, sort); 90 } 91 92 public TopFieldDocs search (Weight weight, Filter filter, int n, Sort sort) 93 throws IOException { 94 return local.search (weight, filter, n, sort); 95 } 96 97 public Document doc(int i) throws IOException { 98 return local.doc(i); 99 } 100 101 public Query rewrite(Query original) throws IOException { 102 return local.rewrite(original); 103 } 104 105 public Explanation explain(Query query, int doc) throws IOException { 108 return local.explain(query, doc); 109 } 110 111 public Explanation explain(Weight weight, int doc) throws IOException { 112 return local.explain(weight, doc); 113 } 114 115 117 public static void main(String args[]) throws Exception { 118 String indexName = null; 119 120 if (args != null && args.length == 1) 121 indexName = args[0]; 122 123 if (indexName == null) { 124 System.out.println("Usage: org.apache.lucene.search.RemoteSearchable <index>"); 125 return; 126 } 127 128 if (System.getSecurityManager() == null) { 130 System.setSecurityManager(new RMISecurityManager ()); 131 } 132 133 Searchable local = new IndexSearcher(indexName); 134 RemoteSearchable impl = new RemoteSearchable(local); 135 136 Naming.rebind("//localhost/Searchable", impl); 138 } 139 140 } 141 | Popular Tags |