Source Code Cross Referenced for DatabasesParser.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » controller » xml » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Database JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.controller.xml 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /**
0002:         * Sequoia: Database clustering technology.
0003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
0004:         * Science And Control (INRIA).
0005:         * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
0006:         * Copyright (C) 2005-2006 Continuent, Inc.
0007:         * Contact: sequoia@continuent.org
0008:         * 
0009:         * Licensed under the Apache License, Version 2.0 (the "License");
0010:         * you may not use this file except in compliance with the License.
0011:         * You may obtain a copy of the License at
0012:         * 
0013:         * http://www.apache.org/licenses/LICENSE-2.0
0014:         * 
0015:         * Unless required by applicable law or agreed to in writing, software
0016:         * distributed under the License is distributed on an "AS IS" BASIS,
0017:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018:         * See the License for the specific language governing permissions and
0019:         * limitations under the License. 
0020:         *
0021:         * Initial developer(s): Emmanuel Cecchet.
0022:         * Contributor(s): Mathieu Peltier, Sara Bouchenakm Nicolas Modrzyk
0023:         */package org.continuent.sequoia.controller.xml;
0024:
0025:        import java.io.IOException;
0026:        import java.io.InputStream;
0027:        import java.io.StringReader;
0028:        import java.util.ArrayList;
0029:        import java.util.Hashtable;
0030:        import java.util.List;
0031:        import java.util.StringTokenizer;
0032:
0033:        import javax.management.ObjectName;
0034:
0035:        import org.continuent.sequoia.common.authentication.AuthenticationManager;
0036:        import org.continuent.sequoia.common.authentication.AuthenticationManagerException;
0037:        import org.continuent.sequoia.common.exceptions.BackupException;
0038:        import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
0039:        import org.continuent.sequoia.common.i18n.Translate;
0040:        import org.continuent.sequoia.common.jmx.JmxConstants;
0041:        import org.continuent.sequoia.common.log.Trace;
0042:        import org.continuent.sequoia.common.sql.filters.MacrosHandler;
0043:        import org.continuent.sequoia.common.sql.schema.DatabaseColumn;
0044:        import org.continuent.sequoia.common.sql.schema.DatabaseProcedure;
0045:        import org.continuent.sequoia.common.sql.schema.DatabaseProcedureParameter;
0046:        import org.continuent.sequoia.common.sql.schema.DatabaseProcedureSemantic;
0047:        import org.continuent.sequoia.common.sql.schema.DatabaseSchema;
0048:        import org.continuent.sequoia.common.sql.schema.DatabaseTable;
0049:        import org.continuent.sequoia.common.users.AdminUser;
0050:        import org.continuent.sequoia.common.users.DatabaseBackendUser;
0051:        import org.continuent.sequoia.common.users.VirtualDatabaseUser;
0052:        import org.continuent.sequoia.common.xml.DatabasesXmlTags;
0053:        import org.continuent.sequoia.common.xml.XmlValidator;
0054:        import org.continuent.sequoia.controller.backend.DatabaseBackend;
0055:        import org.continuent.sequoia.controller.backend.DatabaseBackendSchemaConstants;
0056:        import org.continuent.sequoia.controller.backend.rewriting.AbstractRewritingRule;
0057:        import org.continuent.sequoia.controller.backend.rewriting.PatternRewritingRule;
0058:        import org.continuent.sequoia.controller.backend.rewriting.ReplaceAllRewritingRule;
0059:        import org.continuent.sequoia.controller.backend.rewriting.SimpleRewritingRule;
0060:        import org.continuent.sequoia.controller.backup.BackupManager;
0061:        import org.continuent.sequoia.controller.backup.Backuper;
0062:        import org.continuent.sequoia.controller.cache.metadata.MetadataCache;
0063:        import org.continuent.sequoia.controller.cache.parsing.ParsingCache;
0064:        import org.continuent.sequoia.controller.cache.parsing.ParsingCacheControl;
0065:        import org.continuent.sequoia.controller.cache.result.AbstractResultCache;
0066:        import org.continuent.sequoia.controller.cache.result.CachingGranularities;
0067:        import org.continuent.sequoia.controller.cache.result.ResultCacheFactory;
0068:        import org.continuent.sequoia.controller.cache.result.ResultCacheRule;
0069:        import org.continuent.sequoia.controller.cache.result.rules.EagerCaching;
0070:        import org.continuent.sequoia.controller.connection.FailFastPoolConnectionManager;
0071:        import org.continuent.sequoia.controller.connection.RandomWaitPoolConnectionManager;
0072:        import org.continuent.sequoia.controller.connection.SimpleConnectionManager;
0073:        import org.continuent.sequoia.controller.connection.VariablePoolConnectionManager;
0074:        import org.continuent.sequoia.controller.core.Controller;
0075:        import org.continuent.sequoia.controller.core.ControllerConstants;
0076:        import org.continuent.sequoia.controller.jmx.MBeanServerManager;
0077:        import org.continuent.sequoia.controller.loadbalancer.AbstractLoadBalancer;
0078:        import org.continuent.sequoia.controller.loadbalancer.paralleldb.ParallelDB;
0079:        import org.continuent.sequoia.controller.loadbalancer.paralleldb.ParallelDB_LPRF;
0080:        import org.continuent.sequoia.controller.loadbalancer.paralleldb.ParallelDB_RR;
0081:        import org.continuent.sequoia.controller.loadbalancer.policies.WaitForCompletionPolicy;
0082:        import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTableAll;
0083:        import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTablePolicy;
0084:        import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTableRandom;
0085:        import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTableRoundRobin;
0086:        import org.continuent.sequoia.controller.loadbalancer.policies.createtable.CreateTableRule;
0087:        import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingAll;
0088:        import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingPolicy;
0089:        import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingRandom;
0090:        import org.continuent.sequoia.controller.loadbalancer.policies.errorchecking.ErrorCheckingRoundRobin;
0091:        import org.continuent.sequoia.controller.loadbalancer.raidb0.RAIDb0;
0092:        import org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1_LPRF;
0093:        import org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1_RR;
0094:        import org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1_WRR;
0095:        import org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1ec_RR;
0096:        import org.continuent.sequoia.controller.loadbalancer.raidb1.RAIDb1ec_WRR;
0097:        import org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2_LPRF;
0098:        import org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2_RR;
0099:        import org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2_WRR;
0100:        import org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2ec_RR;
0101:        import org.continuent.sequoia.controller.loadbalancer.raidb2.RAIDb2ec_WRR;
0102:        import org.continuent.sequoia.controller.loadbalancer.singledb.SingleDB;
0103:        import org.continuent.sequoia.controller.monitoring.SQLMonitoring;
0104:        import org.continuent.sequoia.controller.monitoring.SQLMonitoringRule;
0105:        import org.continuent.sequoia.controller.recoverylog.RecoveryLog;
0106:        import org.continuent.sequoia.controller.recoverylog.RecoveryLogControl;
0107:        import org.continuent.sequoia.controller.requestmanager.RAIDbLevels;
0108:        import org.continuent.sequoia.controller.requestmanager.RequestManager;
0109:        import org.continuent.sequoia.controller.requestmanager.distributed.RAIDb1DistributedRequestManager;
0110:        import org.continuent.sequoia.controller.requestmanager.distributed.RAIDb2DistributedRequestManager;
0111:        import org.continuent.sequoia.controller.scheduler.AbstractScheduler;
0112:        import org.continuent.sequoia.controller.scheduler.AbstractSchedulerControl;
0113:        import org.continuent.sequoia.controller.scheduler.raidb0.RAIDb0PassThroughLevelScheduler;
0114:        import org.continuent.sequoia.controller.scheduler.raidb0.RAIDb0PessimisticTransactionLevelScheduler;
0115:        import org.continuent.sequoia.controller.scheduler.raidb1.RAIDb1OptimisticQueryLevelScheduler;
0116:        import org.continuent.sequoia.controller.scheduler.raidb1.RAIDb1OptimisticTransactionLevelScheduler;
0117:        import org.continuent.sequoia.controller.scheduler.raidb1.RAIDb1PassThroughScheduler;
0118:        import org.continuent.sequoia.controller.scheduler.raidb1.RAIDb1PessimisticTransactionLevelScheduler;
0119:        import org.continuent.sequoia.controller.scheduler.raidb1.RAIDb1QueryLevelScheduler;
0120:        import org.continuent.sequoia.controller.scheduler.raidb2.RAIDb2PassThroughScheduler;
0121:        import org.continuent.sequoia.controller.scheduler.raidb2.RAIDb2PessimisticTransactionLevelScheduler;
0122:        import org.continuent.sequoia.controller.scheduler.raidb2.RAIDb2QueryLevelScheduler;
0123:        import org.continuent.sequoia.controller.scheduler.singledb.SingleDBPassThroughScheduler;
0124:        import org.continuent.sequoia.controller.scheduler.singledb.SingleDBPessimisticTransactionLevelScheduler;
0125:        import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
0126:        import org.continuent.sequoia.controller.virtualdatabase.VirtualDatabase;
0127:        import org.continuent.sequoia.controller.virtualdatabase.protocol.MessageTimeouts;
0128:        import org.xml.sax.Attributes;
0129:        import org.xml.sax.InputSource;
0130:        import org.xml.sax.SAXException;
0131:        import org.xml.sax.SAXParseException;
0132:        import org.xml.sax.XMLReader;
0133:        import org.xml.sax.helpers.DefaultHandler;
0134:        import org.xml.sax.helpers.XMLReaderFactory;
0135:
0136:        /**
0137:         * Parses an XML content conforming to sequoia.dtd and configure the given
0138:         * Sequoia Controller accordingly.
0139:         * 
0140:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
0141:         * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
0142:         * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
0143:         * @version 1.0
0144:         */
0145:        public class DatabasesParser extends DefaultHandler {
0146:
0147:            private static final WaitForCompletionPolicy DEFAULT_WAIT_FOR_ALL_COMPLETION = new WaitForCompletionPolicy(
0148:                    WaitForCompletionPolicy.FIRST, false, 30000);
0149:
0150:            /** XML parser. */
0151:            private XMLReader parser;
0152:
0153:            /** Logger instance. */
0154:            static Trace logger = Trace.getLogger(DatabasesParser.class
0155:                    .getName());
0156:            static Trace endUserLogger = Trace
0157:                    .getLogger("org.continuent.sequoia.enduser");
0158:
0159:            /** Sequoia controller to setup. */
0160:            private Controller controller;
0161:
0162:            /** dbToPrepare is used if only a specified database has to be loaded */
0163:            private Hashtable dbToPrepare = null;
0164:            /** setter for jumping from one VirtualDatabase definition to the next one */
0165:            private boolean skipDatabase = false;
0166:
0167:            /**
0168:             * Parsing of Users are only defined in Admin at the moment, but may be
0169:             * defined somewhere else in the future.
0170:             */
0171:            private boolean parsingAdminUsers = false;
0172:
0173:            private VirtualDatabase currentVirtualDatabase = null;
0174:            private BackupManager currentBackupManager = null;
0175:            private DatabaseBackend currentBackend;
0176:            private DatabaseBackendUser currentDatabaseBackendUser;
0177:            private AuthenticationManager currentAuthenticationManager;
0178:            private AbstractScheduler currentRequestScheduler;
0179:            private AbstractResultCache currentResultCache;
0180:            private MetadataCache currentMetadataCache = null;
0181:            private ParsingCache currentParsingCache = null;
0182:            private ResultCacheRule currentResultCacheRule;
0183:            private MacrosHandler currentMacroHandler;
0184:            private AbstractLoadBalancer currentLoadBalancer;
0185:            private RecoveryLog currentRecoveryLog;
0186:            private VirtualDatabaseUser currentVirtualUser;
0187:            private DatabaseSchema currentDatabaseSchema;
0188:            private DatabaseTable currentTable;
0189:            private DatabaseProcedure currentProcedure;
0190:            private int numberOfColumns;
0191:
0192:            private String connectionManagerVLogin;
0193:            private WaitForCompletionPolicy currentWaitForCompletionPolicy = DEFAULT_WAIT_FOR_ALL_COMPLETION;
0194:
0195:            private long beginTimeout;
0196:            private long commitTimeout;
0197:            private long rollbackTimeout;
0198:            private int requestTimeout;
0199:
0200:            private boolean caseSensitiveParsing;
0201:
0202:            private CreateTablePolicy currentCreateTablePolicy;
0203:            private CreateTableRule currentCreateTableRule;
0204:            private ArrayList backendNameList;
0205:            private ErrorCheckingPolicy currentErrorCheckingPolicy;
0206:
0207:            private int currentNbOfConcurrentReads;
0208:
0209:            private int defaultTransactionIsolation;
0210:
0211:            /**
0212:             * We are setting the default connection manager rather than a 'normal'
0213:             * connection manager.
0214:             */
0215:            private boolean settingDefaultConnectionManager;
0216:
0217:            // VDB load options
0218:            private boolean initialize;
0219:            private boolean forceload;
0220:
0221:            /**
0222:             * Creates a new <code>DatabasesParser</code> instance. This method
0223:             * Instanciates also a new <code>DatabasesParser</code>.
0224:             * 
0225:             * @param controller <code>Controller</code> to load the Virtual Database
0226:             *          into
0227:             * @throws SAXException if an error occurs
0228:             */
0229:            public DatabasesParser(Controller controller) throws SAXException {
0230:                prepareHandler(controller);
0231:            }
0232:
0233:            /**
0234:             * Creates a new <code>DatabasesParser</code> instance. This method
0235:             * Instanciates also a new <code>DatabasesParser</code>. This instance will
0236:             * look only for the specified database.
0237:             * 
0238:             * @param controller <code>Controller</code> to load the Virtual Database
0239:             *          into
0240:             * @param virtualName the specified <code>VirtualDatabase</code> to load.
0241:             * @param autoLoad autoenable switch
0242:             * @param checkPoint checkpoint information
0243:             * @throws SAXException if an error occurs
0244:             */
0245:            public DatabasesParser(Controller controller, String virtualName,
0246:                    int autoLoad, String checkPoint) throws SAXException {
0247:                prepareHandler(controller);
0248:                initialize = autoLoad == ControllerConstants.AUTO_ENABLE_INIT;
0249:                forceload = autoLoad == ControllerConstants.AUTO_ENABLE_FORCE_LOAD;
0250:
0251:                // Test if a name has been specified. Otherwise skip.
0252:                if (virtualName != null)
0253:                    prepareDB(virtualName, autoLoad, checkPoint);
0254:            }
0255:
0256:            private void prepareHandler(Controller controller)
0257:                    throws SAXException {
0258:                // Instantiate a new parser
0259:                parser = XMLReaderFactory.createXMLReader();
0260:
0261:                this .controller = controller;
0262:
0263:                // Activate validation
0264:                parser.setFeature("http://xml.org/sax/features/validation",
0265:                        true);
0266:
0267:                // Install error handler
0268:                parser.setErrorHandler(this );
0269:
0270:                // Install document handler
0271:                parser.setContentHandler(this );
0272:
0273:                // Install local entity resolver
0274:                parser.setEntityResolver(this );
0275:            }
0276:
0277:            /**
0278:             * Parses an XML content according to Sequoia DTD.
0279:             * 
0280:             * @param xml a <code>String</code> containing the XML content to parse
0281:             * @exception SAXException if an error occurs
0282:             * @exception IOException if an error occurs
0283:             */
0284:            public void readXML(String xml) throws IOException, SAXException {
0285:                InputSource input = new InputSource(new StringReader(xml));
0286:                parser.parse(input);
0287:            }
0288:
0289:            /**
0290:             * Validate an XML content according to Sequoia DTD.
0291:             * 
0292:             * @param xml content
0293:             * @param validateBeforeParsing if true validate the document before the
0294:             *          parsing
0295:             * @throws IOException if an error occurs
0296:             * @throws SAXException if an error occurs
0297:             */
0298:            public void readXML(String xml, boolean validateBeforeParsing)
0299:                    throws IOException, SAXException {
0300:                if (validateBeforeParsing) {
0301:                    XmlValidator validator = new XmlValidator(
0302:                            ControllerConstants.SEQUOIA_DTD_FILE, xml);
0303:                    if (logger.isDebugEnabled()) {
0304:                        if (validator.isDtdValid())
0305:                            logger.debug(Translate
0306:                                    .get("virtualdatabase.xml.dtd.validated"));
0307:                        if (validator.isXmlValid())
0308:                            logger
0309:                                    .debug(Translate
0310:                                            .get("virtualdatabase.xml.document.validated"));
0311:                    }
0312:
0313:                    if (validator.getWarnings().size() > 0) {
0314:                        ArrayList warnings = validator.getWarnings();
0315:                        for (int i = 0; i < warnings.size(); i++)
0316:                            logger.warn(Translate.get(
0317:                                    "virtualdatabase.xml.parsing.warning",
0318:                                    warnings.get(i)));
0319:                    }
0320:
0321:                    if (!validator.isDtdValid())
0322:                        logger.error(Translate
0323:                                .get("virtualdatabase.xml.dtd.not.validated"));
0324:                    if (!validator.isXmlValid())
0325:                        logger
0326:                                .error(Translate
0327:                                        .get("virtualdatabase.xml.document.not.validated"));
0328:
0329:                    ArrayList errors = validator.getExceptions();
0330:                    for (int i = 0; i < errors.size(); i++)
0331:                        logger.error(((Exception) errors.get(i)).getMessage());
0332:
0333:                    if (!validator.isValid())
0334:                        throw new SAXException(Translate
0335:                                .get("virtualdatabase.xml.document.not.valid"));
0336:                }
0337:                this .readXML(xml);
0338:            }
0339:
0340:            /**
0341:             * Handles notification of a non-recoverable parser error.
0342:             * 
0343:             * @param e the warning information encoded as an exception.
0344:             * @exception SAXException any SAX exception, possibly wrapping another
0345:             *              exception.
0346:             */
0347:            public void fatalError(SAXParseException e) throws SAXException {
0348:                String msg = Translate.get("virtualdatabase.xml.parsing.fatal",
0349:                        new String[] { e.getPublicId(),
0350:                                String.valueOf(e.getLineNumber()),
0351:                                String.valueOf(e.getColumnNumber()),
0352:                                e.getMessage() });
0353:                logger.error(msg);
0354:                endUserLogger.fatal(msg);
0355:                throw e;
0356:            }
0357:
0358:            /**
0359:             * Handles notification of a recoverable parser error.
0360:             * 
0361:             * @param e the warning information encoded as an exception.
0362:             * @exception SAXException any SAX exception, possibly wrapping another
0363:             *              exception
0364:             */
0365:            public void error(SAXParseException e) throws SAXException {
0366:                logger.error(Translate.get("virtualdatabase.xml.parsing.error",
0367:                        new String[] { e.getPublicId(),
0368:                                String.valueOf(e.getLineNumber()),
0369:                                String.valueOf(e.getColumnNumber()),
0370:                                e.getMessage() }));
0371:                throw e;
0372:            }
0373:
0374:            /**
0375:             * Allows to parse the document with a local copy of the DTD whatever the
0376:             * original <code>DOCTYPE</code> found. Warning, this method is called only
0377:             * if the XML document contains a <code>DOCTYPE</code>.
0378:             * 
0379:             * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String,
0380:             *      java.lang.String)
0381:             */
0382:            public InputSource resolveEntity(String publicId, String systemId)
0383:                    throws SAXException {
0384:                InputStream stream = DatabasesXmlTags.class
0385:                        .getResourceAsStream("/"
0386:                                + ControllerConstants.SEQUOIA_DTD_FILE);
0387:                if (stream == null)
0388:                    throw new SAXException("Cannot find Sequoia DTD file '"
0389:                            + ControllerConstants.SEQUOIA_DTD_FILE
0390:                            + "' in classpath");
0391:
0392:                return new InputSource(stream);
0393:            }
0394:
0395:            /**
0396:             * If this method is called. Only the specified DB of the Xml file will be
0397:             * loaded.
0398:             * 
0399:             * @param virtualName <code>VirtualDatabase</code> name
0400:             * @param autoLoad autoenable switch
0401:             * @param checkPoint checkpoint for recovery
0402:             */
0403:            public void prepareDB(String virtualName, int autoLoad,
0404:                    String checkPoint) {
0405:                dbToPrepare = new Hashtable(3);
0406:                dbToPrepare.put("virtualName", virtualName);
0407:                dbToPrepare.put("autoEnable", String.valueOf(autoLoad));
0408:                dbToPrepare.put("checkPoint", checkPoint);
0409:            }
0410:
0411:            /**
0412:             * Initializes parsing of a document.
0413:             * 
0414:             * @exception SAXException unspecialized error
0415:             */
0416:            public void startDocument() throws SAXException {
0417:                logger.info(Translate.get("virtualdatabase.xml.start"));
0418:            }
0419:
0420:            /**
0421:             * Finalizes parsing of a document.
0422:             * 
0423:             * @exception SAXException unspecialized error
0424:             */
0425:            public void endDocument() throws SAXException {
0426:                logger.info(Translate.get("virtualdatabase.xml.done"));
0427:            }
0428:
0429:            /**
0430:             * Analyzes an element first line.
0431:             * 
0432:             * @param uri name space URI
0433:             * @param localName local name
0434:             * @param name element raw name
0435:             * @param atts element attributes
0436:             * @exception SAXException if an error occurs
0437:             */
0438:            public void startElement(String uri, String localName, String name,
0439:                    Attributes atts) throws SAXException {
0440:                logger.debug(Translate.get("virtualdatabase.xml.parsing.start",
0441:                        name));
0442:
0443:                // Virtual database
0444:                if (name.equals(DatabasesXmlTags.ELT_VirtualDatabase)) {
0445:                    if (dbToPrepare == null) {
0446:                        // Prepare all databases
0447:                        newVirtualDatabase(atts);
0448:                    } else {
0449:                        // Only prepare one database
0450:                        String virtualName = atts
0451:                                .getValue(DatabasesXmlTags.ATT_name);
0452:                        if (virtualName.equalsIgnoreCase((String) dbToPrepare
0453:                                .get("virtualName"))) {
0454:                            // This is the database that we want to prepare
0455:                            skipDatabase = false;
0456:                            newVirtualDatabase(atts);
0457:                        } else {
0458:                            // Skip to next one
0459:                            skipDatabase = true;
0460:                        }
0461:                    }
0462:                }
0463:                // Skip to next definition of a virtualDatabase ?
0464:                if (skipDatabase)
0465:                    return;
0466:
0467:                // Distribution
0468:                else if (name.equals(DatabasesXmlTags.ELT_Distribution))
0469:                    newDistribution(atts);
0470:                else if (name.equals(DatabasesXmlTags.ELT_MessageTimeouts))
0471:                    newMessageTimeouts(atts);
0472:
0473:                // Monitoring
0474:                else if (name.equals(DatabasesXmlTags.ELT_SQLMonitoring))
0475:                    newSQLMonitoring(atts);
0476:                else if (name.equals(DatabasesXmlTags.ELT_SQLMonitoringRule))
0477:                    newSQLMonitoringRule(atts);
0478:
0479:                // Backup
0480:                else if (name.equals(DatabasesXmlTags.ELT_Backup))
0481:                    newBackupManager();
0482:                else if (name.equals(DatabasesXmlTags.ELT_Backuper))
0483:                    newBackuper(atts);
0484:
0485:                // Database backend
0486:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseBackend))
0487:                    newDatabaseBackend(atts);
0488:                else if (name.equals(DatabasesXmlTags.ELT_RewritingRule))
0489:                    newRewritingRule(atts);
0490:
0491:                // Authentication manager
0492:                else if (name
0493:                        .equals(DatabasesXmlTags.ELT_AuthenticationManager))
0494:                    newAuthenticationManager(atts);
0495:                else if (name.equals(DatabasesXmlTags.ELT_Admin))
0496:                    parsingAdminUsers = true;
0497:                else if (name.equals(DatabasesXmlTags.ELT_User)
0498:                        && parsingAdminUsers)
0499:                    newAdminUser(atts);
0500:                else if (name.equals(DatabasesXmlTags.ELT_VirtualLogin))
0501:                    newVirtualLogin(atts);
0502:
0503:                // Request manager
0504:                else if (name.equals(DatabasesXmlTags.ELT_RequestManager))
0505:                    newRequestManager(atts);
0506:
0507:                // Macro Handler
0508:                else if (name.equals(DatabasesXmlTags.ELT_MacroHandling))
0509:                    newMacroHandler(atts);
0510:
0511:                // Request schedulers
0512:                else if (name.equals(DatabasesXmlTags.ELT_SingleDBScheduler))
0513:                    newSingleDBScheduler(atts);
0514:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb0Scheduler))
0515:                    newRAIDb0Scheduler(atts);
0516:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb1Scheduler))
0517:                    newRAIDb1Scheduler(atts);
0518:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb2Scheduler))
0519:                    newRAIDb2Scheduler(atts);
0520:
0521:                // Request caches
0522:                else if (name.equals(DatabasesXmlTags.ELT_MetadataCache))
0523:                    newMetadataCache(atts);
0524:                else if (name.equals(DatabasesXmlTags.ELT_ParsingCache))
0525:                    newParsingCache(atts);
0526:                else if (name.equals(DatabasesXmlTags.ELT_ResultCache))
0527:                    newResultCache(atts);
0528:                else if (name
0529:                        .equals(DatabasesXmlTags.ELT_DefaultResultCacheRule))
0530:                    newDefaultResultCacheRule(atts);
0531:                else if (name.equals(DatabasesXmlTags.ELT_ResultCacheRule))
0532:                    newResultCacheRule(atts);
0533:                else if (name.equals(DatabasesXmlTags.ELT_NoCaching))
0534:                    currentResultCacheRule.setCacheBehavior(ResultCacheFactory
0535:                            .getCacheBehaviorInstance(
0536:                                    DatabasesXmlTags.ELT_NoCaching, null));
0537:                else if (name.equals(DatabasesXmlTags.ELT_EagerCaching))
0538:                    newEagerCaching(atts);
0539:                else if (name.equals(DatabasesXmlTags.ELT_RelaxedCaching))
0540:                    newRelaxedCaching(atts);
0541:
0542:                // Request load balancers
0543:                else if (name.equals(DatabasesXmlTags.ELT_LoadBalancer))
0544:                    newLoadBalancer(atts);
0545:                else if (name.equals(DatabasesXmlTags.ELT_SingleDB))
0546:                    newSingleDBRequestLoadBalancer();
0547:                else if (name
0548:                        .equals(DatabasesXmlTags.ELT_ParallelDB_RoundRobin))
0549:                    newParallelDBRoundRobinLoadBalancer();
0550:                else if (name
0551:                        .equals(DatabasesXmlTags.ELT_ParallelDB_LeastPendingRequestsFirst))
0552:                    newParallelDBLeastPendingRequestsFirst();
0553:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_0))
0554:                    newRAIDb0LoadBalancer();
0555:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_1))
0556:                    newRAIDb1LoadBalancer();
0557:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_1_RoundRobin))
0558:                    newRAIDb1RoundRobinLoadBalancer();
0559:                else if (name
0560:                        .equals(DatabasesXmlTags.ELT_RAIDb_1_WeightedRoundRobin))
0561:                    newRAIDb1WeightedRoundRobinLoadBalancer();
0562:                else if (name
0563:                        .equals(DatabasesXmlTags.ELT_RAIDb_1_LeastPendingRequestsFirst))
0564:                    newRAIDb1LeastPendingRequestsFirst();
0565:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_1ec))
0566:                    newRAIDb1ecLoadBalancer(atts);
0567:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_1ec_RoundRobin))
0568:                    newRAIDb1ecRoundRobinLoadBalancer();
0569:                else if (name
0570:                        .equals(DatabasesXmlTags.ELT_RAIDb_1ec_WeightedRoundRobin))
0571:                    newRAIDb1ecWeightedRoundRobinLoadBalancer();
0572:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_2))
0573:                    newRAIDb2LoadBalancer();
0574:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_2_RoundRobin))
0575:                    newRAIDb2RoundRobinLoadBalancer();
0576:                else if (name
0577:                        .equals(DatabasesXmlTags.ELT_RAIDb_2_WeightedRoundRobin))
0578:                    newRAIDb2WeightedRoundRobinLoadBalancer();
0579:                else if (name
0580:                        .equals(DatabasesXmlTags.ELT_RAIDb_2_LeastPendingRequestsFirst))
0581:                    newRAIDb2LeastPendingRequestsFirst();
0582:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_2ec))
0583:                    newRAIDb2ecLoadBalancer();
0584:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_2ec_RoundRobin))
0585:                    newRAIDb2ecRoundRobinLoadBalancer();
0586:                else if (name
0587:                        .equals(DatabasesXmlTags.ELT_RAIDb_2ec_WeightedRoundRobin))
0588:                    newRAIDb2ecWeightedRoundRobinLoadBalancer();
0589:
0590:                // Policies
0591:                else if (name.equals(DatabasesXmlTags.ELT_WaitForCompletion))
0592:                    newWaitForCompletion(atts);
0593:                else if (name.equals(DatabasesXmlTags.ELT_ErrorChecking))
0594:                    newErrorChecking(atts);
0595:                else if (name.equals(DatabasesXmlTags.ELT_CreateTable))
0596:                    newCreateTable(atts);
0597:                else if (name.equals(DatabasesXmlTags.ELT_BackendName))
0598:                    newBackendName(atts);
0599:                else if (name.equals(DatabasesXmlTags.ELT_BackendWeight))
0600:                    newBackendWeight(atts);
0601:
0602:                // Recovery log
0603:                else if (name.equals(DatabasesXmlTags.ELT_RecoveryLog))
0604:                    newRecoveryLog(atts);
0605:                else if (name.equals(DatabasesXmlTags.ELT_RecoveryLogTable))
0606:                    newRecoveryLogTable(atts);
0607:                else if (name.equals(DatabasesXmlTags.ELT_CheckpointTable))
0608:                    newRecoveryCheckpointTable(atts);
0609:                else if (name.equals(DatabasesXmlTags.ELT_BackendTable))
0610:                    newRecoveryBackendTable(atts);
0611:                else if (name.equals(DatabasesXmlTags.ELT_DumpTable))
0612:                    newRecoveryDumpTable(atts);
0613:
0614:                // Connection managers
0615:                else if (name.equals(DatabasesXmlTags.ELT_ConnectionManager))
0616:                    newConnectionManager(atts);
0617:                else if (name
0618:                        .equals(DatabasesXmlTags.ELT_DefaultConnectionManager))
0619:                    newDefaultConnectionManager();
0620:                else if (name
0621:                        .equals(DatabasesXmlTags.ELT_SimpleConnectionManager))
0622:                    newSimpleConnectionManager();
0623:                else if (name
0624:                        .equals(DatabasesXmlTags.ELT_FailFastPoolConnectionManager))
0625:                    newFailFastPoolConnectionManager(atts);
0626:                else if (name
0627:                        .equals(DatabasesXmlTags.ELT_RandomWaitPoolConnectionManager))
0628:                    newRandomWaitPoolConnectionManager(atts);
0629:                else if (name
0630:                        .equals(DatabasesXmlTags.ELT_VariablePoolConnectionManager))
0631:                    newVariablePoolConnectionManager(atts);
0632:
0633:                // Database schema
0634:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseSchema))
0635:                    newDatabaseSchema(atts);
0636:                else if (name
0637:                        .equals(DatabasesXmlTags.ELT_DefaultStoredProcedureSemantic))
0638:                    newDefaultStoredProcedureSemantic(atts);
0639:                else if (name
0640:                        .equals(DatabasesXmlTags.ELT_StoredProcedureSemantic))
0641:                    newStoredProcedureSemantic(atts);
0642:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseStaticSchema)) {
0643:                    if (currentBackend.getDynamicPrecision() != DatabaseBackendSchemaConstants.DynamicPrecisionStatic) {
0644:                        String msg = Translate
0645:                                .get(
0646:                                        "virtualdatabase.xml.schema.static.incompatible.dynamic",
0647:                                        currentBackend.getName());
0648:                        logger.error(msg);
0649:                        throw new SAXException(msg);
0650:                    }
0651:                    currentDatabaseSchema = new DatabaseSchema(
0652:                            currentVirtualDatabase.getVirtualDatabaseName());
0653:                }
0654:
0655:                // Database table (inside a DatabaseSchema)
0656:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseTable))
0657:                    newDatabaseTable(atts);
0658:
0659:                // Table column (inside a DatabaseSchema/DatabaseTable)
0660:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseColumn))
0661:                    newDatabaseColumn(atts);
0662:
0663:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseProcedure))
0664:                    newDatabaseProcedure(atts);
0665:                else if (name
0666:                        .equals(DatabasesXmlTags.ELT_DatabaseProcedureColumn))
0667:                    newDatabaseProcedureColumn(atts);
0668:            }
0669:
0670:            /**
0671:             * DatabasesParser for end of element.
0672:             * 
0673:             * @param uri name space URI
0674:             * @param localName local name
0675:             * @param name element raw name
0676:             * @exception SAXException if an error occurs
0677:             */
0678:            public void endElement(String uri, String localName, String name)
0679:                    throws SAXException {
0680:                logger.debug(Translate.get("virtualdatabase.xml.parsing.end",
0681:                        name));
0682:                // Test if skip is needed
0683:                if (skipDatabase)
0684:                    return;
0685:
0686:                // Virtual database
0687:                if (name.equals(DatabasesXmlTags.ELT_VirtualDatabase)) {
0688:                    if (logger.isDebugEnabled())
0689:                        logger
0690:                                .debug(Translate
0691:                                        .get("virtualdatabase.xml.add.virtualdatabase"));
0692:
0693:                    if (currentVirtualDatabase != null) {
0694:                        try {
0695:                            RecoveryLog recoveryLog = currentVirtualDatabase
0696:                                    .getRequestManager().getRecoveryLog();
0697:                            if (initialize) {
0698:                                recoveryLog.resetRecoveryLog(true);
0699:                                recoveryLog.setLastManDown();
0700:                            }
0701:                            if (forceload) {
0702:                                recoveryLog.setLastManDown();
0703:                            }
0704:                            if (currentVirtualDatabase instanceof  DistributedVirtualDatabase)
0705:                                ((DistributedVirtualDatabase) currentVirtualDatabase)
0706:                                        .joinGroup(true);
0707:                            if (dbToPrepare == null) { // Just add the virtual database without auto-enabling backends
0708:                                controller
0709:                                        .addVirtualDatabase(currentVirtualDatabase);
0710:                            } else {
0711:                                int autoLoad = Integer
0712:                                        .parseInt((String) dbToPrepare
0713:                                                .get("autoEnable"));
0714:                                String checkPoint = (String) dbToPrepare
0715:                                        .get("checkPoint");
0716:                                // checkPoint is store as "" in Hashtable
0717:                                // but methods to enable backend requires checkPoint to be null
0718:                                // if no recovery from checkpoint
0719:                                checkPoint = checkPoint.equalsIgnoreCase("") ? null
0720:                                        : checkPoint;
0721:                                controller.addVirtualDatabase(
0722:                                        currentVirtualDatabase, autoLoad,
0723:                                        checkPoint);
0724:                            }
0725:                        } catch (Exception e) {
0726:                            unregisterRelatedMBeans(currentVirtualDatabase);
0727:
0728:                            String msg = Translate.get(
0729:                                    "controller.add.virtualdatabase.failed",
0730:                                    new String[] {
0731:                                            currentVirtualDatabase
0732:                                                    .getVirtualDatabaseName(),
0733:                                            e.getMessage() });
0734:                            if (logger.isErrorEnabled()) {
0735:                                logger.error(msg, e);
0736:                            }
0737:                            throw new SAXException(msg);
0738:                        }
0739:                    }
0740:                    currentVirtualDatabase = null;
0741:                }
0742:
0743:                // Request manager
0744:                else if (name.equals(DatabasesXmlTags.ELT_RequestManager)) {
0745:                    if (logger.isDebugEnabled())
0746:                        logger.debug(Translate
0747:                                .get("virtualdatabase.xml.requestmanager.set"));
0748:
0749:                    if (currentVirtualDatabase != null) {
0750:                        RequestManager requestManager = null;
0751:
0752:                        // We consider that SingleDB and ParallelDB balancers don't need macros
0753:                        // handler
0754:                        if (currentLoadBalancer == null)
0755:                            throw new SAXException(
0756:                                    "virtualdatabase.xml.loadbalancer.not.set");
0757:                        if (!(currentLoadBalancer instanceof  SingleDB || currentLoadBalancer instanceof  ParallelDB)) {
0758:                            // If no macros handling has been specified, create a default one
0759:                            // based one the dtd default values
0760:                            if (currentMacroHandler == null)
0761:                                currentMacroHandler = new MacrosHandler(
0762:                                        MacrosHandler.RAND_FLOAT, 1000,
0763:                                        MacrosHandler.DATE_TIMESTAMP,
0764:                                        MacrosHandler.DATE_DATE,
0765:                                        MacrosHandler.DATE_TIME,
0766:                                        MacrosHandler.DATE_TIMESTAMP,
0767:                                        MacrosHandler.DATE_TIMESTAMP);
0768:                            currentLoadBalancer
0769:                                    .setMacroHandler(currentMacroHandler);
0770:                        }
0771:
0772:                        try {
0773:                            if (currentVirtualDatabase.isDistributed()) {
0774:                                switch (currentLoadBalancer.getRAIDbLevel()) {
0775:                                case RAIDbLevels.SingleDB:
0776:                                    String smsg = Translate
0777:                                            .get(
0778:                                                    "virtualdatabase.xml.no.single.distributed.requestmanager",
0779:                                                    currentLoadBalancer
0780:                                                            .getRAIDbLevel());
0781:                                    logger.error(smsg);
0782:                                    throw new SAXException(smsg);
0783:                                case RAIDbLevels.RAIDb1:
0784:                                    requestManager = new RAIDb1DistributedRequestManager(
0785:                                            (DistributedVirtualDatabase) currentVirtualDatabase,
0786:                                            currentRequestScheduler,
0787:                                            currentResultCache,
0788:                                            currentLoadBalancer,
0789:                                            currentRecoveryLog, beginTimeout,
0790:                                            commitTimeout, rollbackTimeout);
0791:                                    break;
0792:                                case RAIDbLevels.RAIDb2:
0793:                                    requestManager = new RAIDb2DistributedRequestManager(
0794:                                            (DistributedVirtualDatabase) currentVirtualDatabase,
0795:                                            currentRequestScheduler,
0796:                                            currentResultCache,
0797:                                            currentLoadBalancer,
0798:                                            currentRecoveryLog, beginTimeout,
0799:                                            commitTimeout, rollbackTimeout);
0800:                                    break;
0801:                                default:
0802:                                    String msg = Translate
0803:                                            .get(
0804:                                                    "virtualdatabase.xml.no.distributed.requestmanager",
0805:                                                    currentLoadBalancer
0806:                                                            .getRAIDbLevel());
0807:                                    logger.error(msg);
0808:                                    throw new SAXException(msg);
0809:                                }
0810:                            } else
0811:                                requestManager = new RequestManager(
0812:                                        currentVirtualDatabase,
0813:                                        currentRequestScheduler,
0814:                                        currentResultCache,
0815:                                        currentLoadBalancer,
0816:                                        currentRecoveryLog, beginTimeout,
0817:                                        commitTimeout, rollbackTimeout);
0818:
0819:                            if (requestManager != null) {
0820:                                if (currentParsingCache != null)
0821:                                    requestManager
0822:                                            .setParsingCache(currentParsingCache);
0823:                                if (currentMetadataCache != null)
0824:                                    requestManager
0825:                                            .setMetadataCache(currentMetadataCache);
0826:                                requestManager
0827:                                        .setCaseSensitiveParsing(caseSensitiveParsing);
0828:                            }
0829:
0830:                            currentVirtualDatabase
0831:                                    .setRequestManager(requestManager);
0832:                            if (currentBackupManager == null)
0833:                                currentBackupManager = new BackupManager();
0834:                            requestManager
0835:                                    .setBackupManager(currentBackupManager);
0836:                        } catch (Exception e) {
0837:                            String msg = Translate
0838:                                    .get("virtualdatabase.xml.requestmanager.creation.failed");
0839:                            logger.error(msg, e);
0840:                            throw new SAXException(msg, e);
0841:                        }
0842:                    }
0843:                    if (currentRequestScheduler != null) {
0844:                        try {
0845:                            MBeanServerManager
0846:                                    .registerMBean(
0847:                                            new AbstractSchedulerControl(
0848:                                                    currentRequestScheduler),
0849:                                            JmxConstants
0850:                                                    .getAbstractSchedulerObjectName(currentVirtualDatabase
0851:                                                            .getVirtualDatabaseName()));
0852:                        } catch (Exception e) {
0853:                            if (logger.isWarnEnabled()) {
0854:                                logger
0855:                                        .warn(
0856:                                                Translate
0857:                                                        .get(
0858:                                                                "virtualdatabase.xml.scheduler.jmx.failed", currentVirtualDatabase.getVirtualDatabaseName()), e); //$NON-NLS-1$
0859:                            }
0860:                        }
0861:                        if (currentParsingCache != null) {
0862:                            try {
0863:                                MBeanServerManager
0864:                                        .registerMBean(
0865:                                                new ParsingCacheControl(
0866:                                                        currentParsingCache),
0867:                                                JmxConstants
0868:                                                        .getParsingCacheObjectName(currentVirtualDatabase
0869:                                                                .getVirtualDatabaseName()));
0870:                            } catch (Exception e) {
0871:                                if (logger.isWarnEnabled()) {
0872:                                    logger
0873:                                            .warn(
0874:                                                    Translate
0875:                                                            .get(
0876:                                                                    "virtualdatabase.xml.parsing.cache.jmx.failed", currentVirtualDatabase.getVirtualDatabaseName()), e); //$NON-NLS-1$
0877:                                }
0878:                            }
0879:                        }
0880:                    }
0881:                }
0882:
0883:                // Database backend
0884:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseBackend)) {
0885:                    if (currentBackend != null) {
0886:                        try {
0887:                            currentVirtualDatabase.addBackend(currentBackend,
0888:                                    false);
0889:                        } catch (Exception e) {
0890:                            String msg = Translate
0891:                                    .get("virtualdatabase.xml.backend.add.failed");
0892:                            logger.error(msg, e);
0893:                            throw new SAXException(msg, e);
0894:                        }
0895:                    }
0896:                    currentBackend = null;
0897:                }
0898:
0899:                // Authentication manager
0900:                else if (name
0901:                        .equals(DatabasesXmlTags.ELT_AuthenticationManager)) {
0902:                    if (currentVirtualDatabase != null) {
0903:                        currentVirtualDatabase
0904:                                .setAuthenticationManager(currentAuthenticationManager);
0905:                    }
0906:                }
0907:
0908:                // Request cache
0909:                else if (name.equals(DatabasesXmlTags.ELT_RequestCache)) {
0910:                    if (currentResultCache != null) { // Set default result cache rule if missing
0911:                        if (currentResultCache.getDefaultRule() == null) {
0912:                            ResultCacheRule defaultRule = null;
0913:                            defaultRule = new ResultCacheRule("", false, false,
0914:                                    1000);
0915:                            defaultRule.setCacheBehavior(new EagerCaching(0));
0916:                            currentResultCache.setDefaultRule(defaultRule);
0917:                        }
0918:                    }
0919:                } else if (name
0920:                        .equals(DatabasesXmlTags.ELT_DefaultResultCacheRule)) {
0921:                    currentResultCache.setDefaultRule(currentResultCacheRule);
0922:                }
0923:
0924:                // Database schema
0925:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseStaticSchema)) {
0926:                    if (currentDatabaseSchema != null) {
0927:                        if (currentBackend != null) {
0928:                            try {
0929:                                currentBackend.setDatabaseSchema(
0930:                                        currentDatabaseSchema, true);
0931:                            } catch (Exception e) {
0932:                                logger
0933:                                        .error(
0934:                                                Translate
0935:                                                        .get("virtualdatabase.xml.backend.set.schema.failed"),
0936:                                                e);
0937:                            }
0938:                        } else {
0939:                            try {
0940:                                currentVirtualDatabase
0941:                                        .setStaticDatabaseSchema(currentDatabaseSchema);
0942:                            } catch (Exception e) {
0943:                                logger
0944:                                        .error(
0945:                                                Translate
0946:                                                        .get("virtualdatabase.xml.virtualdatabase.set.schema.failed"),
0947:                                                e);
0948:                            }
0949:                        }
0950:                        currentDatabaseSchema = null;
0951:                    }
0952:                }
0953:
0954:                // Database table
0955:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseTable)) {
0956:                    if (currentTable != null) {
0957:                        try {
0958:                            ArrayList cols = currentTable.getColumns();
0959:                            if (cols == null)
0960:                                logger.warn(Translate.get(
0961:                                        "virtualdatabase.xml.table.no.column",
0962:                                        currentTable.getName()));
0963:                            else if (cols.size() != numberOfColumns)
0964:                                logger
0965:                                        .warn(Translate
0966:                                                .get(
0967:                                                        "virtualdatabase.xml.table.column.mismatch",
0968:                                                        new String[] {
0969:                                                                String
0970:                                                                        .valueOf(numberOfColumns),
0971:                                                                currentTable
0972:                                                                        .getName(),
0973:                                                                String
0974:                                                                        .valueOf(cols
0975:                                                                                .size()) }));
0976:
0977:                            currentDatabaseSchema.addTable(currentTable);
0978:                            if (logger.isDebugEnabled())
0979:                                logger.debug(Translate.get(
0980:                                        "virtualdatabase.xml.table.add",
0981:                                        currentTable.getName()));
0982:                        } catch (Exception e) {
0983:                            logger
0984:                                    .error(
0985:                                            Translate
0986:                                                    .get("virtualdatabase.xml.table.add.failed"),
0987:                                            e);
0988:                        }
0989:                        currentTable = null;
0990:                    }
0991:                }
0992:
0993:                else if (name.equals(DatabasesXmlTags.ELT_DatabaseProcedure)) {
0994:                    if (currentProcedure != null) {
0995:                        try {
0996:
0997:                            currentDatabaseSchema
0998:                                    .addProcedure(currentProcedure);
0999:                            if (logger.isDebugEnabled())
1000:                                logger.debug(Translate.get(
1001:                                        "virtualdatabase.xml.procedure.add",
1002:                                        currentProcedure.getName()));
1003:                        } catch (Exception e) {
1004:                            logger
1005:                                    .error(
1006:                                            Translate
1007:                                                    .get("virtualdatabase.xml.procedure.add.failed"),
1008:                                            e);
1009:                        }
1010:                        currentProcedure = null;
1011:                    }
1012:                }
1013:
1014:                // CreateTable rule
1015:                else if (name.equals(DatabasesXmlTags.ELT_CreateTable)) {
1016:                    if (currentCreateTablePolicy != null) {
1017:                        if (logger.isDebugEnabled())
1018:                            logger.debug(Translate.get(
1019:                                    "virtualdatabase.xml.create.table.add",
1020:                                    currentCreateTableRule.getInformation()));
1021:                        currentCreateTablePolicy
1022:                                .addRule(currentCreateTableRule);
1023:                    }
1024:                }
1025:
1026:                else if (name.equals(DatabasesXmlTags.ELT_LoadBalancer)) {
1027:                    if (logger.isDebugEnabled())
1028:                        logger
1029:                                .debug(Translate
1030:                                        .get(
1031:                                                "virtualdatabase.xml.loadbalancer.transaction.isolation.set",
1032:                                                defaultTransactionIsolation));
1033:
1034:                    currentLoadBalancer
1035:                            .setDefaultTransactionIsolationLevel(defaultTransactionIsolation);
1036:                }
1037:
1038:                // RAIDb-0 load balancer
1039:                else if (name.equals(DatabasesXmlTags.ELT_RAIDb_0)) {
1040:                    if (logger.isDebugEnabled())
1041:                        logger
1042:                                .debug(Translate
1043:                                        .get("virtualdatabase.xml.loadbalancer.raidb0.set"));
1044:
1045:                    if (currentCreateTablePolicy.getDefaultRule() == null) {
1046:                        if (logger.isDebugEnabled())
1047:                            logger
1048:                                    .debug(Translate
1049:                                            .get("virtualdatabase.xml.create.table.default"));
1050:                        CreateTableRule rule = new CreateTableRoundRobin();
1051:                        currentCreateTablePolicy.addRule(rule);
1052:                    }
1053:                    try {
1054:                        currentLoadBalancer = new RAIDb0(
1055:                                currentVirtualDatabase,
1056:                                currentCreateTablePolicy);
1057:                    } catch (Exception e) {
1058:                        String msg = Translate
1059:                                .get("virtualdatabase.xml.loadbalancer.raidb0.failed");
1060:                        logger.error(msg, e);
1061:                        throw new SAXException(msg, e);
1062:                    }
1063:                }
1064:
1065:                // Recovery Log
1066:                else if (name.equals(DatabasesXmlTags.ELT_RecoveryLog)) {
1067:                    if (logger.isDebugEnabled())
1068:                        logger
1069:                                .debug(Translate
1070:                                        .get("virtualdatabase.xml.recoverylog.cheking.tables"));
1071:                    try {
1072:                        currentRecoveryLog.checkRecoveryLogTables();
1073:                    } catch (Exception e) {
1074:                        String msg = Translate
1075:                                .get("virtualdatabase.xml.recoverylog.cheking.tables.failed");
1076:                        logger.error(msg, e);
1077:                        throw new SAXException(msg);
1078:                    }
1079:                    try {
1080:                        MBeanServerManager
1081:                                .registerMBean(
1082:                                        new RecoveryLogControl(
1083:                                                currentRecoveryLog),
1084:                                        JmxConstants
1085:                                                .getRecoveryLogObjectName(currentVirtualDatabase
1086:                                                        .getVirtualDatabaseName()));
1087:                    } catch (Exception e) {
1088:                        if (logger.isWarnEnabled()) {
1089:                            logger
1090:                                    .warn(
1091:                                            Translate
1092:                                                    .get(
1093:                                                            "virtualdatabase.xml.recoverylog.jmx.failed", currentVirtualDatabase.getVirtualDatabaseName()), e); //$NON-NLS-1$
1094:                        }
1095:                    }
1096:                }
1097:            }
1098:
1099:            /**
1100:             * Unregisters MBeans associated to the vdb.
1101:             */
1102:            private void unregisterRelatedMBeans(VirtualDatabase vdb) {
1103:                try {
1104:                    MBeanServerManager.unregister(JmxConstants
1105:                            .getVirtualDataBaseObjectName(vdb
1106:                                    .getVirtualDatabaseName()));
1107:                } catch (Exception ee) {
1108:                }
1109:                try {
1110:                    MBeanServerManager.unregister(JmxConstants
1111:                            .getAbstractSchedulerObjectName(vdb
1112:                                    .getVirtualDatabaseName()));
1113:                } catch (Exception ee) {
1114:                }
1115:                try {
1116:                    MBeanServerManager.unregister(JmxConstants
1117:                            .getRecoveryLogObjectName(vdb
1118:                                    .getVirtualDatabaseName()));
1119:                } catch (Exception ee) {
1120:                }
1121:                try {
1122:                    MBeanServerManager.unregister(JmxConstants
1123:                            .getLoadBalancerObjectName(vdb
1124:                                    .getVirtualDatabaseName()));
1125:                } catch (Exception ee) {
1126:                }
1127:                try {
1128:                    MBeanServerManager.unregister(JmxConstants
1129:                            .getRequestManagerObjectName(vdb
1130:                                    .getVirtualDatabaseName()));
1131:                } catch (Exception ee) {
1132:                }
1133:                try {
1134:                    MBeanServerManager.unregister(JmxConstants
1135:                            .getParsingCacheObjectName(vdb
1136:                                    .getVirtualDatabaseName()));
1137:                } catch (Exception ee) {
1138:                }
1139:                List backendNames = new ArrayList();
1140:                try {
1141:                    backendNames = vdb.getAllBackendNames();
1142:                } catch (VirtualDatabaseException ee) {
1143:                }
1144:                for (int i = 0; i < backendNames.size(); i++) {
1145:                    String backendName = (String) backendNames.get(i);
1146:                    try {
1147:                        MBeanServerManager
1148:                                .unregister(JmxConstants
1149:                                        .getDatabaseBackendObjectName(vdb
1150:                                                .getVirtualDatabaseName(),
1151:                                                backendName));
1152:                    } catch (Exception ee) {
1153:                    }
1154:                }
1155:            }
1156:
1157:            /* Virtual database */
1158:
1159:            /**
1160:             * Sets {@link #currentVirtualDatabase}as a new <code> VirtualDatabase
1161:             * </code>
1162:             * using the parsed attributes. An exception is thrown in particular if a
1163:             * virtual database with the same name is already registered in the
1164:             * controller.
1165:             * 
1166:             * @param atts parsed attributes
1167:             * @exception SAXException if an error occurs
1168:             */
1169:            private void newVirtualDatabase(Attributes atts)
1170:                    throws SAXException {
1171:                String name = atts.getValue(DatabasesXmlTags.ATT_name);
1172:                String maxNbOfConnections = atts
1173:                        .getValue(DatabasesXmlTags.ATT_maxNbOfConnections);
1174:                String poolThreads = atts
1175:                        .getValue(DatabasesXmlTags.ATT_poolThreads);
1176:                String minNbOfThreads = atts
1177:                        .getValue(DatabasesXmlTags.ATT_minNbOfThreads);
1178:                String maxNbOfThreads = atts
1179:                        .getValue(DatabasesXmlTags.ATT_maxNbOfThreads);
1180:                String maxThreadIdleTime = atts
1181:                        .getValue(DatabasesXmlTags.ATT_maxThreadIdleTime);
1182:                String sqlDumpLength = atts
1183:                        .getValue(DatabasesXmlTags.ATT_sqlDumpLength);
1184:                String useStaticResultSetMetaData = atts
1185:                        .getValue(DatabasesXmlTags.ATT_useStaticResultSetMetaData);
1186:                String enforcingTableExistenceIntoSchema = atts
1187:                        .getValue(DatabasesXmlTags.ATT_enforceTableExistenceIntoSchema);
1188:
1189:                if (controller.hasVirtualDatabase(name)) {
1190:                    String msg = Translate
1191:                            .get(
1192:                                    "virtualdatabase.xml.virtualdatabase.already.exists",
1193:                                    name);
1194:                    logger.error(msg);
1195:                    throw new SAXException(msg);
1196:                }
1197:
1198:                try {
1199:                    // Process the attributes
1200:                    int maxConnections = Integer.parseInt(maxNbOfConnections);
1201:                    boolean pool = poolThreads
1202:                            .equals(DatabasesXmlTags.VAL_true);
1203:                    int minThreads = Integer.parseInt(minNbOfThreads);
1204:                    int maxThreads = Integer.parseInt(maxNbOfThreads);
1205:                    // converts in ms
1206:                    long threadIdleTime = Long.parseLong(maxThreadIdleTime) * 1000L;
1207:                    int dumpLength = Integer.parseInt(sqlDumpLength);
1208:                    boolean staticMetadata = useStaticResultSetMetaData
1209:                            .equals(DatabasesXmlTags.VAL_true);
1210:                    boolean enforceTableExistenceIntoSchema = enforcingTableExistenceIntoSchema
1211:                            .equals(DatabasesXmlTags.VAL_true);
1212:                    if (logger.isDebugEnabled())
1213:                        logger.debug(Translate.get(
1214:                                "virtualdatabase.xml.virtualdatabase.create",
1215:                                name));
1216:                    currentVirtualDatabase = new VirtualDatabase(controller,
1217:                            name, maxConnections, pool, minThreads, maxThreads,
1218:                            threadIdleTime, dumpLength, staticMetadata,
1219:                            enforceTableExistenceIntoSchema);
1220:                    org.continuent.sequoia.controller.virtualdatabase.management.VirtualDatabase virtualDatabase = new org.continuent.sequoia.controller.virtualdatabase.management.VirtualDatabase(
1221:                            currentVirtualDatabase);
1222:                    ObjectName objectName = JmxConstants
1223:                            .getVirtualDataBaseObjectName(name);
1224:                    MBeanServerManager.registerMBean(virtualDatabase,
1225:                            objectName);
1226:                    currentVirtualDatabase
1227:                            .setNotificationBroadcasterSupport(virtualDatabase
1228:                                    .getBroadcaster());
1229:
1230:                } catch (Exception e) {
1231:                    String msg = Translate
1232:                            .get("virtualdatabase.xml.virtualdatabase.failed");
1233:                    logger.error(msg, e);
1234:                    throw new SAXException(msg, e);
1235:                }
1236:            }
1237:
1238:            /* Distribution */
1239:
1240:            /**
1241:             * Sets {@link #currentVirtualDatabase} as a new
1242:             * <code>DistributedVirtalDatabase</code> using the parsed attributes.
1243:             * 
1244:             * @param atts parsed attributes
1245:             */
1246:            private void newDistribution(Attributes atts) throws SAXException {
1247:                String groupName = atts
1248:                        .getValue(DatabasesXmlTags.ATT_groupName);
1249:                String hederaPropertiesFile = atts
1250:                        .getValue(DatabasesXmlTags.ATT_hederaPropertiesFile);
1251:                String clientFailoverTimeoutString = atts
1252:                        .getValue(DatabasesXmlTags.ATT_clientFailoverTimeout);
1253:
1254:                if (groupName == null)
1255:                    groupName = currentVirtualDatabase.getVirtualDatabaseName();
1256:
1257:                long clientFailoverTimeout;
1258:                try {
1259:                    clientFailoverTimeout = Long
1260:                            .parseLong(clientFailoverTimeoutString);
1261:                } catch (NumberFormatException e) {
1262:                    throw new SAXException(
1263:                            "Invalid long value for clientFailoverTimeout in Distribution element");
1264:                }
1265:
1266:                if (logger.isDebugEnabled())
1267:                    logger
1268:                            .debug(Translate
1269:                                    .get(
1270:                                            "virtualdatabase.xml.virtualdatabase.distributed.create",
1271:                                            new String[] {
1272:                                                    currentVirtualDatabase
1273:                                                            .getVirtualDatabaseName(),
1274:                                                    groupName }));
1275:                try {
1276:                    // we need to replace previous database mbean
1277:                    ObjectName objectName = JmxConstants
1278:                            .getVirtualDataBaseObjectName(currentVirtualDatabase
1279:                                    .getVirtualDatabaseName());
1280:                    MBeanServerManager.unregister(objectName);
1281:
1282:                    // Create the distributed virtual database (does not join the group now)
1283:                    currentVirtualDatabase = new DistributedVirtualDatabase(
1284:                            controller, currentVirtualDatabase
1285:                                    .getVirtualDatabaseName(), groupName,
1286:                            currentVirtualDatabase.getMaxNbOfConnections(),
1287:                            currentVirtualDatabase.isPoolConnectionThreads(),
1288:                            currentVirtualDatabase.getMinNbOfThreads(),
1289:                            currentVirtualDatabase.getMaxNbOfThreads(),
1290:                            currentVirtualDatabase.getMaxThreadIdleTime(),
1291:                            currentVirtualDatabase.getSqlShortFormLength(),
1292:                            clientFailoverTimeout, currentVirtualDatabase
1293:                                    .useStaticResultSetMetaData(),
1294:                            hederaPropertiesFile, currentVirtualDatabase
1295:                                    .enforceTableExistenceIntoSchema());
1296:                    org.continuent.sequoia.controller.virtualdatabase.management.VirtualDatabase virtualDatabase = new org.continuent.sequoia.controller.virtualdatabase.management.VirtualDatabase(
1297:                            currentVirtualDatabase);
1298:                    MBeanServerManager.registerMBean(virtualDatabase,
1299:                            objectName);
1300:                    currentVirtualDatabase
1301:                            .setNotificationBroadcasterSupport(virtualDatabase
1302:                                    .getBroadcaster());
1303:                } catch (Exception e) {
1304:                    String msg = Translate
1305:                            .get("virtualdatabase.xml.virtualdatabase.distributed.failed");
1306:                    logger.error(msg, e);
1307:                    throw new SAXException(msg, e);
1308:                }
1309:            }
1310:
1311:            /**
1312:             * Sets a new <code>MessageTimeouts</code> to the current distributed
1313:             * virtual database.
1314:             * 
1315:             * @param atts parsed attributes
1316:             */
1317:            private void newMessageTimeouts(Attributes atts) {
1318:                MessageTimeouts messageTimeouts = new MessageTimeouts(
1319:                        getTimeout(atts
1320:                                .getValue(DatabasesXmlTags.ATT_defaultTimeout)));
1321:
1322:                messageTimeouts.setBackendStatusTimeout(getTimeout(atts
1323:                        .getValue(DatabasesXmlTags.ATT_backendStatusTimeout)));
1324:                messageTimeouts
1325:                        .setBackendTransferTimeout(getTimeout(atts
1326:                                .getValue(DatabasesXmlTags.ATT_backendTransferTimeout)));
1327:                messageTimeouts
1328:                        .setCacheInvalidateTimeout(getTimeout(atts
1329:                                .getValue(DatabasesXmlTags.ATT_cacheInvalidateTimeout)));
1330:                messageTimeouts.setCommitTimeout(getTimeout(atts
1331:                        .getValue(DatabasesXmlTags.ATT_commitTimeout)));
1332:                messageTimeouts.setControllerNameTimeout(getTimeout(atts
1333:                        .getValue(DatabasesXmlTags.ATT_controllerNameTimeout)));
1334:                messageTimeouts.setCopyLogEntryTimeout(getTimeout(atts
1335:                        .getValue(DatabasesXmlTags.ATT_copyLogEntryTimeout)));
1336:                messageTimeouts.setDisableBackendTimeout(getTimeout(atts
1337:                        .getValue(DatabasesXmlTags.ATT_disableBackendTimeout)));
1338:                messageTimeouts.setEnableBackendTimeout(getTimeout(atts
1339:                        .getValue(DatabasesXmlTags.ATT_enableBackendTimeout)));
1340:                messageTimeouts
1341:                        .setExecReadRequestTimeout(getTimeout(atts
1342:                                .getValue(DatabasesXmlTags.ATT_execReadRequestTimeout)));
1343:                messageTimeouts
1344:                        .setExecReadStoredProcedureTimeout(getTimeout(atts
1345:                                .getValue(DatabasesXmlTags.ATT_execReadStoredProcedureTimeout)));
1346:                messageTimeouts
1347:                        .setExecWriteRequestTimeout(getTimeout(atts
1348:                                .getValue(DatabasesXmlTags.ATT_execWriteRequestTimeout)));
1349:                messageTimeouts
1350:                        .setExecWriteRequestWithKeysTimeout(getTimeout(atts
1351:                                .getValue(DatabasesXmlTags.ATT_execWriteRequestWithKeysTimeout)));
1352:                messageTimeouts
1353:                        .setExecWriteStoredProcedureTimeout(getTimeout(atts
1354:                                .getValue(DatabasesXmlTags.ATT_execWriteStoredProcedureTimeout)));
1355:                messageTimeouts
1356:                        .setInitiateDumpCopyTimeout(getTimeout(atts
1357:                                .getValue(DatabasesXmlTags.ATT_initiateDumpCopyTimeout)));
1358:                messageTimeouts
1359:                        .setNotifyCompletionTimeout(getTimeout(atts
1360:                                .getValue(DatabasesXmlTags.ATT_notifyCompletionTimeout)));
1361:                messageTimeouts
1362:                        .setReleaseSavepointTimeout(getTimeout(atts
1363:                                .getValue(DatabasesXmlTags.ATT_releaseSavepointTimeout)));
1364:                messageTimeouts
1365:                        .setReplicateLogEntriesTimeout(getTimeout(atts
1366:                                .getValue(DatabasesXmlTags.ATT_replicateLogEntriesTimeout)));
1367:                messageTimeouts.setRollbackTimeout(getTimeout(atts
1368:                        .getValue(DatabasesXmlTags.ATT_rollbackTimeout)));
1369:                messageTimeouts
1370:                        .setRollbackToSavepointTimeout(getTimeout(atts
1371:                                .getValue(DatabasesXmlTags.ATT_rollbackToSavepointTimeout)));
1372:                messageTimeouts.setSetCheckpointTimeout(getTimeout(atts
1373:                        .getValue(DatabasesXmlTags.ATT_setCheckpointTimeout)));
1374:                messageTimeouts.setSetSavepointTimeout(getTimeout(atts
1375:                        .getValue(DatabasesXmlTags.ATT_setSavepointTimeout)));
1376:                messageTimeouts.setUnlogCommitTimeout(getTimeout(atts
1377:                        .getValue(DatabasesXmlTags.ATT_unlogCommitTimeout)));
1378:                messageTimeouts.setUnlogRequestTimeout(getTimeout(atts
1379:                        .getValue(DatabasesXmlTags.ATT_unlogRequestTimeout)));
1380:                messageTimeouts.setUnlogRollbackTimeout(getTimeout(atts
1381:                        .getValue(DatabasesXmlTags.ATT_unlogRollbackTimeout)));
1382:                messageTimeouts
1383:                        .setVirtualDatabaseConfigurationTimeout(getTimeout(atts
1384:                                .getValue(DatabasesXmlTags.ATT_virtualDatabaseConfigurationTimeout)));
1385:
1386:                // Set the message timeouts
1387:                ((DistributedVirtualDatabase) currentVirtualDatabase)
1388:                        .setMessageTimeouts(messageTimeouts);
1389:            }
1390:
1391:            private static final int DEFAULT_TIMEOUT = 0;
1392:
1393:            private long getTimeout(String timeoutAsString) {
1394:                if (timeoutAsString == null)
1395:                    return DEFAULT_TIMEOUT;
1396:                long timeout;
1397:                try {
1398:                    timeout = Long.parseLong(timeoutAsString);
1399:                } catch (NumberFormatException e1) {
1400:                    timeout = DEFAULT_TIMEOUT; // Default is no timeout
1401:                }
1402:                return timeout;
1403:            }
1404:
1405:            //
1406:            // Monitoring
1407:            //
1408:
1409:            /**
1410:             * Sets a new <code>SQLMonitoring</code> to the current virtual database.
1411:             * 
1412:             * @param atts parsed attributes
1413:             */
1414:            private void newSQLMonitoring(Attributes atts) {
1415:                String monitoringString = atts
1416:                        .getValue(DatabasesXmlTags.ATT_defaultMonitoring);
1417:                boolean monitoring;
1418:                if (monitoringString != null)
1419:                    monitoring = monitoringString
1420:                            .equals(DatabasesXmlTags.VAL_on);
1421:                else
1422:                    monitoring = false;
1423:
1424:                SQLMonitoring sqlMonitor = new SQLMonitoring(
1425:                        currentVirtualDatabase.getVirtualDatabaseName());
1426:                sqlMonitor.setDefaultRule(monitoring);
1427:                currentVirtualDatabase.setSQLMonitor(sqlMonitor);
1428:            }
1429:
1430:            /**
1431:             * Add a new <code>SQLMonitoringRule</code> to the current SQL monitor.
1432:             * 
1433:             * @param atts parsed attributes
1434:             */
1435:            private void newSQLMonitoringRule(Attributes atts) {
1436:                String queryPattern = atts
1437:                        .getValue(DatabasesXmlTags.ATT_queryPattern);
1438:                String caseSensitiveString = atts
1439:                        .getValue(DatabasesXmlTags.ATT_caseSensitive);
1440:                String applyToSkeletonString = atts
1441:                        .getValue(DatabasesXmlTags.ATT_applyToSkeleton);
1442:                String monitoringString = atts
1443:                        .getValue(DatabasesXmlTags.ATT_monitoring);
1444:
1445:                boolean caseSensitive;
1446:                if (caseSensitiveString != null)
1447:                    caseSensitive = caseSensitiveString
1448:                            .equals(DatabasesXmlTags.VAL_true);
1449:                else
1450:                    caseSensitive = false;
1451:                boolean applyToSkeleton;
1452:                if (applyToSkeletonString != null)
1453:                    applyToSkeleton = applyToSkeletonString
1454:                            .equals(DatabasesXmlTags.VAL_true);
1455:                else
1456:                    applyToSkeleton = false;
1457:                boolean monitoring;
1458:                if (monitoringString != null)
1459:                    monitoring = monitoringString
1460:                            .equals(DatabasesXmlTags.VAL_on);
1461:                else
1462:                    monitoring = false;
1463:
1464:                // Create the rule and add it
1465:                SQLMonitoringRule rule = new SQLMonitoringRule(queryPattern,
1466:                        caseSensitive, applyToSkeleton, monitoring);
1467:
1468:                if (logger.isDebugEnabled())
1469:                    logger.debug(Translate.get(
1470:                            "virtualdatabase.xml.sqlmonitoring.rule.add",
1471:                            new String[] { queryPattern,
1472:                                    String.valueOf(caseSensitive),
1473:                                    applyToSkeletonString,
1474:                                    String.valueOf(monitoring) }));
1475:                currentVirtualDatabase.getSQLMonitor().addRule(rule);
1476:            }
1477:
1478:            //
1479:            // Backup
1480:            //
1481:
1482:            /**
1483:             * Adds a new <code>BackupManager</code>
1484:             */
1485:            private void newBackupManager() {
1486:                currentBackupManager = new BackupManager();
1487:            }
1488:
1489:            /**
1490:             * Adds a new <code>Backuper</code> to the currentBackupManager
1491:             * 
1492:             * @param atts parsed attributes
1493:             */
1494:            private void newBackuper(Attributes atts) {
1495:                String name = atts.getValue(DatabasesXmlTags.ATT_backuperName);
1496:                String className = atts
1497:                        .getValue(DatabasesXmlTags.ATT_className);
1498:                String options = atts.getValue(DatabasesXmlTags.ATT_options);
1499:
1500:                Backuper backuper = null;
1501:                try {
1502:                    backuper = (Backuper) Class.forName(className)
1503:                            .newInstance();
1504:                    backuper.setOptions(options);
1505:                } catch (Exception e) {
1506:                    String msg = "Failed to load backuper " + name
1507:                            + " from class " + className + " (" + e + ")";
1508:                    if (logger.isDebugEnabled())
1509:                        logger.error(msg, e);
1510:                    else
1511:                        logger.error(e);
1512:                    return;
1513:                }
1514:
1515:                try {
1516:                    currentBackupManager.registerBackuper(name, backuper);
1517:                } catch (BackupException e) {
1518:                    logger.error("Failed to load backuper " + name + "(" + e
1519:                            + ")");
1520:                }
1521:            }
1522:
1523:            //
1524:            // Database backend
1525:            //
1526:
1527:            /**
1528:             * Sets {@link #currentBackend}as a new <code> DatabaseBackend</code> using
1529:             * the parsed attributes.
1530:             * 
1531:             * @param atts parsed attributes
1532:             * @throws SAXException
1533:             */
1534:            private void newDatabaseBackend(Attributes atts)
1535:                    throws SAXException {
1536:                String name = atts.getValue(DatabasesXmlTags.ATT_name);
1537:                String driverClassName = atts
1538:                        .getValue(DatabasesXmlTags.ATT_driver);
1539:                String driverPath = atts
1540:                        .getValue(DatabasesXmlTags.ATT_driverPath);
1541:                String url = atts.getValue(DatabasesXmlTags.ATT_url);
1542:                String connectionTestStatement = atts
1543:                        .getValue(DatabasesXmlTags.ATT_connectionTestStatement);
1544:                String nbOfWorkerThreadsString = atts
1545:                        .getValue(DatabasesXmlTags.ATT_nbOfBackendWorkerThreads);
1546:
1547:                int nbOfWorkerThreads;
1548:                try {
1549:                    nbOfWorkerThreads = Integer
1550:                            .parseInt(nbOfWorkerThreadsString);
1551:                } catch (Exception e) {
1552:                    String msg = Translate
1553:                            .get("virtualdatabase.xml.virtualdatabase.failed");
1554:                    logger.error(msg, e);
1555:                    throw new SAXException(msg, e);
1556:                }
1557:
1558:                if (logger.isDebugEnabled()) {
1559:                    logger.debug(Translate.get(
1560:                            "virtualdatabase.xml.backend.create", new String[] {
1561:                                    name, driverClassName, url,
1562:                                    connectionTestStatement }));
1563:                    if (driverPath == null) {
1564:                        logger.debug("no driver path defined for backend.");
1565:                    } else {
1566:                        logger.debug("using driver path " + driverPath);
1567:                    }
1568:                }
1569:                currentBackend = new DatabaseBackend(name, driverPath,
1570:                        driverClassName, url, currentVirtualDatabase
1571:                                .getVirtualDatabaseName(), true,
1572:                        connectionTestStatement, nbOfWorkerThreads);
1573:            }
1574:
1575:            /**
1576:             * Adds a <code>AbstractRewritingRule</code> to the current DatabaseBackend.
1577:             * 
1578:             * @param atts parsed attributes
1579:             */
1580:            private void newRewritingRule(Attributes atts) throws SAXException {
1581:                String queryPattern = atts
1582:                        .getValue(DatabasesXmlTags.ATT_queryPattern);
1583:                String rewrite = atts.getValue(DatabasesXmlTags.ATT_rewrite);
1584:                String matchingType = atts
1585:                        .getValue(DatabasesXmlTags.ATT_matchingType);
1586:                String caseSensitiveString = atts
1587:                        .getValue(DatabasesXmlTags.ATT_caseSensitive);
1588:                String stopOnMatchString = atts
1589:                        .getValue(DatabasesXmlTags.ATT_stopOnMatch);
1590:
1591:                boolean caseSensitive;
1592:                if (caseSensitiveString != null)
1593:                    caseSensitive = caseSensitiveString
1594:                            .equals(DatabasesXmlTags.VAL_true);
1595:                else
1596:                    caseSensitive = false;
1597:                boolean stopOnMatch;
1598:                if (stopOnMatchString != null)
1599:                    stopOnMatch = stopOnMatchString
1600:                            .equals(DatabasesXmlTags.VAL_true);
1601:                else
1602:                    stopOnMatch = false;
1603:
1604:                // Create the rule and add it
1605:                AbstractRewritingRule rule;
1606:                if (matchingType.equals(DatabasesXmlTags.VAL_simple))
1607:                    rule = new SimpleRewritingRule(queryPattern, rewrite,
1608:                            caseSensitive, stopOnMatch);
1609:                else if (matchingType.equals(DatabasesXmlTags.VAL_pattern))
1610:                    rule = new PatternRewritingRule(queryPattern, rewrite,
1611:                            caseSensitive, stopOnMatch);
1612:                else if (matchingType.equals(DatabasesXmlTags.VAL_replaceAll))
1613:                    rule = new ReplaceAllRewritingRule(queryPattern, rewrite,
1614:                            caseSensitive, stopOnMatch);
1615:                else
1616:                    throw new SAXException(
1617:                            Translate
1618:                                    .get(
1619:                                            "virtualdatabase.xml.rewritingrule.unsupported.matching",
1620:                                            matchingType));
1621:
1622:                if (logger.isDebugEnabled())
1623:                    logger.debug(Translate.get(
1624:                            "virtualdatabase.xml.rewritingrule.add",
1625:                            new String[] { queryPattern, rewrite,
1626:                                    String.valueOf(caseSensitive),
1627:                                    String.valueOf(stopOnMatch) }));
1628:                currentBackend.addRewritingRule(rule);
1629:            }
1630:
1631:            /* Authentication manager */
1632:
1633:            /**
1634:             * Sets {@link #currentAuthenticationManager}as a new <code>
1635:             * AuthenticationManager</code>.
1636:             */
1637:            private void newAuthenticationManager(Attributes atts) {
1638:                String transparentLogin = atts
1639:                        .getValue(DatabasesXmlTags.ATT_transparentLogin);
1640:                currentAuthenticationManager = new AuthenticationManager(
1641:                        transparentLogin.equals(DatabasesXmlTags.VAL_on));
1642:            }
1643:
1644:            /**
1645:             * Sets the administrator user of the {@link #currentAuthenticationManager}
1646:             * using the parsed attributs.
1647:             * 
1648:             * @param atts parsed attributes
1649:             */
1650:            private void newAdminUser(Attributes atts) {
1651:                String aLogin = atts.getValue(DatabasesXmlTags.ATT_username);
1652:                String aPassword = atts.getValue(DatabasesXmlTags.ATT_password);
1653:
1654:                if (logger.isDebugEnabled())
1655:                    logger
1656:                            .debug(Translate
1657:                                    .get(
1658:                                            "virtualdatabase.xml.authentication.login.admin.add",
1659:                                            new String[] { aLogin, aPassword }));
1660:                currentAuthenticationManager.addAdminUser(new AdminUser(aLogin,
1661:                        aPassword));
1662:            }
1663:
1664:            /**
1665:             * Sets {@link #currentVirtualUser}as a new <code> VirtualDatabaseUser
1666:             * </code>
1667:             * using the parsed attributes and adds this new virtual database user to the
1668:             * {@link #currentAuthenticationManager}.
1669:             * 
1670:             * @param atts parsed attributes
1671:             */
1672:            private void newVirtualLogin(Attributes atts) {
1673:                String vLogin = atts.getValue(DatabasesXmlTags.ATT_vLogin);
1674:                String vPassword = atts
1675:                        .getValue(DatabasesXmlTags.ATT_vPassword);
1676:                currentVirtualUser = new VirtualDatabaseUser(vLogin, vPassword);
1677:
1678:                if (logger.isDebugEnabled())
1679:                    logger
1680:                            .debug(Translate
1681:                                    .get(
1682:                                            "virtualdatabase.xml.authentication.login.virtual.add",
1683:                                            new String[] { vLogin, vPassword }));
1684:                currentAuthenticationManager.addVirtualUser(currentVirtualUser);
1685:            }
1686:
1687:            /* Request manager */
1688:
1689:            /**
1690:             * Sets the {@link #beginTimeout},{@link #commitTimeout}and
1691:             * {@link #rollbackTimeout}timeouts (in ms) using the parsed attributes.
1692:             * 
1693:             * @param atts element attributes
1694:             * @exception SAXException if an error occurs
1695:             */
1696:            private void newRequestManager(Attributes atts) throws SAXException {
1697:                try {
1698:                    String begin = atts
1699:                            .getValue(DatabasesXmlTags.ATT_beginTimeout);
1700:                    String commit = atts
1701:                            .getValue(DatabasesXmlTags.ATT_commitTimeout);
1702:                    String rollback = atts
1703:                            .getValue(DatabasesXmlTags.ATT_rollbackTimeout);
1704:                    String caseSensitiveParsingString = atts
1705:                            .getValue(DatabasesXmlTags.ATT_caseSensitiveParsing);
1706:
1707:                    // Convert to ms
1708:                    beginTimeout = Long.parseLong(begin) * 1000L;
1709:                    commitTimeout = Long.parseLong(commit) * 1000L;
1710:                    rollbackTimeout = Long.parseLong(rollback) * 1000L;
1711:
1712:                    if (caseSensitiveParsingString != null)
1713:                        caseSensitiveParsing = caseSensitiveParsingString
1714:                                .equals(DatabasesXmlTags.VAL_true);
1715:                    else
1716:                        caseSensitiveParsing = false;
1717:
1718:                    if (logger.isDebugEnabled())
1719:                        logger
1720:                                .debug(Translate
1721:                                        .get(
1722:                                                "virtualdatabase.xml.requestmanager.parameters",
1723:                                                new String[] {
1724:                                                        String
1725:                                                                .valueOf(beginTimeout),
1726:                                                        String
1727:                                                                .valueOf(commitTimeout),
1728:                                                        String
1729:                                                                .valueOf(rollbackTimeout) }));
1730:                } catch (NumberFormatException e) {
1731:                    String msg = Translate
1732:                            .get("virtualdatabase.xml.requestmanager.timeout.failed");
1733:                    logger.error(msg, e);
1734:                    throw new SAXException(msg, e);
1735:                }
1736:            }
1737:
1738:            /* Macro Handling */
1739:
1740:            /**
1741:             * Adds a new <code>MacrosHandler</code> using the parsed attributes.
1742:             * 
1743:             * @param atts parsed attributes
1744:             */
1745:            private void newMacroHandler(Attributes atts) {
1746:                /**
1747:                 * rand (off | int | long | float | double) "float" now (off | date | time |
1748:                 * timestamp) "timestamp" currentDate (off | date | time | timestamp) "date"
1749:                 * currentTime (off | date | time | timestamp) "time" timeOfDay (off | date |
1750:                 * time | timestamp) "timestamp" currentTimestamp (off | date | time |
1751:                 * timestamp) "timestamp" timeResolution CDATA "0"
1752:                 */
1753:                String rand = atts.getValue(DatabasesXmlTags.ATT_rand);
1754:                String now = atts.getValue(DatabasesXmlTags.ATT_now);
1755:                String currentDate = atts
1756:                        .getValue(DatabasesXmlTags.ATT_currentDate);
1757:                String currentTime = atts
1758:                        .getValue(DatabasesXmlTags.ATT_currentTime);
1759:                String currentTimestamp = atts
1760:                        .getValue(DatabasesXmlTags.ATT_currentTimestamp);
1761:                String timeResolution = atts
1762:                        .getValue(DatabasesXmlTags.ATT_timeResolution);
1763:                String timeOfDay = atts
1764:                        .getValue(DatabasesXmlTags.ATT_timeOfDay);
1765:
1766:                int icurrentDate = MacrosHandler.getIntDateLevel(currentDate);
1767:                int icurrentTime = MacrosHandler.getIntDateLevel(currentTime);
1768:                int icurrentTimestamp = MacrosHandler
1769:                        .getIntDateLevel(currentTimestamp);
1770:                int itimeOfDay = MacrosHandler.getIntDateLevel(timeOfDay);
1771:                int inow = MacrosHandler.getIntDateLevel(now);
1772:                int irand = MacrosHandler.getIntRandLevel(rand);
1773:                long ltimeResolution = Long.parseLong(timeResolution);
1774:
1775:                try {
1776:                    currentMacroHandler = new MacrosHandler(irand,
1777:                            ltimeResolution, inow, icurrentDate, icurrentTime,
1778:                            itimeOfDay, icurrentTimestamp);
1779:                } catch (RuntimeException e) {
1780:                    logger
1781:                            .warn(Translate
1782:                                    .get(
1783:                                            "virtualdatabase.xml.invalid.macroshandler.settings",
1784:                                            e));
1785:                }
1786:            }
1787:
1788:            /* Request scheduler */
1789:
1790:            /**
1791:             * Sets {@link #currentRequestScheduler}as a new <code>
1792:             * SingleDBPassThroughScheduler</code>
1793:             * using the parsed attributes.
1794:             * 
1795:             * @param atts parsed attributes
1796:             * @exception SAXException if an error occurs
1797:             */
1798:            private void newSingleDBScheduler(Attributes atts)
1799:                    throws SAXException {
1800:                String level = atts.getValue(DatabasesXmlTags.ATT_level);
1801:
1802:                // SingleDB Query Level
1803:                if (level.equals(DatabasesXmlTags.VAL_passThrough)) {
1804:                    if (logger.isDebugEnabled())
1805:                        logger
1806:                                .debug(Translate
1807:                                        .get("virtualdatabase.xml.scheduler.singledb.create.passthrough"));
1808:                    currentRequestScheduler = new SingleDBPassThroughScheduler();
1809:                }
1810:
1811:                // SingleDB Pessimistic Transaction Level
1812:                else if (level
1813:                        .equals(DatabasesXmlTags.VAL_pessimisticTransaction)) {
1814:                    if (logger.isDebugEnabled())
1815:                        logger
1816:                                .debug(Translate
1817:                                        .get("virtualdatabase.xml.scheduler.singledb.create.pessimistic"));
1818:                    currentRequestScheduler = new SingleDBPessimisticTransactionLevelScheduler();
1819:                } else {
1820:                    throw new SAXException(
1821:                            Translate
1822:                                    .get(
1823:                                            "virtualdatabase.xml.scheduler.singledb.unsupported",
1824:                                            level));
1825:                }
1826:            }
1827:
1828:            /**
1829:             * Sets {@link #currentRequestScheduler}as a new <code>
1830:             * RAIDb0PassThroughLevelScheduler</code>
1831:             * or <code>RAIDb0PessimisticTransactionLevelScheduler</code> using the
1832:             * parsed attributes.
1833:             * 
1834:             * @param atts parsed attributes
1835:             * @exception SAXException if an error occurs
1836:             */
1837:            private void newRAIDb0Scheduler(Attributes atts)
1838:                    throws SAXException {
1839:                String level = atts.getValue(DatabasesXmlTags.ATT_level);
1840:
1841:                if (level.equals(DatabasesXmlTags.VAL_passThrough)) {
1842:                    if (logger.isDebugEnabled())
1843:                        logger
1844:                                .debug(Translate
1845:                                        .get("virtualdatabase.xml.scheduler.raidb0.create.passthrough"));
1846:                    currentRequestScheduler = new RAIDb0PassThroughLevelScheduler();
1847:                } else if (level
1848:                        .equals(DatabasesXmlTags.VAL_pessimisticTransaction)) {
1849:                    if (logger.isDebugEnabled())
1850:                        logger
1851:                                .debug(Translate
1852:                                        .get("virtualdatabase.xml.scheduler.raidb0.create.pessimistic"));
1853:                    currentRequestScheduler = new RAIDb0PessimisticTransactionLevelScheduler();
1854:                } else
1855:                    throw new SAXException(Translate.get(
1856:                            "virtualdatabase.xml.scheduler.raidb0.unsupported",
1857:                            level));
1858:            }
1859:
1860:            /**
1861:             * Sets {@link #currentRequestScheduler}as a new
1862:             * <code>RAIDb1PassThroughScheduler</code>,<code>
1863:             * RAIDb1QueryLevelScheduler</code>,
1864:             * <code>RAIDb1OptimisticQueryLevelScheduler</code> or
1865:             * <code>RAIDb1PessimisticTransactionLevelScheduler</code> using the parsed
1866:             * attributes.
1867:             * 
1868:             * @param atts parsed attributes
1869:             * @exception SAXException if an error occurs
1870:             */
1871:            private void newRAIDb1Scheduler(Attributes atts)
1872:                    throws SAXException {
1873:                String level = atts.getValue(DatabasesXmlTags.ATT_level);
1874:                long waitForSuspendedTransactionsTimeout = Long
1875:                        .parseLong(atts
1876:                                .getValue(DatabasesXmlTags.ATT_waitForSuspendedTransactionsTimeout));
1877:                long waitForPersistentConnectionsTimeout = Long
1878:                        .parseLong(atts
1879:                                .getValue(DatabasesXmlTags.ATT_waitForPersistentConnectionsTimeout));
1880:
1881:                // RAIDb-1 Pass Through level
1882:                if (level.equals(DatabasesXmlTags.VAL_passThrough)) {
1883:                    if (logger.isDebugEnabled())
1884:                        logger
1885:                                .debug(Translate
1886:                                        .get("virtualdatabase.xml.scheduler.raidb1.create.passthrough"));
1887:                    currentRequestScheduler = new RAIDb1PassThroughScheduler(
1888:                            currentVirtualDatabase,
1889:                            waitForSuspendedTransactionsTimeout,
1890:                            waitForPersistentConnectionsTimeout);
1891:                }
1892:                // RAIDb-1 Query level
1893:                else if (level.equals(DatabasesXmlTags.VAL_query)) {
1894:                    if (logger.isDebugEnabled())
1895:                        logger
1896:                                .debug(Translate
1897:                                        .get("virtualdatabase.xml.scheduler.raidb1.create.query"));
1898:                    currentRequestScheduler = new RAIDb1QueryLevelScheduler();
1899:                }
1900:                // RAIDb-1 Optimistic Query level
1901:                else if (level.equals(DatabasesXmlTags.VAL_optimisticQuery)) {
1902:                    if (logger.isDebugEnabled())
1903:                        logger
1904:                                .debug(Translate
1905:                                        .get("virtualdatabase.xml.scheduler.raidb1.create.query.optimistic"));
1906:                    currentRequestScheduler = new RAIDb1OptimisticQueryLevelScheduler();
1907:                }
1908:                // RAIDb-1 Optimistic Transaction level
1909:                else if (level
1910:                        .equals(DatabasesXmlTags.VAL_optimisticTransaction)) {
1911:                    if (logger.isDebugEnabled())
1912:                        logger
1913:                                .debug(Translate
1914:                                        .get("virtualdatabase.xml.scheduler.raidb1.create.optimistic"));
1915:                    currentRequestScheduler = new RAIDb1OptimisticTransactionLevelScheduler();
1916:                }
1917:                // RAIDb-1 Pessimistic Transaction level
1918:                else if (level
1919:                        .equals(DatabasesXmlTags.VAL_pessimisticTransaction)) {
1920:                    if (logger.isDebugEnabled())
1921:                        logger
1922:                                .debug(Translate
1923:                                        .get("virtualdatabase.xml.scheduler.raidb1.create.pessimistic"));
1924:                    currentRequestScheduler = new RAIDb1PessimisticTransactionLevelScheduler();
1925:                } else {
1926:                    throw new SAXException(Translate.get(
1927:                            "virtualdatabase.xml.scheduler.raidb1.unsupported",
1928:                            level));
1929:                }
1930:            }
1931:
1932:            /**
1933:             * Sets {@link #currentRequestScheduler}as a new
1934:             * <code>RAIDb2PassThroughScheduler</code>,<code>
1935:             * RAIDb2QueryLevelScheduler</code>
1936:             * or <code>RAIDb2PessimisticTransactionLevelScheduler</code> using the
1937:             * parsed attributes.
1938:             * 
1939:             * @param atts parsed attributes
1940:             * @exception SAXException if an error occurs
1941:             */
1942:            private void newRAIDb2Scheduler(Attributes atts)
1943:                    throws SAXException {
1944:                String level = atts.getValue(DatabasesXmlTags.ATT_level);
1945:
1946:                // RAIDb-2 Query level
1947:                if (level.equals(DatabasesXmlTags.VAL_passThrough)) {
1948:                    if (logger.isDebugEnabled())
1949:                        logger
1950:                                .debug(Translate
1951:                                        .get("virtualdatabase.xml.scheduler.raidb2.create.passthrough"));
1952:                    currentRequestScheduler = new RAIDb2PassThroughScheduler(
1953:                            currentVirtualDatabase);
1954:                }
1955:                // RAIDb-2 Query level
1956:                else if (level.equals(DatabasesXmlTags.VAL_query)) {
1957:                    if (logger.isDebugEnabled())
1958:                        logger
1959:                                .debug(Translate
1960:                                        .get("virtualdatabase.xml.scheduler.raidb2.create.query"));
1961:                    currentRequestScheduler = new RAIDb2QueryLevelScheduler();
1962:                }
1963:                // RAIDb-2 Pessimistic Transaction level
1964:                else if (level
1965:                        .equals(DatabasesXmlTags.VAL_pessimisticTransaction)) {
1966:                    if (logger.isDebugEnabled())
1967:                        logger
1968:                                .debug(Translate
1969:                                        .get("virtualdatabase.xml.scheduler.raidb2.create.pessimistic"));
1970:                    currentRequestScheduler = new RAIDb2PessimisticTransactionLevelScheduler();
1971:                } else {
1972:                    throw new SAXException(Translate.get(
1973:                            "virtualdatabase.xml.scheduler.raidb2.unsupported",
1974:                            level));
1975:                }
1976:            }
1977:
1978:            /* ********************** */
1979:            /* *** Request caches *** */
1980:            /* ********************** */
1981:
1982:            /**
1983:             * Sets {@link #currentMetadataCache}as a new <code>MetadataCache</code>
1984:             * using the parsed attributes.
1985:             * 
1986:             * @param atts parsed attributes
1987:             * @exception SAXException if an error occurs
1988:             */
1989:            private void newMetadataCache(Attributes atts) throws SAXException {
1990:                try {
1991:                    int maxMetadata = Integer.parseInt(atts
1992:                            .getValue(DatabasesXmlTags.ATT_maxNbOfMetadata));
1993:                    int maxField = Integer.parseInt(atts
1994:                            .getValue(DatabasesXmlTags.ATT_maxNbOfField));
1995:                    currentMetadataCache = new MetadataCache(maxMetadata,
1996:                            maxField);
1997:                } catch (Exception e) {
1998:                    String msg = Translate.get(
1999:                            "virtualdatabase.xml.metadata.cache.create.failed",
2000:                            e);
2001:                    logger.error(msg, e);
2002:                    throw new SAXException(msg, e);
2003:                }
2004:            }
2005:
2006:            /**
2007:             * Sets {@link #currentParsingCache}as a new <code>ParsingCache</code>
2008:             * using the parsed attributes.
2009:             * 
2010:             * @param atts parsed attributes
2011:             * @exception SAXException if an error occurs
2012:             */
2013:            private void newParsingCache(Attributes atts) throws SAXException {
2014:                String backgroundParsingString = atts
2015:                        .getValue(DatabasesXmlTags.ATT_backgroundParsing);
2016:                boolean backgroundParsing;
2017:
2018:                if (backgroundParsingString != null)
2019:                    backgroundParsing = backgroundParsingString
2020:                            .equals(DatabasesXmlTags.VAL_true);
2021:                else
2022:                    backgroundParsing = false;
2023:
2024:                String maxEntriesString = atts
2025:                        .getValue(DatabasesXmlTags.ATT_maxNbOfEntries);
2026:                int maxEntries = Integer.parseInt(maxEntriesString);
2027:
2028:                try {
2029:                    currentParsingCache = new ParsingCache(maxEntries,
2030:                            backgroundParsing);
2031:                } catch (Exception e) {
2032:                    String msg = Translate.get(
2033:                            "virtualdatabase.xml.parsing.cache.create.failed",
2034:                            e);
2035:                    logger.error(msg, e);
2036:                    throw new SAXException(msg, e);
2037:                }
2038:            }
2039:
2040:            /**
2041:             * Sets {@link #currentResultCache}as a new <code> ResultCache</code> using
2042:             * the parsed attributes.
2043:             * 
2044:             * @param atts parsed attributes
2045:             * @exception SAXException if an error occurs
2046:             */
2047:            private void newResultCache(Attributes atts) throws SAXException {
2048:                String granularity = atts
2049:                        .getValue(DatabasesXmlTags.ATT_granularity);
2050:                String maxEntriesString = atts
2051:                        .getValue(DatabasesXmlTags.ATT_maxNbOfEntries);
2052:                String pendingTimeoutString = atts
2053:                        .getValue(DatabasesXmlTags.ATT_pendingTimeout);
2054:
2055:                if (logger.isDebugEnabled())
2056:                    logger.debug(Translate.get(
2057:                            "virtualdatabase.xml.cache.create", granularity));
2058:
2059:                try {
2060:                    int maxEntries = Integer.parseInt(maxEntriesString);
2061:                    int pendingTimeout = Integer.parseInt(pendingTimeoutString);
2062:
2063:                    int granularityValue;
2064:                    if (granularity.equals(DatabasesXmlTags.VAL_table))
2065:                        granularityValue = CachingGranularities.TABLE;
2066:                    else if (granularity.equals(DatabasesXmlTags.VAL_database))
2067:                        granularityValue = CachingGranularities.DATABASE;
2068:                    else if (granularity.equals(DatabasesXmlTags.VAL_column))
2069:                        granularityValue = CachingGranularities.COLUMN;
2070:                    else if (granularity
2071:                            .equals(DatabasesXmlTags.VAL_columnUnique))
2072:                        granularityValue = CachingGranularities.COLUMN_UNIQUE;
2073:                    else
2074:                        throw new InstantiationException(Translate.get(
2075:                                "virtualdatabase.xml.cache.unsupported",
2076:                                granularity));
2077:
2078:                    currentResultCache = ResultCacheFactory.getCacheInstance(
2079:                            granularityValue, maxEntries, pendingTimeout);
2080:
2081:                } catch (Exception e) {
2082:                    String msg = Translate.get(
2083:                            "virtualdatabase.xml.cache.create.failed",
2084:                            granularity);
2085:                    logger.error(msg, e);
2086:                    throw new SAXException(msg, e);
2087:                }
2088:            }
2089:
2090:            /**
2091:             * Add a new <code>ResultCacheRule</code> using the parsed attributes.
2092:             * 
2093:             * @param atts parsed attributes
2094:             */
2095:            private void newResultCacheRule(Attributes atts) {
2096:                String queryString = atts
2097:                        .getValue(DatabasesXmlTags.ATT_queryPattern);
2098:
2099:                String caseSensitiveString = atts
2100:                        .getValue(DatabasesXmlTags.ATT_caseSensitive);
2101:                String applyToSkeletonString = atts
2102:                        .getValue(DatabasesXmlTags.ATT_applyToSkeleton);
2103:                long timestampResolution;
2104:                try {
2105:                    timestampResolution = Long
2106:                            .parseLong(atts
2107:                                    .getValue(DatabasesXmlTags.ATT_timestampResolution));
2108:                    timestampResolution *= 1000;
2109:                } catch (Exception e) {
2110:                    logger
2111:                            .warn(Translate
2112:                                    .get("virtualdatabase.invalid.timestamp.resolution"));
2113:                    timestampResolution = 1000;
2114:                }
2115:
2116:                boolean caseSensitive;
2117:                if (caseSensitiveString != null)
2118:                    caseSensitive = caseSensitiveString
2119:                            .equals(DatabasesXmlTags.VAL_true);
2120:                else
2121:                    caseSensitive = false;
2122:                boolean applyToSkeleton;
2123:                if (applyToSkeletonString != null)
2124:                    applyToSkeleton = applyToSkeletonString
2125:                            .equals(DatabasesXmlTags.VAL_true);
2126:                else
2127:                    applyToSkeleton = false;
2128:
2129:                // Create the rule
2130:                currentResultCacheRule = new ResultCacheRule(queryString,
2131:                        caseSensitive, applyToSkeleton, timestampResolution);
2132:
2133:                if (logger.isDebugEnabled())
2134:                    logger
2135:                            .debug(Translate
2136:                                    .get(
2137:                                            "virtualdatabase.xml.cache.rule.add",
2138:                                            new String[] {
2139:                                                    atts
2140:                                                            .getValue(DatabasesXmlTags.ATT_queryPattern),
2141:                                                    String
2142:                                                            .valueOf(caseSensitive),
2143:                                                    applyToSkeletonString,
2144:                                                    String
2145:                                                            .valueOf(timestampResolution) }));
2146:                currentResultCache.addCachingRule(currentResultCacheRule);
2147:            }
2148:
2149:            /**
2150:             * Set the <code>DefaultResultCacheRule</code> using the parsed attributes.
2151:             * 
2152:             * @param atts parsed attributes
2153:             */
2154:            private void newDefaultResultCacheRule(Attributes atts) {
2155:                long currentTimestampResolution;
2156:                try {
2157:                    currentTimestampResolution = Long
2158:                            .parseLong(atts
2159:                                    .getValue(DatabasesXmlTags.ATT_timestampResolution)) / 1000;
2160:                } catch (Exception e) {
2161:                    String msg = Translate
2162:                            .get("virtualdatabase.invalid.timestamp.resolution");
2163:                    logger.warn(msg);
2164:                    currentTimestampResolution = 1000;
2165:                }
2166:                // Create a fake rule
2167:                currentResultCacheRule = new ResultCacheRule("", false, false,
2168:                        currentTimestampResolution);
2169:            }
2170:
2171:            /**
2172:             * Add a new <code>EagerCaching</code> behavior to the current
2173:             * <code>ResultCacheRule</code>.
2174:             * 
2175:             * @param atts parsed attributes
2176:             * @exception SAXException if an error occurs
2177:             */
2178:            private void newEagerCaching(Attributes atts) {
2179:                Hashtable options = new Hashtable();
2180:                for (int i = 0; i < atts.getLength(); i++)
2181:                    options.put(atts.getQName(i), atts.getValue(i));
2182:                currentResultCacheRule.setCacheBehavior(ResultCacheFactory
2183:                        .getCacheBehaviorInstance(
2184:                                DatabasesXmlTags.ELT_EagerCaching, options));
2185:            }
2186:
2187:            /**
2188:             * Add a new <code>RelaxedCaching</code> behavior to the current
2189:             * <code>ResultCacheRule</code>.
2190:             * 
2191:             * @param atts parsed attributes
2192:             */
2193:            private void newRelaxedCaching(Attributes atts) {
2194:                Hashtable options = new Hashtable();
2195:                for (int i = 0; i < atts.getLength(); i++)
2196:                    options.put(atts.getQName(i), atts.getValue(i));
2197:                currentResultCacheRule.setCacheBehavior(ResultCacheFactory
2198:                        .getCacheBehaviorInstance(
2199:                                DatabasesXmlTags.ELT_RelaxedCaching, options));
2200:            }
2201:
2202:            /* Load balancers */
2203:
2204:            /**
2205:             * Get the transaction isolation level for the load balancer. This will be set
2206:             * at the end of the parsing of this element.
2207:             */
2208:            private void newLoadBalancer(Attributes atts) {
2209:                String transactionIsolation = atts
2210:                        .getValue(DatabasesXmlTags.ATT_transactionIsolation);
2211:
2212:                if (transactionIsolation
2213:                        .equals(DatabasesXmlTags.VAL_readUncommitted))
2214:                    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_UNCOMMITTED;
2215:                else if (transactionIsolation
2216:                        .equals(DatabasesXmlTags.VAL_readCommitted))
2217:                    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_READ_COMMITTED;
2218:                else if (transactionIsolation
2219:                        .equals(DatabasesXmlTags.VAL_repeatableRead))
2220:                    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_REPEATABLE_READ;
2221:                else if (transactionIsolation
2222:                        .equals(DatabasesXmlTags.VAL_serializable))
2223:                    defaultTransactionIsolation = java.sql.Connection.TRANSACTION_SERIALIZABLE;
2224:                else
2225:                    // if (transactionIsolation.equals(DatabasesXmlTags.VAL_databaseDefault))
2226:                    defaultTransactionIsolation = org.continuent.sequoia.driver.Connection.DEFAULT_TRANSACTION_ISOLATION_LEVEL;
2227:            }
2228:
2229:            /**
2230:             * Sets {@link #currentLoadBalancer}as a new <code> SingleDB</code> using
2231:             * the parsed attributes.
2232:             * 
2233:             * @exception SAXException if an error occurs
2234:             */
2235:            private void newSingleDBRequestLoadBalancer() throws SAXException {
2236:                if (logger.isDebugEnabled())
2237:                    logger
2238:                            .debug(Translate
2239:                                    .get("virtualdatabase.xml.loadbalancer.singledb.set"));
2240:
2241:                try {
2242:                    currentLoadBalancer = new SingleDB(currentVirtualDatabase);
2243:                } catch (Exception e) {
2244:                    String msg = Translate
2245:                            .get("virtualdatabase.xml.loadbalancer.singledb.failed");
2246:                    logger.error(msg, e);
2247:                    throw new SAXException(msg, e);
2248:                }
2249:            }
2250:
2251:            //
2252:            // ParallelDB load balancers
2253:            //
2254:
2255:            /**
2256:             * Sets {@link #currentLoadBalancer}as a new <code>ParallelDB_RR</code>
2257:             * using the parsed attributes.
2258:             * 
2259:             * @exception SAXException if an error occurs
2260:             */
2261:            private void newParallelDBLeastPendingRequestsFirst()
2262:                    throws SAXException {
2263:                if (logger.isDebugEnabled())
2264:                    logger
2265:                            .debug(Translate
2266:                                    .get("virtualdatabase.xml.loadbalancer.paralleldb_rr.set"));
2267:
2268:                try {
2269:                    currentLoadBalancer = new ParallelDB_RR(
2270:                            currentVirtualDatabase);
2271:                } catch (Exception e) {
2272:                    String msg = Translate
2273:                            .get("virtualdatabase.xml.loadbalancer.paralleldb_rr.failed");
2274:                    logger.error(msg, e);
2275:                    throw new SAXException(msg, e);
2276:                }
2277:            }
2278:
2279:            /**
2280:             * Sets {@link #currentLoadBalancer}as a new <code>ParallelDB_LPRF</code>
2281:             * using the parsed attributes.
2282:             * 
2283:             * @exception SAXException if an error occurs
2284:             */
2285:            private void newParallelDBRoundRobinLoadBalancer()
2286:                    throws SAXException {
2287:                if (logger.isDebugEnabled())
2288:                    logger
2289:                            .debug(Translate
2290:                                    .get("virtualdatabase.xml.loadbalancer.paralleldb_lprf.set"));
2291:
2292:                try {
2293:                    currentLoadBalancer = new ParallelDB_LPRF(
2294:                            currentVirtualDatabase);
2295:                } catch (Exception e) {
2296:                    String msg = Translate
2297:                            .get("virtualdatabase.xml.loadbalancer.paralleldb_lprf.failed");
2298:                    logger.error(msg, e);
2299:                    throw new SAXException(msg, e);
2300:                }
2301:            }
2302:
2303:            //
2304:            // RAIDb-0 load balancers
2305:            //
2306:
2307:            /**
2308:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb0</code> using the
2309:             * parsed attributes.
2310:             */
2311:            private void newRAIDb0LoadBalancer() {
2312:                currentCreateTablePolicy = new CreateTablePolicy();
2313:                currentCreateTableRule = null;
2314:            }
2315:
2316:            //
2317:            // RAIDb-1 load balancers
2318:            //
2319:
2320:            /**
2321:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1</code> using the
2322:             * parsed attributes.
2323:             */
2324:            private void newRAIDb1LoadBalancer() {
2325:                currentWaitForCompletionPolicy = DEFAULT_WAIT_FOR_ALL_COMPLETION;
2326:            }
2327:
2328:            /**
2329:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1_RR</code> using
2330:             * the parsed attributes.
2331:             * 
2332:             * @exception SAXException if an error occurs
2333:             */
2334:            private void newRAIDb1RoundRobinLoadBalancer() throws SAXException {
2335:                if (logger.isDebugEnabled()) {
2336:                    logger
2337:                            .debug(Translate
2338:                                    .get("virtualdatabase.xml.loadbalancer.raidb1_rr.set"));
2339:                    logger
2340:                            .debug(Translate
2341:                                    .get(
2342:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2343:                                            currentWaitForCompletionPolicy
2344:                                                    .getInformation()));
2345:                }
2346:
2347:                try {
2348:                    currentLoadBalancer = new RAIDb1_RR(currentVirtualDatabase,
2349:                            currentWaitForCompletionPolicy);
2350:                } catch (Exception e) {
2351:                    String msg = Translate
2352:                            .get("virtualdatabase.xml.loadbalancer.raidb1_rr.failed");
2353:                    logger.error(msg, e);
2354:                    throw new SAXException(msg, e);
2355:                }
2356:            }
2357:
2358:            /**
2359:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1_WRR</code> using
2360:             * the parsed attributes.
2361:             * 
2362:             * @exception SAXException if an error occurs
2363:             */
2364:            private void newRAIDb1WeightedRoundRobinLoadBalancer()
2365:                    throws SAXException {
2366:                if (logger.isDebugEnabled()) {
2367:                    logger
2368:                            .debug(Translate
2369:                                    .get("virtualdatabase.xml.loadbalancer.raidb1_wrr.set"));
2370:                    logger
2371:                            .debug(Translate
2372:                                    .get(
2373:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2374:                                            currentWaitForCompletionPolicy
2375:                                                    .getInformation()));
2376:                }
2377:
2378:                try {
2379:                    currentLoadBalancer = new RAIDb1_WRR(
2380:                            currentVirtualDatabase,
2381:                            currentWaitForCompletionPolicy);
2382:                } catch (Exception e) {
2383:                    String msg = Translate
2384:                            .get("virtualdatabase.xml.loadbalancer.raidb1_wrr.failed");
2385:                    logger.error(msg, e);
2386:                    throw new SAXException(msg, e);
2387:                }
2388:            }
2389:
2390:            /**
2391:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1_LPRF</code> using
2392:             * the parsed attributes.
2393:             * 
2394:             * @exception SAXException if an error occurs
2395:             */
2396:            private void newRAIDb1LeastPendingRequestsFirst()
2397:                    throws SAXException {
2398:                if (logger.isDebugEnabled()) {
2399:                    logger
2400:                            .debug(Translate
2401:                                    .get("virtualdatabase.xml.loadbalancer.raidb1_lprf.set"));
2402:                    logger
2403:                            .debug(Translate
2404:                                    .get(
2405:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2406:                                            currentWaitForCompletionPolicy
2407:                                                    .getInformation()));
2408:                }
2409:
2410:                try {
2411:                    currentLoadBalancer = new RAIDb1_LPRF(
2412:                            currentVirtualDatabase,
2413:                            currentWaitForCompletionPolicy);
2414:                } catch (Exception e) {
2415:                    String msg = Translate
2416:                            .get("virtualdatabase.xml.loadbalancer.raidb1_lprf.failed");
2417:                    logger.error(msg, e);
2418:                    throw new SAXException(msg, e);
2419:                }
2420:            }
2421:
2422:            //
2423:            // RAIDb-1ec load balancers
2424:            //
2425:
2426:            /**
2427:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1ec</code> using
2428:             * the parsed attributes.
2429:             * 
2430:             * @param atts parsed attributes
2431:             */
2432:            private void newRAIDb1ecLoadBalancer(Attributes atts) {
2433:                String nbOfConcurrentReads = atts
2434:                        .getValue(DatabasesXmlTags.ATT_nbOfConcurrentReads);
2435:                currentNbOfConcurrentReads = Integer
2436:                        .parseInt(nbOfConcurrentReads);
2437:                currentErrorCheckingPolicy = null;
2438:                currentWaitForCompletionPolicy = DEFAULT_WAIT_FOR_ALL_COMPLETION;
2439:            }
2440:
2441:            /**
2442:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1ec_RR</code> using
2443:             * the parsed attributes.
2444:             * 
2445:             * @exception SAXException if an error occurs
2446:             */
2447:            private void newRAIDb1ecRoundRobinLoadBalancer()
2448:                    throws SAXException {
2449:                if (logger.isDebugEnabled()) {
2450:                    logger
2451:                            .debug(Translate
2452:                                    .get("virtualdatabase.xml.loadbalancer.raidb1ec_rr.set"));
2453:                    logger
2454:                            .debug(Translate
2455:                                    .get(
2456:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2457:                                            currentWaitForCompletionPolicy
2458:                                                    .getInformation()));
2459:                }
2460:
2461:                try {
2462:                    currentLoadBalancer = new RAIDb1ec_RR(
2463:                            currentVirtualDatabase,
2464:                            currentWaitForCompletionPolicy,
2465:                            currentErrorCheckingPolicy,
2466:                            currentNbOfConcurrentReads);
2467:                    if (logger.isDebugEnabled())
2468:                        logger
2469:                                .debug(Translate
2470:                                        .get(
2471:                                                "virtualdatabase.xml.loadbalancer.errorchecking.policy",
2472:                                                currentErrorCheckingPolicy
2473:                                                        .getInformation()));
2474:                } catch (Exception e) {
2475:                    String msg = Translate
2476:                            .get("virtualdatabase.xml.loadbalancer.raidb1ec_rr.failed");
2477:                    logger.error(msg, e);
2478:                    throw new SAXException(msg, e);
2479:                }
2480:            }
2481:
2482:            /**
2483:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb1ec_WRR</code>
2484:             * using the parsed attributes.
2485:             * 
2486:             * @exception SAXException if an error occurs
2487:             */
2488:            private void newRAIDb1ecWeightedRoundRobinLoadBalancer()
2489:                    throws SAXException {
2490:                if (logger.isDebugEnabled()) {
2491:                    logger
2492:                            .debug(Translate
2493:                                    .get("virtualdatabase.xml.loadbalancer.raidb1ec_wrr.set"));
2494:                    logger
2495:                            .debug(Translate
2496:                                    .get(
2497:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2498:                                            currentWaitForCompletionPolicy
2499:                                                    .getInformation()));
2500:                }
2501:
2502:                try {
2503:                    currentLoadBalancer = new RAIDb1ec_WRR(
2504:                            currentVirtualDatabase,
2505:                            currentWaitForCompletionPolicy,
2506:                            currentErrorCheckingPolicy,
2507:                            currentNbOfConcurrentReads);
2508:                    if (logger.isDebugEnabled())
2509:                        logger
2510:                                .debug(Translate
2511:                                        .get(
2512:                                                "virtualdatabase.xml.loadbalancer.errorchecking.policy",
2513:                                                currentErrorCheckingPolicy
2514:                                                        .getInformation()));
2515:                } catch (Exception e) {
2516:                    String msg = Translate
2517:                            .get("virtualdatabase.xml.loadbalancer.raidb1ec_wrr.failed");
2518:                    logger.error(msg, e);
2519:                    throw new SAXException(msg, e);
2520:                }
2521:            }
2522:
2523:            //
2524:            // RAIDb-2 load balancers
2525:            //
2526:
2527:            /**
2528:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2</code> using the
2529:             * parsed attributes.
2530:             */
2531:            private void newRAIDb2LoadBalancer() {
2532:                currentWaitForCompletionPolicy = DEFAULT_WAIT_FOR_ALL_COMPLETION;
2533:                currentCreateTablePolicy = new CreateTablePolicy();
2534:                // Add a default rule to create table on all nodes
2535:                currentCreateTablePolicy.addRule(new CreateTableAll());
2536:                currentCreateTableRule = null;
2537:            }
2538:
2539:            /**
2540:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2_RR</code> using
2541:             * the parsed attributes.
2542:             * 
2543:             * @exception SAXException if an error occurs
2544:             */
2545:            private void newRAIDb2RoundRobinLoadBalancer() throws SAXException {
2546:                if (logger.isDebugEnabled()) {
2547:                    logger
2548:                            .debug(Translate
2549:                                    .get("virtualdatabase.xml.loadbalancer.raidb2_rr.set"));
2550:                    logger
2551:                            .debug(Translate
2552:                                    .get(
2553:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2554:                                            currentWaitForCompletionPolicy
2555:                                                    .getInformation()));
2556:                }
2557:
2558:                try {
2559:                    currentLoadBalancer = new RAIDb2_RR(currentVirtualDatabase,
2560:                            currentWaitForCompletionPolicy,
2561:                            currentCreateTablePolicy);
2562:                } catch (Exception e) {
2563:                    String msg = Translate
2564:                            .get("virtualdatabase.xml.loadbalancer.raidb2_rr.failed");
2565:                    logger.error(msg, e);
2566:                    throw new SAXException(msg, e);
2567:                }
2568:            }
2569:
2570:            /**
2571:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2_WRR</code> using
2572:             * the parsed attributes.
2573:             * 
2574:             * @exception SAXException if an error occurs
2575:             */
2576:            private void newRAIDb2WeightedRoundRobinLoadBalancer()
2577:                    throws SAXException {
2578:                if (logger.isDebugEnabled()) {
2579:                    logger
2580:                            .debug(Translate
2581:                                    .get("virtualdatabase.xml.loadbalancer.raidb2_wrr.set"));
2582:                    logger
2583:                            .debug(Translate
2584:                                    .get(
2585:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2586:                                            currentWaitForCompletionPolicy
2587:                                                    .getInformation()));
2588:                }
2589:
2590:                try {
2591:                    currentLoadBalancer = new RAIDb2_WRR(
2592:                            currentVirtualDatabase,
2593:                            currentWaitForCompletionPolicy,
2594:                            currentCreateTablePolicy);
2595:                } catch (Exception e) {
2596:                    String msg = Translate
2597:                            .get("virtualdatabase.xml.loadbalancer.raidb2_wrr.failed");
2598:                    logger.error(msg, e);
2599:                    throw new SAXException(msg, e);
2600:                }
2601:            }
2602:
2603:            /**
2604:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2_LPRF</code> using
2605:             * the parsed attributes.
2606:             * 
2607:             * @exception SAXException if an error occurs
2608:             */
2609:            private void newRAIDb2LeastPendingRequestsFirst()
2610:                    throws SAXException {
2611:                if (logger.isDebugEnabled()) {
2612:                    logger
2613:                            .debug(Translate
2614:                                    .get("virtualdatabase.xml.loadbalancer.raidb2_lprf.set"));
2615:                    logger
2616:                            .debug(Translate
2617:                                    .get(
2618:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2619:                                            currentWaitForCompletionPolicy
2620:                                                    .getInformation()));
2621:                }
2622:
2623:                try {
2624:                    currentLoadBalancer = new RAIDb2_LPRF(
2625:                            currentVirtualDatabase,
2626:                            currentWaitForCompletionPolicy,
2627:                            currentCreateTablePolicy);
2628:                } catch (Exception e) {
2629:                    String msg = Translate
2630:                            .get("virtualdatabase.xml.loadbalancer.raidb2_lprf.failed");
2631:                    logger.error(msg, e);
2632:                    throw new SAXException(msg, e);
2633:                }
2634:            }
2635:
2636:            //
2637:            // RAIDb-2ec load balancers
2638:            //
2639:
2640:            /**
2641:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2ec</code> using
2642:             * the parsed attributes.
2643:             */
2644:            private void newRAIDb2ecLoadBalancer() {
2645:                currentErrorCheckingPolicy = null;
2646:                currentWaitForCompletionPolicy = DEFAULT_WAIT_FOR_ALL_COMPLETION;
2647:                currentCreateTablePolicy = new CreateTablePolicy();
2648:                currentCreateTableRule = null;
2649:            }
2650:
2651:            /**
2652:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2ec_RR</code> using
2653:             * the parsed attributes.
2654:             * 
2655:             * @exception SAXException if an error occurs
2656:             */
2657:            private void newRAIDb2ecRoundRobinLoadBalancer()
2658:                    throws SAXException {
2659:                if (logger.isDebugEnabled()) {
2660:                    logger
2661:                            .debug(Translate
2662:                                    .get("virtualdatabase.xml.loadbalancer.raidb2_rr.set"));
2663:                    logger
2664:                            .debug(Translate
2665:                                    .get(
2666:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2667:                                            currentWaitForCompletionPolicy
2668:                                                    .getInformation()));
2669:                }
2670:
2671:                try {
2672:                    currentLoadBalancer = new RAIDb2ec_RR(
2673:                            currentVirtualDatabase,
2674:                            currentWaitForCompletionPolicy,
2675:                            currentCreateTablePolicy,
2676:                            currentErrorCheckingPolicy,
2677:                            currentNbOfConcurrentReads);
2678:                    if (logger.isDebugEnabled())
2679:                        logger
2680:                                .debug(Translate
2681:                                        .get(
2682:                                                "virtualdatabase.xml.loadbalancer.errorchecking.policy",
2683:                                                currentErrorCheckingPolicy
2684:                                                        .getInformation()));
2685:                } catch (Exception e) {
2686:                    String msg = Translate
2687:                            .get("virtualdatabase.xml.loadbalancer.raidb2ec_rr.failed");
2688:                    logger.error(msg, e);
2689:                    throw new SAXException(msg, e);
2690:                }
2691:            }
2692:
2693:            /**
2694:             * Sets {@link #currentLoadBalancer}as a new <code> RAIDb2ec_WRR</code>
2695:             * using the parsed attributes.
2696:             * 
2697:             * @exception SAXException if an error occurs
2698:             */
2699:            private void newRAIDb2ecWeightedRoundRobinLoadBalancer()
2700:                    throws SAXException {
2701:                if (logger.isDebugEnabled()) {
2702:                    logger
2703:                            .debug(Translate
2704:                                    .get("virtualdatabase.xml.loadbalancer.raidb2_wrr.set"));
2705:                    logger
2706:                            .debug(Translate
2707:                                    .get(
2708:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.rule",
2709:                                            currentWaitForCompletionPolicy
2710:                                                    .getInformation()));
2711:                }
2712:
2713:                try {
2714:                    currentLoadBalancer = new RAIDb2ec_WRR(
2715:                            currentVirtualDatabase,
2716:                            currentWaitForCompletionPolicy,
2717:                            currentCreateTablePolicy,
2718:                            currentErrorCheckingPolicy,
2719:                            currentNbOfConcurrentReads);
2720:                    if (logger.isDebugEnabled())
2721:                        logger
2722:                                .debug(Translate
2723:                                        .get(
2724:                                                "virtualdatabase.xml.loadbalancer.errorchecking.policy",
2725:                                                currentErrorCheckingPolicy
2726:                                                        .getInformation()));
2727:                } catch (Exception e) {
2728:                    String msg = Translate
2729:                            .get("virtualdatabase.xml.loadbalancer.raidb2ec_wrr.failed");
2730:                    logger.error(msg, e);
2731:                    throw new SAXException(msg, e);
2732:                }
2733:            }
2734:
2735:            //
2736:            // Load balancer policies
2737:            //
2738:
2739:            /**
2740:             * Set the WaitForCompletion policy.
2741:             * 
2742:             * @param atts parsed attributes
2743:             * @exception SAXException if an error occurs
2744:             */
2745:            private void newWaitForCompletion(Attributes atts)
2746:                    throws SAXException {
2747:                String policy = atts.getValue(DatabasesXmlTags.ATT_policy);
2748:                String enforceTableLocking = atts
2749:                        .getValue(DatabasesXmlTags.ATT_enforceTableLocking);
2750:                String deadlockTimeoutInMsString = atts
2751:                        .getValue(DatabasesXmlTags.ATT_deadlockTimeoutInMs);
2752:                long deadlockTimeoutInMs;
2753:                try {
2754:                    deadlockTimeoutInMs = Long
2755:                            .parseLong(deadlockTimeoutInMsString);
2756:                } catch (Exception e) {
2757:                    String msg = Translate
2758:                            .get("virtualdatabase.xml.virtualdatabase.failed");
2759:                    logger.error(msg, e);
2760:                    throw new SAXException(msg, e);
2761:                }
2762:
2763:                if (policy.equals(DatabasesXmlTags.VAL_first))
2764:                    currentWaitForCompletionPolicy = new WaitForCompletionPolicy(
2765:                            WaitForCompletionPolicy.FIRST, "true"
2766:                                    .equals(enforceTableLocking),
2767:                            deadlockTimeoutInMs);
2768:                else if (policy.equals(DatabasesXmlTags.VAL_majority))
2769:                    currentWaitForCompletionPolicy = new WaitForCompletionPolicy(
2770:                            WaitForCompletionPolicy.MAJORITY, "true"
2771:                                    .equals(enforceTableLocking),
2772:                            deadlockTimeoutInMs);
2773:                else if (policy.equals(DatabasesXmlTags.VAL_all))
2774:                    currentWaitForCompletionPolicy = new WaitForCompletionPolicy(
2775:                            WaitForCompletionPolicy.ALL, "true"
2776:                                    .equals(enforceTableLocking),
2777:                            deadlockTimeoutInMs);
2778:                else
2779:                    throw new SAXException(
2780:                            Translate
2781:                                    .get(
2782:                                            "virtualdatabase.xml.loadbalancer.waitforcompletion.unsupported",
2783:                                            policy));
2784:            }
2785:
2786:            /**
2787:             * Add an ErrorChecking policy.
2788:             * 
2789:             * @param atts parsed attributes
2790:             * @exception SAXException if an error occurs
2791:             */
2792:            private void newErrorChecking(Attributes atts) throws SAXException {
2793:                String nbOfNodes = atts
2794:                        .getValue(DatabasesXmlTags.ATT_numberOfNodes);
2795:                String policy = atts.getValue(DatabasesXmlTags.ATT_policy);
2796:                if (policy.equals(DatabasesXmlTags.VAL_random))
2797:                    currentErrorCheckingPolicy = new ErrorCheckingRandom(
2798:                            Integer.parseInt(nbOfNodes));
2799:                else if (policy.equals(DatabasesXmlTags.VAL_roundRobin))
2800:                    currentErrorCheckingPolicy = new ErrorCheckingRoundRobin(
2801:                            Integer.parseInt(nbOfNodes));
2802:                else if (policy.equals(DatabasesXmlTags.VAL_all))
2803:                    currentErrorCheckingPolicy = new ErrorCheckingAll();
2804:                else
2805:                    throw new SAXException(
2806:                            Translate
2807:                                    .get(
2808:                                            "virtualdatabase.xml.loadbalancer.errorchecking.unsupported",
2809:                                            policy));
2810:            }
2811:
2812:            /**
2813:             * Add a CreateTable rule.
2814:             * 
2815:             * @param atts parsed attributes
2816:             * @exception SAXException if an error occurs
2817:             */
2818:            private void newCreateTable(Attributes atts) throws SAXException {
2819:                String tableName = atts
2820:                        .getValue(DatabasesXmlTags.ATT_tableName);
2821:                String nbOfNodes = atts
2822:                        .getValue(DatabasesXmlTags.ATT_numberOfNodes);
2823:                String policy = atts.getValue(DatabasesXmlTags.ATT_policy);
2824:                backendNameList = new ArrayList();
2825:                if (policy.equals(DatabasesXmlTags.VAL_random))
2826:                    currentCreateTableRule = new CreateTableRandom(
2827:                            backendNameList);
2828:                else if (policy.equals(DatabasesXmlTags.VAL_roundRobin))
2829:                    currentCreateTableRule = new CreateTableRoundRobin(
2830:                            backendNameList);
2831:                else if (policy.equals(DatabasesXmlTags.VAL_all))
2832:                    currentCreateTableRule = new CreateTableAll(backendNameList);
2833:                else
2834:                    throw new SAXException(Translate.get(
2835:                            "virtualdatabase.xml.create.table.unsupported",
2836:                            policy));
2837:
2838:                currentCreateTableRule.setNumberOfNodes(Integer
2839:                        .parseInt(nbOfNodes));
2840:                currentCreateTableRule.setTableName(tableName);
2841:            }
2842:
2843:            /**
2844:             * Adds a backend name to the current backendNameList.
2845:             * 
2846:             * @param atts parsed attributes
2847:             */
2848:            private void newBackendName(Attributes atts) {
2849:                String name = atts.getValue(DatabasesXmlTags.ATT_name);
2850:                if (logger.isDebugEnabled())
2851:                    logger.debug(Translate.get(
2852:                            "virtualdatabase.xml.backend.policy.add", name));
2853:                backendNameList.add(name);
2854:            }
2855:
2856:            /**
2857:             * Sets the weight of the {@link #currentLoadBalancer}using the parsed
2858:             * attributes.
2859:             * 
2860:             * @param atts parsed attributes
2861:             * @exception SAXException if an error occurs
2862:             */
2863:            private void newBackendWeight(Attributes atts) throws SAXException {
2864:                String name = atts.getValue(DatabasesXmlTags.ATT_name);
2865:                try {
2866:                    int weight = Integer.parseInt(atts
2867:                            .getValue(DatabasesXmlTags.ATT_weight));
2868:
2869:                    if (logger.isDebugEnabled())
2870:                        logger.debug(Translate.get(
2871:                                "virtualdatabase.xml.backend.weigth.set",
2872:                                new String[] { String.valueOf(weight), name }));
2873:
2874:                    currentLoadBalancer.setWeight(name, weight);
2875:                } catch (Exception e) {
2876:                    String msg = Translate.get(
2877:                            "virtualdatabase.xml.backend.weigth.failed", name);
2878:                    logger.error(msg, e);
2879:                    throw new SAXException(msg, e);
2880:                }
2881:            }
2882:
2883:            /* Log recovery */
2884:
2885:            /**
2886:             * Sets the currentRecoveryLog as new <code>RecoveryLog</code> using the
2887:             * parsed attributes.
2888:             * 
2889:             * @param atts parsed attributes
2890:             * @exception SAXException if an error occurs
2891:             */
2892:            private void newRecoveryLog(Attributes atts) throws SAXException {
2893:                try {
2894:                    String driverClassName = atts
2895:                            .getValue(DatabasesXmlTags.ATT_driver);
2896:                    String driverPath = atts
2897:                            .getValue(DatabasesXmlTags.ATT_driverPath);
2898:                    String url = atts.getValue(DatabasesXmlTags.ATT_url);
2899:                    String login = atts.getValue(DatabasesXmlTags.ATT_login);
2900:                    String password = atts
2901:                            .getValue(DatabasesXmlTags.ATT_password);
2902:                    String timeout = atts
2903:                            .getValue(DatabasesXmlTags.ATT_requestTimeout);
2904:                    int recoveryBatchSize = Integer.parseInt(atts
2905:                            .getValue(DatabasesXmlTags.ATT_recoveryBatchSize));
2906:                    // Convert to ms
2907:                    requestTimeout = Integer.parseInt(timeout) * 1000;
2908:
2909:                    if (logger.isDebugEnabled())
2910:                        logger.debug(Translate.get(
2911:                                "virtualdatabase.xml.recoverylog.jdbc.create",
2912:                                new String[] { driverClassName, url, login,
2913:                                        password,
2914:                                        String.valueOf(requestTimeout) }));
2915:
2916:                    currentRecoveryLog = new RecoveryLog(driverPath,
2917:                            driverClassName, url, login, password,
2918:                            requestTimeout, recoveryBatchSize);
2919:                    // currentRecoveryLog.setBackendTableCreateStatement();
2920:
2921:                    String attr;
2922:                    attr = atts.getValue("idleConnectionTimeout");
2923:                    if (attr != null) {
2924:                        logger
2925:                                .info("Setting recoverylog idleConnectionTimeout="
2926:                                        + attr);
2927:                        try {
2928:                            currentRecoveryLog.setAutoCloseTimeout(Integer
2929:                                    .parseInt(attr));
2930:                        } catch (Exception e) {
2931:                            logger.error(e.getMessage());
2932:                        }
2933:                    }
2934:
2935:                    attr = atts.getValue("checkConnectionValidity");
2936:                    if (attr != null && !"".equals(attr)) {
2937:                        logger
2938:                                .info("Enabling recoverylog ConnectionValidity check.");
2939:                        currentRecoveryLog.setCheckConnectionValidity();
2940:                    }
2941:
2942:                } catch (Exception e) {
2943:                    String msg = Translate
2944:                            .get("virtualdatabase.xml.recoverylog.jdbc.failed");
2945:                    logger.error(msg, e);
2946:                    throw new SAXException(msg, e);
2947:                }
2948:            }
2949:
2950:            /**
2951:             * Sets the recovery log table create statement for the current
2952:             * <code>RecoveryLog</code> using the <code>RecoveryLogTable</code> parsed
2953:             * attributes.
2954:             * 
2955:             * @param atts parsed attributes
2956:             * @exception SAXException if an error occurs
2957:             */
2958:            private void newRecoveryLogTable(Attributes atts)
2959:                    throws SAXException {
2960:                try {
2961:                    String createTable = atts
2962:                            .getValue(DatabasesXmlTags.ATT_createTable);
2963:                    String tableName = atts
2964:                            .getValue(DatabasesXmlTags.ATT_tableName);
2965:                    String idType = atts
2966:                            .getValue(DatabasesXmlTags.ATT_logIdColumnType);
2967:                    String vloginType = atts
2968:                            .getValue(DatabasesXmlTags.ATT_vloginColumnType);
2969:                    String sqlName = atts
2970:                            .getValue(DatabasesXmlTags.ATT_sqlColumnName);
2971:                    String sqlType = atts
2972:                            .getValue(DatabasesXmlTags.ATT_sqlColumnType);
2973:                    String sqlParamType = atts
2974:                            .getValue(DatabasesXmlTags.ATT_sqlParamColumnType);
2975:                    String autoConnTrans = atts
2976:                            .getValue(DatabasesXmlTags.ATT_autoConnTranColumnType);
2977:                    String transactionIdType = atts
2978:                            .getValue(DatabasesXmlTags.ATT_transactionIdColumnType);
2979:                    String requestIdColumnType = atts
2980:                            .getValue(DatabasesXmlTags.ATT_requestIdColumnType);
2981:                    String execTimeColumnType = atts
2982:                            .getValue(DatabasesXmlTags.ATT_execTimeColumnType);
2983:                    String updateCountColumnType = atts
2984:                            .getValue(DatabasesXmlTags.ATT_updateCountColumnType);
2985:                    String extraStatement = atts
2986:                            .getValue(DatabasesXmlTags.ATT_extraStatementDefinition);
2987:
2988:                    if (idType == null)
2989:                        throw new SAXException(
2990:                                "Invalid null column type for logId column");
2991:                    if (vloginType == null)
2992:                        throw new SAXException(
2993:                                "Invalid null column type for vlogin column");
2994:                    if (sqlType == null)
2995:                        throw new SAXException(
2996:                                "Invalid null column type for sql column");
2997:                    if (sqlParamType == null)
2998:                        throw new SAXException(
2999:                                "Invalid null column type for sql_param column");
3000:                    if (transactionIdType == null)
3001:                        throw new SAXException(
3002:                                "Invalid null column type for transaction_id column");
3003:                    if (requestIdColumnType == null)
3004:                        throw new SAXException(
3005:                                "Invalid null column type for request_id column");
3006:                    if (execTimeColumnType == null)
3007:                        throw new SAXException(
3008:                                "Invalid null column type for exec_time column");
3009:                    if (updateCountColumnType == null)
3010:                        throw new SAXException(
3011:                                "Invalid null column type for udpate_count column");
3012:
3013:                    if (currentRecoveryLog == null) {
3014:                        String msg = Translate
3015:                                .get("virtualdatabase.xml.recoverylog.jdbc.recoverytable.setnull");
3016:                        logger.error(msg);
3017:                        throw new SAXException(msg);
3018:                    } else
3019:                        currentRecoveryLog.setLogTableCreateStatement(
3020:                                createTable, tableName, idType, vloginType,
3021:                                sqlName, sqlType, sqlParamType, autoConnTrans,
3022:                                transactionIdType, requestIdColumnType,
3023:                                execTimeColumnType, updateCountColumnType,
3024:                                extraStatement);
3025:                } catch (Exception e) {
3026:                    String msg = Translate
3027:                            .get("virtualdatabase.xml.recoverylog.jdbc.recoverytable.failed");
3028:                    logger.error(msg, e);
3029:                    throw new SAXException(msg, e);
3030:                }
3031:            }
3032:
3033:            /**
3034:             * Sets the checkpoint table create statement for the current
3035:             * <code>RecoveryLog</code> using the <code>CheckpointTable</code> parsed
3036:             * attributes.
3037:             * 
3038:             * @param atts parsed attributes
3039:             * @exception SAXException if an error occurs
3040:             */
3041:            private void newRecoveryCheckpointTable(Attributes atts)
3042:                    throws SAXException {
3043:                try {
3044:                    String createTable = atts
3045:                            .getValue(DatabasesXmlTags.ATT_createTable);
3046:                    String tableName = atts
3047:                            .getValue(DatabasesXmlTags.ATT_tableName);
3048:                    String nameType = atts
3049:                            .getValue(DatabasesXmlTags.ATT_checkpointNameColumnType);
3050:                    String logIdType = atts
3051:                            .getValue(DatabasesXmlTags.ATT_logIdColumnType);
3052:                    String extraStatement = atts
3053:                            .getValue(DatabasesXmlTags.ATT_extraStatementDefinition);
3054:
3055:                    if (currentRecoveryLog == null) {
3056:                        String msg = Translate
3057:                                .get("virtualdatabase.xml.recoverylog.jdbc.checkpointtable.setnull");
3058:                        logger.error(msg);
3059:                        throw new SAXException(msg);
3060:                    } else
3061:                        currentRecoveryLog.setCheckpointTableCreateStatement(
3062:                                createTable, tableName, nameType, logIdType,
3063:                                extraStatement);
3064:                } catch (Exception e) {
3065:                    String msg = Translate
3066:                            .get("virtualdatabase.xml.recoverylog.jdbc.checkpointtable.failed");
3067:                    logger.error(msg, e);
3068:                    throw new SAXException(msg, e);
3069:                }
3070:            }
3071:
3072:            /**
3073:             * Sets the backend table create statement for the current
3074:             * <code>RecoveryLog</code> using the <code>BackendTable</code> parsed
3075:             * attributes.
3076:             * 
3077:             * @param atts parsed attributes
3078:             * @exception SAXException if an error occurs
3079:             */
3080:            private void newRecoveryBackendTable(Attributes atts)
3081:                    throws SAXException {
3082:                try {
3083:                    String createTable = atts
3084:                            .getValue(DatabasesXmlTags.ATT_createTable);
3085:                    String tableName = atts
3086:                            .getValue(DatabasesXmlTags.ATT_tableName);
3087:                    String checkpointNameType = atts
3088:                            .getValue(DatabasesXmlTags.ATT_checkpointNameColumnType);
3089:                    String databaseNameType = atts
3090:                            .getValue(DatabasesXmlTags.ATT_databaseNameColumnType);
3091:                    String backendNameType = atts
3092:                            .getValue(DatabasesXmlTags.ATT_backendNameColumnType);
3093:                    String backendStateType = atts
3094:                            .getValue(DatabasesXmlTags.ATT_backendStateColumnType);
3095:                    String extraStatement = atts
3096:                            .getValue(DatabasesXmlTags.ATT_extraStatementDefinition);
3097:
3098:                    if (currentRecoveryLog == null) {
3099:                        String msg = Translate
3100:                                .get("virtualdatabase.xml.recoverylog.jdbc.backendtable.setnull");
3101:                        logger.error(msg);
3102:                        throw new SAXException(msg);
3103:                    } else
3104:                        currentRecoveryLog.setBackendTableCreateStatement(
3105:                                createTable, tableName, checkpointNameType,
3106:                                backendNameType, backendStateType,
3107:                                databaseNameType, extraStatement);
3108:                } catch (Exception e) {
3109:                    String msg = Translate
3110:                            .get("virtualdatabase.xml.recoverylog.jdbc.backendtable.failed");
3111:                    logger.error(msg, e);
3112:                    throw new SAXException(msg, e);
3113:                }
3114:            }
3115:
3116:            /**
3117:             * Sets the dump table create statement for the current
3118:             * <code>RecoveryLog</code> using the <code>DumpTable</code> parsed
3119:             * attributes.
3120:             * 
3121:             * @param atts parsed attributes
3122:             * @exception SAXException if an error occurs
3123:             */
3124:            private void newRecoveryDumpTable(Attributes atts)
3125:                    throws SAXException {
3126:                try {
3127:                    String createTable = atts
3128:                            .getValue(DatabasesXmlTags.ATT_createTable);
3129:                    String tableName = atts
3130:                            .getValue(DatabasesXmlTags.ATT_tableName);
3131:                    String dumpNameColumnType = atts
3132:                            .getValue(DatabasesXmlTags.ATT_dumpNameColumnType);
3133:                    String dumpDateColumnType = atts
3134:                            .getValue(DatabasesXmlTags.ATT_dumpDateColumnType);
3135:                    String dumpPathColumnType = atts
3136:                            .getValue(DatabasesXmlTags.ATT_dumpPathColumnType);
3137:                    String dumpTypeColumnType = atts
3138:                            .getValue(DatabasesXmlTags.ATT_dumpFormatColumnType);
3139:                    String checkpointNameColumnType = atts
3140:                            .getValue(DatabasesXmlTags.ATT_checkpointNameColumnType);
3141:                    String backendNameColumnType = atts
3142:                            .getValue(DatabasesXmlTags.ATT_backendNameColumnType);
3143:                    String tablesColumnName = atts
3144:                            .getValue(DatabasesXmlTags.ATT_tablesColumnName);
3145:                    String tablesColumnType = atts
3146:                            .getValue(DatabasesXmlTags.ATT_tablesColumnType);
3147:
3148:                    String extraStatement = atts
3149:                            .getValue(DatabasesXmlTags.ATT_extraStatementDefinition);
3150:
3151:                    if (currentRecoveryLog == null) {
3152:                        String msg = Translate
3153:                                .get("virtualdatabase.xml.recoverylog.jdbc.dumptable.setnull");
3154:                        logger.error(msg);
3155:                        throw new SAXException(msg);
3156:                    } else
3157:                        currentRecoveryLog.setDumpTableCreateStatement(
3158:                                createTable, tableName, dumpNameColumnType,
3159:                                dumpDateColumnType, dumpPathColumnType,
3160:                                dumpTypeColumnType, checkpointNameColumnType,
3161:                                backendNameColumnType, tablesColumnName,
3162:                                tablesColumnType, extraStatement);
3163:                } catch (Exception e) {
3164:                    String msg = Translate
3165:                            .get("virtualdatabase.xml.recoverylog.jdbc.dumptable.failed");
3166:                    logger.error(msg, e);
3167:                    throw new SAXException(msg, e);
3168:                }
3169:            }
3170:
3171:            /* Connection manager */
3172:
3173:            /**
3174:             * Sets the currentRecoveryLog as new <code>RecoveryLog</code> using the
3175:             * parsed attributes.
3176:             * 
3177:             * @param atts parsed attributes
3178:             * @exception SAXException if an error occurs
3179:             */
3180:            private void newConnectionManager(Attributes atts)
3181:                    throws SAXException {
3182:                settingDefaultConnectionManager = false;
3183:                connectionManagerVLogin = atts
3184:                        .getValue(DatabasesXmlTags.ATT_vLogin);
3185:                String connectionManagerRLogin = atts
3186:                        .getValue(DatabasesXmlTags.ATT_rLogin);
3187:                String connectionManagerRPassword = atts
3188:                        .getValue(DatabasesXmlTags.ATT_rPassword);
3189:                String backendName = currentBackend.getName();
3190:
3191:                // Check that the virtual login has been defined
3192:                if (!currentAuthenticationManager
3193:                        .isValidVirtualLogin(connectionManagerVLogin)) {
3194:                    String msg = Translate
3195:                            .get(
3196:                                    "virtualdatabase.xml.connectionmanager.vlogin.undefined",
3197:                                    new String[] { connectionManagerVLogin,
3198:                                            currentBackend.getName() });
3199:                    logger.error(msg);
3200:                    throw new SAXException(msg);
3201:                }
3202:
3203:                // If values are missing, we default to the virtual login/password
3204:                if (connectionManagerRLogin == null)
3205:                    connectionManagerRLogin = connectionManagerVLogin;
3206:                if (connectionManagerRPassword == null)
3207:                    connectionManagerRPassword = currentAuthenticationManager
3208:                            .getVirtualPassword(connectionManagerVLogin);
3209:
3210:                // Add Real user for the database
3211:                currentDatabaseBackendUser = new DatabaseBackendUser(
3212:                        backendName, connectionManagerRLogin,
3213:                        connectionManagerRPassword);
3214:
3215:                if (logger.isDebugEnabled())
3216:                    logger
3217:                            .debug(Translate
3218:                                    .get(
3219:                                            "virtualdatabase.xml.authentication.login.real.add",
3220:                                            new String[] {
3221:                                                    connectionManagerRLogin,
3222:                                                    connectionManagerRPassword,
3223:                                                    backendName }));
3224:
3225:                try {
3226:                    currentAuthenticationManager
3227:                            .addRealUser(connectionManagerVLogin,
3228:                                    currentDatabaseBackendUser);
3229:                } catch (AuthenticationManagerException e) {
3230:                    String msg = Translate
3231:                            .get("virtualdatabase.xml.authentication.login.real.add.failed");
3232:                    logger.error(msg, e);
3233:                    throw new SAXException(msg, e);
3234:                }
3235:            }
3236:
3237:            /**
3238:             * TODO: newDefaultConnectionManager definition.
3239:             */
3240:            private void newDefaultConnectionManager() {
3241:                settingDefaultConnectionManager = true;
3242:            }
3243:
3244:            /**
3245:             * Adds a new <code>SimpleConnectionManager</code> to
3246:             * {@link #currentBackend}using the parsed attributes.
3247:             */
3248:            private void newSimpleConnectionManager() {
3249:                if (settingDefaultConnectionManager) {
3250:                    if (logger.isDebugEnabled()) {
3251:                        logger
3252:                                .debug("Setting a SimpleConnectionManager as default connection manager");
3253:                    }
3254:                    currentBackend
3255:                            .setDefaultConnectionManager(new SimpleConnectionManager(
3256:                                    currentBackend.getURL(), currentBackend
3257:                                            .getName(),
3258:                                    currentDatabaseBackendUser.getLogin(),
3259:                                    currentDatabaseBackendUser.getPassword(),
3260:                                    currentBackend.getDriverPath(),
3261:                                    currentBackend.getDriverClassName()));
3262:                } else {
3263:                    if (logger.isDebugEnabled())
3264:                        logger
3265:                                .debug(Translate
3266:                                        .get(
3267:                                                "virtualdatabase.xml.connectionmanager.simple.add",
3268:                                                new String[] {
3269:                                                        currentBackend
3270:                                                                .getName(),
3271:                                                        connectionManagerVLogin,
3272:                                                        currentDatabaseBackendUser
3273:                                                                .getLogin(),
3274:                                                        currentDatabaseBackendUser
3275:                                                                .getPassword() }));
3276:
3277:                    currentBackend.addConnectionManager(
3278:                            connectionManagerVLogin,
3279:                            new SimpleConnectionManager(
3280:                                    currentBackend.getURL(), currentBackend
3281:                                            .getName(),
3282:                                    currentDatabaseBackendUser.getLogin(),
3283:                                    currentDatabaseBackendUser.getPassword(),
3284:                                    currentBackend.getDriverPath(),
3285:                                    currentBackend.getDriverClassName()));
3286:                }
3287:            }
3288:
3289:            /**
3290:             * Adds a new <code>FailFastPoolConnectionManager</code> to
3291:             * {@link #currentBackend}using the parsed attributes.
3292:             * 
3293:             * @param atts parsed attributes
3294:             * @exception SAXException if an error occurs
3295:             */
3296:            private void newFailFastPoolConnectionManager(Attributes atts)
3297:                    throws SAXException {
3298:                try {
3299:                    int poolSize = Integer.parseInt(atts
3300:                            .getValue(DatabasesXmlTags.ATT_poolSize));
3301:
3302:                    // sanity check
3303:                    if (poolSize < 1)
3304:                        throw new IllegalArgumentException(
3305:                                Translate
3306:                                        .get("virtualdatabase.xml.connectionmanager.failfast.failed.parameter"));
3307:
3308:                    if (settingDefaultConnectionManager) {
3309:                        if (logger.isDebugEnabled()) {
3310:                            logger
3311:                                    .debug("Setting a FailFastPoolConnectionManager as default connection manager");
3312:                        }
3313:                        currentBackend
3314:                                .setDefaultConnectionManager(new FailFastPoolConnectionManager(
3315:                                        currentBackend.getURL(), currentBackend
3316:                                                .getName(),
3317:                                        currentDatabaseBackendUser.getLogin(),
3318:                                        currentDatabaseBackendUser
3319:                                                .getPassword(), currentBackend
3320:                                                .getDriverPath(),
3321:                                        currentBackend.getDriverClassName(),
3322:                                        poolSize));
3323:                    } else {
3324:                        if (logger.isDebugEnabled())
3325:                            logger
3326:                                    .debug(Translate
3327:                                            .get(
3328:                                                    "virtualdatabase.xml.connectionmanager.failfast.add",
3329:                                                    new String[] {
3330:                                                            currentBackend
3331:                                                                    .getName(),
3332:                                                            connectionManagerVLogin,
3333:                                                            String
3334:                                                                    .valueOf(poolSize),
3335:                                                            currentDatabaseBackendUser
3336:                                                                    .getLogin(),
3337:                                                            currentDatabaseBackendUser
3338:                                                                    .getPassword() }));
3339:
3340:                        currentBackend.addConnectionManager(
3341:                                connectionManagerVLogin,
3342:                                new FailFastPoolConnectionManager(
3343:                                        currentBackend.getURL(), currentBackend
3344:                                                .getName(),
3345:                                        currentDatabaseBackendUser.getLogin(),
3346:                                        currentDatabaseBackendUser
3347:                                                .getPassword(), currentBackend
3348:                                                .getDriverPath(),
3349:                                        currentBackend.getDriverClassName(),
3350:                                        poolSize));
3351:                    }
3352:                } catch (Exception e) {
3353:                    String msg = Translate
3354:                            .get(
3355:                                    "virtualdatabase.xml.connectionmanager.failfast.failed",
3356:                                    currentBackend.getName());
3357:                    logger.error(msg, e);
3358:                    throw new SAXException(msg, e);
3359:                }
3360:            }
3361:
3362:            /**
3363:             * Adds a new <code>RandomWaitPoolConnectionManager</code> to
3364:             * {@link #currentBackend}using the parsed attributes.
3365:             * 
3366:             * @param atts parsed attributes
3367:             * @exception SAXException if an error occurs
3368:             */
3369:            private void newRandomWaitPoolConnectionManager(Attributes atts)
3370:                    throws SAXException {
3371:                try {
3372:                    int poolSize = Integer.parseInt(atts
3373:                            .getValue(DatabasesXmlTags.ATT_poolSize));
3374:                    int timeout = Integer.parseInt(atts
3375:                            .getValue(DatabasesXmlTags.ATT_timeout));
3376:
3377:                    // sanity check
3378:                    if (timeout < 0 || poolSize < 1)
3379:                        throw new IllegalArgumentException(
3380:                                Translate
3381:                                        .get("virtualdatabase.xml.connectionmanager.randomwait.failed.parameter"));
3382:
3383:                    if (settingDefaultConnectionManager) {
3384:                        if (logger.isDebugEnabled()) {
3385:                            logger
3386:                                    .debug("Setting a RandomWaitPoolConnectionManager as default connection manager");
3387:                        }
3388:                        currentBackend
3389:                                .setDefaultConnectionManager(new RandomWaitPoolConnectionManager(
3390:                                        currentBackend.getURL(), currentBackend
3391:                                                .getName(),
3392:                                        currentDatabaseBackendUser.getLogin(),
3393:                                        currentDatabaseBackendUser
3394:                                                .getPassword(), currentBackend
3395:                                                .getDriverPath(),
3396:                                        currentBackend.getDriverClassName(),
3397:                                        poolSize, timeout));
3398:                    } else {
3399:                        if (logger.isDebugEnabled())
3400:                            logger
3401:                                    .debug(Translate
3402:                                            .get(
3403:                                                    "virtualdatabase.xml.connectionmanager.randomwait.add",
3404:                                                    new String[] {
3405:                                                            currentBackend
3406:                                                                    .getName(),
3407:                                                            connectionManagerVLogin,
3408:                                                            String
3409:                                                                    .valueOf(poolSize),
3410:                                                            String
3411:                                                                    .valueOf(timeout),
3412:                                                            currentDatabaseBackendUser
3413:                                                                    .getLogin(),
3414:                                                            currentDatabaseBackendUser
3415:                                                                    .getPassword() }));
3416:
3417:                        currentBackend.addConnectionManager(
3418:                                connectionManagerVLogin,
3419:                                new RandomWaitPoolConnectionManager(
3420:                                        currentBackend.getURL(), currentBackend
3421:                                                .getName(),
3422:                                        currentDatabaseBackendUser.getLogin(),
3423:                                        currentDatabaseBackendUser
3424:                                                .getPassword(), currentBackend
3425:                                                .getDriverPath(),
3426:                                        currentBackend.getDriverClassName(),
3427:                                        poolSize, timeout));
3428:                    }
3429:                } catch (Exception e) {
3430:                    String msg = Translate
3431:                            .get(
3432:                                    "virtualdatabase.xml.connectionmanager.randomwait.failed",
3433:                                    currentBackend.getName());
3434:                    logger.error(msg, e);
3435:                    throw new SAXException(msg, e);
3436:                }
3437:            }
3438:
3439:            /**
3440:             * Adds a new <code>VariablePoolConnectionManager</code> to
3441:             * {@link #currentBackend}using the parsed attributes.
3442:             * 
3443:             * @param atts parsed attributes
3444:             * @exception SAXException if an error occurs
3445:             */
3446:            private void newVariablePoolConnectionManager(Attributes atts)
3447:                    throws SAXException {
3448:                try {
3449:                    int initPoolSize = Integer.parseInt(atts
3450:                            .getValue(DatabasesXmlTags.ATT_initPoolSize));
3451:
3452:                    int minPoolSize = initPoolSize;
3453:                    // minPoolSize is IMPLIED and may be null
3454:                    String attr = atts
3455:                            .getValue(DatabasesXmlTags.ATT_minPoolSize);
3456:                    if (attr != null)
3457:                        minPoolSize = Integer.parseInt(attr);
3458:
3459:                    int maxPoolSize = Integer.parseInt(atts
3460:                            .getValue(DatabasesXmlTags.ATT_maxPoolSize));
3461:                    int idleTimeout = Integer.parseInt(atts
3462:                            .getValue(DatabasesXmlTags.ATT_idleTimeout));
3463:                    int waitTimeout = Integer.parseInt(atts
3464:                            .getValue(DatabasesXmlTags.ATT_waitTimeout));
3465:
3466:                    // sanity checks
3467:                    if (minPoolSize < 0 || maxPoolSize < 0
3468:                            || (maxPoolSize != 0 && minPoolSize > maxPoolSize)
3469:                            || (maxPoolSize != 0 && initPoolSize > maxPoolSize)
3470:                            || initPoolSize < minPoolSize)
3471:                        throw new IllegalArgumentException(
3472:                                Translate
3473:                                        .get("virtualdatabase.xml.connectionmanager.variable.failed.parameter"));
3474:
3475:                    if (settingDefaultConnectionManager) {
3476:                        if (logger.isDebugEnabled()) {
3477:                            logger
3478:                                    .debug("Setting a VariablePoolConnectionManager as default connection manager");
3479:                        }
3480:                        currentBackend
3481:                                .setDefaultConnectionManager(new VariablePoolConnectionManager(
3482:                                        currentBackend.getURL(), currentBackend
3483:                                                .getName(),
3484:                                        currentDatabaseBackendUser.getLogin(),
3485:                                        currentDatabaseBackendUser
3486:                                                .getPassword(), currentBackend
3487:                                                .getDriverPath(),
3488:                                        currentBackend.getDriverClassName(),
3489:                                        initPoolSize, minPoolSize, maxPoolSize,
3490:                                        idleTimeout, waitTimeout));
3491:                    } else {
3492:                        if (logger.isDebugEnabled())
3493:                            logger
3494:                                    .debug(Translate
3495:                                            .get(
3496:                                                    "virtualdatabase.xml.connectionmanager.randomwait.add",
3497:                                                    new String[] {
3498:                                                            currentBackend
3499:                                                                    .getName(),
3500:                                                            connectionManagerVLogin,
3501:                                                            String
3502:                                                                    .valueOf(initPoolSize),
3503:                                                            String
3504:                                                                    .valueOf(minPoolSize),
3505:                                                            String
3506:                                                                    .valueOf(maxPoolSize),
3507:                                                            String
3508:                                                                    .valueOf(idleTimeout),
3509:                                                            String
3510:                                                                    .valueOf(waitTimeout),
3511:                                                            currentDatabaseBackendUser
3512:                                                                    .getLogin(),
3513:                                                            currentDatabaseBackendUser
3514:                                                                    .getPassword() }));
3515:
3516:                        currentBackend.addConnectionManager(
3517:                                connectionManagerVLogin,
3518:                                new VariablePoolConnectionManager(
3519:                                        currentBackend.getURL(), currentBackend
3520:                                                .getName(),
3521:                                        currentDatabaseBackendUser.getLogin(),
3522:                                        currentDatabaseBackendUser
3523:                                                .getPassword(), currentBackend
3524:                                                .getDriverPath(),
3525:                                        currentBackend.getDriverClassName(),
3526:                                        initPoolSize, minPoolSize, maxPoolSize,
3527:                                        idleTimeout, waitTimeout));
3528:                    }
3529:                } catch (Exception e) {
3530:                    String msg = Translate
3531:                            .get(
3532:                                    "virtualdatabase.xml.connectionmanager.variable.failed",
3533:                                    currentBackend.getName());
3534:                    logger.error(msg, e);
3535:                    throw new SAXException(msg, e);
3536:                }
3537:            }
3538:
3539:            /* Database schema */
3540:
3541:            /**
3542:             * Sets {@link #currentTable}as a new <code> DatabaseTable</code> using the
3543:             * parsed attributs.
3544:             * 
3545:             * @param atts parsed attributes
3546:             * @exception SAXException if error occurs
3547:             */
3548:            private void newDatabaseTable(Attributes atts) throws SAXException {
3549:                String tableName = atts
3550:                        .getValue(DatabasesXmlTags.ATT_tableName);
3551:                String nbOfColumns = atts
3552:                        .getValue(DatabasesXmlTags.ATT_nbOfColumns);
3553:
3554:                if (logger.isDebugEnabled())
3555:                    logger.debug(Translate.get(
3556:                            "virtualdatabase.xml.schema.table.add",
3557:                            new String[] { tableName,
3558:                                    String.valueOf(nbOfColumns) }));
3559:
3560:                numberOfColumns = Integer.parseInt(nbOfColumns);
3561:
3562:                try {
3563:                    currentTable = new DatabaseTable(tableName, numberOfColumns);
3564:                } catch (NumberFormatException e) {
3565:                    String msg = Translate.get(
3566:                            "virtualdatabase.xml.schema.table.failed",
3567:                            tableName);
3568:                    logger.error(msg, e);
3569:                    throw new SAXException(msg, e);
3570:                }
3571:            }
3572:
3573:            /**
3574:             * Set the dynamic schema fetching options on the current backend.
3575:             * 
3576:             * @param atts parsed attributes
3577:             */
3578:            private void newDatabaseSchema(Attributes atts) {
3579:                String dynamicLevel = atts
3580:                        .getValue(DatabasesXmlTags.ATT_dynamicPrecision);
3581:                String gatherSystemTable = atts
3582:                        .getValue(DatabasesXmlTags.ATT_gatherSystemTables);
3583:                String schemaName = atts
3584:                        .getValue(DatabasesXmlTags.ATT_schemaName);
3585:
3586:                if (dynamicLevel == null)
3587:                    dynamicLevel = DatabasesXmlTags.VAL_all;
3588:                if (gatherSystemTable == null)
3589:                    gatherSystemTable = DatabasesXmlTags.VAL_false;
3590:                currentBackend.setDynamicPrecision(
3591:                        DatabaseBackendSchemaConstants
3592:                                .getDynamicSchemaLevel(dynamicLevel),
3593:                        DatabasesXmlTags.VAL_true.equals(gatherSystemTable),
3594:                        schemaName);
3595:            }
3596:
3597:            /**
3598:             * Set the default stored procedure semantic on the current backend.
3599:             * 
3600:             * @param atts parsed attributes
3601:             */
3602:            private void newDefaultStoredProcedureSemantic(Attributes atts) {
3603:                String writeTables = atts
3604:                        .getValue(DatabasesXmlTags.ATT_writeTables);
3605:                String hasSelect = atts
3606:                        .getValue(DatabasesXmlTags.ATT_hasSelect);
3607:                String hasInsert = atts
3608:                        .getValue(DatabasesXmlTags.ATT_hasInsert);
3609:                String hasUpdate = atts
3610:                        .getValue(DatabasesXmlTags.ATT_hasUpdate);
3611:                String hasDelete = atts
3612:                        .getValue(DatabasesXmlTags.ATT_hasDelete);
3613:                String hasDDL = atts.getValue(DatabasesXmlTags.ATT_hasDDL);
3614:                String hasTransaction = atts
3615:                        .getValue(DatabasesXmlTags.ATT_hasTransaction);
3616:                String isCausallyDependent = atts
3617:                        .getValue(DatabasesXmlTags.ATT_isCausallyDependent);
3618:                String isCommutative = atts
3619:                        .getValue(DatabasesXmlTags.ATT_isCommutative);
3620:
3621:                DatabaseProcedureSemantic defaultSemantic = new DatabaseProcedureSemantic(
3622:                        DatabasesXmlTags.VAL_true.equals(hasSelect),
3623:                        DatabasesXmlTags.VAL_true.equals(hasInsert),
3624:                        DatabasesXmlTags.VAL_true.equals(hasUpdate),
3625:                        DatabasesXmlTags.VAL_true.equals(hasDelete),
3626:                        DatabasesXmlTags.VAL_true.equals(hasDDL),
3627:                        DatabasesXmlTags.VAL_true.equals(hasTransaction),
3628:                        DatabasesXmlTags.VAL_true.equals(isCausallyDependent),
3629:                        DatabasesXmlTags.VAL_true.equals(isCommutative));
3630:                if (writeTables != null) {
3631:                    StringTokenizer st = new StringTokenizer(writeTables, ",");
3632:                    while (st.hasMoreTokens()) {
3633:                        defaultSemantic.addWriteTable(st.nextToken().trim());
3634:                    }
3635:                }
3636:                currentBackend
3637:                        .setDefaultStoredProcedureSemantic(defaultSemantic);
3638:            }
3639:
3640:            /**
3641:             * Set the default stored procedure semantic on the current backend.
3642:             * 
3643:             * @param atts parsed attributes
3644:             * @exception SAXException if error occurs
3645:             */
3646:            private void newStoredProcedureSemantic(Attributes atts)
3647:                    throws SAXException {
3648:                String procedureName = atts
3649:                        .getValue(DatabasesXmlTags.ATT_procedureName);
3650:                int parameterCount;
3651:                try {
3652:                    parameterCount = Integer.valueOf(
3653:                            atts.getValue(DatabasesXmlTags.ATT_parameterCount))
3654:                            .intValue();
3655:                } catch (NumberFormatException e) {
3656:                    parameterCount = -1;
3657:                }
3658:                if (parameterCount < 0)
3659:                    throw new SAXException(
3660:                            "Invalid parameter count for stored procedure semantic "
3661:                                    + procedureName);
3662:                String proceduresReferenced = atts
3663:                        .getValue(DatabasesXmlTags.ATT_proceduresReferenced);
3664:                String writeTables = atts
3665:                        .getValue(DatabasesXmlTags.ATT_writeTables);
3666:                String hasSelect = atts
3667:                        .getValue(DatabasesXmlTags.ATT_hasSelect);
3668:                String hasInsert = atts
3669:                        .getValue(DatabasesXmlTags.ATT_hasInsert);
3670:                String hasUpdate = atts
3671:                        .getValue(DatabasesXmlTags.ATT_hasUpdate);
3672:                String hasDelete = atts
3673:                        .getValue(DatabasesXmlTags.ATT_hasDelete);
3674:                String hasDDL = atts.getValue(DatabasesXmlTags.ATT_hasDDL);
3675:                String hasTransaction = atts
3676:                        .getValue(DatabasesXmlTags.ATT_hasTransaction);
3677:                String isCausallyDependent = atts
3678:                        .getValue(DatabasesXmlTags.ATT_isCausallyDependent);
3679:                String isCommutative = atts
3680:                        .getValue(DatabasesXmlTags.ATT_isCommutative);
3681:
3682:                DatabaseProcedureSemantic defaultSemantic = new DatabaseProcedureSemantic(
3683:                        DatabasesXmlTags.VAL_true.equals(hasSelect),
3684:                        DatabasesXmlTags.VAL_true.equals(hasInsert),
3685:                        DatabasesXmlTags.VAL_true.equals(hasUpdate),
3686:                        DatabasesXmlTags.VAL_true.equals(hasDelete),
3687:                        DatabasesXmlTags.VAL_true.equals(hasDDL),
3688:                        DatabasesXmlTags.VAL_true.equals(hasTransaction),
3689:                        DatabasesXmlTags.VAL_true.equals(isCausallyDependent),
3690:                        DatabasesXmlTags.VAL_true.equals(isCommutative));
3691:                if (writeTables != null) {
3692:                    StringTokenizer st = new StringTokenizer(writeTables, ",");
3693:                    while (st.hasMoreTokens()) {
3694:                        defaultSemantic.addWriteTable(st.nextToken().trim());
3695:                    }
3696:                }
3697:                if (proceduresReferenced != null) {
3698:                    StringTokenizer st = new StringTokenizer(
3699:                            proceduresReferenced, ",");
3700:                    while (st.hasMoreTokens()) {
3701:                        defaultSemantic.addProcedureRef(proceduresReferenced);
3702:                    }
3703:                }
3704:                currentBackend.addStoredProcedureSemantic(procedureName,
3705:                        parameterCount, defaultSemantic);
3706:            }
3707:
3708:            /**
3709:             * Adds to {@link #currentTable}a new <code> DatabaseColumn</code> using the
3710:             * parsed attributes.
3711:             * 
3712:             * @param atts parsed attributes
3713:             */
3714:            private void newDatabaseColumn(Attributes atts) {
3715:                String columnName = atts
3716:                        .getValue(DatabasesXmlTags.ATT_columnName);
3717:                String isUnique = atts.getValue(DatabasesXmlTags.ATT_isUnique);
3718:
3719:                if (logger.isDebugEnabled())
3720:                    logger.debug(Translate
3721:                            .get("virtualdatabase.xml.schema.column.add",
3722:                                    new String[] { columnName,
3723:                                            String.valueOf(isUnique) }));
3724:
3725:                currentTable.addColumn(new DatabaseColumn(columnName, isUnique
3726:                        .equals(DatabasesXmlTags.VAL_true)));
3727:            }
3728:
3729:            private void newDatabaseProcedure(Attributes atts) {
3730:                String procedureName = atts.getValue(DatabasesXmlTags.ATT_name);
3731:                String returnType = atts
3732:                        .getValue(DatabasesXmlTags.ATT_returnType);
3733:                if (logger.isDebugEnabled())
3734:                    logger.debug(Translate.get(
3735:                            "virtualdatabase.xml.schema.procedure.add",
3736:                            new String[] { procedureName, returnType }));
3737:
3738:                currentProcedure = new DatabaseProcedure(procedureName, "",
3739:                        DatabaseProcedure.getTypeFromString(returnType));
3740:            }
3741:
3742:            private void newDatabaseProcedureColumn(Attributes atts) {
3743:                String paramName = atts.getValue(DatabasesXmlTags.ATT_name);
3744:                String nullable = atts.getValue(DatabasesXmlTags.ATT_nullable);
3745:                String type = atts.getValue(DatabasesXmlTags.ATT_paramType);
3746:                if (logger.isDebugEnabled())
3747:                    logger
3748:                            .debug(Translate
3749:                                    .get(
3750:                                            "virtualdatabase.xml.schema.procedure.parameter.add",
3751:                                            new String[] { paramName, nullable,
3752:                                                    type }));
3753:                currentProcedure
3754:                        .addParameter(new DatabaseProcedureParameter(paramName,
3755:                                DatabaseProcedureParameter
3756:                                        .getColumnTypeFromString(type),
3757:                                DatabaseProcedureParameter
3758:                                        .getNullFromString(nullable)));
3759:            }
3760:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.