KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > ojb > broker > metadata > RepositoryXmlHandler


1 package org.apache.ojb.broker.metadata;
2
3 /* Copyright 2002-2005 The Apache Software Foundation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 import org.apache.ojb.broker.accesslayer.QueryCustomizer;
19 import org.apache.ojb.broker.locking.IsolationLevels;
20 import org.apache.ojb.broker.locking.LockHelper;
21 import org.apache.ojb.broker.metadata.fieldaccess.PersistentField;
22 import org.apache.ojb.broker.metadata.fieldaccess.PersistentFieldFactory;
23 import org.apache.ojb.broker.util.ClassHelper;
24 import org.apache.ojb.broker.util.logging.Logger;
25 import org.apache.ojb.broker.util.logging.LoggerFactory;
26 import org.xml.sax.Attributes JavaDoc;
27 import org.xml.sax.SAXException JavaDoc;
28 import org.xml.sax.SAXParseException JavaDoc;
29 import org.xml.sax.helpers.DefaultHandler JavaDoc;
30
31 /**
32  * The handler catches Parsing events raised by the xml-parser
33  * and builds up the DescriptorRepository that is used within the
34  * OJB PersistenceBroker System.
35  * <p>
36  * TODO: Reading of metadata are split in two classes {@link RepositoryXmlHandler} and
37  * {@link ConnectionDescriptorXmlHandler}. Thus we should only read relevant tags in this
38  * classes. In further versions we should split repository.dtd in two parts, one for connetion
39  * metadata, one for pc object metadata.
40  * </p>
41  * @author <a HREF="mailto:thma@apache.org">Thomas Mahler<a>
42  * @author Jakob Br?uchi
43  * @version $Id: RepositoryXmlHandler.java,v 1.58.2.10 2005/12/21 22:26:10 tomdz Exp $
44  */

45 public class RepositoryXmlHandler
46         extends DefaultHandler JavaDoc
47         implements RepositoryElements, IsolationLevels
48 {
49     private Logger logger = LoggerFactory.getLogger(RepositoryXmlHandler.class);
50
51     private DescriptorRepository m_repository;
52     private ClassDescriptor m_CurrentCLD;
53     private ProcedureDescriptor m_CurrentProcedure;
54     private FieldDescriptor m_CurrentFLD;
55     private ObjectReferenceDescriptor m_CurrentORD;
56     private CollectionDescriptor m_CurrentCOD;
57     private IndexDescriptor m_CurrentIndexDescriptor;
58     private String JavaDoc m_CurrentString;
59     /** holds custom attributes */
60     private AttributeContainer m_CurrentAttrContainer;
61     /** the default proxy prefetching limit*/
62     private int defProxyPrefetchingLimit = 50;
63     /**
64      * Allows not to specify field id
65      */

66     private int m_lastId;
67
68     /**
69      * All known xml tags are kept in this table.
70      * The tags table allows lookup from literal to id
71      * and from id to literal.
72      */

73     private RepositoryTags tags = RepositoryTags.getInstance();
74
75     /**
76      * returns the XmlCapable id associated with the literal.
77      * OJB maintains a RepositoryTags table that provides
78      * a mapping from xml-tags to XmlCapable ids.
79      * @param literal the literal to lookup
80      * @return the int value representing the XmlCapable
81      *
82      * @throws MetadataException if no literal was found in tags mapping
83      */

84     private int getLiteralId(String JavaDoc literal) throws MetadataException
85     {
86         //logger.debug("lookup: " + literal);
87
try
88         {
89             return tags.getIdByTag(literal);
90         }
91         catch (NullPointerException JavaDoc t)
92         {
93             throw new MetadataException("Found Unknown literal '" + literal +
94                     "' in the repository file. Check repository file or/and RepositoryTags.java", t);
95         }
96
97     }
98
99     /**
100      * build a handler that fills the given repository
101      * from an XML file.
102      */

103     public RepositoryXmlHandler(DescriptorRepository dr)
104     {
105         if (dr != null)
106         {
107             m_repository = dr;
108         }
109         else
110         {
111             throw new MetadataException("Given DescriptorRepository argument was null");
112         }
113     }
114
115     /**
116      * startDocument callback, nothing to do here.
117      */

118     public void startDocument()
119     {
120         logger.debug("startDoc");
121     }
122
123     /**
124      * endDocument callback, nothing to do here.
125      */

126     public void endDocument()
127     {
128         // arminw: no longer needed since SuperReferenceDescriptor was used
129
// AnonymousPersistentFieldHelper.computeInheritedPersistentFields(m_repository);
130
logger.debug("endDoc");
131     }
132
133     /**
134      * startElement callback.
135      * Only some Elements need special start operations.
136      * @throws MetadataException indicating mapping errors
137      */

138     public void startElement(String JavaDoc uri, String JavaDoc name, String JavaDoc qName, Attributes JavaDoc atts)
139     {
140         boolean isDebug = logger.isDebugEnabled();
141
142         m_CurrentString = null;
143         try
144         {
145             switch (getLiteralId(qName))
146             {
147                 case MAPPING_REPOSITORY:
148                     {
149                         if (isDebug) logger.debug(" > " + tags.getTagById(MAPPING_REPOSITORY));
150                         this.m_CurrentAttrContainer = m_repository;
151
152                         String JavaDoc defIso = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
153                         this.m_repository.setDefaultIsolationLevel(LockHelper.getIsolationLevelFor(defIso));
154                         if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + defIso);
155
156
157                         String JavaDoc proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
158                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
159                         if (proxyPrefetchingLimit != null)
160                         {
161                             defProxyPrefetchingLimit = Integer.parseInt(proxyPrefetchingLimit);
162                         }
163
164                         // check repository version:
165
String JavaDoc version = atts.getValue(tags.getTagById(REPOSITORY_VERSION));
166                         if (DescriptorRepository.getVersion().equals(version))
167                         {
168                             if (isDebug) logger.debug(" " + tags.getTagById(REPOSITORY_VERSION) + ": " + version);
169                         }
170                         else
171                         {
172                             throw new MetadataException("Repository version does not match. expected " +
173                                     DescriptorRepository.getVersion() + " but found: " +
174                                     version+". Please update your repository.dtd and your repository.xml"+
175                                     " version attribute entry");
176                         }
177                         break;
178                     }
179                 case CLASS_DESCRIPTOR:
180                     {
181                         if (isDebug) logger.debug(" > " + tags.getTagById(CLASS_DESCRIPTOR));
182                         m_CurrentCLD = new ClassDescriptor(m_repository);
183
184                         // prepare for custom attributes
185
this.m_CurrentAttrContainer = this.m_CurrentCLD;
186
187                         // set isolation-level attribute
188
String JavaDoc isoLevel = atts.getValue(tags.getTagById(ISOLATION_LEVEL));
189                         if (isDebug) logger.debug(" " + tags.getTagById(ISOLATION_LEVEL) + ": " + isoLevel);
190                         /*
191                         arminw:
192                         only when an isolation-level is set in CLD, set it.
193                         Else the CLD use the default iso-level defined in the repository
194                         */

195                         if(checkString(isoLevel)) m_CurrentCLD.setIsolationLevel(LockHelper.getIsolationLevelFor(isoLevel));
196
197                         // set class attribute
198
String JavaDoc classname = atts.getValue(tags.getTagById(CLASS_NAME));
199                         if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + classname);
200                         try
201                         {
202                             m_CurrentCLD.setClassOfObject(ClassHelper.getClass(classname));
203                         }
204                         catch (ClassNotFoundException JavaDoc e)
205                         {
206                             m_CurrentCLD = null;
207                             throw new MetadataException("Class "+classname+" could not be found"
208                                     +" in the classpath. This could cause unexpected behaviour of OJB,"+
209                                     " please remove or comment out this class descriptor" +
210                                     " in the repository.xml file.", e);
211                         }
212
213                         // set schema attribute
214
String JavaDoc schema = atts.getValue(tags.getTagById(SCHEMA_NAME));
215                         if (schema != null)
216                         {
217                             if (isDebug) logger.debug(" " + tags.getTagById(SCHEMA_NAME) + ": " + schema);
218                             m_CurrentCLD.setSchema(schema);
219                         }
220
221                         // set proxy attribute
222
String JavaDoc proxy = atts.getValue(tags.getTagById(CLASS_PROXY));
223                         if (isDebug) logger.debug(" " + tags.getTagById(CLASS_PROXY) + ": " + proxy);
224                         if (checkString(proxy))
225                         {
226                             if (proxy.equalsIgnoreCase(ClassDescriptor.DYNAMIC_STR))
227                             {
228                                 m_CurrentCLD.setProxyClassName(ClassDescriptor.DYNAMIC_STR);
229                             }
230                             else
231                             {
232                                 m_CurrentCLD.setProxyClassName(proxy);
233                             }
234                         }
235
236                         // set proxyPrefetchingLimit attribute
237
String JavaDoc proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
238                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
239                         if (proxyPrefetchingLimit == null)
240                         {
241                             m_CurrentCLD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
242                         }
243                         else
244                         {
245                             m_CurrentCLD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
246                         }
247
248                         // set table attribute:
249
String JavaDoc table = atts.getValue(tags.getTagById(TABLE_NAME));
250                         if (isDebug) logger.debug(" " + tags.getTagById(TABLE_NAME) + ": " + table);
251                         m_CurrentCLD.setTableName(table);
252                         if (table == null)
253                         {
254                             m_CurrentCLD.setIsInterface(true);
255                         }
256
257                         // set row-reader attribute
258
String JavaDoc rowreader = atts.getValue(tags.getTagById(ROW_READER));
259                         if (isDebug) logger.debug(" " + tags.getTagById(ROW_READER) + ": " + rowreader);
260                         if (rowreader != null)
261                         {
262                             m_CurrentCLD.setRowReader(rowreader);
263                         }
264
265                         // set if extends
266
// arminw: TODO: this feature doesn't work, remove this stuff?
267
String JavaDoc extendsAtt = atts.getValue(tags.getTagById(EXTENDS));
268                         if (isDebug) logger.debug(" " + tags.getTagById(EXTENDS) + ": " + extendsAtt);
269                         if (checkString(extendsAtt))
270                         {
271                             m_CurrentCLD.setSuperClass(extendsAtt);
272                         }
273
274                         //set accept-locks attribute
275
String JavaDoc acceptLocks = atts.getValue(tags.getTagById(ACCEPT_LOCKS));
276                         if (acceptLocks==null)
277                             acceptLocks="true"; // default is true
278
logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
279                         if (isDebug) logger.debug(" " + tags.getTagById(ACCEPT_LOCKS) + ": " + acceptLocks);
280                         boolean b = (Boolean.valueOf(acceptLocks)).booleanValue();
281                         m_CurrentCLD.setAcceptLocks(b);
282
283                         //set initializationMethod attribute
284
String JavaDoc initializationMethod = atts.getValue(tags.getTagById(INITIALIZATION_METHOD));
285                         if (isDebug) logger.debug(" " + tags.getTagById(INITIALIZATION_METHOD) + ": " + initializationMethod);
286                         if (initializationMethod != null)
287                         {
288                             m_CurrentCLD.setInitializationMethod(initializationMethod);
289                         }
290
291                         // set factoryClass attribute
292
String JavaDoc factoryClass = atts.getValue(tags.getTagById(FACTORY_CLASS));
293                         if (isDebug)
294                             logger.debug(" " + tags.getTagById(FACTORY_CLASS) + ": " + factoryClass);
295                         if (factoryClass != null)
296                         {
297                             m_CurrentCLD.setFactoryClass(factoryClass);
298                         }
299
300                         //set factoryMethod attribute
301
String JavaDoc factoryMethod = atts.getValue(tags.getTagById(FACTORY_METHOD));
302                         if (isDebug)
303                             logger.debug(" " + tags.getTagById(FACTORY_METHOD) + ": " + factoryMethod);
304                         if (factoryMethod != null)
305                         {
306                             m_CurrentCLD.setFactoryMethod(factoryMethod);
307                         }
308
309                         // set refresh attribute
310
String JavaDoc refresh = atts.getValue(tags.getTagById(REFRESH));
311                         if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh);
312                         b = (Boolean.valueOf(refresh)).booleanValue();
313                         m_CurrentCLD.setAlwaysRefresh(b);
314
315                         // TODO: remove this or make offical feature
316
// persistent field
317
String JavaDoc pfClassName = atts.getValue("persistent-field-class");
318                         if (isDebug) logger.debug(" persistent-field-class: " + pfClassName);
319                         m_CurrentCLD.setPersistentFieldClassName(pfClassName);
320
321                         // put cld to the metadata repository
322
m_repository.put(classname, m_CurrentCLD);
323                         break;
324                     }
325                 case OBJECT_CACHE:
326                     {
327                         // we only interessted in object-cache tags declared within
328
// an class-descriptor
329
if(m_CurrentCLD != null)
330                         {
331                             String JavaDoc className = atts.getValue(tags.getTagById(CLASS_NAME));
332                             if(checkString(className))
333                             {
334                                 if (isDebug) logger.debug(" > " + tags.getTagById(OBJECT_CACHE));
335                                 ObjectCacheDescriptor ocd = new ObjectCacheDescriptor();
336                                 this.m_CurrentAttrContainer = ocd;
337                                 ocd.setObjectCache(ClassHelper.getClass(className));
338                                 if(m_CurrentCLD != null)
339                                 {
340                                     m_CurrentCLD.setObjectCacheDescriptor(ocd);
341                                 }
342                                 if (isDebug) logger.debug(" " + tags.getTagById(CLASS_NAME) + ": " + className);
343                             }
344                         }
345                         break;
346                     }
347                 case CLASS_EXTENT:
348                     {
349                         String JavaDoc classname = atts.getValue("class-ref");
350                         if (isDebug) logger.debug(" " + tags.getTagById(CLASS_EXTENT) + ": " + classname);
351                         m_CurrentCLD.addExtentClass(classname);
352                         break;
353                     }
354
355                 case FIELD_DESCRIPTOR:
356                     {
357                         if (isDebug) logger.debug(" > " + tags.getTagById(FIELD_DESCRIPTOR));
358
359                         String JavaDoc strId = atts.getValue(tags.getTagById(ID));
360                         m_lastId = (strId == null ? m_lastId + 1 : Integer.parseInt(strId));
361
362                         String JavaDoc strAccess = atts.getValue(tags.getTagById(ACCESS));
363
364                         if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
365                         {
366                             m_CurrentFLD = new AnonymousFieldDescriptor(m_CurrentCLD, m_lastId);
367                         }
368                         else
369                         {
370                             m_CurrentFLD = new FieldDescriptor(m_CurrentCLD, m_lastId);
371                         }
372                         m_CurrentFLD.setAccess(strAccess);
373                         m_CurrentCLD.addFieldDescriptor(m_CurrentFLD);
374
375                         // prepare for custom attributes
376
this.m_CurrentAttrContainer = this.m_CurrentFLD;
377
378                         String JavaDoc fieldName = atts.getValue(tags.getTagById(FIELD_NAME));
379                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + fieldName);
380
381                         if (RepositoryElements.TAG_ACCESS_ANONYMOUS.equalsIgnoreCase(strAccess))
382                         {
383                             AnonymousFieldDescriptor anonymous = (AnonymousFieldDescriptor) m_CurrentFLD;
384                             anonymous.setPersistentField(null,fieldName);
385                         }
386                         else
387                         {
388                             String JavaDoc classname = m_CurrentCLD.getClassNameOfObject();
389                             PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),ClassHelper.getClass(classname),fieldName);
390                             m_CurrentFLD.setPersistentField(pf);
391                         }
392
393                         String JavaDoc columnName = atts.getValue(tags.getTagById(COLUMN_NAME));
394                         if (isDebug) logger.debug(" " + tags.getTagById(COLUMN_NAME) + ": " + columnName);
395                         m_CurrentFLD.setColumnName(columnName);
396
397                         String JavaDoc jdbcType = atts.getValue(tags.getTagById(JDBC_TYPE));
398                         if (isDebug) logger.debug(" " + tags.getTagById(JDBC_TYPE) + ": " + jdbcType);
399                         m_CurrentFLD.setColumnType(jdbcType);
400
401                         String JavaDoc primaryKey = atts.getValue(tags.getTagById(PRIMARY_KEY));
402                         if (isDebug) logger.debug(" " + tags.getTagById(PRIMARY_KEY) + ": " + primaryKey);
403                         boolean b = (Boolean.valueOf(primaryKey)).booleanValue();
404                         m_CurrentFLD.setPrimaryKey(b);
405
406                         String JavaDoc nullable = atts.getValue(tags.getTagById(NULLABLE));
407                         if (nullable != null)
408                         {
409                             if (isDebug) logger.debug(" " + tags.getTagById(NULLABLE) + ": " + nullable);
410                             b = !(Boolean.valueOf(nullable)).booleanValue();
411                             m_CurrentFLD.setRequired(b);
412                         }
413
414                         String JavaDoc indexed = atts.getValue(tags.getTagById(INDEXED));
415                         if (isDebug) logger.debug(" " + tags.getTagById(INDEXED) + ": " + indexed);
416                         b = (Boolean.valueOf(indexed)).booleanValue();
417                         m_CurrentFLD.setIndexed(b);
418
419                         String JavaDoc autoincrement = atts.getValue(tags.getTagById(AUTO_INCREMENT));
420                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_INCREMENT) + ": " + autoincrement);
421                         b = (Boolean.valueOf(autoincrement)).booleanValue();
422                         m_CurrentFLD.setAutoIncrement(b);
423
424                         String JavaDoc sequenceName = atts.getValue(tags.getTagById(SEQUENCE_NAME));
425                         if (isDebug) logger.debug(" " + tags.getTagById(SEQUENCE_NAME) + ": " + sequenceName);
426                         m_CurrentFLD.setSequenceName(sequenceName);
427
428                         String JavaDoc locking = atts.getValue(tags.getTagById(LOCKING));
429                         if (isDebug) logger.debug(" " + tags.getTagById(LOCKING) + ": " + locking);
430                         b = (Boolean.valueOf(locking)).booleanValue();
431                         m_CurrentFLD.setLocking(b);
432
433                         String JavaDoc updateLock = atts.getValue(tags.getTagById(UPDATE_LOCK));
434                         if (isDebug) logger.debug(" " + tags.getTagById(UPDATE_LOCK) + ": " + updateLock);
435                         if(checkString(updateLock))
436                         {
437                             b = (Boolean.valueOf(updateLock)).booleanValue();
438                             m_CurrentFLD.setUpdateLock(b);
439                         }
440
441                         String JavaDoc fieldConversion = atts.getValue(tags.getTagById(FIELD_CONVERSION));
442                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_CONVERSION) + ": " + fieldConversion);
443                         if (fieldConversion != null)
444                         {
445                             m_CurrentFLD.setFieldConversionClassName(fieldConversion);
446                         }
447
448                         // set length attribute
449
String JavaDoc length = atts.getValue(tags.getTagById(LENGTH));
450                         if (length != null)
451                         {
452                             int i = Integer.parseInt(length);
453                             if (isDebug) logger.debug(" " + tags.getTagById(LENGTH) + ": " + i);
454                             m_CurrentFLD.setLength(i);
455                             m_CurrentFLD.setLengthSpecified(true);
456                         }
457
458                         // set precision attribute
459
String JavaDoc precision = atts.getValue(tags.getTagById(PRECISION));
460                         if (precision != null)
461                         {
462                             int i = Integer.parseInt(precision);
463                             if (isDebug) logger.debug(" " + tags.getTagById(PRECISION) + ": " + i);
464                             m_CurrentFLD.setPrecision(i);
465                             m_CurrentFLD.setPrecisionSpecified(true);
466                         }
467
468                         // set scale attribute
469
String JavaDoc scale = atts.getValue(tags.getTagById(SCALE));
470                         if (scale != null)
471                         {
472                             int i = Integer.parseInt(scale);
473                             if (isDebug) logger.debug(" " + tags.getTagById(SCALE) + ": " + i);
474                             m_CurrentFLD.setScale(i);
475                             m_CurrentFLD.setScaleSpecified(true);
476                         }
477
478                         break;
479                     }
480
481                 case REFERENCE_DESCRIPTOR:
482                     {
483                         if (isDebug) logger.debug(" > " + tags.getTagById(REFERENCE_DESCRIPTOR));
484                         // set name attribute
485
name = atts.getValue(tags.getTagById(FIELD_NAME));
486                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
487
488                         // set class-ref attribute
489
String JavaDoc classRef = atts.getValue(tags.getTagById(REFERENCED_CLASS));
490                         if (isDebug) logger.debug(" " + tags.getTagById(REFERENCED_CLASS) + ": " + classRef);
491
492                         ObjectReferenceDescriptor ord;
493                         if (name.equals(TAG_SUPER))
494                         {
495                             // no longer needed sine SuperReferenceDescriptor was used
496
// checkThis(classRef);
497
// AnonymousObjectReferenceDescriptor aord =
498
// new AnonymousObjectReferenceDescriptor(m_CurrentCLD);
499
// aord.setPersistentField(null, TAG_SUPER);
500
// ord = aord;
501

502                             ord = new SuperReferenceDescriptor(m_CurrentCLD);
503                         }
504                         else
505                         {
506                             ord = new ObjectReferenceDescriptor(m_CurrentCLD);
507                             PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name);
508                             ord.setPersistentField(pf);
509                         }
510                         m_CurrentORD = ord;
511
512                         // now we add the new descriptor
513
m_CurrentCLD.addObjectReferenceDescriptor(m_CurrentORD);
514                         m_CurrentORD.setItemClass(ClassHelper.getClass(classRef));
515
516                         // prepare for custom attributes
517
this.m_CurrentAttrContainer = m_CurrentORD;
518
519                         // set proxy attribute
520
String JavaDoc proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
521                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
522                         boolean b = (Boolean.valueOf(proxy)).booleanValue();
523                         m_CurrentORD.setLazy(b);
524
525                         // set proxyPrefetchingLimit attribute
526
String JavaDoc proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
527                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
528                         if (proxyPrefetchingLimit == null)
529                         {
530                             m_CurrentORD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
531                         }
532                         else
533                         {
534                             m_CurrentORD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
535                         }
536
537                         // set refresh attribute
538
String JavaDoc refresh = atts.getValue(tags.getTagById(REFRESH));
539                         if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh);
540                         b = (Boolean.valueOf(refresh)).booleanValue();
541                         m_CurrentORD.setRefresh(b);
542
543                         // set auto-retrieve attribute
544
String JavaDoc autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
545                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
546                         b = (Boolean.valueOf(autoRetrieve)).booleanValue();
547                         m_CurrentORD.setCascadeRetrieve(b);
548
549                         // set auto-update attribute
550
String JavaDoc autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
551                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
552                         if(autoUpdate != null)
553                         {
554                             m_CurrentORD.setCascadingStore(autoUpdate);
555                         }
556
557                         //set auto-delete attribute
558
String JavaDoc autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
559                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
560
561                         if(autoDelete != null)
562                         {
563                             m_CurrentORD.setCascadingDelete(autoDelete);
564                         }
565
566                         //set otm-dependent attribute
567
String JavaDoc otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT));
568                         if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent);
569                         b = (Boolean.valueOf(otmDependent)).booleanValue();
570                         m_CurrentORD.setOtmDependent(b);
571
572                         break;
573                     }
574
575                 case FOREIGN_KEY:
576                     {
577                         if (isDebug) logger.debug(" > " + tags.getTagById(FOREIGN_KEY));
578                         String JavaDoc fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
579
580                         if (fieldIdRef != null)
581                         {
582                             if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
583
584                             try
585                             {
586                                 int fieldId;
587                                 fieldId = Integer.parseInt(fieldIdRef);
588                                 m_CurrentORD.addForeignKeyField(fieldId);
589                             }
590                             catch (NumberFormatException JavaDoc rex)
591                             {
592                                 throw new MetadataException(tags.getTagById(FIELD_ID_REF)
593                                         + " attribute must be an int. Found: "
594                                         + fieldIdRef + ". Please check your repository file.", rex);
595                             }
596                         }
597                         else
598                         {
599                             String JavaDoc fieldRef = atts.getValue(tags.getTagById(FIELD_REF));
600                             if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef);
601                             m_CurrentORD.addForeignKeyField(fieldRef);
602                         }
603                         break;
604                     }
605
606                 case COLLECTION_DESCRIPTOR:
607                     {
608                         if (isDebug) logger.debug(" > " + tags.getTagById(COLLECTION_DESCRIPTOR));
609                         m_CurrentCOD = new CollectionDescriptor(m_CurrentCLD);
610
611
612                         // prepare for custom attributes
613
this.m_CurrentAttrContainer = m_CurrentCOD;
614
615                         // set name attribute
616
name = atts.getValue(tags.getTagById(FIELD_NAME));
617                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
618                         PersistentField pf = PersistentFieldFactory.createPersistentField(m_CurrentCLD.getPersistentFieldClassName(),m_CurrentCLD.getClassOfObject(),name);
619                         m_CurrentCOD.setPersistentField(pf);
620
621                         // set collection-class attribute
622
String JavaDoc collectionClassName = atts.getValue(tags.getTagById(COLLECTION_CLASS));
623                         if (collectionClassName != null)
624                         {
625                             if (isDebug) logger.debug(" " + tags.getTagById(COLLECTION_CLASS) + ": " + collectionClassName);
626                             m_CurrentCOD.setCollectionClass(ClassHelper.getClass(collectionClassName));
627                         }
628                         // set element-class-ref attribute
629
String JavaDoc elementClassRef = atts.getValue(tags.getTagById(ITEMS_CLASS));
630                         if (isDebug) logger.debug(" " + tags.getTagById(ITEMS_CLASS) + ": " + elementClassRef);
631                         if (elementClassRef != null)
632                         {
633                             m_CurrentCOD.setItemClass(ClassHelper.getClass(elementClassRef));
634                         }
635
636                         //set orderby and sort attributes:
637
String JavaDoc orderby = atts.getValue(tags.getTagById(ORDERBY));
638                         String JavaDoc sort = atts.getValue(tags.getTagById(SORT));
639                         if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + orderby + ", " + sort);
640                         if (orderby != null)
641                         {
642                             m_CurrentCOD.addOrderBy(orderby, "ASC".equalsIgnoreCase(sort));
643                         }
644
645                         // set indirection-table attribute
646
String JavaDoc indirectionTable = atts.getValue(tags.getTagById(INDIRECTION_TABLE));
647                         if (isDebug) logger.debug(" " + tags.getTagById(INDIRECTION_TABLE) + ": " + indirectionTable);
648                         m_CurrentCOD.setIndirectionTable(indirectionTable);
649
650                         // set proxy attribute
651
String JavaDoc proxy = atts.getValue(tags.getTagById(PROXY_REFERENCE));
652                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_REFERENCE) + ": " + proxy);
653                         boolean b = (Boolean.valueOf(proxy)).booleanValue();
654                         m_CurrentCOD.setLazy(b);
655
656                         // set proxyPrefetchingLimit attribute
657
String JavaDoc proxyPrefetchingLimit = atts.getValue(tags.getTagById(PROXY_PREFETCHING_LIMIT));
658                         if (isDebug) logger.debug(" " + tags.getTagById(PROXY_PREFETCHING_LIMIT) + ": " + proxyPrefetchingLimit);
659                         if (proxyPrefetchingLimit == null)
660                         {
661                             m_CurrentCOD.setProxyPrefetchingLimit(defProxyPrefetchingLimit);
662                         }
663                         else
664                         {
665                             m_CurrentCOD.setProxyPrefetchingLimit(Integer.parseInt(proxyPrefetchingLimit));
666                         }
667
668                         // set refresh attribute
669
String JavaDoc refresh = atts.getValue(tags.getTagById(REFRESH));
670                         if (isDebug) logger.debug(" " + tags.getTagById(REFRESH) + ": " + refresh);
671                         b = (Boolean.valueOf(refresh)).booleanValue();
672                         m_CurrentCOD.setRefresh(b);
673
674                         // set auto-retrieve attribute
675
String JavaDoc autoRetrieve = atts.getValue(tags.getTagById(AUTO_RETRIEVE));
676                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_RETRIEVE) + ": " + autoRetrieve);
677                         b = (Boolean.valueOf(autoRetrieve)).booleanValue();
678                         m_CurrentCOD.setCascadeRetrieve(b);
679
680                         // set auto-update attribute
681
String JavaDoc autoUpdate = atts.getValue(tags.getTagById(AUTO_UPDATE));
682                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_UPDATE) + ": " + autoUpdate);
683                         if(autoUpdate != null)
684                         {
685                             m_CurrentCOD.setCascadingStore(autoUpdate);
686                         }
687
688                         //set auto-delete attribute
689
String JavaDoc autoDelete = atts.getValue(tags.getTagById(AUTO_DELETE));
690                         if (isDebug) logger.debug(" " + tags.getTagById(AUTO_DELETE) + ": " + autoDelete);
691                         if(autoDelete != null)
692                         {
693                             m_CurrentCOD.setCascadingDelete(autoDelete);
694                         }
695
696                         //set otm-dependent attribute
697
String JavaDoc otmDependent = atts.getValue(tags.getTagById(OTM_DEPENDENT));
698                         if (isDebug) logger.debug(" " + tags.getTagById(OTM_DEPENDENT) + ": " + otmDependent);
699                         b = (Boolean.valueOf(otmDependent)).booleanValue();
700                         m_CurrentCOD.setOtmDependent(b);
701
702                         m_CurrentCLD.addCollectionDescriptor(m_CurrentCOD);
703
704                         break;
705                     }
706                 case ORDERBY :
707                     {
708                         if (isDebug) logger.debug(" > " + tags.getTagById(ORDERBY));
709                         name = atts.getValue(tags.getTagById(FIELD_NAME));
710                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_NAME) + ": " + name);
711                         String JavaDoc sort = atts.getValue(tags.getTagById(SORT));
712                         if (isDebug) logger.debug(" " + tags.getTagById(SORT) + ": " + name + ", " + sort);
713
714                         m_CurrentCOD.addOrderBy(name, "ASC".equalsIgnoreCase(sort));
715                         break;
716                     }
717                 case INVERSE_FK:
718                     {
719                         if (isDebug) logger.debug(" > " + tags.getTagById(INVERSE_FK));
720                         String JavaDoc fieldIdRef = atts.getValue(tags.getTagById(FIELD_ID_REF));
721
722                         if (fieldIdRef != null)
723                         {
724                             if (isDebug) logger.debug(" " + tags.getTagById(FIELD_ID_REF) + ": " + fieldIdRef);
725
726                             try
727                             {
728                                 int fieldId;
729                                 fieldId = Integer.parseInt(fieldIdRef);
730                                 m_CurrentCOD.addForeignKeyField(fieldId);
731                             }
732                             catch (NumberFormatException JavaDoc rex)
733                             {
734                                 throw new MetadataException(tags.getTagById(FIELD_ID_REF)
735                                         + " attribute must be an int. Found: "
736                                         + fieldIdRef + " Please check your repository file.", rex);
737                             }
738                         }
739                         else
740                         {
741                             String JavaDoc fieldRef = atts.getValue(tags.getTagById(FIELD_REF));
742                             if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) + ": " + fieldRef);
743                             m_CurrentCOD.addForeignKeyField(fieldRef);
744                         }
745                         break;
746                     }
747
748                 case FK_POINTING_TO_THIS_CLASS:
749                     {
750                         if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
751                         String JavaDoc column = atts.getValue("column");
752                         if (isDebug) logger.debug(" " + "column" + ": " + column);
753                         m_CurrentCOD.addFkToThisClass(column);
754                         break;
755                     }
756
757                 case FK_POINTING_TO_ITEMS_CLASS:
758                     {
759                         if (isDebug) logger.debug(" > " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
760                         String JavaDoc column = atts.getValue("column");
761                         if (isDebug) logger.debug(" " + "column" + ": " + column);
762                         m_CurrentCOD.addFkToItemClass(column);
763                         break;
764                     }
765                 case ATTRIBUTE:
766                     {
767                         //handle custom attributes
768
String JavaDoc attributeName = atts.getValue(tags.getTagById(ATTRIBUTE_NAME));
769                         String JavaDoc attributeValue = atts.getValue(tags.getTagById(ATTRIBUTE_VALUE));
770                         // If we have a container to store this attribute in, then do so.
771
if (this.m_CurrentAttrContainer != null)
772                         {
773                             if (isDebug) logger.debug(" > " + tags.getTagById(ATTRIBUTE));
774                             if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_NAME) + ": " + attributeName);
775                             if (isDebug) logger.debug(" " + tags.getTagById(ATTRIBUTE_VALUE) + ": " + attributeValue);
776                             this.m_CurrentAttrContainer.addAttribute(attributeName, attributeValue);
777                         }
778                         else
779                         {
780 // logger.debug("Found attribute (name="+attributeName+", value="+attributeValue+
781
// ") but I can not assign them to a descriptor");
782
}
783                         break;
784                     }
785 // case SEQUENCE_MANAGER:
786
// {
787
// if (isDebug) logger.debug(" > " + tags.getTagById(SEQUENCE_MANAGER));
788
// // currently it's not possible to specify SM on class-descriptor level
789
// // thus we use a dummy object to prevent ATTRIBUTE container report
790
// // unassigned attributes
791
// this.m_CurrentAttrContainer = new SequenceDescriptor(null);
792
// break;
793
// }
794
case QUERY_CUSTOMIZER:
795                         {
796                             // set collection-class attribute
797
String JavaDoc className = atts.getValue("class");
798                             QueryCustomizer queryCust;
799
800                             if (className != null)
801                             {
802                                 if (isDebug) logger.debug(" " + "class" + ": " + className);
803                                 queryCust = (QueryCustomizer)ClassHelper.newInstance(className);
804                                 m_CurrentAttrContainer = queryCust;
805                                 m_CurrentCOD.setQueryCustomizer(queryCust);
806                             }
807                             break;
808                         }
809                     case INDEX_DESCRIPTOR:
810                         {
811                             m_CurrentIndexDescriptor = new IndexDescriptor();
812                             m_CurrentIndexDescriptor.setName(atts.getValue(tags.getTagById(NAME)));
813                             m_CurrentIndexDescriptor.setUnique(Boolean.valueOf(atts.getValue(tags.getTagById(UNIQUE))).booleanValue());
814                             break;
815                         }
816                     case INDEX_COLUMN:
817                         {
818                             m_CurrentIndexDescriptor.getIndexColumns().add(atts.getValue(tags.getTagById(NAME)));
819                             break;
820                         }
821                     case INSERT_PROCEDURE:
822                     {
823                         if (isDebug) logger.debug(" > " + tags.getTagById(INSERT_PROCEDURE));
824
825                         // Get the proc name and the 'include all fields' setting
826
String JavaDoc procName = atts.getValue(tags.getTagById(NAME));
827                         String JavaDoc includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS));
828                         if (isDebug) logger.debug(" " + tags.getTagById(NAME) +
829                                                   ": " + procName);
830                         if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) +
831                                                   ": " + includeAllFields);
832
833                         // create the procedure descriptor
834
InsertProcedureDescriptor proc =
835                             new InsertProcedureDescriptor(m_CurrentCLD,
836                                                           procName,
837                                                           Boolean.valueOf(includeAllFields).booleanValue());
838                         m_CurrentProcedure = proc;
839
840                         // Get the name of the field ref that will receive the
841
// return value.
842
String JavaDoc returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
843                         if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) +
844                                                   ": " + returnFieldRefName);
845                         proc.setReturnValueFieldRef(returnFieldRefName);
846
847                         break;
848                     }
849                 case UPDATE_PROCEDURE:
850                     {
851                         if (isDebug) logger.debug(" > " + tags.getTagById(UPDATE_PROCEDURE));
852
853                         // Get the proc name and the 'include all fields' setting
854
String JavaDoc procName = atts.getValue(tags.getTagById(NAME));
855                         String JavaDoc includeAllFields = atts.getValue(tags.getTagById(INCLUDE_ALL_FIELDS));
856                         if (isDebug) logger.debug(" " + tags.getTagById(NAME) +
857                                                   ": " + procName);
858                         if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_ALL_FIELDS) +
859                                                   ": " + includeAllFields);
860
861                         // create the procedure descriptor
862
UpdateProcedureDescriptor proc =
863                             new UpdateProcedureDescriptor(m_CurrentCLD,
864                                                           procName,
865                                                           Boolean.valueOf(includeAllFields).booleanValue());
866                         m_CurrentProcedure = proc;
867
868                         // Get the name of the field ref that will receive the
869
// return value.
870
String JavaDoc returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
871                         if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) +
872                                                   ": " + returnFieldRefName);
873                         proc.setReturnValueFieldRef(returnFieldRefName);
874
875                         break;
876                     }
877                 case DELETE_PROCEDURE:
878                     {
879                         if (isDebug) logger.debug(" > " + tags.getTagById(DELETE_PROCEDURE));
880
881                         // Get the proc name and the 'include all fields' setting
882
String JavaDoc procName = atts.getValue(tags.getTagById(NAME));
883                         String JavaDoc includeAllPkFields = atts.getValue(tags.getTagById(INCLUDE_PK_FIELDS_ONLY));
884                         if (isDebug) logger.debug(" " + tags.getTagById(NAME) +
885                                                   ": " + procName);
886                         if (isDebug) logger.debug(" " + tags.getTagById(INCLUDE_PK_FIELDS_ONLY) +
887                                                   ": " + includeAllPkFields);
888
889                         // create the procedure descriptor
890
DeleteProcedureDescriptor proc =
891                             new DeleteProcedureDescriptor(m_CurrentCLD,
892                                                           procName,
893                                                           Boolean.valueOf(includeAllPkFields).booleanValue());
894                         m_CurrentProcedure = proc;
895
896                         // Get the name of the field ref that will receive the
897
// return value.
898
String JavaDoc returnFieldRefName = atts.getValue(tags.getTagById(RETURN_FIELD_REF));
899                         if (isDebug) logger.debug(" " + tags.getTagById(RETURN_FIELD_REF) +
900                                                   ": " + returnFieldRefName);
901                         proc.setReturnValueFieldRef(returnFieldRefName);
902
903                         break;
904
905                     }
906                 case CONSTANT_ARGUMENT:
907                     {
908                         if (isDebug) logger.debug(" > " + tags.getTagById(CONSTANT_ARGUMENT));
909                         ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure);
910
911                         // Get the value
912
String JavaDoc value = atts.getValue(tags.getTagById(VALUE));
913                         if (isDebug) logger.debug(" " + tags.getTagById(VALUE) + ": " + value);
914
915                         // Set the value for the argument
916
arg.setValue(value);
917
918                         // Add the argument to the procedure.
919
m_CurrentProcedure.addArgument(arg);
920                         break;
921                     }
922                 case RUNTIME_ARGUMENT:
923                     {
924                         if (isDebug) logger.debug(" > " + tags.getTagById(RUNTIME_ARGUMENT));
925                         ArgumentDescriptor arg = new ArgumentDescriptor(m_CurrentProcedure);
926
927                         // Get the name of the field ref
928
String JavaDoc fieldRefName = atts.getValue(tags.getTagById(FIELD_REF));
929                         if (isDebug) logger.debug(" " + tags.getTagById(FIELD_REF) +
930                                                   ": " + fieldRefName);
931
932                         // Get the 'return' value.
933
String JavaDoc returnValue = atts.getValue(tags.getTagById(RETURN));
934                         if (isDebug) logger.debug(" " + tags.getTagById(RETURN) +
935                                                   ": " + returnValue);
936
937                         // Set the value for the argument.
938
if ((fieldRefName != null) && (fieldRefName.trim().length() != 0)) {
939                             arg.setValue(fieldRefName,
940                                          Boolean.valueOf(returnValue).booleanValue());
941                         }
942
943                         // Add the argument to the procedure.
944
m_CurrentProcedure.addArgument(arg);
945                         break;
946                     }
947
948                 default :
949                     {
950                         // nop
951
}
952             }
953         }
954         catch (Exception JavaDoc ex)
955         {
956             logger.error("Exception while read metadata", ex);
957             if(ex instanceof MetadataException) throw (MetadataException)ex;
958             else throw new MetadataException("Exception when reading metadata information,"+
959                     " please check your repository.xml file", ex);
960         }
961     }
962
963     /**
964      * endElement callback. most elements are build up from here.
965      */

966     public void endElement(String JavaDoc uri, String JavaDoc name, String JavaDoc qName)
967     {
968         boolean isDebug = logger.isDebugEnabled();
969         try
970         {
971             switch (getLiteralId(qName))
972             {
973                 case MAPPING_REPOSITORY:
974                     {
975                         if (isDebug) logger.debug(" < " + tags.getTagById(MAPPING_REPOSITORY));
976                         this.m_CurrentAttrContainer = null;
977                         m_CurrentCLD = null;
978                         break;
979                     }
980                 case CLASS_DESCRIPTOR:
981                     {
982                         if (isDebug) logger.debug(" < " + tags.getTagById(CLASS_DESCRIPTOR));
983                         m_CurrentCLD = null;
984                         this.m_CurrentAttrContainer = null;
985                         break;
986                     }
987                 case OBJECT_CACHE:
988                     {
989                         if(m_CurrentAttrContainer != null)
990                         {
991                             if (isDebug) logger.debug(" < " + tags.getTagById(OBJECT_CACHE));
992                         }
993                         this.m_CurrentAttrContainer = m_CurrentCLD;
994                         break;
995                     }
996                 case CLASS_EXTENT:
997                     {
998                         break;
999                     }
1000                case FIELD_DESCRIPTOR:
1001                    {
1002                        if (isDebug) logger.debug(" < " + tags.getTagById(FIELD_DESCRIPTOR));
1003                        m_CurrentFLD = null;
1004                        m_CurrentAttrContainer = m_CurrentCLD;
1005                        break;
1006                    }
1007                case REFERENCE_DESCRIPTOR:
1008                    {
1009                        if (isDebug) logger.debug(" < " + tags.getTagById(REFERENCE_DESCRIPTOR));
1010                        m_CurrentORD = null;
1011                        m_CurrentAttrContainer = m_CurrentCLD;
1012                        break;
1013                    }
1014                case FOREIGN_KEY:
1015                    {
1016                        if (isDebug) logger.debug(" < " + tags.getTagById(FOREIGN_KEY));
1017                        break;
1018                    }
1019                case COLLECTION_DESCRIPTOR:
1020                    {
1021                        if (isDebug) logger.debug(" < " + tags.getTagById(COLLECTION_DESCRIPTOR));
1022                        m_CurrentCOD = null;
1023                        m_CurrentAttrContainer = m_CurrentCLD;
1024                        break;
1025                    }
1026                case INVERSE_FK:
1027                    {
1028                        if (isDebug) logger.debug(" < " + tags.getTagById(INVERSE_FK));
1029                        break;
1030                    }
1031                case ORDERBY :
1032                    {
1033                        if (isDebug) logger.debug(" < " + tags.getTagById(ORDERBY));
1034                        break;
1035                    }
1036                case FK_POINTING_TO_THIS_CLASS:
1037                    {
1038                        if (isDebug) logger.debug(" < " + tags.getTagById(FK_POINTING_TO_THIS_CLASS));
1039                        break;
1040                    }
1041                case FK_POINTING_TO_ITEMS_CLASS:
1042                    {
1043                        if (isDebug) logger.debug(" < " + tags.getTagById(FK_POINTING_TO_ITEMS_CLASS));
1044                        break;
1045                    }
1046                case ATTRIBUTE:
1047                    {
1048                        if(m_CurrentAttrContainer != null)
1049                        {
1050                            if (isDebug) logger.debug(" < " + tags.getTagById(ATTRIBUTE));
1051                        }
1052                        break;
1053                    }
1054                case DOCUMENTATION:
1055                    {
1056                        if (isDebug) logger.debug(" < " + tags.getTagById(DOCUMENTATION));
1057                        break;
1058                    }
1059// case SEQUENCE_MANAGER:
1060
// {
1061
// // currently not used on class-descriptor level
1062
// // if (isDebug) logger.debug(" < " + tags.getTagById(SEQUENCE_MANAGER));
1063
// this.m_CurrentAttrContainer = null;
1064
// break;
1065
// }
1066
// case CONNECTION_POOL:
1067
// {
1068
// // not used on class-descriptor level
1069
// // if (isDebug) logger.debug(" < " + tags.getTagById(CONNECTION_POOL));
1070
// this.m_CurrentAttrContainer = null;
1071
// break;
1072
// }
1073
// case JDBC_CONNECTION_DESCRIPTOR:
1074
// {
1075
// // not used on class-descriptor level
1076
// // if (isDebug) logger.debug(" < " + tags.getTagById(JDBC_CONNECTION_DESCRIPTOR));
1077
// this.m_CurrentAttrContainer = null;
1078
// break;
1079
// }
1080
case QUERY_CUSTOMIZER:
1081                    {
1082                        m_CurrentAttrContainer = m_CurrentCOD;
1083                        break;
1084                    }
1085                case INDEX_DESCRIPTOR:
1086                    {
1087                        m_CurrentCLD.getIndexes().add(m_CurrentIndexDescriptor);
1088                        m_CurrentIndexDescriptor = null;
1089                        break;
1090                    }
1091                case INDEX_COLUMN:
1092                    {
1093                        // ignore; all processing done in startElement
1094
break;
1095                    }
1096                case INSERT_PROCEDURE:
1097                {
1098                    if (isDebug) logger.debug(" < " + tags.getTagById(INSERT_PROCEDURE));
1099                    m_CurrentCLD.setInsertProcedure((InsertProcedureDescriptor)m_CurrentProcedure);
1100                    m_CurrentProcedure = null;
1101                    break;
1102                }
1103                case UPDATE_PROCEDURE:
1104                    {
1105                        if (isDebug) logger.debug(" < " + tags.getTagById(UPDATE_PROCEDURE));
1106                        m_CurrentCLD.setUpdateProcedure((UpdateProcedureDescriptor)m_CurrentProcedure);
1107                        m_CurrentProcedure = null;
1108                        break;
1109                    }
1110                case DELETE_PROCEDURE:
1111                    {
1112                        if (isDebug) logger.debug(" < " + tags.getTagById(DELETE_PROCEDURE));
1113                        m_CurrentCLD.setDeleteProcedure((DeleteProcedureDescriptor)m_CurrentProcedure);
1114                        m_CurrentProcedure = null;
1115                        break;
1116                    }
1117                case CONSTANT_ARGUMENT:
1118                    {
1119                        if (isDebug) logger.debug(" < " + tags.getTagById(CONSTANT_ARGUMENT));
1120                        break;
1121                    }
1122                case RUNTIME_ARGUMENT:
1123                    {
1124                        if (isDebug) logger.debug(" < " + tags.getTagById(RUNTIME_ARGUMENT));
1125                        break;
1126                    }
1127
1128                    // handle failure:
1129
default :
1130                    {
1131                        logger.debug("Ignoring unused Element " + qName);
1132                    }
1133            }
1134        }
1135        catch (Exception JavaDoc ex)
1136        {
1137            if(ex instanceof MetadataException) throw (MetadataException) ex;
1138            else throw new MetadataException("Exception when reading metadata information,"+
1139                    " please check your repository.xml file", ex);
1140        }
1141    }
1142
1143    /**
1144     * characters callback.
1145     */

1146    public void characters(char ch[], int start, int length)
1147    {
1148        if (m_CurrentString == null)
1149            m_CurrentString = new String JavaDoc(ch, start, length);
1150        else
1151            m_CurrentString += new String JavaDoc(ch, start, length);
1152    }
1153
1154    /**
1155     * Error callback.
1156     */

1157    public void error(SAXParseException JavaDoc e) throws SAXException JavaDoc
1158    {
1159        logger.error(e);
1160        throw e;
1161    }
1162
1163    /**
1164     * fatal error callback.
1165     */

1166    public void fatalError(SAXParseException JavaDoc e) throws SAXException JavaDoc
1167    {
1168        logger.fatal(e);
1169        throw e;
1170    }
1171
1172    /**
1173     * warning callback.
1174     */

1175    public void warning(SAXParseException JavaDoc e) throws SAXException JavaDoc
1176    {
1177        logger.warn(e);
1178        throw e;
1179    }
1180
1181
1182
1183    private boolean checkString(String JavaDoc str)
1184    {
1185        return (str != null && !str.trim().equals(""));
1186    }
1187}
1188
Popular Tags