- Timestamp:
- 2009-05-08T12:27:53+12:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
greenstone3/trunk/src/java/org/greenstone/gsdl3/core/MessageRouter.java
r16688 r19352 47 47 * The hub of a Greenstone system. 48 48 * 49 * Accepts XML requests (via process method of ModuleInterface) and routes them to the appropriate collection or50 * service or external entity.49 * Accepts XML requests (via process method of ModuleInterface) and routes them 50 * to the appropriate collection or service or external entity. 51 51 * 52 52 * contains a map of module objects - may be services, collections, comms … … 61 61 * @see Communicator 62 62 * 63 * Since some service classes are moved into a separate directory in order for them to be checked out from a different repository, 64 * we modify the configureServices method to search some of the classes in other place if they are not found in the service directory. 63 * Since some service classes are moved into a separate directory in order for 64 * them to be checked out from a different repository, we modify the 65 * configureServices method to search some of the classes in other place if they 66 * are not found in the service directory. 65 67 */ 66 68 public class MessageRouter implements ModuleInterface { … … 174 176 // set up the authenticator 175 177 Authenticator.setDefault(new Authenticator(){ 176 177 178 179 178 protected PasswordAuthentication getPasswordAuthentication(){ 179 return new PasswordAuthentication(user, new String(passwd).toCharArray()); 180 } 181 }); 180 182 181 183 } catch (Exception e) { … … 263 265 mainResult.appendChild(this.doc.importNode(result, true)); 264 266 } else { 265 266 267 267 // The message needs to go to another module. The same message can 268 // be passed to multiple modules - they will be in a comma 269 // separated list in the 'to' attribute 268 270 String [] modules = path.split(","); 269 271 … … 311 313 } 312 314 public Element getCollectionList() { 313 315 return collection_list; 314 316 } 315 317 public HashMap getModuleMap() { 316 318 return module_map; 317 319 } 318 320 // ******************************************************************** … … 327 329 while (i.hasNext()) { 328 330 ((ModuleInterface)i.next()).cleanUp(); 329 331 i.remove(); 330 332 } 331 333 } … … 345 347 String potential_site_name = GSPath.getFirstLink(name); 346 348 if (remote_site != null) { 347 348 349 349 if (remote_site.equals(potential_site_name)) { 350 list.removeChild(item); 351 } 350 352 } else { 351 if (name.equals(potential_site_name)) {// there was no site 352 list.removeChild(item); 353 ModuleInterface m = (ModuleInterface)this.module_map.remove(name); 354 m.cleanUp(); // clean up any open files/connections etc 355 m=null; 356 } 357 } 358 } 359 360 logger.error(this.converter.getString(list)); 361 353 if (name.equals(potential_site_name)) {// there was no site 354 list.removeChild(item); 355 ModuleInterface m = (ModuleInterface)this.module_map.remove(name); 356 m.cleanUp(); // clean up any open files/connections etc 357 m=null; 358 } 359 } 360 } 361 logger.error(this.converter.getString(list)); 362 362 } 363 363 … … 370 370 String name = item.getAttribute(GSXML.NAME_ATT); 371 371 // will remove the node from site_list 372 deactivateModule(GSXML.SITE_ELEM, name); 373 } 374 375 } 372 deactivateModule(GSXML.SITE_ELEM, name); 373 } 374 375 } 376 376 377 /** read thru own site config file - create services and connect to sites 377 378 */ 378 379 protected boolean configureLocalSite() { 379 380 380 381 // this may be a reconfigure, so clean up the old moduleMap 381 382 cleanUpModuleMapEntire(); … … 449 450 Class service_class = null; 450 451 try { 451 452 service_class = Class.forName("org.greenstone.gsdl3.service."+service_name); 452 453 } catch(ClassNotFoundException e) { 453 454 try { 455 //try the service_name alone in case the package name is already specified 456 service_class = Class.forName(service_name); 457 458 }catch(ClassNotFoundException ae) { 459 logger.info(ae.getMessage()); 460 } 454 try { 455 //try the service_name alone in case the package name is already specified 456 service_class = Class.forName(service_name); 457 }catch(ClassNotFoundException ae) { 458 logger.info(ae.getMessage()); 459 } 461 460 } 462 461 try { 463 464 ServiceRack s = (ServiceRack)service_class.newInstance(); 465 s.setSiteHome(this.site_home); 462 ServiceRack s = (ServiceRack)service_class.newInstance(); 463 s.setSiteHome(this.site_home); 466 464 s.setSiteAddress(this.site_http_address); 467 465 s.setLibraryName(this.library_name); 468 466 s.setMessageRouter(this); 469 467 // pass the XML node to the service for service configuration 470 468 if (!s.configure(n, null)) { 471 472 473 469 logger.error ("couldn't configure ServiceRack "+service_name); 470 continue; 471 } 474 472 475 473 // find out the supported services for this service module … … 520 518 sc.setMessageRouter(this); 521 519 if (!sc.configure(cluster)) { 522 523 520 logger.error ("couldn't configure ServiceCluster "+name); 521 continue; 524 522 } 525 523 … … 603 601 // only public collections will appear on the home page 604 602 // add short description_ to collection_list_ 605 606 603 this.collection_list.appendChild(e); 604 607 605 if (c.hasOAI()) { 608 606 Element ane = this.doc.createElement(GSXML.COLLECTION_ELEM); … … 616 614 617 615 } else { 618 616 this.private_collection_list.appendChild(e); 619 617 } 620 618 return true; 621 619 } else { 622 620 logger.error("Couldn't configure collection: "+ 623 621 col_name+"."); 624 622 return false; 625 623 } … … 803 801 // also remove the xml bit from description list 804 802 if (type.equals(GSXML.COLLECTION_ELEM)) { 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 803 if (((Collection)m).isPublic()) { 804 Element this_col = GSXML.getNamedElement(this.collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 805 if (this_col != null) { 806 this.collection_list.removeChild(this_col); 807 } 808 if (((Collection)m).hasOAI()) { 809 this_col = GSXML.getNamedElement(this.oai_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 810 if (this_col != null) { 811 this.oai_collection_list.removeChild(this_col); 812 } 813 } 814 } else { 815 // a private collection 816 Element this_col = GSXML.getNamedElement(this.private_collection_list, GSXML.COLLECTION_ELEM, GSXML.NAME_ATT, name); 817 if (this_col != null) { 818 this.private_collection_list.removeChild(this_col); 819 } 820 } 823 821 } else if (type.equals(GSXML.SERVICE_ELEM)) { 824 822 Element this_service = GSXML.getNamedElement(this.service_list, GSXML.SERVICE_ELEM, GSXML.NAME_ATT, name); … … 840 838 cleanUpModuleMapSubset(this.cluster_list, name); 841 839 cleanUpModuleMapSubset(this.service_list, name); 842 843 840 841 // can remote collections be in the oai_coll list, or private coll list ?? 844 842 } 845 843 } else { 846 844 logger.error("invalid module type: "+type+", can't remove info about this module"); 847 } 845 } 848 846 849 847 m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows … … 941 939 // else it a specific request 942 940 if (subset.equals(GSXML.COLLECTION_ELEM+GSXML.LIST_MODIFIER)) { 943 944 945 941 // get rid of all the old collection stuff (not counting remote ones) before activating all the new ones 942 cleanUpModuleMapSubset(this.collection_list, null); 943 cleanUpModuleMapSubset(this.private_collection_list, null); 946 944 success = configureCollections(); 947 945 } else { … … 972 970 } else if (subset.equals(GSXML.SITE_ELEM+GSXML.LIST_MODIFIER)) { 973 971 Element site_list = (Element)GSXML.getChildByTagName(site_config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER); 974 972 cleanUpAllExternalSiteInfo(); 975 973 success = configureExternalSites(site_list); 976 974 } … … 993 991 if (action.equals(GSXML.SYSTEM_TYPE_DEACTIVATE)) { 994 992 success = deactivateModule(module_type, module_name); 995 996 997 998 999 1000 1001 993 if (success) { 994 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" deactivated"); 995 response.appendChild(s); 996 } else { 997 Element s = GSXML.createTextElement(this.doc, GSXML.STATUS_ELEM, module_type+": "+module_name+" could not be deactivated"); 998 response.appendChild(s); 999 } 1002 1000 1003 1001 } else if (action.equals(GSXML.SYSTEM_TYPE_ACTIVATE)) { 1004 1005 1006 1002 // we need to deactivate the module first, in case this is a 1003 // reconfigure 1004 deactivateModule(module_type, module_name); 1007 1005 if (module_type.equals(GSXML.COLLECTION_ELEM)) { 1008 1006 success = activateCollectionByName(module_name);
Note:
See TracChangeset
for help on using the changeset viewer.