[Buix-commits] r1389 - guix/trunk/guix-compiler/src/main/java/org/nuiton/guix
Author: kmorin Date: 2009-05-06 14:42:53 +0000 (Wed, 06 May 2009) New Revision: 1389 Modified: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java Log: Modified: guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java =================================================================== --- guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java 2009-05-06 07:29:23 UTC (rev 1388) +++ guix/trunk/guix-compiler/src/main/java/org/nuiton/guix/GuixLauncher.java 2009-05-06 14:42:53 UTC (rev 1389) @@ -4,6 +4,7 @@ import org.nuiton.guix.compiler.GuixCompiler; import java.io.File; import java.io.FileWriter; +import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; @@ -65,7 +66,8 @@ this.targetDirectory = targetDirectory; if (rootPackage != null) { this.rootPackage = rootPackage; - } else { + } + else { this.rootPackage = ""; } if (files != null) { @@ -75,11 +77,13 @@ if (baseDir != null) { classNames[i] = rootPackage + "." + path.substring(baseDir.getAbsolutePath().length() + 1, path.lastIndexOf('.')).replace(File.separatorChar, '.'); - } else { + } + else { classNames[i] = path.substring(0, path.lastIndexOf('.')); } } - } else { + } + else { classNames = null; } } @@ -118,7 +122,8 @@ if (dotPos != -1) { destDir = new File(targetDirectory, className.substring(0, dotPos).replace('.', File.separatorChar)); classPackage = className.substring(0, dotPos); - } else { + } + else { destDir = new File(targetDirectory, className); classPackage = className; } @@ -128,7 +133,8 @@ } continue; } - } else { + } + else { destDir = file.getParentFile(); classPackage = destDir.getAbsolutePath().replace(File.separatorChar, '.'); } @@ -141,7 +147,8 @@ if (compiler.isFailed()) { success = false; } - } else { + } + else { if (log.isWarnEnabled()) { log.warn(file.getName() + " has already been compiled."); } @@ -160,11 +167,23 @@ } } if (success || true) { - /*XmlPullParserFactory factory = - XmlPullParserFactory.newInstance( - System.getProperty(XmlPullParserFactory.PROPERTY_NAME), - null);*/ + XmlPullParserFactory factory = + XmlPullParserFactory.newInstance( + System.getProperty(XmlPullParserFactory.PROPERTY_NAME), + null); + XmlSerializer serializer = factory.newSerializer(); + File config = new File(targetDirectory,"config.xml"); + + serializer.setOutput(new PrintWriter(config)); + serializer.startDocument("UTF-8", null); + serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-line-separator", "\n"); + serializer.setProperty("http://xmlpull.org/v1/doc/properties.html#serializer-indentation", "\t"); + serializer.text("\n"); + serializer.docdecl(" beans SYSTEM \"http://www.springframework.org/dtd/spring-beans.dtd\""); + serializer.text("\n"); + serializer.startTag("", "beans"); + for (GuixModelObject mo : rootModelObjects.keySet()) { //File f = new File(destDir, mo.getClassDescriptor().getName() + "ModelTree.xml"); File out = new File(destDir, mo.getClassDescriptor().getName() + ".java"); @@ -174,6 +193,7 @@ if (log.isInfoEnabled()) { log.info(mo.getClassDescriptor().getName() + " last modification : " + new Date(rootModelObjects.get(mo).getLastModification())); } + if (rootModelObjects.get(mo).getLastModification() > out.lastModified()) { if (log.isInfoEnabled()) { log.info("Generation of " + mo.getClassDescriptor().getName()); @@ -210,10 +230,38 @@ ImplementationGenerator img = new ImplementationGenerator(mo); img.generate(outImpl); - } else if (log.isWarnEnabled()) { + serializer.startTag("", "bean"); + serializer.attribute("", "id", out.getName().replace(out.getName().charAt(0), + Character.toLowerCase(out.getName().charAt(0)))); + serializer.attribute("", "class", out.getName() + "Impl"); + serializer.attribute("", "singleton", "false"); + + /*<bean id = "articlesDao" class + + ="istia.st.articles.dao.ArticlesDaoPlainJdbc"> + <constructor-arg index="0"> + <value>org.firebirdsql.jdbc.FBDriver</value> + </constructor-arg> + <constructor-arg index="1"> + <value>jdbc:firebirdsql:localhost/3050:d:/databases/dbarticles.gdb</value> + </constructor-arg> + <constructor-arg index="2"> + <value>someone</value> + </constructor-arg> + <constructor-arg index="3"> + <value>somepassword</value> + </constructor-arg> + </bean>*/ + + + } + else + if (log.isWarnEnabled()) { log.warn(mo.getClassDescriptor().getName() + " has already been generated and is up to date."); } } + serializer.endTag("", "beans"); + serializer.endDocument(); /*// pass 2 if (!nextStep(LifeCycle.compile_second_pass, success)) { @@ -299,12 +347,14 @@ e.printStackTrace(); return false;*/ } - } catch (Throwable e) { + } + catch (Throwable e) { e.printStackTrace(); return false; } return success; - } else { + } + else { if (log.isWarnEnabled()) { log.warn("No file to compile"); } @@ -438,7 +488,8 @@ if (log.isDebugEnabled()) { log.debug("add script to ClassDescriptor " + classDescriptor); } - } else if (!classDescriptors.get(i).getScript().equals(classDescriptor.getScript())) { + } + else if (!classDescriptors.get(i).getScript().equals(classDescriptor.getScript())) { if (log.isDebugEnabled()) { log.error("ClassDescriptor " + classDescriptor + " script already defined and different !"); } @@ -451,7 +502,8 @@ if (log.isDebugEnabled()) { log.debug("add superclass to ClassDescriptor " + classDescriptor); } - } else if (!classDescriptors.get(i).getSuperClass().equals(classDescriptor.getSuperClass())) { + } + else if (!classDescriptors.get(i).getSuperClass().equals(classDescriptor.getSuperClass())) { if (log.isErrorEnabled()) { log.error("ClassDescriptor " + classDescriptor + " superclass already defined and different !"); }
participants (1)
-
kmorin@users.labs.libre-entreprise.org