Author: tchemit Date: 2008-07-23 15:30:43 +0000 (Wed, 23 Jul 2008) New Revision: 768 Modified: trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java Log: do not use log level + fix bug with static block in JaxxCompiler when we want to reexecute the compiler with a secon maven goal in the same time Modified: trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java =================================================================== --- trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-23 10:27:17 UTC (rev 767) +++ trunk/lutinjaxx/core/src/main/java/jaxx/compiler/JAXXCompiler.java 2008-07-23 15:30:43 UTC (rev 768) @@ -244,7 +244,9 @@ static { try { - loadLibraries(); + // fixme beware, this is a very dangerous thing to use a static block + //loadLibraries(); + // fixeme for the moment the compiler is init in maven plugin, not here } catch (Exception e) { throw new RuntimeException(e); @@ -255,11 +257,15 @@ // forces static initializer to run if it hasn't yet } - public static void loadLibraries() throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { - ServiceLoader<Initializer> loader = ServiceLoader.load(Initializer.class); + public static void loadLibraries(boolean verbose) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException { + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + if (verbose) { + log.info("with cl " + classloader); + } + ServiceLoader<Initializer> loader = ServiceLoader.load(Initializer.class, classloader); for (Initializer initializer : loader) { - if (log.isDebugEnabled()) { - log.debug("load initializer " + initializer); + if (verbose) { + log.info("load initializer " + initializer); } initializer.initialize(); } Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-23 10:27:17 UTC (rev 767) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractActionGeneratorMojo.java 2008-07-23 15:30:43 UTC (rev 768) @@ -38,8 +38,8 @@ String path = file.getAbsolutePath().substring(outResource.getAbsolutePath().length() + 1); File compiledFile = new File(outClass, path); - if (getLog().isDebugEnabled()) { - getLog().debug("copy to classapth generated file " + compiledFile); + if (verbose) { + getLog().info("copy to classapth generated file " + compiledFile); } File parent = compiledFile.getParentFile(); if (!parent.exists()) { Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-07-23 10:27:17 UTC (rev 767) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/AbstractJaxxMojo.java 2008-07-23 15:30:43 UTC (rev 768) @@ -63,7 +63,7 @@ /** * @description verbose - * @parameter expression="${jaxx.verbose}" default-value="${maven.verbose}" + * @parameter expression="${jaxx.verbose}" default-value="false" */ protected boolean verbose; @@ -141,7 +141,7 @@ } loader = result; } - if (log.isDebugEnabled() && loader != null) { + if (verbose && loader != null) { for (URL entry : loader.getURLs()) { log.info("outClass url " + entry); } Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-23 10:27:17 UTC (rev 767) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/ActionGeneratorMojo.java 2008-07-23 15:30:43 UTC (rev 768) @@ -84,8 +84,8 @@ for (String file : files) { String fqn = file.substring(0, file.length() - 5).replaceAll("\\/", "."); - if (getLog().isDebugEnabled()) { - getLog().debug("fqn to treate " + fqn); + if (verbose) { + getLog().info("fqn to treate " + fqn); } Class<?> clazz = Class.forName(fqn, false, loader); @@ -198,8 +198,8 @@ protected void registerEntry(Class<?> clazz, Properties result, String... names) { for (String name : names) { - if (getLog().isDebugEnabled()) { - getLog().debug("name: " + name + ", class:" + clazz); + if (verbose) { + getLog().info("name: " + name + ", class:" + clazz); } result.put("action." + name, clazz.getName()); } @@ -208,7 +208,7 @@ protected void printInit() { for (String file : files) { - getLog().debug(file); + getLog().info(file); } printCP(); @@ -216,10 +216,10 @@ protected void printCP() { - getLog().debug(loader.toString()); + getLog().info(loader.toString()); for (URL url : loader.getURLs()) { - getLog().debug("url in class loader " + url); + getLog().info("url in class loader " + url); } } Modified: trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java =================================================================== --- trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-23 10:27:17 UTC (rev 767) +++ trunk/lutinjaxx/maven/src/main/java/org/codelutin/jaxx/JaxxGeneratorMojo.java 2008-07-23 15:30:43 UTC (rev 768) @@ -25,6 +25,7 @@ import org.codehaus.plexus.util.DirectoryScanner; import java.io.File; +import java.net.URL; /** * Classe permettant de transformer des sources jaxx vers du source java. @@ -87,6 +88,10 @@ } protected void doExecute() throws Exception { + + // force compiler init from here, not in a static block + JAXXCompiler.loadLibraries(verbose); + if (!JAXXCompiler.compile(src, files, options)) { throw new MojoFailureException("Aborting due to errors reported by jaxxc"); } @@ -106,14 +111,34 @@ } protected void printInit() { - getLog().debug("classPath: " + options.getClassPath()); - getLog().debug("javaOut : " + options.getTargetDirectory()); - getLog().debug("outClass : " + options.getJavacTargetDirectory()); - getLog().debug("javacOpts: " + options.getJavacOpts()); - getLog().debug("optiomize: " + options.getOptimize()); + getLog().info("classPath: " + options.getClassPath()); + getLog().info("javaOut : " + options.getTargetDirectory()); + getLog().info("outClass : " + options.getJavacTargetDirectory()); + getLog().info("javacOpts: " + options.getJavacOpts()); + getLog().info("optiomize: " + options.getOptimize()); for (String file : files) { - getLog().debug(file); + getLog().info(file); } + + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + getLog().info(cl.toString()); + if (cl.getClass().getSimpleName().equals("RealmClassLoader")) { + try { + java.lang.reflect.Method m = cl.getClass().getDeclaredMethod("getURLs"); + m.setAccessible(true); + URL[] urls = (URL[]) m.invoke(cl); + + for (URL url : urls) { + getLog().info("url in class loader " + url); + } + } catch (Exception e) { + getLog().warn("??? : " + e.getMessage(), e); + } + } + + for (Object e : getPluginContext().keySet()) { + getLog().info("pluginContext " + e + " : " + getPluginContext().get(e)); + } } public File getSrc() {