public void start() { for (Iterator iter = getModel().getClasses(); iter.hasNext();) { String className = ((DomainClass) iter.next()).getFullName(); try { loadClass(className); } catch (ClassNotFoundException cnfe) { System.err.println("Error: Couldn't load class " + className + ": " + cnfe); } } } }
/** * @return a <code>Map</code> of <code>Classes</code> to {@link DomainClass} with all the existing classes of the * domain model, except those annotated with {@link NoDomainMetaObjects}. */ private Map<Class<? extends DomainObject>, DomainClass> getExistingDomainClasses(DomainModel domainModel) { Map<Class<? extends DomainObject>, DomainClass> existingDomainClasses = new HashMap<Class<? extends DomainObject>, DomainClass>(); Iterator<DomainClass> domainClassesIterator = domainModel.getClasses(); try { while (domainClassesIterator.hasNext()) { DomainClass dmlDomainClass = domainClassesIterator.next(); Class<? extends DomainObject> domainClass = (Class<? extends DomainObject>) Class.forName(dmlDomainClass.getFullName()); if (!domainClass.getSuperclass().getName().equals(domainClass.getName() + "_Base")) { throw new Error("The domain class: " + domainClass + " must extend its corresponding _Base class."); } if (domainClass.isAnnotationPresent(NoDomainMetaObjects.class)) { continue; } existingDomainClasses.put(domainClass, dmlDomainClass); } return existingDomainClasses; } catch (ClassNotFoundException e) { e.printStackTrace(); throw new Error(e); } }
@Override public void generateCode() { File file = new File(getBaseDirectoryFor("") + "/META-INF/orm.xml"); file.getParentFile().mkdirs(); FileWriter fileWriter = null; try { fileWriter = new FileWriter(file); this.ormWriter = new PrintWriter(fileWriter, true); ormBeginFile(); super.generateCode(); ormGenerateNonBaseClasses(getDomainModel().getClasses()); ormEndFile(); generatePersistenceXml(); } catch (IOException ioe) { throw new Error("Can't open file " + file); } finally { if (fileWriter != null) { try { fileWriter.close(); } catch (IOException e) { } } } }
/** * Generate the backend-specific code for the domain model. */ public void generateCode() { // used by the value-type generator ValueTypeSerializationGenerator valueTypeGenerator = new ValueTypeSerializationGenerator(compArgs, domainModel); valueTypeGenerator.generateCode(); generateClasses(getDomainModel().getClasses()); generateBackEndId(); }