source: trunk/java-client/org/nzdl/gsdl/SimpleServer.java@ 2197

Last change on this file since 2197 was 2188, checked in by say1, 23 years ago

added NzdlPreferences.java and hooked it up in all the necessary places. The PreferencesDialog doesn"t save \(yet\).

  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
Line 
1/*
2 * SimpleServer.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.util.NzdlCorbaFactory;
41import org.nzdl.gsdl.util.NzdlServiceFactory;
42import org.nzdl.gsdl.util.NzdlPreferences;
43
44
45/**
46 * SimpleServer A very basic Greenstone server (not yet complete).
47 *
48 * @author stuart yeates ([email protected])
49 * @version $Revision: 2188 $
50 * @see org.nzdl.gsdl.SimpleClient
51 * @see org.nzdl.gsdl.service.NzdlServiceServer
52 * @see org.omg.CORBA.ORB
53 * @see <a href="http://www.nzdl.org/">The New Zealand Digital Library Project</a>
54 * @see <a href="http://www.nzdl.org/fast-cgi-bin/library?&a=p&p=gsdl">Greenstone Digital Library Software</a>
55 */
56
57
58public class SimpleServer implements Serializable, Cloneable
59{
60 static String IORFileName = "/tmp/localcorba.proxy.objid";
61
62
63 /**
64 * Starts up a trivial server.
65 *
66 * @param args the arguments passed through to the orb initialisation code...
67 */
68 public static void main(String args[])
69 {
70 corbaComErrorHolder error = NzdlCorbaFactory.createComErrorHolder();
71 try{
72
73 NzdlPreferences.setBoolean("Connect to multiple servers", true);
74 NzdlPreferences.setBoolean("Cache corba requests", true);
75 NzdlPreferences.setBoolean("Save documents", true);
76 NzdlPreferences.setBoolean("Log at the NzdlService level", true);
77
78 NzdlService client = NzdlServiceFactory.createNzdlService(args,
79 null,
80 null,
81 null,
82 null);
83
84 ORB orb = ORB.init(args, null);
85
86 // Create the servant and register it with the ORB
87 NzdlServiceServer simpleRef = new NzdlServiceServer(client);
88
89 simpleRef.initialise(error);
90 if (error.value.value() != corbaComError._corbaNoError) {
91 System.err.println("CORBA error after initialisation:" + error.value.value());
92 }
93
94 orb.connect(simpleRef);
95 System.err.println(orb.object_to_string(simpleRef));
96
97 NzdlServiceFactory.registerIOR(orb.object_to_string(simpleRef));
98
99 try {
100 BufferedWriter output
101 = new BufferedWriter(new FileWriter(IORFileName));
102 output.write(orb.object_to_string(simpleRef));
103 output.flush();
104 } catch (java.io.IOException e) {
105 System.err.println("Error reading IOR file:\n" + e);
106 }
107
108
109
110 // Wait for invocations from clients
111 java.lang.Object sync = new java.lang.Object();
112 synchronized(sync){
113 sync.wait();
114 }
115
116 } catch(Exception e) {
117 System.err.println("CORBA error:" + error.value.value());
118 System.err.println("ERROR: " + e);
119 e.printStackTrace(System.out);
120 }
121
122 }
123}
124
125
126
127
128
129
Note: See TracBrowser for help on using the repository browser.