Package org.eclipse.persistence.internal.jpa.modelgen

Examples of org.eclipse.persistence.internal.jpa.modelgen.MetadataMirrorFactory


     * INTERNAL:
     */
    @Override
    public MetadataClass visitType(TypeElement typeElement, MetadataClass metadataClass) {
        //processingEnv.getMessager().printMessage(Kind.NOTE, "Visiting class: " + typeElement);
        MetadataMirrorFactory factory = ((MetadataMirrorFactory) metadataClass.getMetadataFactory());
       
        // Set the qualified name.
        metadataClass.setName(typeElement.getQualifiedName().toString());
       
        // By default, set the type to be the same as the name, which in most
        // cases is correct. For non JDK elements we'll visit the typeElement
        // further (see below). This will further process any generic types,
        // e.g. Employee<Integer>. For the most part I don't think we need to
        // care, certainly not with JDK classes but for round elements we'll
        // set them anyway.
        metadataClass.setType(metadataClass.getName());
       
        // Add the interfaces.
        for (TypeMirror interfaceCls : typeElement.getInterfaces()) {
            metadataClass.addInterface(factory.getMetadataClass(interfaceCls).getName());
        }
       
        // Set the superclass name (if there is one)
        TypeMirror superclass = typeElement.getSuperclass();
        if (superclass != null) {
            metadataClass.setSuperclassName(factory.getMetadataClass(superclass).getName());
        }
       
        // As a performance gain, limit what is visited by JDK elements.
        if (! metadataClass.isJDK()) {
            // Set the modifiers.
            metadataClass.setModifiers(getModifiers(typeElement.getModifiers()));
           
            // Visit the type element for type and generic type.
            typeElement.asType().accept(typeVisitor, metadataClass);
           
            // Visit the enclosed elements.
            for (Element enclosedElement : typeElement.getEnclosedElements()) {
                if (enclosedElement.getKind().isClass()) {
                    metadataClass.addEnclosedClass(factory.getMetadataClass(enclosedElement));
                } else {
                    enclosedElement.accept(this, metadataClass);
                }
            }
       
View Full Code Here


     */
    @Override
    public MetadataClass visitType(TypeElement typeElement, MetadataClass metadataClass) {
        //m_processingEnv.getMessager().printMessage(Kind.NOTE, "Visiting class: " + typeElement);
       
        MetadataMirrorFactory factory = ((MetadataMirrorFactory) metadataClass.getMetadataFactory());
       
        // Set the qualified name.
        metadataClass.setName(typeElement.getQualifiedName().toString());
       
        // Set the modifiers.
        metadataClass.setModifiers(getModifiers(typeElement.getModifiers()));
       
        // Visit the enclosed elements.
        for (Element enclosedElement : typeElement.getEnclosedElements()) {
            if (enclosedElement.getKind().isClass()) {
                metadataClass.addEnclosedClass(factory.getMetadataClass(enclosedElement));
            } else {
                enclosedElement.accept(this, metadataClass);
            }
        }
       
        // Add the interfaces.
        for (TypeMirror interfaceCls : typeElement.getInterfaces()) {
            metadataClass.addInterface(factory.getMetadataClass(interfaceCls).getName());
        }
       
        // Set the superclass name (if there is one)
        TypeMirror superclass = typeElement.getSuperclass();
        if (superclass != null) {
            metadataClass.setSuperclassName(factory.getMetadataClass(superclass).getName());
        }
       
        // Visit the type element for type and generic type.
        TypeVisitor<MetadataClass, MetadataClass> visitor = new TypeVisitor<MetadataClass, MetadataClass>();
        typeElement.asType().accept(visitor, metadataClass);
View Full Code Here

                    // factory will also hang onto static projects for each
                    // persistence unit. Doing this is going to need careful
                    // cleanup thoughts though. Adding classes ok, but what
                    // about removing some?
                    MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
                    factory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
                    processingEnv.getMessager().printMessage(Kind.NOTE, "Creating the metadata factory ...");
                }
               
                // Step 1 - The factory is passed around so those who want the
                // processing or round env can get it off the factory. This
View Full Code Here

                    // factory will also hang onto static projects for each
                    // persistence unit. Doing this is going to need careful
                    // cleanup thoughts though. Adding classes ok, but what
                    // about removing some?
                    MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
                    factory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
                    processingEnv.getMessager().printMessage(Kind.NOTE, "Creating the metadata factory ...");
                }
               
                // Step 1 - The factory is passed around so those who want the
                // processing or round env can get it off the factory. This
View Full Code Here

     * INTERNAL:
     */
    @Override
    public MetadataClass visitType(TypeElement typeElement, MetadataClass metadataClass) {
        //processingEnv.getMessager().printMessage(Kind.NOTE, "Visiting class: " + typeElement);
        MetadataMirrorFactory factory = ((MetadataMirrorFactory) metadataClass.getMetadataFactory());
       
        // Set the qualified name.
        metadataClass.setName(typeElement.getQualifiedName().toString());
       
        // By default, set the type to be the same as the name, which in most
        // cases is correct. For round elements we'll visit the typeElement
        // further (see below). This will further process any generic types,
        // e.g. Employee<Integer>. For the most part I don't think we need to
        // care, certainly not with library classes but for round elements we'll
        // set them anyway.
        metadataClass.setType(metadataClass.getName());
       
        // Add the interfaces.
        for (TypeMirror interfaceCls : typeElement.getInterfaces()) {
            metadataClass.addInterface(factory.getMetadataClass(interfaceCls).getName());
        }
       
        // Set the superclass name (if there is one)
        TypeMirror superclass = typeElement.getSuperclass();
        if (superclass != null) {
            metadataClass.setSuperclassName(factory.getMetadataClass(superclass).getName());
        }
       
        // As a performance gain, limit what is visited by non-round elements.
        if (factory.isRoundElement(typeElement)) {
            // Set the modifiers.
            metadataClass.setModifiers(getModifiers(typeElement.getModifiers()));
           
            // Visit the type element for type and generic type.
            typeElement.asType().accept(typeVisitor, metadataClass);
           
            // Visit the enclosed elements.
            for (Element enclosedElement : typeElement.getEnclosedElements()) {
                if (enclosedElement.getKind().isClass()) {
                    metadataClass.addEnclosedClass(factory.getMetadataClass(enclosedElement));
                } else {
                    enclosedElement.accept(this, metadataClass);
                }
            }
       
View Full Code Here

     */
    @Override
    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
        if (! roundEnv.processingOver() && ! roundEnv.errorRaised()) {
            try {
                MetadataMirrorFactory factory;
               
                if (Boolean.valueOf(CanonicalModelProperties.getOption(CANONICAL_MODEL_USE_STATIC_FACTORY, CANONICAL_MODEL_USE_STATIC_FACTORY_DEFAULT, processingEnv.getOptions()))) {
                    if (staticFactory == null) {
                        // We must remember some state from one round to another.
                        // In some rounds, the user may only change one class
                        // meaning we only have one root element from the round.
                        // If it is a child class to an existing already generated
                        // parent class we need to know about this class, so the
                        // factory will also hang onto static projects for each
                        // persistence unit. Doing this is going to need careful
                        // cleanup thoughts though. Adding classes ok, but what
                        // about removing some?
                        MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
                        staticFactory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
                        processingEnv.getMessager().printMessage(Kind.NOTE, "Creating static metadata factory ...");
                    }
                   
                    factory = staticFactory;
                } else {
                    if (nonStaticFactory == null) {
                        MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
                        nonStaticFactory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
                        processingEnv.getMessager().printMessage(Kind.NOTE, "Creating non-static metadata factory ...");
                    }
                   
                    factory = nonStaticFactory;
                }
               
                // Step 1 - The factory is passed around so those who want the
                // processing or round env can get it off the factory. This
                // saves us from having to pass around multiple objects.
                factory.setEnvironments(processingEnv, roundEnv);
               
                // Step 2 - read the persistence xml classes (gives us extra
                // classes and mapping files. From them we get transients and
                // access). Metadata read from XML causes new accessors to be
                // created and override existing ones (causing them to be un-
View Full Code Here

     * INTERNAL:
     */
    @Override
    public MetadataClass visitType(TypeElement typeElement, MetadataClass metadataClass) {
        //processingEnv.getMessager().printMessage(Kind.NOTE, "Visiting class: " + typeElement);
        MetadataMirrorFactory factory = ((MetadataMirrorFactory) metadataClass.getMetadataFactory());
       
        // Set the qualified name.
        metadataClass.setName(typeElement.getQualifiedName().toString());
       
        // By default, set the type to be the same as the name, which in most
        // cases is correct. For non JDK elements we'll visit the typeElement
        // further (see below). This will further process any generic types,
        // e.g. Employee<Integer>. For the most part I don't think we need to
        // care, certainly not with JDK classes but for round elements we'll
        // set them anyway.
        metadataClass.setType(metadataClass.getName());
       
        // Add the interfaces.
        for (TypeMirror interfaceCls : typeElement.getInterfaces()) {
            metadataClass.addInterface(factory.getMetadataClass(interfaceCls).getName());
        }
       
        // Set the superclass name (if there is one)
        TypeMirror superclass = typeElement.getSuperclass();
        if (superclass != null) {
            metadataClass.setSuperclassName(factory.getMetadataClass(superclass).getName());
        }
       
        // As a performance gain, limit what is visited by JDK elements.
        if (! metadataClass.isJDK()) {
            // Set the modifiers.
            metadataClass.setModifiers(getModifiers(typeElement.getModifiers()));
           
            // Visit the type element for type and generic type.
            typeElement.asType().accept(typeVisitor, metadataClass);
           
            // Visit the enclosed elements.
            for (Element enclosedElement : typeElement.getEnclosedElements()) {
                if (enclosedElement.getKind().isClass()) {
                    metadataClass.addEnclosedClass(factory.getMetadataClass(enclosedElement));
                } else {
                    enclosedElement.accept(this, metadataClass);
                }
            }
       
View Full Code Here

     * Visit a declared field or Class.
     */
    @Override
    public MetadataAnnotatedElement visitDeclared(DeclaredType declaredType, MetadataAnnotatedElement annotatedElement) {
        // Get the metadata class of the declared type from the factory.
        MetadataMirrorFactory factory = (MetadataMirrorFactory) annotatedElement.getMetadataFactory();
        MetadataClass cls = factory.getMetadataClass(declaredType);
       
        // Set the type, which is the class name.
        annotatedElement.setType(cls.getName());
       
        // Set the generic types. Internally EclipseLink wants the class name
        // in the 0 position of the generic list.
        annotatedElement.addGenericType(cls.getName());
       
        for (TypeMirror typeArgument : declaredType.getTypeArguments()) {
            // Set the type from the metadata class as it may be a generic and
            // we don't want to set the letter type, rather our default GENERIC_TYPE.
            annotatedElement.addGenericType(factory.getMetadataClass(typeArgument).getType());
        }
       
        return annotatedElement;
    }
View Full Code Here

     * INTERNAL:
     * Visit a method.
     */
    @Override
    public MetadataAnnotatedElement visitExecutable(ExecutableType executableType, MetadataAnnotatedElement annotatedElement) {
        MetadataMirrorFactory factory = ((MetadataMirrorFactory) annotatedElement.getMetadataFactory());
        MetadataMethod method = (MetadataMethod) annotatedElement;
       
        // Set the parameters.
        for (TypeMirror parameter : executableType.getParameterTypes()) {
            method.addParameter(factory.getMetadataClass(parameter).getType());
        }
       
        // Visit the return type (will set the type and generic types).
        executableType.getReturnType().accept(this, method);
        method.setReturnType(method.getType());
View Full Code Here

                    // factory will also hang onto static projects for each
                    // persistence unit. Doing this is going to need careful
                    // cleanup thoughts though. Adding classes ok, but what
                    // about removing some?
                    MetadataLogger logger = new MetadataLogger(new ServerSession(new Project(new DatabaseLogin())));
                    factory = new MetadataMirrorFactory(logger, Thread.currentThread().getContextClassLoader());
                    processingEnv.getMessager().printMessage(Kind.NOTE, "Creating the metadata factory ...");
                }
               
                // Step 1 - The factory is passed around so those who want the
                // processing or round env can get it off the factory. This
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.internal.jpa.modelgen.MetadataMirrorFactory

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.