source: trunk/java-client/org/nzdl/gsdl/Proxy.java@ 2316

Last change on this file since 2316 was 2284, checked in by say1, 23 years ago

Cross collection searching

  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1/*
2 * Proxy.java
3 * Copyright (C) 2000 Stuart Yeates
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20// the package we're in
21package org.nzdl.gsdl;
22
23// java standard library classes used
24import java.io.*;
25//import java.util.*;
26
27import org.omg.CosNaming.*;
28import org.omg.CORBA.ORB;
29
30// local libraries
31import org.nzdl.gsdl.corba.gsdlInterface.*;
32import org.nzdl.gsdl.service.NzdlCollectionInfo;
33import org.nzdl.gsdl.service.NzdlQuery;
34import org.nzdl.gsdl.service.NzdlRequest;
35import org.nzdl.gsdl.service.NzdlResponse;
36import org.nzdl.gsdl.service.NzdlResultSet;
37import org.nzdl.gsdl.service.NzdlService;
38import org.nzdl.gsdl.service.NzdlServiceServer;
39import org.nzdl.gsdl.service.NzdlServiceClient;
40import org.nzdl.gsdl.service.NzdlCrossCollectionWrapper;
41import org.nzdl.gsdl.util.NzdlCorbaFactory;
42import org.nzdl.gsdl.util.NzdlServiceFactory;
43import org.nzdl.gsdl.util.NzdlPreferences;
44
45
46/**
47 * SimpleServer A very basic Greenstone server (not yet complete).
48 *
49 * @author stuart yeates ([email protected])
50 * @version $Revision: 2284 $
51 * @see org.nzdl.gsdl.SimpleClient
52 * @see org.nzdl.gsdl.service.NzdlServiceServer
53 * @see org.omg.CORBA.ORB
54 * @see <a href="http://www.nzdl.org/">The New Zealand Digital Library Project</a>
55 * @see <a href="http://www.nzdl.org/fast-cgi-bin/library?&a=p&p=gsdl">Greenstone Digital Library Software</a>
56 */
57
58
59public class Proxy implements Serializable, Cloneable
60{
61 static String IORFileName = "/tmp/localcorba.proxy.objid";
62
63
64 /**
65 * Starts up a trivial server.
66 *
67 * @param args the arguments passed through to the orb initialisation code...
68 */
69 public static void main(String args[])
70 {
71 corbaComErrorHolder error = NzdlCorbaFactory.createComErrorHolder();
72 try{
73 NzdlPreferences.saving = false;
74 NzdlPreferences.setBoolean("Connect to multiple servers", false);
75 NzdlPreferences.setBoolean("Cache corba requests", true);
76 NzdlPreferences.setBoolean("Save documents", true);
77 NzdlPreferences.setBoolean("Log at the NzdlService level", false);
78
79 NzdlService client = NzdlServiceFactory.createNzdlService(args,
80 null,
81 null,
82 null,
83 null);
84 //client = new NzdlCrossCollectionWrapper(client,"");
85
86 ORB orb = ORB.init(args, null);
87
88 // Create the servant and register it with the ORB
89 NzdlServiceServer simpleRef = new NzdlServiceServer(client);
90
91 simpleRef.initialise(error);
92 if (error.value.value() != corbaComError._corbaNoError) {
93 System.err.println("CORBA error after initialisation:" + error.value.value());
94 }
95
96 orb.connect(simpleRef);
97 System.err.println(orb.object_to_string(simpleRef));
98
99 NzdlServiceFactory.registerIOR(orb.object_to_string(simpleRef));
100
101 try {
102 BufferedWriter output
103 = new BufferedWriter(new FileWriter(IORFileName));
104 output.write(orb.object_to_string(simpleRef));
105 output.flush();
106 } catch (java.io.IOException e) {
107 System.err.println("Error reading IOR file:\n" + e);
108 }
109
110
111
112 // Wait for invocations from clients
113 java.lang.Object sync = new java.lang.Object();
114 synchronized(sync){
115 sync.wait();
116 }
117
118 } catch(Exception e) {
119 System.err.println("CORBA error:" + error.value.value());
120 System.err.println("ERROR: " + e);
121 e.printStackTrace(System.out);
122 }
123
124 }
125}
126
127
128
129
130
131
Note: See TracBrowser for help on using the repository browser.