2006/unicorn/src/org/w3c/unicorn Framework.java,1.1.2.12,1.1.2.13

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

Modified Files:
      Tag: dev2
	Framework.java 
Log Message:
split initialization actions

Index: Framework.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Attic/Framework.java,v
retrieving revision 1.1.2.12
retrieving revision 1.1.2.13
diff -u -d -r1.1.2.12 -r1.1.2.13
--- Framework.java	19 Aug 2009 08:14:13 -0000	1.1.2.12
+++ Framework.java	19 Aug 2009 18:49:34 -0000	1.1.2.13
@@ -61,12 +61,12 @@
 	/**
 	 * Data structure for the Observers
 	 */
-	public static Map<String, Observer> mapOfObserver = null;
+	public static Map<String, Observer> mapOfObserver;
 
 	/**
 	 * Data structure for the tasks
 	 */
-	public static Map<String, Task> mapOfTask = null;
+	public static Map<String, Task> mapOfTask;
 
 	/**
 	 * List of available output languages in PATH_TO_OUTPUT_TEMPLATES
@@ -76,7 +76,7 @@
 	/**
 	 * Data structure for the various response parser
 	 */
-	public static Map<String, ResponseParser> mapOfReponseParser = null;
+	public static Map<String, ResponseParser> mapOfReponseParser;
 	
 	/**
 	 * Logger
@@ -104,10 +104,7 @@
 		"specialFormaters.properties",
 		"velocity.properties"};
 
-	/**
-	 * Initialize Unicorn
-	 */
-	public static void init() {// throws Exception {
+	public static void reset() {
 		unicornPropertiesFiles = new Hashtable<String, Properties>();
 		languageContexts = new Hashtable<String, VelocityContext>();
 		languageProperties = new Hashtable<String, Properties>();
@@ -115,6 +112,24 @@
 		velocityTemplates = new Hashtable<String, Template>();
 		mapOfObserver = new LinkedHashMap<String, Observer>();
 		mapOfReponseParser = new LinkedHashMap<String, ResponseParser>();
+	}
+	
+	/**
+	 * Initialize Unicorn
+	 */
+	public static void init() {
+		reset();
+		initCore();
+		initConfig();
+		initUnmarshallers();
+		initResponseParsers();
+		initObservers();
+		initTasklists();
+		initLanguages();
+		initVelocity();
+	}
+	
+	public static void initCore() {// throws Exception {
 		
 		// Checks that unicorn.home (JVM parameter) is set to an existing directory
 		String ucnHome = System.getProperty("unicorn.home");
@@ -153,6 +168,8 @@
 			logger.warn("Log4j will not be initialized");
 		}
 		
+	}	
+	public static void initConfig() {
 		// Load unicorn.properties	
 		logger.debug("-------------------------------------------------------");
 		String unicornPath = unicornHome.getPath() + "/WEB-INF/conf/unicorn.properties";
@@ -182,7 +199,8 @@
 				return;
 			}
 		}
-		
+	}
+	public static void initUnmarshallers() {
 		// Initialize WADLUnmarshallerXPath (Gets the Namespace URI and the prefix)
 		WADLUnmarshallerXPath.setNamespaceContext(new NamespaceContext() {
 			public String getNamespaceURI(final String sPrefix) {
@@ -212,6 +230,7 @@
 		// Initialize RDFUnmarshallerJena
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Initializing RDFUnmarshallerJena");
+		
 		try {
 			FileInputStream fis = new FileInputStream(Property.get("TASKLIST_RDF_MODEL"));
 			RDFUnmarshallerJena.getModel().read(fis, null);
@@ -247,7 +266,8 @@
 		RDFUnmarshallerJena.setPROPERTY_VALUE(model.getProperty(
 				namespace + "value"));
 		logger.info("OK - RDFUnmarshallerJena successfully initialized.");
-		
+	}
+	public static void initResponseParsers() {
 	    // Load the map of ResponseParser
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Loading available parsers form responseParsers.properties");
@@ -272,6 +292,8 @@
 			logger.info("OK - " + mapOfReponseParser.size() + " parser(s) successfully loaded.");
 		}
 
+	}
+	public static void initObservers() {
 		// Loading observers
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Loading available observers from the observers list file.");
@@ -346,7 +368,8 @@
 		} else {
 			logger.info("OK - " + mapOfObserver.size() + " observer(s) successfully loaded.");
 		}
-		
+	}
+	public static void initTasklists() {	
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Loading xml task files from tasklist directory: " + Property.get("PATH_TO_TASKLIST"));
 		TasksListUnmarshaller aTaskListUnmarshaller = new TaskListUnmarshallerBeans(mapOfObserver);
@@ -407,23 +430,8 @@
 			logger.debug(s);
 			logger.info("OK - " + mapOfTask.size() + " task(s) successfully loaded.");
 		}
-		
-
-		// Retrieve output lang from PATH_TO_OUTPUT_TEMPLATES
-		/*File[] listFD = (new File(Property.get("PATH_TO_TEMPLATES")))
-				.listFiles(new FileFilter() {
-					public boolean accept(File pathname) {
-						return pathname.getName().matches(".*\\.vm$");
-					}
-				});
-		outputLang = new HashSet<String>();
-		for (int i = 0; i < listFD.length; i++) {
-			outputLang.add((listFD[i].getName().split("_"))[0]);
-		}*/
-
-		//outputLang = new HashSet<String>();
-		
-		
+	}
+	public static void initLanguages() {	
 		// Loading language files
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Loading language files from language directory: " + Property.get("PATH_TO_LANGUAGE_FILES"));
@@ -496,7 +504,8 @@
 		for (String key : languageProperties.keySet()) {
 			languages.put(key, languageProperties.get(key).getProperty("language"));
 		}
-		
+	}	
+	public static void initVelocity() {	
 		// Creating velocity contexts
 		logger.debug("-------------------------------------------------------");
 		logger.debug("Initializing Velocity");
@@ -531,6 +540,7 @@
 		// Loading velocity templates
 		try {
 			velocityTemplates.put("index", velocityEngine.getTemplate("index.vm", "UTF-8"));
+			velocityTemplates.put("parameters", velocityEngine.getTemplate("includes/parameters.vm", "UTF-8"));
 		} catch (ResourceNotFoundException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
@@ -569,19 +579,15 @@
 	public static Hashtable<String, Properties> getUnicornPropertiesFiles() {
 		return unicornPropertiesFiles;
 	}
-
 	public static Hashtable<String, VelocityContext> getLanguageContexts() {
 		return languageContexts;
 	}
-
 	public static VelocityEngine getVelocityEngine() {
 		return velocityEngine;
 	}
-
 	public static Template getTemplate(String name) {
 		return velocityTemplates.get(name);
 	}
-
 	public static Hashtable<String, Properties> getLanguageProperties() {
 		return languageProperties;
 	}

Received on Wednesday, 19 August 2009 18:49:46 UTC