1 36 37 package com.bluecubs.xinco.conf; 38 39 import javax.naming.InitialContext ; 40 import java.util.Vector ; 41 42 46 public class XincoConfigSingletonServer { 47 48 public String FileRepositoryPath = null; 49 public String FileIndexPath = null; 50 public String FileArchivePath = null; 51 public long FileArchivePeriod = 0; 52 public int FileIndexerCount = 0; 53 public Vector IndexFileTypesClass = null; 54 public Vector IndexFileTypesExt = null; 55 public String [] IndexNoIndex = null; 56 public String JNDIDB = null; 57 public int MaxSearchResult = 0; 58 private static XincoConfigSingletonServer instance = null; 59 60 public static XincoConfigSingletonServer getInstance() { 61 62 if (instance == null) { 63 instance = new XincoConfigSingletonServer(); 64 } 65 return instance; 66 67 } 68 69 private XincoConfigSingletonServer() { 71 try { 72 FileRepositoryPath = (String )(new InitialContext ()).lookup("java:comp/env/xinco/FileRepositoryPath"); 73 if (!(FileRepositoryPath.substring(FileRepositoryPath.length()-1).equals(System.getProperty("file.separator")))) { 74 FileRepositoryPath = FileRepositoryPath + System.getProperty("file.separator"); 75 } 76 try { 78 FileIndexPath = (String )(new InitialContext ()).lookup("java:comp/env/xinco/FileIndexPath"); 79 } catch (Exception ce) { 80 FileIndexPath = FileRepositoryPath + "index"; 81 } 82 if (!(FileIndexPath.substring(FileIndexPath.length()-1).equals(System.getProperty("file.separator")))) { 83 FileIndexPath = FileIndexPath + System.getProperty("file.separator"); 84 } 85 FileArchivePath = (String )(new InitialContext ()).lookup("java:comp/env/xinco/FileArchivePath"); 86 if (!(FileArchivePath.substring(FileArchivePath.length()-1).equals(System.getProperty("file.separator")))) { 87 FileArchivePath = FileArchivePath + System.getProperty("file.separator"); 88 } 89 FileArchivePeriod = ((Long )(new InitialContext ()).lookup("java:comp/env/xinco/FileArchivePeriod")).longValue(); 90 91 FileIndexerCount = ((Integer )(new InitialContext ()).lookup("java:comp/env/xinco/FileIndexerCount")).intValue(); 92 IndexFileTypesClass = new Vector (); 93 IndexFileTypesExt = new Vector (); 94 for (int i=0;i<FileIndexerCount;i++) { 95 IndexFileTypesClass.add((String )(new InitialContext ()).lookup("java:comp/env/xinco/FileIndexer_" + (i+1) + "_Class")); 96 IndexFileTypesExt.add(((String )(new InitialContext ()).lookup("java:comp/env/xinco/FileIndexer_" + (i+1) + "_Ext")).split(";")); 97 } 98 IndexNoIndex = ((String )(new InitialContext ()).lookup("java:comp/env/xinco/IndexNoIndex")).split(";"); 99 100 JNDIDB = (String )(new InitialContext ()).lookup("java:comp/env/xinco/JNDIDB"); 101 MaxSearchResult = ((Integer )(new InitialContext ()).lookup("java:comp/env/xinco/MaxSearchResult")).intValue(); 102 } catch (Exception e) { 103 FileRepositoryPath = ""; 104 FileIndexPath = ""; 105 FileArchivePath = ""; 106 FileArchivePeriod = 14400000; 107 FileIndexerCount = 4; 108 IndexFileTypesClass = new Vector (); 109 IndexFileTypesExt = new Vector (); 110 String [] tsa = null; 111 IndexFileTypesClass.add("com.bluecubs.xinco.index.filetypes.XincoIndexAdobePDF"); 112 tsa = null; 113 tsa[0] = "pdf"; 114 IndexFileTypesExt.add(tsa); 115 IndexFileTypesClass.add("com.bluecubs.xinco.index.filetypes.XincoIndexMSWord"); 116 tsa = null; 117 tsa[0] = "doc"; 118 IndexFileTypesExt.add(tsa); 119 IndexFileTypesClass.add("com.bluecubs.xinco.index.filetypes.XincoIndexMSExcel"); 120 tsa = null; 121 tsa[0] = "xls"; 122 IndexFileTypesExt.add(tsa); 123 IndexFileTypesClass.add("com.bluecubs.xinco.index.filetypes.XincoIndexHTML"); 124 tsa = null; 125 tsa[0] = "htm"; 126 tsa[1] = "html"; 127 tsa[2] = "php"; 128 tsa[3] = "jsp"; 129 IndexFileTypesExt.add(tsa); 130 IndexNoIndex[0] = ""; 131 IndexNoIndex[1] = "com"; 132 IndexNoIndex[2] = "exe"; 133 134 JNDIDB = "java:comp/env/jdbc/XincoDB"; 135 MaxSearchResult = 30; 136 } 137 } 138 139 } 140 | Popular Tags |