|
From: Michael A. <mic...@us...> - 2004-03-29 21:00:45
|
Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/jmx In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16790/modules/scanner/src/com/babeldoc/scanner/jmx Modified Files: ScannerServiceMBean.java ScannerService.java Log Message: General improvements in the JMX ScannerService, as well as including pipelines in the refresh. Index: ScannerService.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/jmx/ScannerService.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ScannerService.java 4 Dec 2003 00:44:42 -0000 1.6 --- ScannerService.java 29 Mar 2004 20:49:14 -0000 1.7 *************** *** 67,71 **** --- 67,74 ---- import com.babeldoc.core.LogService; + import com.babeldoc.core.pipeline.IPipelineFactory; + import com.babeldoc.core.pipeline.PipelineFactoryFactory; import com.babeldoc.scanner.Scanner; + import com.babeldoc.scanner.ScannerWorkerVO; import java.net.URL; *************** *** 85,92 **** LogService.getInstance(ScannerService.class.getName()); public static final int STATE_STOPPED = 0; ! public static final int STATE_STARTED = 1; public static final String stateDescriptions[] = new String[] {"scanner.002", "scanner.001"}; int state = 0; Scanner scanner = null; // Property --- 88,96 ---- LogService.getInstance(ScannerService.class.getName()); public static final int STATE_STOPPED = 0; ! public static final int STATE_STARTED = 1; public static final String stateDescriptions[] = new String[] {"scanner.002", "scanner.001"}; int state = 0; Scanner scanner = null; + boolean passedFirstStart = false; // Property *************** *** 137,141 **** */ public String getBabeldocHome() throws Exception { ! String home = System.getProperty("babeldoc.home"); getLog().logDebug("getBabeldocHome: " + home); return (home); --- 141,145 ---- */ public String getBabeldocHome() throws Exception { ! String home = System.getProperty("babeldoc.home"); getLog().logDebug("getBabeldocHome: " + home); return (home); *************** *** 147,153 **** getLog().logDebug("setBabeldocUserHome: " + home); } ! public String getBabeldocUserHome() throws Exception { ! String home = System.getProperty("babeldoc.user"); getLog().logDebug("getBabeldocUserHome: " + home); return (home); --- 151,157 ---- getLog().logDebug("setBabeldocUserHome: " + home); } ! public String getBabeldocUserHome() throws Exception { ! String home = System.getProperty("babeldoc.user"); getLog().logDebug("getBabeldocUserHome: " + home); return (home); *************** *** 163,168 **** */ public String getStateString() throws Exception { ! getLog().logDebug("getStateString: " + com.babeldoc.core.I18n.get(stateDescriptions[state])); ! return (com.babeldoc.core.I18n.get(stateDescriptions[state])); } --- 167,177 ---- */ public String getStateString() throws Exception { ! if (passedFirstStart) { ! getLog().logDebug("getStateString: " + com.babeldoc.core.I18n.get(stateDescriptions[state])); ! return (com.babeldoc.core.I18n.get(stateDescriptions[state])); ! } else { ! getLog().logDebug("getStateString: " + stateDescriptions[state]); ! return (stateDescriptions[state]); ! } } *************** *** 173,177 **** */ public void start() throws Exception { ! /* This section determines what the usual babeldoc.home will be for a standard * JBoss system. This will be ignored by other J2EE application containers, --- 182,188 ---- */ public void start() throws Exception { ! ! passedFirstStart = true; ! /* This section determines what the usual babeldoc.home will be for a standard * JBoss system. This will be ignored by other J2EE application containers, *************** *** 182,192 **** // This assumes that jboss.server.conf.url will always be a file:// // Not sure if babeldoc can handle a non-file home directory, e.g. ftp:// URL urlHome = new URL(babeldocHome); setBabeldocHome(urlHome.getFile()); setBabeldocUserHome(urlHome.getFile()); } ! scanner = new Scanner(new String[] { }); ! //TODO: Double check this since it maybe won't work... Did anyone used this anyway??? // MCA: I checked, it works. --- 193,204 ---- // This assumes that jboss.server.conf.url will always be a file:// // Not sure if babeldoc can handle a non-file home directory, e.g. ftp:// + // But then, I'm not sure if JBoss can handle a non-file conf directory URL urlHome = new URL(babeldocHome); setBabeldocHome(urlHome.getFile()); setBabeldocUserHome(urlHome.getFile()); } ! scanner = new Scanner(new String[] { }); ! //TODO: Double check this since it maybe won't work... Did anyone used this anyway??? // MCA: I checked, it works. *************** *** 207,212 **** } if (state != ScannerService.STATE_STOPPED) { ! scanner.stop(); ! scanner.finishUp(); } state = ScannerService.STATE_STOPPED; --- 219,224 ---- } if (state != ScannerService.STATE_STOPPED) { ! scanner.stop(); ! scanner.finishUp(); } state = ScannerService.STATE_STOPPED; *************** *** 222,232 **** } ! public void refreshConfig() throws Exception { ! if (state == ScannerService.STATE_STOPPED) { ! getLog().logDebug("Refreshing scanner configuration"); ! scanner.refreshConfig(); ! } else { ! throw new Exception("Invalid state for operation"); ! } } ! } \ No newline at end of file --- 234,261 ---- } ! public void refreshConfig() throws com.babeldoc.scanner.ScannerException { ! if (passedFirstStart) { ! if (state == ScannerService.STATE_STOPPED) { ! getLog().logDebug("Refreshing scanner configuration"); ! scanner.refreshConfig(); ! IPipelineFactory pf = PipelineFactoryFactory.getPipelineFactory(); ! pf.clearCache(); ! } else { ! throw new com.babeldoc.scanner.ScannerException("Invalid state for operation"); ! } ! } } ! ! public String scannerStatus() { ! String result = ""; ! if ((passedFirstStart) && (scanner != null)) { ! for (int i=0; i < scanner.listWorkers().length; i++) { ! ScannerWorkerVO s = scanner.listWorkers()[i]; ! String currentScannerStatus = "Name: " + s.getName(); ! currentScannerStatus += ", Status: " + s.getStatus(); ! result += currentScannerStatus; ! } ! } ! return result; ! } ! } Index: ScannerServiceMBean.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/jmx/ScannerServiceMBean.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ScannerServiceMBean.java 4 Dec 2003 00:44:42 -0000 1.4 --- ScannerServiceMBean.java 29 Mar 2004 20:49:14 -0000 1.5 *************** *** 122,124 **** --- 122,132 ---- */ public void refreshConfig() throws Exception; + + /** + * TODO: DOCUMENT ME! + * + * @throws Exception DOCUMENT ME! + */ + public String scannerStatus() throws Exception; + } |