[jboss-svn-commits] JBL Code SVN: r8516 - labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Dec 21 13:27:37 EST 2006


Author: kurt.stam at jboss.com
Date: 2006-12-21 13:27:36 -0500 (Thu, 21 Dec 2006)
New Revision: 8516

Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java
Log:
fix so it will validate more then once.

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java	2006-12-21 18:21:04 UTC (rev 8515)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/config/ConfigurationController.java	2006-12-21 18:27:36 UTC (rev 8516)
@@ -50,7 +50,7 @@
 	private Logger mLogger = Logger.getLogger(this.getClass());
 	private boolean mIsEndRequested = false;
 	private String mConfigFileName;
-	private StreamSource mValidationInputSource;
+	private String mValidationFileName;
 	private File mConfigDirectory;
 	private long mPreviousFileTimestamp;
 	private boolean ended = false;
@@ -92,27 +92,10 @@
 	{
 		mConfigFileName = configFileName;
 		//Try to obtain a handle to the validation file (xsd)
-		if (validationFileName==null) {
-			validationFileName=JBOSSESB_XSD;
+		if (mValidationFileName==null) {
+			mValidationFileName=JBOSSESB_XSD;
 		}
-		InputStream validationInputStream = this.getClass().getResourceAsStream(validationFileName);
-		//if this fails try using the 
-		if (validationInputStream==null) {
-			File validationFile = new File(validationFileName);
-			mLogger.debug("Validation file " + validationFileName + " exists?:" + validationFile.exists());
-			try {
-				validationInputStream = new FileInputStream(validationFile);
-			} catch (FileNotFoundException e) {
-				mLogger.error(e.getMessage(),e);
-				throw new IllegalStateException("ESB configuration file [" + (new File(configFileName)).getAbsolutePath() + "] not found.", e);
-			}
-		}
-		if (validationInputStream==null) {
-			mLogger.warn("Could not obtain validation file " + validationFileName);
-		} else {
-			mLogger.debug("Reading validation info from " + validationFileName);
-			mValidationInputSource = new StreamSource(validationInputStream);
-		}
+		
 	}
     /**
      * Thread that observes the configuration (file). If the configuration is updated it is
@@ -127,12 +110,32 @@
 				while (!mIsEndRequested) {
 					if (isReloadNeeded()) { 
 						try {
+							StreamSource validationInputSource=null;
+							InputStream validationInputStream = this.getClass().getResourceAsStream(mValidationFileName);
+							//if this fails try using the 
+							if (validationInputStream==null) {
+								File validationFile = new File(mValidationFileName);
+								mLogger.debug("Validation file " + mValidationFileName + " exists?:" + validationFile.exists());
+								try {
+									validationInputStream = new FileInputStream(validationFile);
+								} catch (FileNotFoundException e) {
+									mLogger.error(e.getMessage(),e);
+									throw new IllegalStateException("ESB configuration file [" + (new File(mValidationFileName)).getAbsolutePath() + "] not found.", e);
+								}
+							}
+							if (validationInputStream==null) {
+								mLogger.warn("Could not obtain validation file " + mValidationFileName);
+							} else {
+								mLogger.debug("Reading validation info from " + mValidationFileName);
+								validationInputSource = new StreamSource(validationInputStream);
+							}
+							
 							mLogger.info("loading configuration..");
 							String configXml = ParamRepositoryFactory.getInstance().get(mConfigFileName);
 							mLogger.debug("Start validation on configXml=" + configXml);
 							InputSource xmlInputSource = new InputSource(new StringReader(configXml));
 							XmlValidator validator = new XmlValidatorImpl();
-							if (validator.validate(xmlInputSource, mValidationInputSource)) {
+							if (validator.validate(xmlInputSource, validationInputSource)) {
 								mLogger.debug("Configuration file " + mConfigFileName + " passed validation. Starting " +
 										" the generation process of the jbossesb-listener.xml and the jbossesb-gateway.xml.");
 								Generator generator = new Generator(new ByteArrayInputStream(configXml.getBytes()));




More information about the jboss-svn-commits mailing list