Skip to Content.
Sympa Menu

perfsonar-dev - perfsonar: r2748 - in branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary base/auxiliary/components/configuration/properties base/auxiliary/components/logger/log4j service/base/web

Subject: perfsonar development work

List archive

perfsonar: r2748 - in branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary base/auxiliary/components/configuration/properties base/auxiliary/components/logger/log4j service/base/web


Chronological Thread 
  • From:
  • To:
  • Subject: perfsonar: r2748 - in branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary base/auxiliary/components/configuration/properties base/auxiliary/components/logger/log4j service/base/web
  • Date: Wed, 29 Aug 2007 12:27:55 -0400

Author: michael.bischoff
Date: 2007-08-29 12:27:54 -0400 (Wed, 29 Aug 2007)
New Revision: 2748

Modified:

branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/AuxiliaryComponentManager.java

branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/configuration/properties/PropertiesConfigurationComponent.java

branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/logger/log4j/Log4jLoggerComponent.java

branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/web/RequestHandler.java
Log:
Lookup fix for SAX_PARSER_CONFIG

Modified:
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/AuxiliaryComponentManager.java
===================================================================
---
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/AuxiliaryComponentManager.java
2007-08-29 14:23:59 UTC (rev 2747)
+++
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/AuxiliaryComponentManager.java
2007-08-29 16:27:54 UTC (rev 2748)
@@ -64,22 +64,19 @@
public boolean initManager() throws PerfSONARException {
//read components from Configuration file and init them
//String configFileName =
"/projects/sonar/perfsonar/conf/components.properties";
- URL urlString = lookupFile("/perfsonar/conf/components.properties");
+ File componentsProperties =
lookupFile("/perfsonar/conf/components.properties");

- if(urlString==null || urlString.toString()==null) {
+ if(componentsProperties==null) {
throw new PerfSONARException(
"AuxiliaryComponentManager.initManager: " +
"Missing or unable to locate components.properties file.
Cannot continue"
);
}

- String configFileName = urlString.getFile();
-
- logger.info("AuxiliaryComponentManager.initManager: Read config file
name as: "+configFileName);
-
+ logger.info("AuxiliaryComponentManager.initManager: Read config file
name as: "+componentsProperties);
try {
//read configfile into properties (name, value)
- ArrayList<ComponentsConfigurationReader.Entry> properties = new
ComponentsConfigurationReader().readFile(configFileName);
+ ArrayList<ComponentsConfigurationReader.Entry> properties = new
ComponentsConfigurationReader().readFile(componentsProperties.getCanonicalPath());

//for each entry in properties - create and initialize component
for (ComponentsConfigurationReader.Entry e : properties) {
@@ -225,31 +222,42 @@

/**
* Profides a consistent way to lookup files within perfsonar.
- * @return URL containting the path or null if not found.
+ * @return File at the specified location or null if not found.
*/
- public static URL lookupFile(String file) {
- logger.fine("Looking up file: "+file);
+ public static File lookupFile(String location) {
+ logger.fine("Looking up file: "+location);

- if(file == null) {
+ if(location == null) {
return null;
- }
+ }

- logger.finer("WEB-INF:"+componentManager.webInfLocation);
URL url = null;
// try WEB-INF
+ logger.finer("WEB-INF:"+componentManager.webInfLocation);
if(componentManager.webInfLocation != null) {
- if(file.startsWith("/")) {
+ if(location.startsWith("/")) {
url = componentManager.getClass().getResource(
- componentManager.webInfLocation + file
+ componentManager.webInfLocation +
location
);
} else {
url = componentManager.getClass().getResource(
-
componentManager.webInfLocation + "/" + file
+
componentManager.webInfLocation + "/" + location
);
}
+ if(url != null) {
+ return new File(url.getFile());
+ }
}
- // return url or try absolute
- return (url!=null) ? url :
componentManager.getClass().getResource(file);
+
+ // try class path
+ url = componentManager.getClass().getResource(location);
+ if(url!=null) {
+ return new File(url.getFile());
+ }
+
+ // try absolute
+ File file = new File(location);
+ return (file.exists()) ? file : null;
}

public static void setWebInfLocation(String location) {

Modified:
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/configuration/properties/PropertiesConfigurationComponent.java
===================================================================
---
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/configuration/properties/PropertiesConfigurationComponent.java
2007-08-29 14:23:59 UTC (rev 2747)
+++
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/configuration/properties/PropertiesConfigurationComponent.java
2007-08-29 16:27:54 UTC (rev 2748)
@@ -2,7 +2,6 @@

import java.io.File;
import java.io.FileInputStream;
-import java.net.URL;
import java.util.Properties;
import java.util.logging.Logger;

@@ -43,30 +42,16 @@
// ---------------------------------- constructor
public void initComponent() throws PerfSONARException {
// bootstrapped absolute file location in catalina.properties file
- URL fileNameURL =
AuxiliaryComponentManager.lookupFile("/perfsonar/conf/service.properties");
+ file =
AuxiliaryComponentManager.lookupFile("/perfsonar/conf/service.properties");

- if(fileNameURL==null) {
+ if(file==null) {
logger.severe("PropertiesConfigurationComponent.initComponent:" +
" Missing or unable to locate service.properties file. Cannot
initialise PropertiesConfigurationComponent.");

throw new
PerfSONARException("PropertiesConfigurationComponent.initComponent:" +
" Missing or unable to locate service.properties file. Cannot
initialise PropertiesConfigurationComponent.");
}
-
- String fileName = fileNameURL.getFile();
- logger.info("PropertiesConfigurationComponent.initComponent: Read
the file name as: "+fileName);
-
- // create a new file object with the read file name
- try {
- file = new File(fileName);
- } catch(NullPointerException npe) {
- throw new PerfSONARException(
- "PropertiesConfigurationComponent.initComponent: "
- + "Unable to create a file object referring to
service.properties" ,
- npe
- );
- }
-
+ logger.info("PropertiesConfigurationComponent.initComponent: Read
the file name as: "+file);
// load configuration
this.loadConfiguration();
}

Modified:
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/logger/log4j/Log4jLoggerComponent.java
===================================================================
---
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/logger/log4j/Log4jLoggerComponent.java
2007-08-29 14:23:59 UTC (rev 2747)
+++
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/base/auxiliary/components/logger/log4j/Log4jLoggerComponent.java
2007-08-29 16:27:54 UTC (rev 2748)
@@ -1,6 +1,6 @@
package org.perfsonar.base.auxiliary.components.logger.log4j;

-import java.net.URL;
+import java.io.File;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;
@@ -55,10 +55,10 @@
configuration =
(ConfigurationComponent)AuxiliaryComponentManager.getInstance().getComponent(ComponentNames.CONFIG);

String logconf =
configuration.getProperty("service.log.log4j.config");
- URL logConfiguration =
AuxiliaryComponentManager.lookupFile(logconf);
+ File logConfiguration =
AuxiliaryComponentManager.lookupFile(logconf);

if(logConfiguration!=null) {
- PropertyConfigurator.configure(logConfiguration);
+
PropertyConfigurator.configure(logConfiguration.getAbsolutePath());
} else {
System.err.println("PerfSONAR:WARNING: perfsonar logging not
configured correctly. (specified logging properties file not found.)");
}

Modified:
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/web/RequestHandler.java
===================================================================
---
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/web/RequestHandler.java
2007-08-29 14:23:59 UTC (rev 2747)
+++
branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar/service/base/web/RequestHandler.java
2007-08-29 16:27:54 UTC (rev 2748)
@@ -7,6 +7,7 @@

package org.perfsonar.service.base.web;

+import java.io.File;
import java.net.URL;

import org.ggf.ns.nmwg.base.v2_0.Message;
@@ -131,7 +132,8 @@
try {
if(saxParserConfig == null) {
saxParserConfig =
attemptSaxParserConfigLookup();
- }
+ }
+ logger.debug("Using file: "+saxParserConfig+" as
SAX_PARSER_CONFIG");
requestMessage = XMLUtils.convertToMessage(request,
saxParserConfig);
} catch (Exception e) {
throw new PerfSONARException(
@@ -203,11 +205,11 @@
throw e;
}

- URL url = AuxiliaryComponentManager.lookupFile(config);
- if(url!=null) {
- return url.getFile();
+ File file = AuxiliaryComponentManager.lookupFile(config);
+ if(file!=null) {
+ return file.getAbsolutePath();
}
- logger.error("Sax parser config could not be found. (lookup
failed)");
+ logger.error("Sax parser config could not be found. (lookup
failed for: "+config+" )");
throw new PerfSONARException(
"error.common.no_configuration",
"specified service.sax_parser.config not found"



  • perfsonar: r2748 - in branches/new-structure/trunk/perfsonar_base/src/main/java/org/perfsonar: base/auxiliary base/auxiliary/components/configuration/properties base/auxiliary/components/logger/log4j service/base/web, svnlog, 08/29/2007

Archive powered by MHonArc 2.6.16.

Top of Page