Author: alexsmirnov
Date: 2010-01-25 22:16:25 -0500 (Mon, 25 Jan 2010)
New Revision: 16359
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
Removed:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
Modified:
root/cdk/branches/guice/plugins/generator/pom.xml
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
Log:
https://jira.jboss.org/jira/browse/RF-8288
Modified: root/cdk/branches/guice/plugins/generator/pom.xml
===================================================================
--- root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-26 03:15:23 UTC (rev 16358)
+++ root/cdk/branches/guice/plugins/generator/pom.xml 2010-01-26 03:16:25 UTC (rev 16359)
@@ -197,11 +197,34 @@
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>2.5.2</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.collections</groupId>
<artifactId>google-collections</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-multibindings</artifactId>
+ <version>2.0</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.inject.extensions</groupId>
+ <artifactId>guice-assisted-inject</artifactId>
+ <version>2.0</version>
+ </dependency>
+
+ <!--
<dependency>
<groupId>com.sun.xsom</groupId>
<artifactId>xsom</artifactId>
@@ -217,5 +240,5 @@
</exclusion>
</exclusions>
</dependency>
- </dependencies>
+ --></dependencies>
</project>
\ No newline at end of file
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.richfaces.cdk.CdkContext.SourceType;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+import java.io.File;
+import java.util.Map;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.Maps;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+import com.google.inject.TypeLiteral;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+public class Generator {
+
+ private CdkClassLoader loader;
+
+ private Logger log = new JavaLogger();
+
+ private Injector injector;
+
+ private Map<StandardOutputFolders, File> outputFolders;
+
+ private Map<StandardSources, Iterable<File>> sources;
+
+ public void setLoader(CdkClassLoader loader) {
+ this.loader = loader;
+ }
+
+ public void setLog(Logger log) {
+ this.log = log;
+ }
+
+ public void setOutputFolders(Map<StandardOutputFolders, File> outputFolders) {
+ this.outputFolders = outputFolders;
+ }
+
+ public void init(){
+ checkNotNull(loader, "classLoader");
+ injector = Guice.createInjector(new CdkConfigurationModule());
+ }
+
+ public void execute() {
+ checkNotNull(injector, "initialized");
+ injector.getInstance(LibraryBuilder.class).build();
+ }
+
+ public class CdkConfigurationModule extends AbstractModule {
+
+ @Override
+ protected void configure() {
+ bind(CdkClassLoader.class).toInstance(loader);
+ bind(Logger.class).toInstance(log);
+ for (Map.Entry<StandardOutputFolders, File> entry :
outputFolders.entrySet()) {
+ bind(File.class).annotatedWith(new
OutputFolderImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ for (Map.Entry<StandardSources, Iterable<File>> entry :
sources.entrySet()) {
+ bind(new TypeLiteral<Iterable<File>>(){}).annotatedWith(new
SourceImpl(entry.getKey())).toInstance(entry.getValue());
+ }
+ bind(ComponentLibrary.class).in(Singleton.class);
+ }
+
+ }
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-01-26
03:15:23 UTC (rev 16358)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/JavaLogger.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -31,8 +31,13 @@
* @author asmirnov(a)exadel.com
*/
class JavaLogger implements Logger {
- java.util.logging.Logger jdkLogger =
java.util.logging.Logger.getLogger(LoggerFactory.CDK_LOG);
+
+ public static final String CDK_LOG = "org.richfaces.cdk";
+ private int errorCount = 0;
+
+ private java.util.logging.Logger jdkLogger =
java.util.logging.Logger.getLogger(CDK_LOG);
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#debug(java.lang.CharSequence)
@@ -66,6 +71,7 @@
*/
@Override
public void error(CharSequence content) {
+ errorCount++;
jdkLogger.severe(String.valueOf(content));
}
@@ -75,6 +81,7 @@
*/
@Override
public void error(CharSequence content, Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, String.valueOf(content), error);
}
@@ -84,9 +91,15 @@
*/
@Override
public void error(Throwable error) {
+ errorCount++;
jdkLogger.log(Level.SEVERE, "", error);
}
+ @Override
+ public int getErrorCount() {
+ return errorCount;
+ }
+
/*
* (non-Javadoc)
* @see org.richfaces.cdk.Logger#info(java.lang.CharSequence)
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26
03:15:23 UTC (rev 16358)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Logger.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -29,35 +29,37 @@
* @author shura
*/
public interface Logger {
- boolean isDebugEnabled();
+ public boolean isDebugEnabled();
- void debug(CharSequence content);
+ public void debug(CharSequence content);
- void debug(CharSequence content, Throwable error);
+ public void debug(CharSequence content, Throwable error);
- void debug(Throwable error);
+ public void debug(Throwable error);
- boolean isInfoEnabled();
+ public boolean isInfoEnabled();
- void info(CharSequence content);
+ public void info(CharSequence content);
- void info(CharSequence content, Throwable error);
+ public void info(CharSequence content, Throwable error);
- void info(Throwable error);
+ public void info(Throwable error);
- boolean isWarnEnabled();
+ public boolean isWarnEnabled();
- void warn(CharSequence content);
+ public void warn(CharSequence content);
- void warn(CharSequence content, Throwable error);
+ public void warn(CharSequence content, Throwable error);
- void warn(Throwable error);
+ public void warn(Throwable error);
- boolean isErrorEnabled();
+ public boolean isErrorEnabled();
- void error(CharSequence content);
+ public void error(CharSequence content);
- void error(CharSequence content, Throwable error);
+ public void error(CharSequence content, Throwable error);
- void error(Throwable error);
+ public void error(Throwable error);
+
+ public int getErrorCount();
}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-01-26
03:15:23 UTC (rev 16358)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LoggerFactory.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -1,143 +0,0 @@
-/*
- * $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;
-
-/**
- * <p class="changed_added_4_0"></p>
- *
- * @author asmirnov(a)exadel.com
- */
-public final class LoggerFactory {
- public static final String CDK_LOG = "org.richfaces.cdk";
-
- /**
- * <p class="changed_added_4_0">Current logger. By default all calls
will be sent to system
- * {@link java.util.logging.Logger}</p>
- */
- private static Logger logger = new JavaLogger();
-
- /**
- * <p class="changed_added_4_0">
- * That constant wraps current logger object to allow access to logger at
- * the class instantiation time.
- * </p>
- */
- private static final Logger WRAPPER = new LoggerWrapper();
-
- private LoggerFactory() {
-
- // That class has static methods only.
- }
-
- public static Logger getLogger() {
- return WRAPPER;
- }
-
- public static void setLogger(Logger newLogger) {
- assert null != newLogger;
- logger = newLogger;
- }
-
- private static final class LoggerWrapper implements Logger {
- @Override
- public void debug(CharSequence content) {
- logger.debug(content);
- }
-
- @Override
- public void debug(CharSequence content, Throwable error) {
- logger.debug(content, error);
- }
-
- @Override
- public void debug(Throwable error) {
- logger.debug(error);
- }
-
- @Override
- public void error(CharSequence content) {
- logger.error(content);
- }
-
- @Override
- public void error(CharSequence content, Throwable error) {
- logger.error(content, error);
- }
-
- @Override
- public void error(Throwable error) {
- logger.error(error);
- }
-
- @Override
- public void info(CharSequence content) {
- logger.info(content);
- }
-
- @Override
- public void info(CharSequence content, Throwable error) {
- logger.info(content, error);
- }
-
- @Override
- public void info(Throwable error) {
- logger.info(error);
- }
-
- @Override
- public boolean isDebugEnabled() {
- return logger.isDebugEnabled();
- }
-
- @Override
- public boolean isErrorEnabled() {
- return logger.isErrorEnabled();
- }
-
- @Override
- public boolean isInfoEnabled() {
- return logger.isInfoEnabled();
- }
-
- @Override
- public boolean isWarnEnabled() {
- return logger.isWarnEnabled();
- }
-
- @Override
- public void warn(CharSequence content) {
- logger.warn(content);
- }
-
- @Override
- public void warn(CharSequence content, Throwable error) {
- logger.warn(content, error);
- }
-
- @Override
- public void warn(Throwable error) {
- logger.warn(error);
- }
- }
-}
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+public @interface OutputFolder {
+ public StandardOutputFolders value();
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolder.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -0,0 +1,36 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class OutputFolderImpl implements OutputFolder {
+
+ private final StandardOutputFolders value;
+
+ public OutputFolderImpl(StandardOutputFolders value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardOutputFolders value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof OutputFolder)) {
+ return false;
+ }
+
+ OutputFolder other = (OutputFolder) o;
+ return value.equals(other.value());
+ }
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return OutputFolder.class;
+ }
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputFolderImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
===================================================================
--- root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+
+package org.richfaces.cdk;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import com.google.inject.BindingAnnotation;
+
+/**
+ * @author asmirnov
+ * @version $Id$
+ *
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+@BindingAnnotation
+(a)Target({ElementType.PARAMETER, ElementType.FIELD,ElementType.METHOD})
+public @interface Source {
+ public StandardSources value();
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Source.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -0,0 +1,36 @@
+package org.richfaces.cdk;
+
+import java.lang.annotation.Annotation;
+
+
+public class SourceImpl implements Source {
+
+ private final StandardSources value;
+
+ public SourceImpl(StandardSources value) {
+ this.value = value;
+ }
+
+ @Override
+ public StandardSources value() {
+ return value;
+ }
+
+ public int hashCode() {
+ // This is specified in java.lang.Annotation.
+ return (127 * "value".hashCode()) ^ value.hashCode();
+ }
+
+ public boolean equals(Object o) {
+ if (!(o instanceof Source)) {
+ return false;
+ }
+
+ Source other = (Source) o;
+ return value.equals(other.value());
+ }
+ @Override
+ public Class<? extends Annotation> annotationType() {
+ return Source.class;
+ }
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-01-26
03:15:23 UTC (rev 16358)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ConfigExtension.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -23,8 +23,9 @@
package org.richfaces.cdk.model;
-import org.dom4j.Element;
+import org.w3c.dom.Element;
+
import javax.xml.bind.annotation.XmlAnyElement;
import java.util.List;
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-01-26
03:15:23 UTC (rev 16358)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/testmodel/Child.java 2010-01-26
03:16:25 UTC (rev 16359)
@@ -25,6 +25,8 @@
package org.richfaces.cdk.xmlconfig.testmodel;
+import org.w3c.dom.Element;
+
import java.util.ArrayList;
import java.util.List;
@@ -34,7 +36,6 @@
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
-import org.dom4j.Element;
/**
* <p class="changed_added_4_0"></p>