Search in sources :

Example 1 with Main

use of com.sun.jdo.api.persistence.enhancer.generator.Main in project Payara by payara.

the class JDOCodeGenerator method generatePC.

/**
 * Generate PC class for the ConcreteImpl bean.
 * @see CMPGenerator#generate(IASEjbCMPEntityDescriptor, File, File)
 */
private Collection<File> generatePC(IASEjbCMPEntityDescriptor ejbcmp, File srcout, File classout) throws IOException {
    ArrayList<File> fileList = new ArrayList<File>();
    Main gen = new Main(ejbModel, srcout);
    String className = nameMapper.getPersistenceClassForEjbName(ejbcmp.getName());
    if (className != null) {
        // generate PC class
        // @olsen, 4653156: the enhancer-generator deals with class names
        // in JVM format, i.e., with '/' for '.' as separator
        String jvmClassName = className.replace('.', '/');
        File file = gen.generate(jvmClassName);
        fileList.add(file);
        // write mapping file
        MappingClassElement mappingClass = model.getMappingClass(className);
        BufferedOutputStream mapOut = null;
        try {
            String mapPath = className.replace('.', File.separatorChar);
            String mappingFile = mapPath + MAPPING_EXTENSION;
            mapOut = new BufferedOutputStream(new FileOutputStream(new File(classout, mappingFile)));
            // "touch" need to create the output stream first since the
            // classout directory is not in the classpath and
            // therefore the standard storeMappingClass can't be used
            model.storeMappingClass(mappingClass, mapOut);
        } finally {
            if (mapOut != null) {
                try {
                    mapOut.close();
                } catch (Exception ex) {
                    if (logger.isLoggable(Logger.FINE))
                        logger.fine(ex.getMessage());
                }
            }
        }
    }
    return fileList;
}
Also used : MappingClassElement(com.sun.jdo.api.persistence.model.mapping.MappingClassElement) Main(com.sun.jdo.api.persistence.enhancer.generator.Main) ModelException(com.sun.jdo.api.persistence.model.ModelException) EJBQLException(com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException) SQLException(java.sql.SQLException) DBException(org.netbeans.modules.dbschema.DBException) JDOUserException(com.sun.jdo.api.persistence.support.JDOUserException) Schema2BeansException(org.netbeans.modules.schema2beans.Schema2BeansException) GeneratorException(com.sun.jdo.spi.persistence.support.ejb.codegen.GeneratorException) ConversionException(com.sun.jdo.api.persistence.mapping.ejb.ConversionException)

Aggregations

Main (com.sun.jdo.api.persistence.enhancer.generator.Main)1 ConversionException (com.sun.jdo.api.persistence.mapping.ejb.ConversionException)1 ModelException (com.sun.jdo.api.persistence.model.ModelException)1 MappingClassElement (com.sun.jdo.api.persistence.model.mapping.MappingClassElement)1 JDOUserException (com.sun.jdo.api.persistence.support.JDOUserException)1 GeneratorException (com.sun.jdo.spi.persistence.support.ejb.codegen.GeneratorException)1 EJBQLException (com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException)1 SQLException (java.sql.SQLException)1 DBException (org.netbeans.modules.dbschema.DBException)1 Schema2BeansException (org.netbeans.modules.schema2beans.Schema2BeansException)1