KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > internal > ejb > cmp3 > xml > accessors > XMLClassAccessor


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors;
23
24 import java.lang.reflect.Field JavaDoc;
25 import java.lang.reflect.Method JavaDoc;
26
27 // WIP shouldn't be here
28
import oracle.toplink.essentials.exceptions.ValidationException;
29
30 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.ClassAccessor;
31 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.MetadataAccessor;
32
33 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataAccessibleObject;
34 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataClass;
35 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataField;
36 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.objects.MetadataMethod;
37
38 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.columns.MetadataPrimaryKeyJoinColumns;
39
40 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.listeners.MetadataEntityListener;
41
42 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataDescriptor;
43 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataHelper;
44 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataPersistenceUnit;
45 import oracle.toplink.essentials.internal.ejb.cmp3.metadata.MetadataProcessor;
46
47 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLBasicAccessor;
48 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLEmbeddedAccessor;
49 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLManyToManyAccessor;
50 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLManyToOneAccessor;
51 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLOneToManyAccessor;
52 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLOneToOneAccessor;
53 import oracle.toplink.essentials.internal.ejb.cmp3.xml.accessors.XMLTransientAccessor;
54
55 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLColumn;
56 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLDiscriminatorColumn;
57 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLJoinColumns;
58 import oracle.toplink.essentials.internal.ejb.cmp3.xml.columns.XMLPrimaryKeyJoinColumns;
59
60 import oracle.toplink.essentials.internal.ejb.cmp3.xml.listeners.XMLEntityClassListener;
61 import oracle.toplink.essentials.internal.ejb.cmp3.xml.listeners.XMLEntityListener;
62
63 import oracle.toplink.essentials.internal.ejb.cmp3.xml.queries.XMLNamedNativeQuery;
64 import oracle.toplink.essentials.internal.ejb.cmp3.xml.queries.XMLNamedQuery;
65 import oracle.toplink.essentials.internal.ejb.cmp3.xml.queries.XMLSQLResultSetMapping;
66
67 import oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing.XMLSequenceGenerator;
68 import oracle.toplink.essentials.internal.ejb.cmp3.xml.sequencing.XMLTableGenerator;
69
70 import oracle.toplink.essentials.internal.ejb.cmp3.xml.tables.XMLSecondaryTable;
71 import oracle.toplink.essentials.internal.ejb.cmp3.xml.tables.XMLTable;
72
73 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLConstants;
74 import oracle.toplink.essentials.internal.ejb.cmp3.xml.XMLHelper;
75
76 import org.w3c.dom.Node JavaDoc;
77 import org.w3c.dom.NodeList JavaDoc;
78
79 /**
80  * An XML extended class accessor.
81  *
82  * @author Guy Pelletier
83  * @since TopLink EJB 3.0 Reference Implementation
84  */

85 public class XMLClassAccessor extends ClassAccessor implements XMLAccessor {
86     protected Node JavaDoc m_node;
87     protected XMLHelper m_helper;
88     
89     // These entity-mappings settings need to be available to all xml entities
90
// in the given xml file. The are processed by the first entity in the file.
91
protected static String JavaDoc m_entityMappingsAccess;
92     protected static String JavaDoc m_entityMappingsSchema;
93     protected static String JavaDoc m_entityMappingsCatalog;
94     
95     /**
96      * INTERNAL:
97      */

98     public XMLClassAccessor(MetadataAccessibleObject accessibleObject, Node JavaDoc node, XMLHelper helper, MetadataProcessor processor, MetadataDescriptor descriptor) {
99         super(accessibleObject, processor, descriptor);
100         m_node = node;
101         m_helper = helper;
102     }
103     
104     /**
105      * INTERNAL:
106      * Create and return the appropriate accessor based on the given node.
107      */

108     protected MetadataAccessor buildAccessor(Node JavaDoc node) {
109         MetadataAccessibleObject accessibleObject;
110         
111         // Process the required name attribute.
112
String JavaDoc attributeName = m_helper.getNodeValue(node, XMLConstants.ATT_NAME);
113         
114         // WIP - left to do here is perform validation on the accessors just
115
// like the annotation processor does.
116
if (m_descriptor.usesPropertyAccess()) {
117             Method JavaDoc method = MetadataHelper.getMethodForPropertyName(attributeName, getJavaClass());
118             
119             if (method == null) {
120                 m_validator.throwUnableToDetermineClassForProperty(attributeName, getJavaClass());
121             }
122             
123             accessibleObject = new MetadataMethod(method);
124         } else {
125             Field JavaDoc field = MetadataHelper.getFieldForName(attributeName, getJavaClass());
126             
127             if (field == null) {
128                 m_validator.throwUnableToDetermineClassForField(attributeName, getJavaClass());
129             }
130             
131             accessibleObject = new MetadataField(field);
132         }
133         
134         String JavaDoc nodeName = node.getLocalName();
135         
136         if (nodeName.equals(XMLConstants.ONE_TO_ONE)) {
137             return new XMLOneToOneAccessor(accessibleObject, node, this);
138         } else if (nodeName.equals(XMLConstants.MANY_TO_ONE)) {
139             return new XMLManyToOneAccessor(accessibleObject, node, this);
140         } else if (nodeName.equals(XMLConstants.ONE_TO_MANY)) {
141             if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
142                 return new XMLOneToManyAccessor(accessibleObject, node, this);
143             } else {
144                 throw ValidationException.invalidCollectionTypeForRelationship(accessibleObject.getRawClass(), getAttributeName());
145                 //m_validator.throwInvalidCollectionTypeForRelationship(accessibleObject.getRawClass(), getAttributeName());
146
}
147         } else if (nodeName.equals(XMLConstants.MANY_TO_MANY)) {
148             if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
149                 return new XMLManyToManyAccessor(accessibleObject, node, this);
150             } else {
151                 // m_validator.throwInvalidCollectionTypeForRelationship(accessibleObject.getRawClass(), getAttributeName());
152
throw ValidationException.invalidCollectionTypeForRelationship(accessibleObject.getRawClass(), getAttributeName());
153             }
154         } else if (nodeName.equals(XMLConstants.EMBEDDED)) {
155             return new XMLEmbeddedAccessor(accessibleObject, node, this, false);
156         } else if (nodeName.equals(XMLConstants.EMBEDDED_ID)) {
157             return new XMLEmbeddedAccessor(accessibleObject, node, this, true);
158         } else if (nodeName.equals(XMLConstants.TRANSIENT)) {
159             return new XMLTransientAccessor(accessibleObject, node, this);
160         } else {
161             return new XMLBasicAccessor(accessibleObject, node, this);
162         }
163     }
164     
165     /**
166      * INTERNAL:
167      */

168     public String JavaDoc getCatalog() {
169         return m_entityMappingsCatalog;
170     }
171     
172     /**
173      * INTERNAL: (OVERRIDE)
174      * Return the name of this entity class. If it is not defined call the
175      * parent to check for an annotation.
176      */

177     public String JavaDoc getEntityName() {
178         String JavaDoc entityName = m_helper.getNodeValue(m_node, XMLConstants.ATT_NAME);
179         
180         if (entityName.equals("")) {
181             return super.getEntityName();
182         } else {
183             return entityName;
184         }
185     }
186     
187     /**
188      * INTERNAL:
189      */

190     public XMLHelper getHelper() {
191         return m_helper;
192     }
193     
194     /**
195      * INTERNAL:
196      */

197     public String JavaDoc getSchema() {
198          return m_entityMappingsSchema;
199     }
200     
201     /**
202      * INTERNAL: (OVERRIDE)
203      * Return the discriminator value for this accessor. If it is not defined
204      * call the parent to check for an annotation.
205      */

206     public String JavaDoc getDiscriminatorValue() {
207         String JavaDoc discriminatorValue = m_helper.getNodeTextValue(m_node, XMLConstants.DISCRIMINATOR_VALUE);
208         
209         if (discriminatorValue.equals("")) {
210             return super.getDiscriminatorValue();
211         } else {
212             return discriminatorValue;
213         }
214     }
215     
216     /**
217      * INTERNAL:
218      */

219     public String JavaDoc getDocumentName() {
220         return m_helper.getDocumentName();
221     }
222     
223     /**
224      * INTERNAL:
225      */

226     protected boolean hasEntityTag(Class JavaDoc cls) {
227         Node JavaDoc node = m_helper.locateEntityNode(cls);
228         
229         if (node != null) {
230             return true;
231         } else {
232             return super.hasEntityTag(cls);
233         }
234     }
235     
236     /**
237      * INTERNAL: (OVERRIDE)
238      * Indicates if a given node has an inheritance sub-element.
239      */

240     protected boolean hasInheritanceTag(Class JavaDoc entityClass) {
241         Node JavaDoc node = m_helper.locateEntityNode(entityClass);
242         
243         if (node != null && m_helper.hasNode(node, XMLConstants.INHERITANCE)) {
244             return true;
245         } else {
246             return super.hasInheritanceTag(entityClass);
247         }
248     }
249     
250     /**
251      * INTERNAL:
252      * Return true if this is an XML processing accessor.
253      */

254     public boolean isXMLAccessor() {
255         return true;
256     }
257     
258     /**
259      * INTERNAL:
260      * Process any entity tag specifics then call the parent process.
261      */

262     public void process() {
263         // Process the metadata-complete attribute node.
264
m_descriptor.setIgnoreAnnotations(m_helper.getNodeValue(m_node, XMLConstants.ATT_METADATA_COMPLETE, m_descriptor.ignoreAnnotations()));
265             
266         // Process the access attribute.
267
m_descriptor.setAccess(m_helper.getNodeValue(m_node, XMLConstants.ATT_ACCESS, m_entityMappingsAccess));
268         
269         // Set the entity mapping schema value. The schema defaults to the
270
// persistence unit schema if it is not set.
271
m_descriptor.setSchema(m_entityMappingsSchema);
272             
273         // Set the entity mapping catalog value. The catalog defaults to the
274
// persistence unit catalog if it is not set.
275
m_descriptor.setCatalog(m_entityMappingsCatalog);
276         
277         super.process();
278     }
279     
280     /**
281      * INTERNAL: (OVERRIDE)
282      * Fast track processing a ClassAccessor for the given descriptor.
283      * Inheritance root classes and embeddables may be fast tracked.
284      */

285     protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
286         Node JavaDoc node = m_helper.locateEntityNode(descriptor.getJavaClass());
287         
288         if (node != null) {
289             XMLClassAccessor accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), node, m_helper, m_processor, descriptor);
290             descriptor.setClassAccessor(accessor);
291             accessor.process();
292             accessor.setIsProcessed();
293             return accessor;
294         } else {
295             return super.processAccessor(descriptor);
296         }
297     }
298     
299     /**
300      * INTERNAL: (OVERRIDE)
301      * Process the accessors for the given class.
302      */

303     protected void processAccessors() {
304         NodeList JavaDoc nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTES, XMLConstants.ALL_CHILDREN);
305         
306         if (nodes != null) {
307             for (int i = 0; i < nodes.getLength(); i++) {
308                 processAccessor(buildAccessor(nodes.item(i)));
309             }
310         }
311         
312         super.processAccessors();
313     }
314     
315     /**
316      * INTERNAL: (OVERRIDE)
317      * Process the association overrides for a class that inherits from a
318      * mapped superclass. Once the association overrides are processed from
319      * XML process the association overrides from annotations.
320      */

321     protected void processAssociationOverrides() {
322         // Process the XML association override elements first.
323
NodeList JavaDoc nodes = m_helper.getNodes(m_node, XMLConstants.ASSOCIATION_OVERRIDE);
324         
325         if (nodes != null) {
326             for (int i = 0; i < nodes.getLength(); i++) {
327                 Node JavaDoc node = nodes.item(i);
328                 processAssociationOverride(m_helper.getNodeValue(node, XMLConstants.ATT_NAME), new XMLJoinColumns(node, m_helper));
329             }
330         }
331         
332         // Process the association override annotations second.
333
super.processAssociationOverrides();
334     }
335     
336     /**
337      * INTERNAL: (OVERRIDE)
338      * Process the attribute overrides for a class that inherits from a
339      * mapped superclass. Once the attribute overrides are processed from
340      * XML process the attribute overrides from annotations.
341      */

342     protected void processAttributeOverrides() {
343         NodeList JavaDoc nodes = m_helper.getNodes(m_node, XMLConstants.ATTRIBUTE_OVERRIDE);
344         
345         if (nodes != null) {
346             for (int i = 0; i < nodes.getLength(); i++) {
347                 processAttributeOverride(new XMLColumn(nodes.item(i), m_helper, getAnnotatedElement()));
348             }
349         }
350         
351         
352         // Now, Process the attribute override annotations second.
353
super.processAttributeOverrides();
354     }
355     
356     /**
357      * INTERNAL:
358      * Process an XML discriminator-column metadata. If we don't find a node
359      * here, check for an annotation by calling the parent. It will default if
360      * no annotation is found.
361      */

362     protected void processDiscriminatorColumn() {
363         Node JavaDoc node = m_helper.getNode(m_node, XMLConstants.DISCRIMINATOR_COLUMN);
364         
365         if (node == null) {
366             super.processDiscriminatorColumn();
367         } else {
368             processDiscriminatorColumn(new XMLDiscriminatorColumn(node, m_helper));
369         }
370     }
371     
372     /**
373      * INTERNAL: (OVERRIDE)
374      * Process the entity class for lifecycle callback event methods.
375      */

376     public MetadataEntityListener processEntityEventListener(ClassLoader JavaDoc loader) {
377         // Update the class loader.
378
m_helper.setLoader(loader);
379         
380         // Create the listener.
381
XMLEntityClassListener listener = new XMLEntityClassListener(getJavaClass());
382             
383         // Process the lifecycle callback events from XML.
384
Method JavaDoc[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForEntityClass(getJavaClass());
385         processLifecycleEvents(listener, m_node, m_helper, candidateMethods);
386             
387         // Check the entity class for lifecycle callback annotations.
388
processCallbackMethods(candidateMethods, listener);
389         
390         // WIP - at this point we should turn the override ignore off for
391
// mapped superclasses ...
392
return listener;
393     }
394     
395     /**
396      * INTERNAL: (OVERRIDE)
397      * Process the entity listeners for this class accessor. Entity listeners
398      * defined in XML will override those specified on the class.
399      */

400     public void processEntityListeners(Class JavaDoc entityClass, ClassLoader JavaDoc loader) {
401         // Update the class loader.
402
m_helper.setLoader(loader);
403         
404         NodeList JavaDoc nodes = m_helper.getNodes(m_node, new String JavaDoc[] {XMLConstants.ENTITY_LISTENERS, XMLConstants.ENTITY_LISTENER});
405         
406         if (nodes.getLength() > 0) {
407             for (int i = 0; i < nodes.getLength(); i++) {
408                 Node JavaDoc node = nodes.item(i);
409                 
410                 // Build an xml entity listener.
411
XMLEntityListener listener = new XMLEntityListener(m_helper.getClassForNode(node), entityClass);
412                 
413                 // Process the lifecycle callback events from XML.
414
Method JavaDoc[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForEntityListener(listener);
415                 processLifecycleEvents(listener, node, m_helper, candidateMethods);
416                 
417                 // Process the candidate callback methods on this listener for
418
// additional callback methods decorated with annotations.
419
processCallbackMethods(candidateMethods, listener);
420         
421                 // Add the listener to the descriptor.
422
m_descriptor.addEntityListenerEventListener(listener);
423             }
424         } else {
425             super.processEntityListeners(entityClass, loader);
426         }
427     }
428     
429     /**
430      * INTERNAL:
431      * Process the information contained in the entity-mappings node.
432      */

433     public void processEntityMappings() {
434         MetadataPersistenceUnit persistenceUnit = m_project.getPersistenceUnit();
435         
436         if (persistenceUnit != null) {
437             // Use the persistent unit defaults ..
438
m_entityMappingsAccess = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ACCESS, persistenceUnit.getAccess());
439             m_entityMappingsSchema = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SCHEMA, persistenceUnit.getSchema());
440             m_entityMappingsCatalog = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.CATALOG, persistenceUnit.getCatalog());
441         } else {
442             m_entityMappingsAccess = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.ACCESS);
443             m_entityMappingsSchema = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SCHEMA);
444             m_entityMappingsCatalog = m_helper.getNodeTextValue(XMLConstants.ENTITY_MAPPINGS, XMLConstants.CATALOG);
445         }
446         
447         // Process the table-generator nodes.
448
NodeList JavaDoc tableGeneratorNodes = m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.TABLE_GENERATOR);
449         
450         if (tableGeneratorNodes != null) {
451             for (int i = 0; i < tableGeneratorNodes.getLength(); i++) {
452                 processTableGenerator(tableGeneratorNodes.item(i));
453             }
454         }
455         
456         // Process the sequence-generator nodes.
457
NodeList JavaDoc sequenceGeneratorNodes = m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SEQUENCE_GENERATOR);
458         
459         if (sequenceGeneratorNodes != null) {
460             for (int i = 0; i < sequenceGeneratorNodes.getLength(); i++) {
461                 processSequenceGenerator(sequenceGeneratorNodes.item(i));
462             }
463         }
464         
465         // Process the named-query nodes.
466
processNamedQueries(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.NAMED_QUERY));
467
468         // Process the named-native-query nodes.
469
processNamedNativeQueries(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.NAMED_NATIVE_QUERY));
470
471         // Process the sql-result-set-mapping nodes.
472
processSqlResultSetMappings(m_helper.getNodes(XMLConstants.ENTITY_MAPPINGS, XMLConstants.SQL_RESULT_SET_MAPPING));
473     }
474     
475     /**
476      * INTERNAL: (OVERRIDE)
477      * Process the exclude-default-listeners tag if one is specified, otherwise,
478      * ask the parent to look for an annotation.
479      */

480     protected void processExcludeDefaultListeners() {
481         if (m_helper.hasNode(m_node, XMLConstants.EXCLUDE_DEFAULT_LISTENERS)) {
482             m_descriptor.setExcludeDefaultListeners(true);
483         } else {
484             super.processExcludeDefaultListeners();
485         }
486     }
487     
488     /**
489      * INTERNAL: (OVERRIDE)
490      * Process the exclude-superclass-listeners tag if one is specified,
491      * otherwise, ask the parent to look for an annotation.
492      */

493     protected void processExcludeSuperclassListeners() {
494         if (m_helper.hasNode(m_node, XMLConstants.EXCLUDE_SUPERCLASS_LISTENERS)) {
495             m_descriptor.setExcludeSuperclassListeners(true);
496         } else {
497             super.processExcludeSuperclassListeners();
498         }
499     }
500     
501     /**
502      * INTERNAL: (OVERRIDE)
503      * Return the id-class if there is one.
504      */

505     protected Class JavaDoc getIdClass() {
506         Node JavaDoc result = m_helper.getNode(m_node, XMLConstants.ID_CLASS);
507             
508         if (result != null) {
509             return m_helper.getClassForNode(result);
510         }
511         
512         return super.getIdClass();
513     }
514     
515     /**
516      * INTERNAL: (OVERRIDE)
517      * Return the inheritance strategy. This method should only be called
518      * on the root of the inheritance hierarchy.
519      */

520     protected String JavaDoc getInheritanceStrategy() {
521         Node JavaDoc inheritanceNode = m_helper.getNode(m_node, XMLConstants.INHERITANCE);
522         
523         if (inheritanceNode == null) {
524             return super.getInheritanceStrategy();
525         } else {
526             return m_helper.getNodeValue(inheritanceNode, XMLConstants.ATT_STRATEGY);
527         }
528     }
529     
530     /**
531      * INTERNAL: (OVERRIDE)
532      * Process the primary-key-join-column(s) elements.
533      */

534     protected MetadataPrimaryKeyJoinColumns getPrimaryKeyJoinColumns(String JavaDoc sourceTableName, String JavaDoc targetTableName) {
535         if (m_helper.nodeHasPrimaryKeyJoinColumns(m_node)) {
536             return new XMLPrimaryKeyJoinColumns(m_node, m_helper, sourceTableName, targetTableName);
537         } else {
538             return super.getPrimaryKeyJoinColumns(sourceTableName, targetTableName);
539         }
540     }
541     
542     /**
543      * INTERNAL: (OVERRIDE)
544      * Process the mapped superclass class for lifecycle callback event methods.
545      */

546     public void processMappedSuperclassEventListener(MetadataEntityListener listener, Class JavaDoc entityClass, ClassLoader JavaDoc loader) {
547         // Update the class loader
548
m_helper.setLoader(loader);
549         
550         // Process the lifecycle callback events from XML.
551
Method JavaDoc[] candidateMethods = MetadataHelper.getCandidateCallbackMethodsForMappedSuperclass(getJavaClass(), entityClass);
552         processLifecycleEvents(listener, m_node, m_helper, candidateMethods);
553         
554         // Check for annotations on the mapped superclass now.
555
processCallbackMethods(candidateMethods, listener);
556     }
557     
558     /**
559      * INTERNAL: (OVERRIDE)
560      * Process the named native queries for the given class which could be an
561      * entity or a mapped superclass.
562      */

563     protected void processNamedNativeQueries() {
564         // Process the named native query elements first.
565
processNamedNativeQueries(m_helper.getNodes(m_node, XMLConstants.NAMED_NATIVE_QUERY));
566         
567         // Process the XML named native query annotations second.
568
super.processNamedNativeQueries();
569     }
570     
571     /**
572      * INTERNAL:
573      * Process named-queries at either the entity-mappings or entity level. The
574      * queries will be stored in a hashmap - EntityManagerSetupImpl will call
575      * 'addNamedQueriesToSession()' after processing; this is when the queries
576      * will be added to the session.
577      */

578     protected void processNamedNativeQueries(NodeList JavaDoc queryNodes) {
579         if (queryNodes != null) {
580             for (int i = 0; i < queryNodes.getLength(); i++) {
581                 // Ask the common processor to process what we found.
582
processNamedNativeQuery(new XMLNamedNativeQuery(queryNodes.item(i), m_helper));
583             }
584         }
585     }
586     
587     /**
588      * INTERNAL: (OVERRIDE)
589      * Process the named queries for the given class which could be an entity
590      * or a mapped superclass.
591      */

592     protected void processNamedQueries() {
593         // Process the XML named query elements first.
594
processNamedQueries(m_helper.getNodes(m_node, XMLConstants.NAMED_QUERY));
595         
596         // Process the named query annotations second.
597
super.processNamedQueries();
598     }
599     
600     /**
601      * INTERNAL:
602      * Process named queries at either the entity-mapping or entity level. The
603      * queries will be stored in a hashmap - EntityManagerSetupImpl will call
604      * 'addNamedQueriesToSession()' after processing; this is when the queries
605      * will be added to the session.
606      */

607     protected void processNamedQueries(NodeList JavaDoc queryNodes) {
608         if (queryNodes != null) {
609             for (int i = 0; i < queryNodes.getLength(); i++) {
610                 // Ask the common processor to process what we found.
611
processNamedQuery(new XMLNamedQuery(queryNodes.item(i), m_helper));
612             }
613         }
614     }
615     
616     /**
617      * INTERNAL: (OVERRIDE)
618      * Process secondary-table(s) for a given entity.
619      */

620     protected void processSecondaryTables() {
621         NodeList JavaDoc secondaryTables = m_helper.getNodes(m_node, XMLConstants.SECONDARY_TABLE);
622         
623         if (secondaryTables != null) {
624             for (int i = 0; i < secondaryTables.getLength(); i++) {
625                 processSecondaryTable(new XMLSecondaryTable(secondaryTables.item(i), m_helper));
626             }
627         }
628     }
629     
630     /**
631      * INTERNAL: (OVERRIDE)
632      * Process this accessor's sequence-generator node into a common metadata
633      * sequence generator.
634      */

635     protected void processSequenceGenerator() {
636         // Process the xml defined sequence generators first.
637
processSequenceGenerator(m_helper.getNode(m_node, XMLConstants.SEQUENCE_GENERATOR));
638         
639         // Process the annotation defined sequence generators second.
640
super.processSequenceGenerator();
641     }
642     
643     /**
644      * INTERNAL:
645      * Process a sequence-generator node into a common metadata sequence
646      * generator.
647      */

648     protected void processSequenceGenerator(Node JavaDoc node) {
649         if (node != null) {
650             // Ask the common processor to process what we found.
651
processSequenceGenerator(new XMLSequenceGenerator(node, m_helper));
652         }
653     }
654     
655     /**
656      * INTERNAL: (OVERRIDE)
657      * Process the sql result set mappings for the given class which could be an
658      * entity or a mapped superclass.
659      */

660     protected void processSqlResultSetMappings() {
661         // Process the XML sql result set mapping elements first.
662
processSqlResultSetMappings(m_helper.getNodes(m_node, XMLConstants.SQL_RESULT_SET_MAPPING));
663         
664         // Process the sql result set mapping query annotations second.
665
super.processSqlResultSetMappings();
666     }
667     
668     /**
669      * INTERNAL:
670      * Process sql-result-set-mappings and store them on the session.
671      */

672     protected void processSqlResultSetMappings(NodeList JavaDoc sqlResultSetNodes) {
673         if (sqlResultSetNodes != null) {
674             int nodeCount = sqlResultSetNodes.getLength();
675         
676             for (int i = 0; i < nodeCount; i++) {
677                 // Ask the common processor to process what we found.
678
processSqlResultSetMapping(new XMLSQLResultSetMapping(sqlResultSetNodes.item(i), m_helper));
679             }
680         }
681     }
682     
683     /**
684      * INTERNAL: (OVERRIDE)
685      * Process table information for the given metadata descriptor.
686      */

687     protected void processTable() {
688         if (m_descriptor.ignoreTables()) {
689             m_logger.logWarningMessage(m_logger.IGNORE_TABLE, getJavaClass());
690         } else {
691             Node JavaDoc tableNode = m_helper.getNode(m_node, XMLConstants.TABLE);
692             
693             if (tableNode != null) {
694                 processTable(new XMLTable(tableNode, m_helper));
695             } else {
696                 // Check for a table annotation. If no annotation is defined
697
// then the table will default.
698
super.processTable();
699             }
700         }
701     }
702     
703     /**
704      * INTERNAL: (OVERRIDE)
705      * Process the table generator for the given class which could be an entity
706      * or a mapped superclass.
707      */

708     protected void processTableGenerator() {
709         // Process the xml defined table generators first.
710
processTableGenerator(m_helper.getNode(m_node, XMLConstants.TABLE_GENERATOR));
711         
712         // Process the annotation defined sequence generators second.
713
super.processTableGenerator();
714     }
715     
716     /**
717      * INTERNAL:
718      * Process a table-generator node into a common metadata table generator.
719      */

720     protected void processTableGenerator(Node JavaDoc node) {
721         if (node != null) {
722             // Ask the common processor to process what we found.
723
processTableGenerator(new XMLTableGenerator(node, this));
724         }
725     }
726 }
727     
Popular Tags