Package org.objectweb.speedo.metadata

Examples of org.objectweb.speedo.metadata.SpeedoClass


    super.visitXml(xml);
    List classes = xml.getSpeedoClasses();

    if (!xml.requireEnhancement) {
      for(int i=(classes.size() -1); i>=0 && !xml.requireEnhancement; i--) {
        SpeedoClass sc = (SpeedoClass) classes.get(i);
        sc.setRequireEnhancement(xml.requireEnhancement);
      }
    }
    if (xml.requireEnhancement) {
      logger.log(BasicLevel.INFO, "Enhancement required for :" + xml.xmlFile);

      //Remove the JMI file
      if (debug) {
        logger.log(BasicLevel.DEBUG, "Removing the jmi file:"
            + jmiFile.getAbsolutePath());
      }
      if (jmiFile.exists() && !jmiFile.delete()) {
        throw new SpeedoException(
            "Impossible to remove the JMI file associated to the jdo file:"
            + xml.xmlFile);
      }

      for (int i = (enhancedClasses.size() - 1); i >= 0; i--) {
        SpeedoClass sc = (SpeedoClass) enhancedClasses.get(i);
        String baseName = StringReplace.replaceChar(
            '.', File.separatorChar, sc.getFQName());
        File classFile = new File(output, baseName + ".class");
        if (debug) {
          logger.log(BasicLevel.DEBUG, "Removing class files:" + classFile);
        }
        if (classFile.exists() && !classFile.delete()) {
View Full Code Here


    } else
            return mo;
    }
   
    private Object treatClassNode(Node node, Object mo) throws SpeedoException {
        SpeedoClass c = new SpeedoClass();
        Node n = null;
        //attribute name (compulsory)
        n = node.getAttributes().getNamedItem("name");
        if (n == null)
            throw new SpeedoXMLError("Attribute name for tag class requested.");
        c.name = c.nameForQuery = n.getNodeValue();

        //attribute identity-type
        n = node.getAttributes().getNamedItem("identity-type");
        if (n != null)
            c.setIdentityType(SpeedoIdentity.getStrategy(n.getNodeValue()));
         
        //attribute object-id
        n = node.getAttributes().getNamedItem("objectid-class");
        if (n != null) {
            c.identity.objectidClass = n.getNodeValue();
            c.setIdentityType(SpeedoIdentity.USER_ID);
        }

        //attribute requires-extent is not taking in account

        //attribute detachable
        n = node.getAttributes().getNamedItem("detachable");
        if (n != null)
            c.isDetachable = Boolean.valueOf(n.getNodeValue()).booleanValue();
             
        //attribute persistence-capable-superclass
        n = node.getAttributes().getNamedItem("persistence-capable-superclass");
        if (n != null) {
            if (c.inheritance == null) {
                c.inheritance = new SpeedoInheritance();
            }
            c.inheritance.superClassName = n.getNodeValue();
        }
        //attribute table
        n = node.getAttributes().getNamedItem("table");
        if (n != null) {
            c.mainTable = new SpeedoTable();
            c.mainTable.name = n.getNodeValue();
        }

        logger.log(BasicLevel.DEBUG, "New class: "
                + "name=" + c.name
                + "  / id = " + c.getIdentityType()
                + "  / idClass = " + c.identity.objectidClass
                + "  / detachable = " + c.isDetachable
        );
        ((SpeedoPackage) mo).addClass(c, true, logger);
        return c;
View Full Code Here

            } else {
                fg.postLoad = false;
            }
        }
        if (mo instanceof SpeedoClass) {
            SpeedoClass sc = (SpeedoClass) mo;
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "add fetchgroup '" +  fg.name +
                    "' into the class '"  + sc.getFQName() +"'");
            }
            sc.addFetchGroup(fg);
        } else if (mo instanceof SpeedoFetchGroup) {
            SpeedoFetchGroup pfg = (SpeedoFetchGroup) mo;
            if (logger.isLoggable(BasicLevel.DEBUG)) {
                logger.log(BasicLevel.DEBUG, "add fetchgroup '" +  fg.name +
                    "' into the fetchgroup '" + pfg.name +"'");
View Full Code Here

        ((SpeedoXMLDescriptor) mo).add(p, true, logger);
        logger.log(BasicLevel.DEBUG, "New package: name= " + p.name);
        return p;
    }
    private Object treatInheritance(Node node, Object mo) throws SpeedoException {
        SpeedoClass sc = (SpeedoClass) mo;
        if (sc.inheritance == null) {
            sc.inheritance = new SpeedoInheritance();
        }
        Node n = node.getAttributes().getNamedItem("strategy");
        if (n == null) {
View Full Code Here

            SpeedoXMLDescriptor xmlDesc = (SpeedoXMLDescriptor) i.next();
            String fieldPackage = NamingRules.packageName(className);
            String fieldClass = NamingRules.className(className);
            SpeedoPackage pkg = (SpeedoPackage) xmlDesc.packages.get(fieldPackage);
            if (pkg != null) {
                SpeedoClass c = (SpeedoClass) pkg.classes.get(fieldClass);
                if (c != null) {
                    return c;
                }
            }
        }
View Full Code Here

     * @param name the name of the field to be fetched
     * @param className the complete class name that the field belongs to
     * @return the corresponding SpeedoField if it exists, null either
     */
    SpeedoField fetchJDOField(final String name, final String className) {
        SpeedoClass c = smi.getSpeedoClass(className);
        if (c != null) {
          SpeedoField speedoField = null;
          //try to find the field in the current class
          // and in its parents (if any)
          while (speedoField == null && c != null) {
            speedoField = (SpeedoField) c.fields.get(name);
            c = c.getSuper();
          }
          return speedoField;
        } else {
            return null;
        }
View Full Code Here

        for (Iterator itDesc = xmls.iterator(); itDesc.hasNext();) {
            SpeedoXMLDescriptor desc = (SpeedoXMLDescriptor) itDesc.next();
            for (Iterator itPack = desc.packages.values().iterator(); itPack.hasNext();) {
                SpeedoPackage sp = (SpeedoPackage) itPack.next();
                for (Iterator itclass = sp.classes.values().iterator(); itclass.hasNext();) {
                    SpeedoClass sc = (SpeedoClass) itclass.next();
                    Logger log = scp.loggerFactory.getLogger(LOGGER_NAME + '.' + sc.getFQName());
                    treatPC(sc, log);
                    treatOID(sc, log);
                    processedClasses ++;
                }
            }
View Full Code Here

        _cv.visitMethodInsn(Constants.INVOKESPECIAL, uicn, "<init>", "()V");
        _cv.visitVarInsn(Constants.ASTORE, 1);

        //t.f1 = this.f1
        boolean hasLongOrDouble = false;
        SpeedoClass current = speedoClass;
        while(current != null) {
          for(Iterator it = current.fields.values().iterator(); it.hasNext();) {
              SpeedoField sp = (SpeedoField) it.next();
              if (sp.primaryKey) {
                  hasLongOrDouble |= sp.type.charAt(0) == 'D'
                        || sp.type.charAt(0) == 'J';
                  logger.log(BasicLevel.DEBUG, "add code: this." + sp.name + " = t." + sp.name);
                  _cv.visitVarInsn(Constants.ALOAD, 1); //Can be a long|double value
                  _cv.visitVarInsn(Constants.ALOAD, 0);
                  _cv.visitFieldInsn(Constants.GETFIELD, className, sp.name, sp.type);
                  _cv.visitFieldInsn(Constants.PUTFIELD, uicn, sp.name, sp.type);
              }
          }
      SpeedoClass tmp = current.getSuper();
      current = (tmp == current ? null : tmp);
    }

        // GENERATE: t.speedoSetPersistentClassName(this.getPType().getJormName());
        logger.log(BasicLevel.DEBUG, "add code: t.speedoSetPersistentClassName(this.getPType().getJormName());");
View Full Code Here

     * @param name the name of the field to be fetched
     * @param className the complete class name that the field belongs to
     * @return the corresponding SpeedoField if it exists, null either
     */
    SpeedoField fetchField(final String name, final String className) {
        SpeedoClass c = smi.getSpeedoClass(className);
        if (c != null) {
            return (SpeedoField) c.fields.get(name);
        } else {
            return null;
        }
View Full Code Here

        this.speedoClass = sc;
        this.classToWrite = getJVMClassName(speedoClass.getFQName());
        this.xfieldsJCN = NamingRules.fieldsName(classToWrite);
        this.xfieldsJT = getJVMType(xfieldsJCN);
        this.scp = cp;
        SpeedoClass anc = sc.getAncestor();
        if (anc == null) {
            ancestorJCN = classToWrite;
            xfieldsAncestorJCN = xfieldsJCN;
            xfieldsAncestorJT = xfieldsJT;
        } else {
            ancestorJCN = getJVMClassName(anc.getFQName());;
            xfieldsAncestorJCN = NamingRules.fieldsName(ancestorJCN);
            xfieldsAncestorJT = getJVMType(xfieldsAncestorJCN);
        }
        JCN_JDOPOM = getJVMClassName(personality.getPOMClass());
        JT_JDOPOM = getJVMType(personality.getPOMClass());
View Full Code Here

TOP

Related Classes of org.objectweb.speedo.metadata.SpeedoClass

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.