Changeset 11023 for trunk/gsdl3
- Timestamp:
- 2005-12-22T13:28:31+13:00 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r10297 r11023 1 1 package org.greenstone.gsdl3; 2 2 3 import org.greenstone.gsdl3.comms.*; 3 4 import org.greenstone.gsdl3.core.*; 4 5 import org.greenstone.gsdl3.util.*; … … 40 41 /** the cgi stuff - the Receptionist can add new args to this 41 42 * its used by the servlet to determine what args to save */ 42 //protected GSCGI cgi = null;43 43 protected GSParams params = null; 44 44 … … 57 57 String library_name = config.getInitParameter(GSConstants.LIBRARY_NAME); 58 58 String gsdl3_home = config.getInitParameter(GSConstants.GSDL3_HOME); 59 String site_name = config.getInitParameter(GSConstants.SITE_NAME);60 59 String interface_name = config.getInitParameter(GSConstants.INTERFACE_NAME); 61 60 this.default_lang = config.getInitParameter(GSConstants.DEFAULT_LANG); 62 if (library_name == null || site_name ==null ||interface_name ==null) {61 if (library_name == null || interface_name ==null) { 63 62 // must have this 64 63 System.err.println("initialisation parameters not all set!"); 65 System.err.println(" you must have libraryname , sitename,interfacename");64 System.err.println(" you must have libraryname and interfacename"); 66 65 System.exit(1); 67 66 } 68 67 68 String site_name = config.getInitParameter(GSConstants.SITE_NAME); 69 String remote_site_name = null; 70 String remote_site_type = null; 71 String remote_site_address = null; 72 73 if (site_name == null) { 74 // no site, try for communicator 75 remote_site_name = config.getInitParameter("remote_site_name"); 76 remote_site_type = config.getInitParameter("remote_site_type"); 77 remote_site_address = config.getInitParameter("remote_site_address"); 78 if (remote_site_name == null || remote_site_type == null || remote_site_address == null) { 79 System.err.println("initialisation paramters not all set!"); 80 System.err.println("if site_name is not set, then you must have remote_site_name, remote_site_type and remote_site_address set"); 81 System.exit(1); 82 } 83 } 84 69 85 if (this.default_lang == null) { 70 86 // choose english … … 75 91 76 92 config_params.put(GSConstants.LIBRARY_NAME, library_name); 77 config_params.put(GSConstants.SITE_NAME, site_name);78 93 config_params.put(GSConstants.INTERFACE_NAME, interface_name); 79 94 if (site_name != null) { 95 config_params.put(GSConstants.SITE_NAME, site_name); 96 } 80 97 this.converter = new XMLConverter(); 81 98 this.doc = this.converter.newDOM(); 82 83 // now try and create MR and recpt84 // new message router - create it and pass reference to recept.85 // the servlet wont use this directly86 String mr_name = (String)config.getInitParameter("messagerouter_class");87 MessageRouter message_router = null;88 if (mr_name == null) { // just use the normal MR89 message_router = new MessageRouter();90 } else { // try the specified one91 try {92 message_router = (MessageRouter)Class.forName("org.greenstone.gsdl3.core."+mr_name).newInstance();93 } catch (Exception e) { // cant use this new one, so use normal one94 System.err.println("LibraryServlet configure exception when trying to use a new MessageRouter "+mr_name+": "+e.getMessage());95 e.printStackTrace();96 message_router = new MessageRouter();97 }98 }99 100 message_router.setSiteName(site_name);101 message_router.configure();102 99 103 100 // the receptionist -the servlet will talk to this … … 115 112 } 116 113 this.recept.setConfigParams(config_params); 117 this.recept.setMessageRouter(message_router); 114 115 // the receptionist uses a MessageRouter or Communicator to send its requests to. We either create a MessageRouter here for the designated site (if site_name set), or we create a Communicator for a remote site. The is given to teh Receptionist, and the servlet never talks to it again.directly. 116 if (site_name != null) { 117 String mr_name = (String)config.getInitParameter("messagerouter_class"); 118 MessageRouter message_router = null; 119 if (mr_name == null) { // just use the normal MR 120 message_router = new MessageRouter(); 121 } else { // try the specified one 122 try { 123 message_router = (MessageRouter)Class.forName("org.greenstone.gsdl3.core."+mr_name).newInstance(); 124 } catch (Exception e) { // cant use this new one, so use normal one 125 System.err.println("LibraryServlet configure exception when trying to use a new MessageRouter "+mr_name+": "+e.getMessage()); 126 e.printStackTrace(); 127 message_router = new MessageRouter(); 128 } 129 } 130 131 message_router.setSiteName(site_name); 132 message_router.configure(); 133 this.recept.setMessageRouter(message_router); 134 } else { 135 // talking to a remote site, create a communicator 136 Communicator communicator = null; 137 // we need to create the XML to configure the communicator 138 Element site_elem = this.doc.createElement(GSXML.SITE_ELEM); 139 site_elem.setAttribute(GSXML.TYPE_ATT, remote_site_type); 140 site_elem.setAttribute(GSXML.NAME_ATT, remote_site_name); 141 site_elem.setAttribute(GSXML.ADDRESS_ATT, remote_site_address); 142 143 if (remote_site_type.equals(GSXML.COMM_TYPE_SOAP_JAVA)) { 144 communicator = new SOAPCommunicator(); 145 } else { 146 System.err.println("LibraryServlet.init Error: invalid Communicator type: "+remote_site_type); 147 System.exit(1); 148 } 149 150 if (!communicator.configure(site_elem)) { 151 System.err.println("LibraryServlet.init Error: Couldn't configure communicator"); 152 System.exit(1); 153 } 154 this.recept.setMessageRouter(communicator); 155 } 156 118 157 // the params arg thingy 119 158
Note:
See TracChangeset
for help on using the changeset viewer.