Package oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors

Examples of oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.MetadataAccessor


     * session. This call is made from the EntityManagerSetup deploy call.
     */
    public void addEntityListeners() {
        for (MetadataDescriptor descriptor: m_project.getDescriptors()) {
            // Process all descriptors that are in our project.
            ClassAccessor accessor = descriptor.getClassAccessor();
           
            descriptor.setJavaClass(descriptor.getClassDescriptor().getJavaClass());
            // The class loader has changed, update the class stored for
            // our class accessor and its list of mapped superclasses.
            accessor.setAnnotatedElement(descriptor.getJavaClass());
            accessor.clearMappedSuperclasses();           
           
            accessor.processListeners(m_loader);
        }
    }
View Full Code Here


        // take a copy of the collection to avoid concurrent modification exception
        // that would result when embeddables are added lazily.
        for (MetadataDescriptor descriptor:
             m_project.getDescriptors().toArray(new MetadataDescriptor[]{})) {
            // Process all descriptors that are in our project.
            ClassAccessor accessor = descriptor.getClassAccessor();
               
            // If there is no accessor on this descriptor then it has not been
            // processed yet. Create one and process it.
            if (accessor == null) {
                accessor = new ClassAccessor(new MetadataClass(descriptor.getJavaClass()), this, descriptor);
                descriptor.setClassAccessor(accessor);
                accessor.process();
            }
        }
       
        // Process the project and anything that was deferred like
        // sequencing and relationship mappings and we are done.
View Full Code Here

                    Node entityNode = entityNodes.item(i);
                    Class entityClass = helper.getClassForNode(entityNode);
                    MetadataDescriptor descriptor = m_project.getDescriptor(entityClass);

                    // Process all descriptors that are in our project.
                    ClassAccessor accessor = descriptor.getClassAccessor();

                    // If there is no accessor on this descriptor then it has not
                    // been processed yet. Create one and process it.
                    if (accessor == null) {
                        accessor = new XMLClassAccessor(new MetadataClass(descriptor.getJavaClass()), entityNode, helper, this, descriptor);
                        descriptor.setClassAccessor(accessor);
                        accessor.process();
                    }
                }
            }
        } else {
            // There are no classes to process ...
View Full Code Here

     * object given. Order of checking is important, careful when modifying
     * or adding, check what the isXyz call does to determine if the accessor
     * is of type xyz.
     */
    protected MetadataAccessor buildAccessor(MetadataAccessibleObject accessibleObject) {
        MetadataAccessor accessor = m_descriptor.getAccessorFor(accessibleObject.getAttributeName());
       
        if (accessor == null) {
            if (MetadataHelper.isBasic(accessibleObject, m_descriptor)) {
                return new BasicAccessor(accessibleObject, this);
            } else if (MetadataHelper.isEmbedded(accessibleObject, m_descriptor)) {
View Full Code Here

     * again. If still no accessor is found and this descriptor metadata is
     * and an inheritance sublcass, than it will then look on the root metadata
     * descriptor. Null is returned otherwise.
     */
    public MetadataAccessor getAccessorFor(String fieldOrPropertyName) {
      MetadataAccessor accessor = m_accessors.get(fieldOrPropertyName);
       
        if (accessor == null) {
            // Perhaps we have a property name ...
            accessor = m_accessors.get(MetadataHelper.getAttributeNameFromMethodName(fieldOrPropertyName));
          
View Full Code Here

     * Non-owning mappings that need to look up the owning mapping, should call
     * this method with their respective accessor to check for circular mappedBy
     * references. If the referencingAccessor is null, no check will be made.
     */
    public DatabaseMapping getMappingForAttributeName(String attributeName, MetadataAccessor referencingAccessor) {
        MetadataAccessor accessor = (MetadataAccessor) getAccessorFor(attributeName);
       
        if (accessor != null) {
            // If the accessor is a relationship accessor than it may or may
            // not have been processed yet. Fast track its processing if it
            // needs to be. The process call will do nothing if it has already
            // been processed.
            if (accessor.isRelationship()) {
                RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
               
                // Check that we don't have circular mappedBy values which
                // will cause an infinite loop.
                if (referencingAccessor != null && ! relationshipAccessor.isManyToOne() && relationshipAccessor.getMappedBy().equals(referencingAccessor.getAttributeName())) {
View Full Code Here

            // If the accessor is a relationship accessor than it may or may
            // not have been processed yet. Fast track its processing if it
            // needs to be. The process call will do nothing if it has already
            // been processed.
            if (accessor.isRelationship()) {
                RelationshipAccessor relationshipAccessor = (RelationshipAccessor) accessor;
               
                // Check that we don't have circular mappedBy values which
                // will cause an infinite loop.
                if (referencingAccessor != null && ! relationshipAccessor.isManyToOne() && relationshipAccessor.getMappedBy().equals(referencingAccessor.getAttributeName())) {
                    getValidator().throwCircularMappedByReferences(referencingAccessor.getJavaClass(), referencingAccessor.getAttributeName(), getJavaClass(), attributeName);
                }
               
                relationshipAccessor.processRelationship();
            }
           
            return m_descriptor.getMappingForAttributeName(attributeName);
        }
       
View Full Code Here

    /**
     * INTERNAL:
     * Create and return the appropriate accessor based on the given node.
     */
    protected MetadataAccessor buildAccessor(Node node) {
        MetadataAccessibleObject accessibleObject;
       
        // Process the required name attribute.
        String attributeName = m_helper.getNodeValue(node, XMLConstants.ATT_NAME);
       
        // WIP - left to do here is perform validation on the accessors just
        // like the annotation processor does.
        if (m_descriptor.usesPropertyAccess()) {
            Method method = MetadataHelper.getMethodForPropertyName(attributeName, getJavaClass());
           
            if (method == null) {
                m_validator.throwUnableToDetermineClassForProperty(attributeName, getJavaClass());
            }
           
            accessibleObject = new MetadataMethod(method);
        } else {
            Field field = MetadataHelper.getFieldForName(attributeName, getJavaClass());
           
            if (field == null) {
                m_validator.throwUnableToDetermineClassForField(attributeName, getJavaClass());
            }
           
            accessibleObject = new MetadataField(field);
        }
       
        String nodeName = node.getLocalName();
       
        if (nodeName.equals(XMLConstants.ONE_TO_ONE)) {
            return new XMLOneToOneAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.MANY_TO_ONE)) {
            return new XMLManyToOneAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.ONE_TO_MANY)) {
            if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
                return new XMLOneToManyAccessor(accessibleObject, node, this);       
            } else {
                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
                return null;
            }
        } else if (nodeName.equals(XMLConstants.MANY_TO_MANY)) {
            if (MetadataHelper.isSupportedCollectionClass(accessibleObject.getRawClass())) {
                return new XMLManyToManyAccessor(accessibleObject, node, this);
            } else {
                m_validator.throwInvalidCollectionTypeForRelationship(getJavaClass(), accessibleObject.getRawClass(), getAttributeName());
                return null;
            }
        } else if (nodeName.equals(XMLConstants.EMBEDDED)) {
            return new XMLEmbeddedAccessor(accessibleObject, node, this);
        } else if (nodeName.equals(XMLConstants.EMBEDDED_ID)) {
View Full Code Here

     * INTERNAL: (Overidden in XMLClassAccessor and XMLEmbeddedAccessor)
     * Fast track processing a ClassAccessor for the given descriptor.
     * Inheritance root classes and embeddables may be fast tracked.
     */
    protected ClassAccessor processAccessor(MetadataDescriptor descriptor) {
        ClassAccessor accessor = new ClassAccessor(new MetadataClass(descriptor.getJavaClass()), getProcessor(), descriptor);
        descriptor.setClassAccessor(accessor);
        accessor.process();
        return accessor;
    }
View Full Code Here

                    // us before the next entity in the hierarchy.
                    break;
                } else if (m_project.hasMappedSuperclass(parent)) {
                    Node node = m_project.getMappedSuperclassNode(parent);
                    XMLHelper helper = m_project.getMappedSuperclassHelper(parent);                   
                    m_mappedSuperclasses.add(new XMLMappedSuperclassAccessor(new MetadataClass(parent), node, helper, m_processor, m_descriptor));
                } else if (isAnnotationPresent(MappedSuperclass.class, parent)) {
                    m_mappedSuperclasses.add(new MappedSuperclassAccessor(new MetadataClass(parent), m_processor, m_descriptor));
                }
               
                parent = parent.getSuperclass();
            }
        }
View Full Code Here

TOP

Related Classes of oracle.toplink.essentials.internal.ejb.cmp3.metadata.accessors.MetadataAccessor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.