Author: alexsmirnov
Date: 2010-07-22 16:10:13 -0400 (Thu, 22 Jul 2010)
New Revision: 18203
Added:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
Modified:
root/cdk/trunk/plugins/generator/pom.xml
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
Log:
https://jira.jboss.org/browse/RF-8964
Modified: root/cdk/trunk/plugins/generator/pom.xml
===================================================================
--- root/cdk/trunk/plugins/generator/pom.xml 2010-07-22 19:39:26 UTC (rev 18202)
+++ root/cdk/trunk/plugins/generator/pom.xml 2010-07-22 20:10:13 UTC (rev 18203)
@@ -166,16 +166,6 @@
<artifactId>dom4j</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-model</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-core</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>com.google.code.javaparser</groupId>
<artifactId>javaparser</artifactId>
<scope>test</scope>
@@ -205,11 +195,11 @@
<!--
<dependency> <groupId>com.google.inject.extensions</groupId>
<artifactId>guice-assisted-inject</artifactId> </dependency>
- -->
+ --><!--
<dependency>
<groupId>org.beanshell</groupId>
<artifactId>bsh</artifactId>
<version>2.0b4</version>
</dependency>
- </dependencies>
+ --></dependencies>
</project>
\ No newline at end of file
Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
(rev 0)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java 2010-07-22
20:10:13 UTC (rev 18203)
@@ -0,0 +1,100 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.cdk;
+
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class CDKHandler extends Handler {
+
+ private final Logger log;
+
+ public CDKHandler(Logger log) {
+ this.log = log;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#close()
+ */
+ @Override
+ public void close() throws SecurityException {
+ // do nothing
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#flush()
+ */
+ @Override
+ public void flush() {
+ // do nothing
+
+ }
+
+ @Override
+ public boolean isLoggable(LogRecord record) {
+ int level = record.getLevel().intValue();
+ if (level >= Level.SEVERE.intValue()) {
+ return log.isErrorEnabled();
+ } else if (level >= Level.WARNING.intValue()) {
+ return log.isWarnEnabled();
+ } else if (level >= Level.INFO.intValue()) {
+ return log.isInfoEnabled();
+ } else {
+ return log.isDebugEnabled();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.util.logging.Handler#publish(java.util.logging.LogRecord)
+ */
+ @Override
+ public void publish(LogRecord record) {
+ int level = record.getLevel().intValue();
+ if (level >= Level.SEVERE.intValue()) {
+ log.error(record.getMessage(), record.getThrown());
+ } else if (level >= Level.WARNING.intValue()) {
+ log.warn(record.getMessage(), record.getThrown());
+ } else if (level >= Level.INFO.intValue()) {
+ log.info(record.getMessage(), record.getThrown());
+ } else {
+ log.debug(record.getMessage(), record.getThrown());
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/CDKHandler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-07-22
19:39:26 UTC (rev 18202)
+++
root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-07-22
20:10:13 UTC (rev 18203)
@@ -32,6 +32,7 @@
import java.util.Collections;
import java.util.Locale;
import java.util.Map;
+import java.util.logging.Level;
import org.richfaces.cdk.apt.AptModule;
import org.richfaces.cdk.generate.java.ClassGeneratorModule;
@@ -79,6 +80,8 @@
private Map<String, String> options = Maps.newHashMap();
+ private java.util.logging.Logger logger;
+
public Generator() {
EmptyFileManager emptyFileManager = new EmptyFileManager();
for (Sources source : Sources.values()) {
@@ -96,6 +99,25 @@
public void setLog(Logger log) {
this.log = log;
+ // setup freemaker logger.
+ try {
+
freemarker.log.Logger.selectLoggerLibrary(freemarker.log.Logger.LIBRARY_JAVA);
+ freemarker.log.Logger.setCategoryPrefix(JavaLogger.CDK_LOG + ".");
+ logger = java.util.logging.Logger.getLogger(JavaLogger.CDK_LOG);
+ logger.addHandler(new CDKHandler(log));
+ if (log.isDebugEnabled()) {
+ logger.setLevel(Level.ALL);
+ } else if (log.isInfoEnabled()) {
+ logger.setLevel(Level.INFO);
+ } else if (log.isWarnEnabled()) {
+ logger.setLevel(Level.WARNING);
+ } else {
+ logger.setLevel(Level.SEVERE);
+ }
+ } catch (ClassNotFoundException e) {
+ log.error(e);
+ // DO Nothing, JDK 6 has built-in Logger facility;
+ }
}
public void addOutputFolder(Outputs type, File outputFolder) {
@@ -114,8 +136,7 @@
public void init() {
injector =
Guice.createInjector(Stage.PRODUCTION, new CdkConfigurationModule(), new
AptModule(), new ModelModule(),
- new ClassGeneratorModule(), new TemplateModule(),
- new XmlModule(), new TaglibModule());
+ new ClassGeneratorModule(), new TemplateModule(), new XmlModule(), new
TaglibModule());
if (!log.isDebugEnabled()) {
try {
@@ -178,7 +199,6 @@
Names.bindProperties(binder(), options);
}
-
}
public String getNamespace() {
Modified:
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java
===================================================================
---
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-07-22
19:39:26 UTC (rev 18202)
+++
root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/LibraryBuilderTest.java 2010-07-22
20:10:13 UTC (rev 18203)
@@ -9,7 +9,6 @@
import java.util.Collections;
import java.util.List;
-import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
/**
@@ -75,14 +74,9 @@
// configure CDK workers.
// setupPlugins(generator);
- try {
-
// Build JSF library.
// LibraryBuilder builder = LibraryBuilder.createInstance(context);
- generator.init();
- } catch (CdkException e) {
- throw new MojoExecutionException("CDK build error", e);
- }
+ generator.init();
}
/**
@@ -100,16 +94,16 @@
return new CdkClassLoader(this.getClass().getClassLoader());
}
- private Iterable<File> findFacesConfigFiles() throws MojoExecutionException {
+ private Iterable<File> findFacesConfigFiles() {
return Collections.emptySet();
}
- private Iterable<File> findJavaFiles() throws MojoExecutionException {
+ private Iterable<File> findJavaFiles() {
return Collections.emptySet();
}
- private Iterable<File> findTemplateFiles() throws MojoExecutionException {
+ private Iterable<File> findTemplateFiles() {
return Collections.emptySet();
}
}