- Timestamp:
- 2005-05-16T11:02:50+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/core/MessageRouter.java
r9276 r9874 98 98 this.converter = new XMLConverter(); 99 99 this.doc = this.converter.newDOM(); 100 101 102 } 103 100 } 101 102 public void cleanUp() { 103 if (this.module_map != null) { 104 Iterator i = this.module_map.values().iterator(); 105 while (i.hasNext()) { 106 ((ModuleInterface)i.next()).cleanUp(); 107 } 108 } 109 } 104 110 /** site_home must be set before configure called */ 105 111 public void setSiteHome(String home) { … … 133 139 this.module_map = new HashMap(); 134 140 135 Element config = this.converter.getDOM(configFile).getDocumentElement(); 136 137 Element local_site_name = (Element)GSXML.getChildByTagName(config, GSXML.SITE_NAME_ELEM); 141 Document config_doc = this.converter.getDOM(configFile); 142 if (config_doc == null) { 143 System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath()); 144 return false; 145 } 146 Element config_elem = config_doc.getDocumentElement(); 147 148 Element local_site_name = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_NAME_ELEM); 138 149 if (local_site_name == null) { 139 150 System.err.println("MessageRouter configure error:no site name in config file"); … … 143 154 } 144 155 145 Element http_address = (Element)GSXML.getChildByTagName(config , GSXML.SITE_HTTP_ADDRESS_ELEM);156 Element http_address = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_HTTP_ADDRESS_ELEM); 146 157 if (http_address == null) { 147 158 System.err.println("MessageRouter configure error: no http address in config file"); … … 151 162 } 152 163 153 Element proxy = (Element)GSXML.getChildByTagName(config , "proxy");164 Element proxy = (Element)GSXML.getChildByTagName(config_elem, "proxy"); 154 165 if (proxy != null) { 155 166 String host = proxy.getAttribute("host"); … … 180 191 181 192 // load up the services 182 Element service_rack_list = (Element)GSXML.getChildByTagName(config , GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER);193 Element service_rack_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SERVICE_CLASS_ELEM+GSXML.LIST_MODIFIER); 183 194 configureServices(service_rack_list); 184 195 185 196 // load up the service clusters 186 Element cluster_list = (Element)GSXML.getChildByTagName(config , GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER);197 Element cluster_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.CLUSTER_ELEM+GSXML.LIST_MODIFIER); 187 198 configureClusters(cluster_list); 188 199 … … 191 202 192 203 // load up the external sites - this also adds their services/clusters/collections to the other lists - so must be done last 193 Element site_list = (Element)GSXML.getChildByTagName(config , GSXML.SITE_ELEM+GSXML.LIST_MODIFIER);204 Element site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER); 194 205 configureSites(site_list); 195 206 … … 603 614 continue; 604 615 } 605 site_config_elem = this.converter.getDOM(configFile).getDocumentElement(); 616 Document site_config_doc = this.converter.getDOM(configFile); 617 if (site_config_doc == null) { 618 System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath()); 619 continue; 620 } 621 site_config_elem = site_config_doc.getDocumentElement(); 606 622 } 607 623 if (subset.equals(GSXML.SERVICE_ELEM+GSXML.LIST_MODIFIER)) { … … 684 700 File init_file = new File(GSFile.collectionInitFile(this.site_home, col_name)); 685 701 if (init_file.exists()) { 686 Element init_elem = this.converter.getDOM(init_file).getDocumentElement(); 687 String coll_class_name = init_elem.getAttribute("class"); 688 if (coll_class_name.equals("")) { 689 c = new Collection(); 690 } else { 691 try { 692 c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance(); 693 } catch (Exception e) { 694 System.out.println("MessageRouter: couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection"); 695 c = new Collection(); 696 } 697 } 698 } else { 699 // use the defualt collection 702 Document init_doc = this.converter.getDOM(init_file); 703 if (init_doc != null) { 704 Element init_elem = init_doc.getDocumentElement(); 705 if (init_elem != null) { 706 String coll_class_name = init_elem.getAttribute("class"); 707 if (!coll_class_name.equals("")) { 708 try { 709 c = (Collection)Class.forName("org.greenstone.gsdl3.collection."+coll_class_name).newInstance(); 710 } catch (Exception e) { 711 System.out.println("MessageRouter: couldn't create a new collection, type "+coll_class_name+", defaulting to class Collection"); 712 } 713 } 714 } 715 } 716 } 717 if (c==null) { // we haven't found anpther classname to use 700 718 c = new Collection(); 701 719 } 720 702 721 c.setCollectionName(col_name); 703 722 c.setSiteHome(this.site_home); … … 720 739 721 740 } 722 741 723 742 protected boolean activateSite(String site_name) { 724 743 System.out.println("MessageRouter:Activating site: "+site_name+"."); … … 732 751 return false; 733 752 } 734 Element config = this.converter.getDOM(configFile).getDocumentElement(); 735 736 Element site_list = (Element)GSXML.getChildByTagName(config, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER); 753 Document config_doc = this.converter.getDOM(configFile); 754 if (config_doc == null) { 755 System.err.println("MessageRouter: couldn't parse site config file: "+configFile.getPath()); 756 return false; 757 } 758 Element config_elem = config_doc.getDocumentElement(); 759 760 Element site_list = (Element)GSXML.getChildByTagName(config_elem, GSXML.SITE_ELEM+GSXML.LIST_MODIFIER); 737 761 if (site_list ==null ) { 738 762 System.err.println("MessageRouter:activateSite, no sites found"); … … 789 813 790 814 System.out.println("MessageRouter: deactivating "+name); 791 this.module_map.remove(name);792 815 ModuleInterface m = (ModuleInterface)this.module_map.remove(name); 816 m.cleanUp(); // clean up any open files/connections etc - can cause trouble on windows 793 817 // also remove the xml bit from description list 794 818 if (type.equals(GSXML.COLLECTION_ELEM)) {
Note:
See TracChangeset
for help on using the changeset viewer.