| ServerProperties.java |
1 package ch.ige.edossier.util;
2
3 import java.net.URL;
4 import java.util.Properties;
5 import org.apache.log4j.Logger;
6
7 /**
8 * B32.03 - eDossier-Interceptions - Diplomarbeit an der Software-Schule Schweiz<br>
9 * Die Klasse ServerProperties liest die Properties aus der Properties-Datei die auf dem Webserver abgelegt ist.
10 * <p>
11 * Copyright (c) 2004, Eidgenössisches Institut für Geistiges Eigentum
12 * @author Anita Rueegsegger, Marc Bouquet
13 * @version $Id: ServerProperties.java,v 1.7 2004/10/22 05:07:23 bouquet Exp $
14 */
15 public class ServerProperties
16 {
17 // Attribute für Log4j-Logging
18 private static final Logger LOG = Logger.getLogger( ServerProperties.class );
19
20 // // Attribut PROPERTIESPATH setzt den Pfad der Properties-Datei
21 private static final String PROPERTIESPATH = "file:////c://programme//ige//edossier//config//edossier.properties";
22 // private static final String PROPERTIESPATH = "file:////c://jp//projects//edossier//config//edossier.properties";
23
24 // // Attribut WEBPATH setzt den Pfad auf die jeweilige Properties-Datei
25 private static final String WEBPATH = "file:////c://Programme//Tomcat~1.0//webapps//edossier//WEB-INF//classes//ApplicationResources_";
26 // private static final String WEBPATH = "file:////c://jp//Projects//edossier//src//ApplicationResources_";
27
28 /**
29 * Standard-Konstruktor
30 */
31 public ServerProperties()
32 {}
33
34 /**
35 * Liest die Server-Properties-Datei und gibt diese der aufrufenden Methode zurück.
36 * @return Properties geladene Properties
37 * @throws Exception Unerwarteter Fehler
38 */
39 public static Properties loadServerProperties() throws Exception
40 {
41 Properties properties = new Properties();
42
43 try
44 {
45 URL propsFileURL = new URL( PROPERTIESPATH );
46 properties = new Properties();
47 properties.load( propsFileURL.openStream() );
48 return properties;
49 }
50 catch( Exception ex )
51 {
52 ex.printStackTrace();
53 LOG.error( "Properties-Datei: (" + PROPERTIESPATH + ") oder Properties: (" + properties + ") konnte nicht gelesen werden." );
54 return null;
55 }
56 }
57
58 /**
59 * Liest die Webapplication-Properties-Datei und gibt diese der aufrufenden Methode zurück.
60 * @param languageCd String Sprach-Code
61 * @return Properties geladene Properties
62 * @throws Exception Unerwarteter Fehler
63 */
64 public static Properties loadWebProperties( String languageCd ) throws Exception
65 {
66 Properties properties = new Properties();
67
68 try
69 {
70 URL propsFileURL = new URL( WEBPATH + languageCd + ".properties" );
71 properties = new Properties();
72 properties.load( propsFileURL.openStream() );
73 return properties;
74 }
75 catch( Exception ex )
76 {
77 ex.printStackTrace();
78 LOG.error( "Properties-Datei: (" + WEBPATH + languageCd + ".properties) oder Properties: (" + properties + ") konnte nicht gelesen werden." );
79 return null;
80 }
81 }
82 }
83 | ServerProperties.java |