2006/unicorn/src/org/w3c/unicorn Framework.java,1.22,1.23 UnicornCall.java,1.36,1.37

Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv29765/src/org/w3c/unicorn

Modified Files:
	Framework.java UnicornCall.java 
Log Message:
new response parsing process
+ implementations for the new observer schema

Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Framework.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- Framework.java	12 Oct 2009 15:27:33 -0000	1.22
+++ Framework.java	19 Oct 2009 10:09:04 -0000	1.23
@@ -10,6 +10,7 @@
 import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URL;
@@ -37,7 +38,6 @@
 import org.w3c.unicorn.contract.WADLUnmarshallerXPath;
 import org.w3c.unicorn.exceptions.InitializationFailedException;
 import org.w3c.unicorn.exceptions.UnknownParserException;
-import org.w3c.unicorn.response.parser.ResponseParser;
 import org.w3c.unicorn.tasklist.RDFUnmarshaller;
 import org.w3c.unicorn.tasklist.RDFUnmarshallerJena;
 import org.w3c.unicorn.tasklist.Task;
@@ -48,6 +48,7 @@
 import org.w3c.unicorn.util.ListFiles;
 import org.w3c.unicorn.util.Property;
 import org.w3c.unicorn.util.UCNProperties;
+import org.w3c.unicorn.response.Response;
 
 import com.hp.hpl.jena.rdf.model.Model;
 
@@ -71,7 +72,7 @@
 	/**
 	 * Data structure for the various response parser
 	 */
-	public static Map<String, ResponseParser> mapOfReponseParser;
+	public static Map<String, Class<Response>> responseImpl;
 	
 	/**
 	 * Logger
@@ -105,7 +106,7 @@
 		languageProperties = new Hashtable<String, Properties>();
 		languages = new TreeMap<String, String>();
 		mapOfObserver = new LinkedHashMap<String, Observer>();
-		mapOfReponseParser = new LinkedHashMap<String, ResponseParser>();
+		responseImpl = new LinkedHashMap<String, Class<Response>>();
 		LanguageAction.setLanguageProperties(new TreeMap<String, Properties>());
 	}
 	
@@ -257,31 +258,38 @@
 				namespace + "value"));
 		logger.info("OK - RDFUnmarshallerJena successfully initialized.");
 	}
+	
+	@SuppressWarnings("unchecked")
 	public static void initResponseParsers() throws InitializationFailedException {
 	    // Load the map of ResponseParser
 		logger.debug("-------------------------------------------------------");
-		logger.debug("Loading available parsers form responseParsers.properties");
+		logger.debug("Loading available response implementations form responseParsers.properties");
 		Properties aProperties = Property.getProps("responseParsers.properties");
 		for (Object key : aProperties.keySet()) {
 			String className = aProperties.getProperty(key.toString());
 			try {
-				ResponseParser aResponseParser = (ResponseParser) Class
-					.forName(className).newInstance();
-				mapOfReponseParser.put(key.toString(), aResponseParser);
-				logger.debug("> Parser loaded: " + mapOfReponseParser.get(key).getClass().toString());
+				if (Response.class.isAssignableFrom(Class.forName(className))) {
+					Class.forName(className).getConstructor(InputStream.class, String.class);
+					responseImpl.put(key.toString(), (Class<Response>) Class.forName(className));
+					logger.debug("> Parser loaded: " + responseImpl.get(key).getClass().toString());
+				} else {
+					logger.error("> Class: " + className + " is not a Response implementation.");
+				}
 			} catch (ClassNotFoundException e) {
-				logger.warn("Class not found: " + className + ". Check responseParsers.properties.", e);
+				logger.error("Class not found: " + className + ". Check responseParsers.properties.");
+			} catch (NoSuchMethodException e) {
+				logger.error("Response implementation: " + className + " does not have a constructor with signature (InputStream is, String charset). Implementation skipped.");
 			} catch (Exception e) {
-				logger.warn("Error trying to instanciate: " + className, e);
+				logger.error("Error trying to instanciate: " + className, e);
 			}
 		}
-		if (mapOfReponseParser.size() == 0) {
+		if (responseImpl.size() == 0) {
 			throw new InitializationFailedException("There is no parser loaded. Check responseParsers.properties.");
 		} else {
-			logger.info("OK - " + mapOfReponseParser.size() + " parser(s) successfully loaded.");
+			logger.info("OK - " + responseImpl.size() + " implementation(s) successfully loaded.");
 		}
-
 	}
+	
 	public static void initObservers() throws InitializationFailedException {
 		// Loading observers
 		logger.debug("-------------------------------------------------------");

Index: UnicornCall.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/UnicornCall.java,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- UnicornCall.java	13 Oct 2009 15:23:55 -0000	1.36
+++ UnicornCall.java	19 Oct 2009 10:09:04 -0000	1.37
@@ -440,7 +440,7 @@
 								logger.warn("unknown observer id (" + observerId + ") in output group of task: " + this.getTask().getID() + ". It is possible that this observation failed, or that the tasklist is not valid.");
 								continue;
 							}
-							if (mapOfResponse.get(observerId).isPassed()) {
+							if (mapOfResponse.get(observerId).getStatus() == Response.PASSED) {
 								passedId = observerId;
 								break;
 							}
@@ -461,7 +461,7 @@
 	public boolean isPassed() {
 		boolean passed = true;
 		for (String key : getObservationList().keySet()) {
-			if (!observationMap.get(key).isPassed()) {
+			if (observationMap.get(key).getStatus() != Response.PASSED) {
 				passed = false;
 			}
 		}
@@ -565,7 +565,6 @@
 			case UPLOAD:
 				logger.debug("Creating FakeUploadInputModule");
 				return new FakeUploadInputModule(inputModule);
-				//return new FileItemInputModule(inputModule);
 			case URI:
 				logger.debug("Creating URIInputModule");
 				return new URIInputModule(inputModule);

Received on Monday, 19 October 2009 10:09:09 UTC