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

Last change on this file since 2163 was 2163, checked in by bas6, 23 years ago

Tidied up some comments & added package.html to SimpleGraphical Client

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