|
Letzte
Bearbeitung dieses Dokuments: |
Code
Erklärungen
und Anwendungsbeispiele
Verwandte
Dokumentation
package
js_base.xml;
import
java.util.Properties;
import
javax.naming.InitialContext;
import
org.jdom.Element;
import
js_base.frame.JSBS_StartFrame;
import
js_base.structures.JSBS_UniversalParameters;/**
*
* @author kurt(at)javascout[dot]biz
* @date
2006-08-23
*
* @description
* de:
* Klasse
mit speziellen Methoden zum Auselesen der Parameter für die
Verbindung
* zu einem Datenbanksystem oder einem
Java-Application-Server (JAS).
* Diese Klasse
erbt JSBS_XML_Base und verwendet die Methoden der geerbten
Klasse
* zum Lesen einer Datei mit einer
XML-Struktur.
* en:
* Class with
specialized methods for getting parameters for the connection
to
* a database-system or a
Java-Application-Server (JAS).
* This class
inherits JSBS_XML_Base and uses its methods to read a
file
* containing a XML-structure.
*
*
@change-log
*
when who why
*
--------------------------------------------------------
*
*/public
class JSBS_XML_Connections
extends
JSBS_XML_Base
{/*
*
-------------------------------
* de: CONSTRUCTOR der
Klasse.
* en: CONSTRUCTOR of the class. */ public
JSBS_XML_Connections(JSBS_StartFrame
parmCC)
{/* de:
Ausführen des Codes im Constructor der geerbten Klasse.
*//* en:
Perform the code in the constructor of the inherited class.
*/
super(parmCC);
/*
* de:
* Erstellen
des vollen Namens der Datei mit der XML-Struktur mit den
Verbindungs-Parametern.
* Der Namen wird durch
Zusammensetzen des Verzeichnisses und des Dateinamen gebildet,
* en:
* Build the full filename for the
XML-structure with the connection-parameters.
* This is
done by concatenating the directory for connection-relating
files
* and the filename for the file with the
XML-structure. */
String
locstrFileName
=
parmCC.structJSBS_UniversalParameters.strConnectionsDirectoryName
+
JSBS_UniversalParameters.CONST_CONNECTIONS_PARM_FILE_NAME;
/*
* de:
* Lesen
des 'RootElement' (oberstes XML-Element) der XML-Struktur.
* Die
Methode ist in der Superklasse – das ist die geerbte Klasse –
implementiert.
* en:
* Read the
RootElement of the XML-structure within the file.
* The
method is implemented in the superclass - i.e. the class inherited.
*/
readXMLFile(locstrFileName);
/*
* de:
* Methode aufrufen die prüft, ob eine Mandanten-Identifikation (Client-ID) festgelegt
* ist, diese aus der XML-Struktur ausliest und den Client-ID in die entsprechende
* Variable der Universal-Parameter für die Anwendung übertragen. * en:
* Call the method that checks if a client-ID is defined, reads it out of the XML-structure
* and transfer the value to the associated variable of the universal-parameters of the
* application.
*/
parmCC.structJSBS_UniversalParameters.intClientID = getClientID(); }/*
*
************************************************** */
/*
* de:
* METHODE um den (Java-)Klassen-Namen des Treibers für
das Datenbanksystem aus der
* XML-Struktur
auszulesen.
* en:
* METHOD to get the
(Java-)class-name of the database-driver out of the XML-structure
*/ public
String
getDataBaseDriverName() {/*
* de:
* Der
Code hier ist einfacher als in anderen Klassen die XML-Strukturen
verarbeiten.
* Der Grund dafür ist, dass die
XML-Struktur nicht 'tief' ist und ein XML-Element
* nicht
zu finden gleich ein kritischer Fehler ist (und kein Algorithmus für
eine
* Umgehung des Fehlers notwendig ist) und zu einem
'Dump' des Anwendungsprogramms
* führt.
* en:
* The
code here is more simple as in other classes dealing with
XML-structures.
* The reason is, that the XML-structure
is not deep and not finding a XML-element
* is a
critical error which should lead to a dump of the
application. */ String
locstrDataBaseDriverName = "";/*
* de:
* Zuerst das XML-Element, das den Abschnitt für
die Datenbank-Parameter darstellt, auslesen.
* en:
* First read the XML-element representing the section
for the database-parameters. */
Element
elementDataBaseParameters =
XML_RootElement.getChild("DataBaseParameters"); if
(elementDataBaseParameters
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des XML-Elements mit dem Parameter.
* en: Get the
XML-element with the parameter. */
Element
elementDataBaseDriverName =
elementDataBaseParameters.getChild("DataBaseDriverName"); if
(elementDataBaseDriverName
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des Inhalts (Text) des XML-Elements und zurückliefern.
* en:
Get the content (text) of the XML-element and return
it. */ locstrDataBaseDriverName
= elementDataBaseDriverName.getTextTrim();
return
locstrDataBaseDriverName;
}/*
*
************************************************** */
/*
* de:
* METHODE um den Datenbank-Namen mit allen
Verbindungs-Parametern aus der XML-Struktur auszulesen.
*
en:
* METHOD to get the database-name with all
connection-parameters out of the XML-structure */ public
String
getDataBaseName() { String
locstrDataBaseName = "";/*
* de:
* Zuerst das XML-Element, das den Abschnitt für
die Datenbank-Parameter darstellt, auslesen.
* en:
* First read the XML-element representing the section
for the database-parameters. */
Element
elementDataBaseParameters =
XML_RootElement.getChild("DataBaseParameters"); if
(elementDataBaseParameters
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des XML-Elements mit dem Parameter.
* en: Get the
XML-element with the parameter. */
Element
elementDataBaseName =
elementDataBaseParameters.getChild("DataBaseName"); if
(elementDataBaseName
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des Inhalts (Text) des XML-Elements und zurückliefern.
* en:
Get the content (text) of the XML-element and return
it. */ locstrDataBaseName
= elementDataBaseName.getTextTrim();
return
locstrDataBaseName;
}/*
*
************************************************** */
/*
* de:
* METHODE um den User-ID für die Verbindung zur
Datenbank aus der XML-Struktur auszulesen.
* en:
* METHOD to get the User-ID for the connection to the
database out of the XML-structure */ public
String
getDataBaseUserID() { String
locstrDataBaseUserID = "";/*
* de:
* Zuerst das XML-Element, das den Abschnitt für
die Datenbank-Parameter darstellt, auslesen.
* en:
* First read the XML-element representing the section
for the database-parameters. */
Element
elementDataBaseParameters =
XML_RootElement.getChild("DataBaseParameters"); if
(elementDataBaseParameters
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des XML-Elements mit dem Parameter.
* en: Get the
XML-element with the parameter. */
Element
elementDataBaseUserID =
elementDataBaseParameters.getChild("DataBaseUserID"); if
(elementDataBaseUserID
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des Inhalts (Text) des XML-Elements und zurückliefern.
* en:
Get the content (text) of the XML-element and return
it. */ locstrDataBaseUserID
= elementDataBaseUserID.getTextTrim();
return
locstrDataBaseUserID;
}/*
*
************************************************** */
/*
* de:
* METHODE um das Passwort für die Verbindung zur
Datenbank aus der XML-Struktur auszulesen.
* en:
* METHOD to get the Password for the connection to the
database out of the XML-structure */ public
String
getDataBasePassword() { String
locstrDataBasePassword = "";/*
* de:
* Zuerst das XML-Element, das den Abschnitt für
die Datenbank-Parameter darstellt, auslesen.
* en:
* First read the XML-element representing the section
for the database-parameters. */
Element
elementDataBaseParameters =
XML_RootElement.getChild("DataBaseParameters"); if
(elementDataBaseParameters
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des XML-Elements mit dem Parameter.
* en: Get the
XML-element with the parameter. */
Element
elementDataBasePassword =
elementDataBaseParameters.getChild("DataBasePassword"); if
(elementDataBasePassword
== null)
{/*
* de:
XML-Element nicht innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: XML-Element not found within
the XML-structure. Very critical error. */ return
null;
}/*
* de:
Holen des Inhalts (Text) des XML-Elements und zurückliefern.
* en:
Get the content (text) of the XML-element and return
it. */ locstrDataBasePassword
= elementDataBasePassword.getTextTrim();
return
locstrDataBasePassword;
}/*
*
************************************************** */
/*
* de:
* METHODE um ein XML-Element mit den Parametern für
die Verbindung zu einem JAS (Java
* Application
Server) aus der XML-Struktur auszulesen.
* Als
Parameter wird der – in der XML-Struktur festgelegte -
symbolische Name der Verbindung
* zum JAS übergeben.
*
en:
* METHOD to get a XML-Element with the parameters
for the connection to a JAS (Java Application
* Server)
out of the XML-structure.
* The passed parameter is the
symbolic Name – defined within the XML-structure – for
the
* connection to the JAS. */ private
Element
getJASParameter(String parmSymbolicName) {/*
* de:
* Variable für die XML-Elemente und den
enthaltenen Text mit dem symbolischen Namen.
* en:
* Variables for the XML-elements and the contained
text with the symbolic name. */ Element
elementJASParameter; Element
elementSymbolicName; String
strSymbolicName;/*
* de:
* Liste mit allen <JASParameter>-Elementen,
Anzahl der Elemente in der Liste und
* Index zum
Durchsuchen der Liste.
* en:
* List with
all <JASParameter>-Elementen, number of elements within the
list and
* Index to search the
list. */ java.util.List
listJASParameter; int
intlistJASParameterSize; int
intlistJASParameterIndex;/*
* de:
* Alle Abschnitte mit <JASParameter>-Elementen
in die Liste einlesen.
* en:
* Read all
section with <JASParameter>-elements into the
list. */
listJASParameter
= XML_RootElement.getChildren("JASParameter");/*
* de:
* Ermitteln der Anzahl von <JASParameter>-Elementen
in der Liste und prüfen,
* ob mindestens ein
XML-Element vorhanden ist.
* en:
* Get
the number of <JASParameter>-elements within the list and
verify that
* at least one XML-element is
present. */
intlistJASParameterSize
= listJASParameter.size(); if
(intlistJASParameterSize
== 0) {/*
* de:
Kein gesuchtes XML-Element innerhalb der XML-Struktur gefurnden. Sehr
kritischer Fehler.
* en: No requested XML-Element found
within the XML-structure. Very critical error. */ return
null;
}/*
* de:
Untersuchen jedes XML-Elementes innerhalb der Liste.
* en:
Inspect each XML-element within the list. */ for
(intlistJASParameterIndex
= 0; intlistJASParameterIndex
< intlistJASParameterSize; intlistJASParameterIndex++)
{/*
* de:
Einzelnes XML-Element aus der Liste holen.
* en: Get a
single XML-Element out of the list. */ elementJASParameter
= (Element)
listJASParameter.get(intlistJASParameterIndex);/*
* de:
XML-Element mit dem symbolischen Namen auslesen.
* en:
Get the XML-Element with the Symbolic
Name. */ elementSymbolicName
= elementJASParameter.getChild("SymbolicName");/*
* de:
* Prüfen ob ein passendes XML-Element gefunden
wurde. Wenn kein XML-Element gefunden wurde ist
* das
vorerst kein Fehler; es wird das nächste <JASParameter>-Element
untersucht.
* en:
* Verify if a fitting
XML-element was found. If no XML-element was found then that is
not
* an error yet; the next <JASParameter>-Element
will be inspected. */ if
(elementSymbolicName
== null)
continue;
/*
* de:
* Wert (Text) des XML-Elements auslesen und
vergleichen ob es das gesuchte XML-Element ist.
* Der
symbolische Name für den Vergleich wurde als Parameter
übergeben.
* en:
* Get the value
(text) of the XML-element and compare if it is the requested
XML-element.
* The symbolic name for the comparison was
passed as parameter. */ strSymbolicName
= elementSymbolicName.getTextTrim(); if
(strSymbolicName.compareTo(parmSymbolicName)
== 0) {/*
* de:
* Gesuchtes XML-Element für die JAS-Parameter
gefunden; an die aufrufender Methode zurück liefern.
* en:
* Fitting XML-element for the JAS-Parameter found;
return to the calling methode.. */
return
elementJASParameter;
}
}/*
* de:
* Kein passendes XML-Element in der Liste; über
null-Wert an aufrufende Methode signalisieren.
* en:
* No fitting XML-element with the list; return this
fact to the calling method via a null-value. */
return
null;
}/*
*
************************************************** */
/*
* de:
* METHODE um den Namen, mit der das EJB von
Client-Programmen aufgerufen werden kann,
* aus der
XML-Struktur auszulesen.
* Als Parameter wird der –
in der XML-Struktur festgelegte - symbolische Name der
Verbindung
* zum JAS übergeben.
* en:
* METHOD to get the name which is used by
client-programms to address the bean
* out of the
XML-structure.
* The passed parameter is the symbolic
Name – defined within the XML-structure – for
the
* connection to the JAS. */ public
String
getJASJNDIName(String parmSymbolicName) {/*
* de:
* Variable für das XML-Element mit dem Namen, der
für das EJB (Enterprise Java Bean) in der
* Java
Naming and Directory Interface (JNDI) registriert ist.
* en:
* Variable for the XML-elements with the name, that is
registered in the Java Naming and Directory
* Interface
(JNDI) for the EJB (Enterprise Java Bean). */ Element
elementJNDIName;/*
* de:
* Methode, die das XML-Element mit allen Parametern
für die Verbindung zum JAS
* aus der XML-Struktur
ausliest, aufrufen.
* en:
* Call the
method that gets the XML-element containing all parameters for the
* connection to the JAS. */ Element
elementJASParameter = getJASParameter(parmSymbolicName);/*
* de:
* Prüfen ob ein passendes XML-Element gefunden
wurde; über 'null'-Wert an die aufrufende
* Methode
signalisieren wenn kein passendes XML-Element existiert.
* en:
* Verify if a fitting XML-element was found; signal
using 'null'-value if a fitting
* XML-element does not
exist. */ if
(elementJASParameter
== null)
return
null;/*
* de:
XML-Element mit dem JNDI-Namen auslesen.
* en: Get the
XML-Element with the JNDI-name. */ elementJNDIName
= elementJASParameter.getChild("mappedJNDIName");/*
* de:
* Prüfen ob ein <mappedJNDIName>-XML-Element
enthalten ist; über 'null'-Wert an die aufrufende
* Methode
signalisieren wenn kein passendes XML-Element existiert.
* en:
* Verify if a <mappedJNDIName>-XML-element is
within the structure; signal using 'null'-value
* if a
fitting XML-element does not exist. */ if
(elementJNDIName
== null)
return
null;/*
* de:
Wert (Text) des XML-Elements an die aufrufende Methode zurück
liefern.
* en: Return the value (text) of the
XML-element to the calling method. */
return
elementJNDIName.getTextTrim();
}/*
*
************************************************** */
/*
* de:
* METHODE um die Properties (Parameter, die für
die Verbindung zum JAS erforderlich sind)
* aus der
XML-Struktur auszulesen.
* Als Parameter wird der –
in der XML-Struktur festgelegte - symbolische Name der
Verbindung
* zum JAS übergeben.
* en:
* METHOD to get the Properties (parameter needed for
the connection to the JAS)
* out of the
XML-structure.
* The passed parameter is the symbolic
Name – defined within the XML-structure – for
the
* connection to the JAS. */ public
Properties
getJASContextProperties(String parmSymbolicName) {/*
* de:
* Methode, die das XML-Element mit allen Parametern
für die Verbindung zum JAS
* aus der XML-Struktur
ausliest, aufrufen.
* en:
* Call the
method that gets the XML-element containing all parameters for the
* connection to the JAS. */ Element
elementJASParameter = getJASParameter(parmSymbolicName);/*
* de:
* Prüfen ob ein passendes XML-Element gefunden
wurde; über 'null'-Wert an die aufrufende
* Methode
signalisieren wenn kein passendes XML-Element existiert.
* en:
* Verify if a fitting XML-element was found; signal
using 'null'-value if a fitting
* XML-element does not
exist. */ if
(elementJASParameter
== null)
return
null;/*
* de:
* Variable für ein Objekt der Klasse 'Properties'
erstellen. Darin werden die einzelnen
* Werte
'gesammelt'.
* en:
* Variable for for
one Object of the class 'Properties'.
* Singular values
are collected within there. */ Properties
propReturn = new
Properties();/*
* de:
* Merker ob mindestens ein Wert für die
Properties in der XML-Struktur vorhanden ist.
* en:
* Flag if at least one value for the Properties is
found within the XML-structure. */ boolean
bolAtLeastOnePropertyPresent
= false;/*
* de:
* Variable für ein XML-Element
<ConnectionProperty> mit Unterelementen für Schlüssel
und Wert.
* en:
* Variable for one
XML-Element <ConnectionProperty> with sub-elements for key and
value. */ Element
elementConnectionProperty;/*
* de:
* Universell genutzte Variable für ein
XML-Element (Schlüssel oder Wert einer Property).
* en:
* Universally use variable for one XML-Element (key or
value of a property). */ Element
elementProperty;/*
* de:
* Variable für den Schlüssel und den Wert
einer Property.
* en:
* Variable for the
key and the value of a property. */ String
strPropertyKey; String
strPropertyValue;/*
* de:
* Liste mit allen XML-Elementen <ConnectionProperty>
für die Verbindung zu einem JAS,
* Anzahl der
Elemente und Index.
* en:
* List with
all XML-Elements <ConnectionProperty> for the connection to a
JAS,
* Number of Elements and
Index. */ java.util.List
listConnectionProperty =
elementJASParameter.getChildren("ConnectionProperty"); int
intlistConnectionPropertySize
= listConnectionProperty.size(); int
intlistConnectionPropertyIndex;/*
* de:
* Verarbeiten jeder Kombination aus Schlüssel und
Wert für eine Property
* innerhalb einer
for-Schleife.
* en:
* List with all
XML-Elements <ConnectionProperty> for the connection to a
JAS,
* Number of Elements and Index. */ for
(intlistConnectionPropertyIndex
= 0;
intlistConnectionPropertyIndex
<
intlistConnectionPropertySize;
intlistConnectionPropertyIndex++)
{/*
* de:
* Initialisieren
der Werte für Schlüssel und Wert mit 'null'.
* Damit
kann später abgefragt werden ob ein gültiges Paar in der
XML-Struktur gefunden wurde.
* en:
* Initialise
the values for Key and Value with 'null'
* This allows
later to check if a valid pair was found within the
XML-structure. */ strPropertyKey
= null; strPropertyValue
= null;/*
* de: Herausholen
eines XML-Elements <ConnectionProperty> aus der
Liste.
* en: Get one XML-Elements
<ConnectionProperty> out of the
List. */ elementConnectionProperty
= (Element)
listConnectionProperty.get(intlistConnectionPropertyIndex);/*
* de: Prüfen,
dass das XML-Element nicht 'null' ist; nur dann weiter
bearbeiten.
* en: Verify that the XML-Element is
not 'null'; continue only in that case. */ if
(elementConnectionProperty
!=
null)
{/*
* de: Holen
des XML-Unter-Elements für den Schlüssel der
Property.
* en: Get the XML-sub-elementfor the key
of the property. */ elementProperty
=
elementConnectionProperty.getChild("PropertyKey");/*
* de: Prüfen,
dass das XML-Element nicht 'null' ist; nur dann kann der Wert
ausgelesen werden.
* en: Verify that the
XML-Element is not 'null'; only in that case the value can be
derived. */ if
(elementProperty
!=
null)
strPropertyKey = elementProperty.getText();/*
* de: Holen
des XML-Unter-Elements für den Wert der Property.
* en: Get
the XML-sub-elementfor the value of the
property. */ elementProperty
=
elementConnectionProperty.getChild("PropertyValue");/*
* de: Prüfen,
dass das XML-Element nicht 'null' ist; nur dann kann der Wert
ausgelesen werden.
* en: Verify that the
XML-Element is not 'null'; only in that case the value can be
derived. */ if
(elementProperty
!=
null)
strPropertyValue = elementProperty.getText();/*
* de:
* Prüfen,
dass die Werte für Schlüssel und Wert nicht 'null' sind;
* nur dann macht es Sinn, das Paar in die Gruppe der
Properties aufzunehmen.
* en:
* Verify
that the values for Key and Value ar not 'null';
* only
in that case ist makes sense to integrate that pair into the set of
properties. */ if
((strPropertyKey
!= null)
&& (strPropertyValue
!= null))
{
propReturn.put(strPropertyKey,
strPropertyValue);/*
* de: Setzen
des Markers, dass die Gruppe der Properties mindestens ein Paar
enthält.
* en: Set the flag, signalling that
the Set of Propertiex contains at least one
pair. */ bolAtLeastOnePropertyPresent
=
true; } } }/*
* ********************************************************************
* de:
* Es folgt der Algorithmus zum Verarbeiten der früher
verwendeten, fix definierten
* XML-Elemente für
Property-Schlüssel und -Werte. Diese wurde verwendet bevor
die
* frei definierbaren Werte für die
Property-Schlüssel eingeführt wurden.
* en:
* Following is the algorithm to process the static
defined XML-elements for property-keys
* and -values.
Those were used before the free definable keys were
introduced. *//*
* de:
* Der Algorithmus für den Property-Wert
'PROVIDER_URL' ist anschliessend im Detail beschrieben.
* Das
Auslesen der weiteren Property Werte ist ohne Kommentar.
* en:
* The following algorithm for the Property-value
'PROVIDER_URL' is described in detail
* The extracting
of following Property values is without a comment. *//*
* de:
XML-Element für 'PROVIDER_URL' extrahieren.
* en:
Extract the XML-element for 'PROVIDER_URL'. */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_APPLET");/*
* de:
Prüfen ob das angeforderte XML-Element enthalten ist.
* en:
Verify if the requested XML-element is contained. */ if
(elementProperty
!= null)
{/*
* de:
XML-Element mit der gesuchten 'Property' vorhanden; Wert
auslesen.
* en: XML-element with the searched
'Property' exists; extract value. */ strPropertyValue
= elementProperty.getText();/*
* de:
Prüfen ob ein Wert im XML-Element enthalten ist.
* en:
Verify if the XML-element contains a value. */ if
(strPropertyValue
!= null)
{/*
* de:
Zuerst im Merker festhalten dass mindestens ein Property-Wert
existiert.
* en: First, keep within the flag that al
least one Property-value
exists. */ bolAtLeastOnePropertyPresent
= true;/*
* de:
Wert mit passendem 'Schlüssel' in die 'Properties'
hinzufügen.
* en: Add value with fitting 'key'
into the
'Properties'. */ propReturn.put(InitialContext.APPLET
,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_AUTHORITATIVE"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.AUTHORITATIVE,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_BATCHSIZE"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.BATCHSIZE,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_DNS_URL"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.DNS_URL,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_INITIAL_CONTEXT_FACTORY"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
=
true; propReturn.put(InitialContext.INITIAL_CONTEXT_FACTORY,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_LANGUAGE"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.LANGUAGE,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_OBJECT_FACTORIES"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.OBJECT_FACTORIES,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_PROVIDER_URL"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.PROVIDER_URL,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_REFERRAL"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.REFERRAL,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_SECURITY_AUTHENTICATION"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
=
true; propReturn.put(InitialContext.SECURITY_AUTHENTICATION,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_SECURITY_CREDENTIALS"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.SECURITY_CREDENTIALS,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_SECURITY_PRINCIPAL"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.SECURITY_PRINCIPAL,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_SECURITY_PROTOCOL"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.SECURITY_PROTOCOL,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_STATE_FACTORIES"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.STATE_FACTORIES,
strPropertyValue); } }/* ---------------------- */ elementProperty
=
elementJASParameter.getChild("ConnectionProperty_URL_PKG_PREFIXES"); if
(elementProperty
!= null)
{ strPropertyValue
= elementProperty.getText(); if
(strPropertyValue
!= null)
{ bolAtLeastOnePropertyPresent
= true; propReturn.put(InitialContext.URL_PKG_PREFIXES,
strPropertyValue); } }/*
* de:
* Prüfen ob überhaupt ein Wert für die
Properties in der XML-Struktur vorhanden ist.
* Wenn
ein Wert vorhanden dann das Objekt mit den Properties zurück
liefern;
* sonst der aufrufenden Methode über den
'null'-Wert signalisieren, dass keine Werte festgelegt sind.
* en:
* Verify, that at least one value for the Properties
ist defined within the XML-structure.
* If a value is
present then return the object with the Properties;
* otherwise
signal via 'null'-value that no values are defined. */
if
(bolAtLeastOnePropertyPresent)
return
propReturn;
else
return null; }/*
*
************************************************** */
/*
* de:
* METHODE um einen eventuell vorhandenen Wert für die Mandanten-Identifikation aus der
* XML-Struktur
auszulesen. Ist keine Mandanten-Identifikation definiert wird der Wert '0'
* zurück geliefert.
* en:
* METHOD to get an optional value for the Client-ID out of the XML-structure.
* If a Client-ID ist not defined then the value '0' is returned.
*/ public int
getClientID() {/*
* de:
* Variable für das XML-Element mit dem Client-ID und die Zeichenkette mit dem Wert.
* en:
* Variables for the XML-element with the client-ID and String with the value. */ Element
elementClientID; String strClientID;/*
* de:
* XML-Element <ClientID> aus der Struktur lesen. Per Definition darf nur ein Element
* direkt unterhalb des 'root'-Elements vorhanden sein.
* en:
* Read the XML-element <ClientID> directly out of the structure. As per definition only
* one element may exist direct under the 'root'-element. */ elementClientID = XML_RootElement.getChild("ClientID");/*
* de:
* Wenn kein XML-Element <ClientID> (Mandanten-Identifikation) vorhanden ist, dann wird
* als Mandanten-ID der Wert '0' zurück geliefert.
* en:
* If the XML-element <ClientID> is not present then the value '0' is returned as client-ID. */ if (elementClientID == null) return 0;/*
* de:
* Wert (als Zeichenkette) aus dem XML-Element <ClientID> (Mandanten-Identifikation) auslesen.
* Wenn kein Wert vorhanden ist dann wird als Mandanten-ID der Wert '0' zurück geliefert.
* en:
* Get the value (as string) of the XML-element <ClientID>.
* If a value is not present then the value '0' is returned as Client-ID. */ strClientID = elementClientID.getTextTrim(); if (strClientID == null) return 0;/*
* de:
* Wert (als Zeichenkette) in eine Integer-Zahl umwandeln. Wenn die Zeichenkette keine ganze Zahl
* enthält, dann wird als Mandanten-ID der Wert '0' zurück geliefert.
* en:
* Convert the value (as string) into an Interger-number. If the string does not contain an
* integer-number, then the value '0' is returned as Client-ID. */ try { Integer intClientID = new Integer(strClientID); return intClientID.intValue(); } catch (Exception Exc) {return 0;} }
}
xxx
|
Dokument |
Inhalt |
|
Datei 'Connections.xml' mit Parametern für Datenbank und JAS |
Das
referenzierte Dokument beschreibt den Aufbau der Datei
'Connections.xml' und die Bedeutung der einzelnen
XML-Elemente. |