Author: alexsmirnov
Date: 2010-01-27 20:49:03 -0500 (Wed, 27 Jan 2010)
New Revision: 16371
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
Removed:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
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/LibraryBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
Log:
Convert context to dependency injection
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContext.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,115 +0,0 @@
-package org.richfaces.cdk;
-
-import java.io.File;
-
-import org.richfaces.cdk.model.ComponentLibrary;
-
-/**
- * <p class="changed_added_4_0">
- * That interface defines context for all CDK operations
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface CdkContext {
-
- /**
- * <p class="changed_added_4_0">
- * Tools classloader.
- * </p>
- *
- * @return the loader
- */
- public CdkClassLoader getLoader();
-
- /**
- * <p class="changed_added_4_0">Get all sources for given
type.</p>
- * @param type
- * @return
- */
- public Iterable<File> getSources(SourceType type);
-
- /**
- * <p class="changed_added_4_0">Provides default output folder for
given output type.</p>
- * TODO - define "output families" to group similar outputs ( classes,
resources, tests ... ).
- * @param type of output
- * @return output folder for requested type.
- */
- public File getOutputFolder(OutputType type);
-
- /**
- * <p class="changed_added_4_0">This method creates output file in
the appropriate output folder. If target file exists and its modification time is late
than model modification time from {@code lastModified} parameter, no new file will be
created.</p>
- * @param output target output folder.
- * @param relativePath path to file in the output folder.
- * @param lastModified model modification time. If that parameter is less then 0, no
checks for existing file will be performed.
- * @return new created file or null if the target file exists and its modification
time is late then model.
- */
- public File createOutputFile(OutputType output, String relativePath, long
lastModified) throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Record recowerable CdkError. To avoid
consequence builds of the project with many errors, all non-fatal errors ( Java
compilation errors, incorrect xml fales, inconsistent component descriptions ) these error
are stored in the context and marks whole build failed.</p>
- * @param error
- */
- public void sendError(CdkProcessingException error);
-
- public abstract Iterable<CdkProcessingException> getErrors();
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param type
- * @return
- */
- public Iterable<File> getSourceFolders(SourceType type);
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param <W>
- * @param workerClass
- * @return
- * @throws CdkException
- */
- public <W extends CdkWorker> W getWorker(Class<W> workerClass) throws
CdkException;
-
- public abstract <W extends CdkWorker> W setWorker(Class<W> workerClass, W
workerInstance);
-
- /**
- * <p class="changed_added_4_0">Get value of configuration
option.</p>
- * TODO make it type safe.
- * @param name option name.
- * @return option value or null.
- */
- public String getOption(String name);
-
- /**
- * <p class="changed_added_4_0">current JSF components library
model</p>
- * @return
- */
- public ComponentLibrary getLibrary();
-
- public abstract ModelBuilder getBuilderFor(SourceType type) throws CdkException;
-
- public abstract CdkWriter getGeneratorFor(OutputType type) throws CdkException;
-
- /**
- * <p class="changed_added_4_0">Id of source files e.g. Java classes,
faces-configs, renderer templates</p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface SourceType {
-
- String getName();
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @author asmirnov(a)exadel.com
- *
- */
- public interface OutputType {
- String getName();
-
- OutputType getFolderType();
- }
-
-}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkContextBase.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,294 +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;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.richfaces.cdk.apt.AptBuilder;
-import org.richfaces.cdk.generate.java.ComponentClassGenerator;
-import org.richfaces.cdk.model.ComponentLibrary;
-import org.richfaces.cdk.templatecompiler.RendererClassGenerator;
-import org.richfaces.cdk.templatecompiler.RendererTemplateParser;
-import org.richfaces.cdk.xmlconfig.FacesConfigGenerator;
-import org.richfaces.cdk.xmlconfig.FacesConfigParser;
-import org.richfaces.cdk.freemarker.ValidatorTaglibGenerator;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.MutableClassToInstanceMap;
-
-/**
- * <p class="changed_added_4_0">Base CDK context class. Particular build
tool ( Ant, Maven ) should extend that
- * class with tool-specific methods.</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class CdkContextBase implements CdkContext {
-
- /* Map contains writer classes for standard outputs.
- */
- static final ImmutableMap<OutputType, Class<? extends CdkWriter>> WRITERS
=
- ImmutableMap.<OutputType, Class<? extends CdkWriter>>builder()
- .put(StandardOutputs.COMPONENT_CLASSES, ComponentClassGenerator.class)
- .put(StandardOutputs.TAG_LIBRARY, ValidatorTaglibGenerator.class)
- .put(StandardOutputs.RENDERER_CLASSES, RendererClassGenerator.class)
- .put(StandardOutputs.FACES_CONFIG, FacesConfigGenerator.class)
- .build();
-
- /**
- * map contain library model builder classes for each source type.
- */
- static final ImmutableMap<SourceType, Class<? extends ModelBuilder>>
BUILDERS =
- ImmutableMap.<SourceType, Class<? extends ModelBuilder>> builder()
- .put(StandardSources.FACES_CONFIGS, FacesConfigParser.class)
- .put(StandardSources.JAVA_SOURCES, AptBuilder.class)
- .put(StandardSources.RENDERER_TEMPLATES, RendererTemplateParser.class)
- .build();
-
- private Map<String, String> options = Maps.newHashMap();
- private Map<SourceType, Iterable<File>> sources = Maps.newHashMap();
- private Map<OutputType, File> outputs = Maps.newHashMap();
- private Map<SourceType, Iterable<File>> inputFolders =
Maps.newHashMap();
- private ClassToInstanceMap<CdkWorker> workers =
MutableClassToInstanceMap.create();
- private List<CdkProcessingException> errors = Lists.newArrayList();
- private final CdkClassLoader loader;
- private ComponentLibrary library;
-
- public CdkContextBase(CdkClassLoader loader) {
- this.loader = loader;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkContext#getLoader()
- */
- @Override
- public CdkClassLoader getLoader() {
- return loader;
- }
-
- public void addSources(SourceType type, Iterable<File> files) {
- sources.put(type, files);
- }
-
- @Override
- public Iterable<File> getSources(SourceType type) {
- return sources.get(type);
- }
-
- @Override
- public File getOutputFolder(OutputType type) {
- File outputFolder = outputs.get(type);
- OutputType folderType = type.getFolderType();
-
- if (null == outputFolder && null != folderType) {
-
- // Lookup for standard folder type.
- outputFolder = outputs.get(folderType);
-
- // Lookup for output with same folder type.
- Iterator<OutputType> keysIterator = outputs.keySet().iterator();
-
- while (null == outputFolder && keysIterator.hasNext()) {
- OutputType outputType = keysIterator.next();
-
- if (folderType.equals(outputType.getFolderType())) {
- outputFolder = outputs.get(outputType);
- }
- }
- }
-
- return outputFolder;
- }
-
- public void setOutputFolder(OutputType type, File folder) {
- outputs.put(type, folder);
- }
-
- @Override
- public void sendError(CdkProcessingException error) {
- errors.add(error);
- }
-
- @Override
- public Iterable<CdkProcessingException> getErrors() {
- return errors;
- }
-
- @Override
- public Iterable<File> getSourceFolders(SourceType type) {
- return inputFolders.get(type);
- }
-
- public void setSourceFolders(SourceType type, Iterable<File> folders) {
- inputFolders.put(type, folders);
- }
-
- @Override
- public <W extends CdkWorker> W getWorker(Class<W> workerClass) throws
CdkException {
- W worker = workers.getInstance(workerClass);
-
- if (null == worker) {
-
- // instantiate worker.
- try {
- worker = workerClass.newInstance();
- worker.init(this);
- workers.putInstance(workerClass, worker);
- } catch (InstantiationException e) {
- throw new CdkException("error to instantiate cdk component " +
workerClass.getName(), e);
- } catch (IllegalAccessException e) {
- throw new CdkException("Illegal access to cdk component " +
workerClass.getName(), e);
- }
- }
-
- return worker;
- }
-
- @Override
- public <W extends CdkWorker> W setWorker(Class<W> workerClass, W
workerInstance) {
- return workers.putInstance(workerClass, workerInstance);
- }
-
- @Override
- public File createOutputFile(OutputType output, String relativePath, long
lastModified) throws CdkException {
- if (null == relativePath) {
- throw new NullPointerException();
- }
-
- File outputFolder = getOutputFolder(output);
-
- if (null == outputFolder) {
- throw new CdkException("No output folder for type " +
output.getName());
- }
-
- if (outputFolder.exists() && !outputFolder.isDirectory()) {
- throw new CdkException("Output folder " + outputFolder + " not
is directory.");
- }
-
- // Strip leading '/'
- if (relativePath.startsWith(File.separator)) {
- relativePath = relativePath.substring(1);
- }
-
- File outputFile = new File(outputFolder, relativePath);
-
- if (outputFile.exists()) {
- if (lastModified > 0 && outputFile.lastModified() >
lastModified) {
- return null;
- } else {
- outputFile.delete();
- }
- }
-
- // Create file folder.
- outputFile.getParentFile().mkdirs();
-
- try {
- outputFile.createNewFile();
- } catch (IOException e) {
- throw new CdkException("Error create output file", e);
- }
-
- return outputFile;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param options the options to set
- */
- public void setOptions(Map<String, String> options) {
- this.options.putAll(options);
- }
-
- @Override
- public String getOption(String name) {
- return options.get(name);
- }
-
- /**
- * This method returns instance of {@link CdkWriter} for given output type.
- * @param type
- * @return
- * @throws CdkException
- */
- @Override
- public CdkWriter getGeneratorFor(OutputType type) throws CdkException {
- CdkWriter generator = null;
- Class<? extends CdkWriter> writerClass = CdkContextBase.WRITERS.get(type);
-
- if (null != writerClass) {
- generator = getWorker(writerClass);
- } else {
- generator = new DummyGenerator();
- generator.init(this);
-
- // TODO - make service method for new source types.
- // throw new CdkException("No generator for type " +
- // type.getName());
- }
-
- return generator;
- }
-
- /**
- * This method returns initialized instance of the {@link ModelBuilder} for given
source type.
- * @param type
- * @return
- * @throws CdkException
- */
- @Override
- public ModelBuilder getBuilderFor(SourceType type) throws CdkException {
- ModelBuilder builder;
- Class<? extends ModelBuilder> builderClass =
CdkContextBase.BUILDERS.get(type);
-
- if (null != builderClass) {
- builder = getWorker(builderClass);
- } else {
- builder = new DummyBuilder();
- builder.init(this);
-
- // TODO - make service method for new source types.
- // throw new CdkException("No model builder for source type " +
- // type.getName());
- }
-
- return builder;
- }
-
- @Override
- public ComponentLibrary getLibrary() {
- if (library == null) {
- library = new ComponentLibrary();
- }
- return library;
- }
-
-}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkError.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,79 +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">That class incapsulates information about
recoverable CDK errors.</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class CdkError {
- private Throwable cause;
- private String description;
- private String message;
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- */
- public CdkError(String message) {
- this.message = message;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- * @param cause
- */
- public CdkError(String message, Throwable cause) {
- this.message = message;
- this.cause = cause;
- }
-
- public Throwable getCause() {
- return cause;
- }
-
- public void setCause(Throwable cause) {
- this.cause = cause;
- }
-
- public String getDescription() {
- return description;
- }
-
- public void setDescription(String description) {
- this.description = description;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkProcessingError.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,74 +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">That exception indicates recoverable CDK
error, that it is, means
- * errors in source code or configuration files that makes project build failed, so no
result shulde be generated,
- * but does not stop further processing of other classes or files. CDK should collect
such errors but do not stop
- * processing that let developer to know about all errors in the project.</p>
- *
- * @author asmirnov(a)exadel.com
- */
-public class CdkProcessingError extends CdkException {
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- private static final long serialVersionUID = -3696046213271071968L;
-
- /**
- * <p class="changed_added_4_0"></p>
- */
- public CdkProcessingError() {
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- */
- public CdkProcessingError(String message) {
- super(message);
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param cause
- */
- public CdkProcessingError(Throwable cause) {
- super(cause);
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- *
- * @param message
- * @param cause
- */
- public CdkProcessingError(String message, Throwable cause) {
- super(message, cause);
- }
-}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWorker.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,39 +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">Interface for all CDK worker objects (
parsers, validators, renderers etc. ).
- * Instances of these objects are stored in the {@link CdkContext}</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public interface CdkWorker {
- /**
- *
- */
- public void init(CdkContext context);
-}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/CdkWriter.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -30,7 +30,7 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface CdkWriter extends CdkWorker {
+public interface CdkWriter {
public void render() throws CdkException;
}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyBuilder.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,63 +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">This is dummy model builder class for not
yet implemented source types</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class DummyBuilder implements ModelBuilder {
- private CdkContext context;
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#build()
- */
- @Override
- public void build() throws CdkException {
- // Do nothing
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- protected CdkContext getContext() {
- return context;
- }
-}
Deleted:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/DummyGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -1,58 +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">This is dummy generator for not yet
implemented output types</p>
- * @author asmirnov(a)exadel.com
- *
- */
-public class DummyGenerator implements CdkWriter {
- private CdkContext context;
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#init(org.richfaces.cdk.CdkContext)
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
-
- /*
- * (non-Javadoc)
- * @see org.richfaces.cdk.CdkWriter#render(org.richfaces.cdk.model.ComponentLibrary)
- */
- @Override
- public void render() throws CdkException {
-
- // Do nothing
- }
-
- protected CdkContext getContext() {
- return context;
- }
-}
Modified:
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 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/Generator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -24,8 +24,13 @@
import static com.google.common.base.Preconditions.checkNotNull;
-import org.richfaces.cdk.CdkContext.SourceType;
+import org.richfaces.cdk.apt.AptModule;
+import org.richfaces.cdk.freemarker.FreeMakerModule;
+import org.richfaces.cdk.generate.java.ClassGeneratorModule;
import org.richfaces.cdk.model.ComponentLibrary;
+import org.richfaces.cdk.model.ModelModule;
+import org.richfaces.cdk.templatecompiler.TemplateModule;
+import org.richfaces.cdk.xmlconfig.XmlModule;
import java.io.File;
import java.util.Map;
@@ -70,7 +75,8 @@
public void init(){
checkNotNull(loader, "classLoader");
- injector = Guice.createInjector(new CdkConfigurationModule());
+ injector = Guice.createInjector(new CdkConfigurationModule(),new AptModule(),new
ModelModule(),
+ new ClassGeneratorModule(),new FreeMakerModule(),new TemplateModule(),new
XmlModule());
}
public void execute() {
@@ -90,7 +96,6 @@
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);
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/LibraryBuilder.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,9 +25,11 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
-import org.richfaces.cdk.CdkContext.SourceType;
+import javax.inject.Inject;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+
/**
* <p class="changed_added_4_0">
* That class builds JSF library model from different sources. It acts as
@@ -37,61 +39,37 @@
* @author asmirnov(a)exadel.com
*
*/
-public final class LibraryBuilder implements CdkWorker {
+public final class LibraryBuilder {
- /**
- * <p class="changed_added_4_0">
- * Current CDK context
- * </p>
- */
- private CdkContext context;
+ @Inject
+ private Logger log;
+
+ private final ModelValidator validator;
+ private final Iterable<ModelBuilder> builders;
+ private final Iterable<CdkWriter> generators;
+ private final ComponentLibrary library;
+
+
/**
* <p class="changed_added_4_0">
* </p>
*
* @param context
*/
- public LibraryBuilder() {}
+ @Inject
+ public LibraryBuilder(ModelValidator validator,Iterable<ModelBuilder>
builders,Iterable<CdkWriter> generators, ComponentLibrary library) {
+ this.validator = validator;
+ this.builders = builders;
+ this.generators = generators;
+ this.library = library;
+ }
- @Override
- public void init(CdkContext context) {
- this.context = context;
- // default workers.
- }
- /**
- * <p class="changed_added_4_0">
- * Static factory method
- * </p>
- *
- * @return
- * @throws CdkException
- */
- public static LibraryBuilder createInstance(CdkContext context) throws CdkException
{
- return context.getWorker(LibraryBuilder.class);
- }
/**
* <p class="changed_added_4_0">
- * Parse source files for annotations and populate CDK-related information
- * into model.
- * </p>
- * @param library TODO
- * @param sources
- * Java Source files.
- *
- * @return generated library model.
- * @throws CdkException
- */
- public void buildModel(SourceType type) throws CdkException {
- ModelBuilder modelBuilder = context.getBuilderFor(type);
- modelBuilder.build();
- }
-
- /**
- * <p class="changed_added_4_0">
* Build library model from all available sources.
* </p>
*
@@ -100,11 +78,11 @@
*/
public void build() throws CdkException {
- for (SourceType type : StandardSources.values()) {
- buildModel(type);
+ for (ModelBuilder builder : builders) {
+ builder.build();
}
- getVerifier().verify(context.getLibrary());
+ getValidator().verify(library);
generate();
}
@@ -115,38 +93,15 @@
* @throws CdkException
*/
public void generate() throws CdkException {
- for (OutputType type : StandardOutputs.values()) {
- generate(type);
+ if (0 == log.getErrorCount()) {
+ for (CdkWriter generator : generators) {
+ generator.render();
+ }
}
}
- /**
- * <p class="changed_added_4_0">
- * Cenerate files from library model for given type ( eg. component classes,
faces-config ).
- * </p>
- *
- * @param library model
- * @param type of generated files.
- * @throws CdkException
- */
- public void generate(OutputType type) throws CdkException {
- CdkWriter generator = context.getGeneratorFor(type);
- generator.render();
- }
- /**
- * <p class="changed_added_4_0">
- * Getter for the current CDK context
- * </p>
- *
- * @return the context
- */
- protected CdkContext getContext() {
- return context;
+ protected ModelValidator getValidator() throws CdkException {
+ return validator;
}
-
-
- protected ModelValidator getVerifier() throws CdkException {
- return getContext().getWorker(ModelValidator.class);
- }
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelBuilder.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -31,16 +31,8 @@
* @author asmirnov(a)exadel.com
*
*/
-public interface ModelBuilder extends CdkWorker {
+public interface ModelBuilder {
- /**
- * <p class="changed_added_4_0">
- * Initialize builder.
- * </p>
- *
- * @param context
- */
- public void init(CdkContext context);
/**
* <p class="changed_added_4_0">
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ModelValidator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -30,7 +30,7 @@
*
* @author asmirnov(a)exadel.com
*/
-public interface ModelValidator extends CdkWorker {
+public interface ModelValidator {
/**
* <p class="changed_added_4_0">Perform verify procedure on the
library model.</p>
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/NamingConventions.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -34,7 +34,7 @@
*
* @author asmirnov(a)exadel.com
*/
-public interface NamingConventions extends CdkWorker {
+public interface NamingConventions {
/**
* <p class="changed_added_4_0">Calculates component type from
explicit value or base class name.</p>
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,12 @@
+package org.richfaces.cdk;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface OutputType {
+ String getName();
+
+ OutputType getFolderType();
+}
\ No newline at end of file
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/OutputType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/RichFacesConventions.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -20,14 +20,9 @@
private static final String[] COMPONENT_PREFIXES = {UI, ABSTRACT};
private String baseName;
- private CdkContext context;
public RichFacesConventions() {}
- @Override
- public void init(CdkContext context) {
- this.context = context;
- }
@Override
public String inferComponentType(String explicitType, String className) throws
InvalidNameException {
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,11 @@
+package org.richfaces.cdk;
+
+/**
+ * <p class="changed_added_4_0">Id of source files e.g. Java classes,
faces-configs, renderer templates</p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface SourceType {
+
+ String getName();
+}
\ No newline at end of file
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/SourceType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputFolders.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,7 +25,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
/**
* <p class="changed_added_4_0">This enumeration defines standard types
of output folders.</p>
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardOutputs.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,7 +25,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.OutputType;
/**
* <p class="changed_added_4_0"></p>
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/StandardSources.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -23,7 +23,6 @@
package org.richfaces.cdk;
-import org.richfaces.cdk.CdkContext.SourceType;
/**
* <p class="changed_added_4_0">This enumeration defines standard types
for project sources.</p>
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/ValidatorImpl.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -32,32 +32,41 @@
import java.util.Collection;
+import javax.inject.Inject;
+
/**
* <p class="changed_added_4_0"></p>
* @author asmirnov(a)exadel.com
*
*/
public class ValidatorImpl implements ModelValidator {
- private CdkContext context;
- public void init(CdkContext context) {
- this.context = context;
+ @Inject
+ private Logger log;
+
+ private final ComponentLibrary library;
+ private final NamingConventions namingConventions;
+
+ @Inject
+ public ValidatorImpl(ComponentLibrary library, NamingConventions namingConventions)
{
+ this.library = library;
+ // TODO Auto-generated constructor stub
+ this.namingConventions = namingConventions;
}
-
/*
* (non-Javadoc)
* @see
org.richfaces.cdk.ValidatorModel#verify(org.richfaces.cdk.model.ComponentLibrary)
*/
@Override
public void verify(ComponentLibrary library) throws CdkException {
- verifyRenderers(library);
+ verifyRenderers();
verifyComponents(library);
// After all, merge all similar elements.
compact(library.getComponents());
}
- protected void verifyRenderers(ComponentLibrary library) {
+ protected void verifyRenderers() {
for (RenderKitModel.Id renderKitId : library.getRenderKits().keySet()) {
// Check render kit name and class.
RenderKitModel renderKit = library.getRenderKits().get(renderKitId);
@@ -93,7 +102,7 @@
}
private NamingConventions getNamingConventions() throws CdkException {
- return context.getWorker(NamingConventions.class);
+ return namingConventions;
}
protected void compact(Collection<?> collection) {
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptBuilder.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,35 +25,18 @@
package org.richfaces.cdk.apt;
-import org.richfaces.cdk.CdkClassLoader;
-import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkException;
-import org.richfaces.cdk.Logger;
-import org.richfaces.cdk.ModelBuilder;
-import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.StandardSources;
-
import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Locale;
import javax.annotation.processing.Processor;
import javax.inject.Inject;
-import javax.tools.Diagnostic;
-import javax.tools.DiagnosticListener;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-import javax.tools.Diagnostic.Kind;
import javax.tools.JavaCompiler.CompilationTask;
-import com.google.common.collect.Lists;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardSources;
/**
* <p class="changed_added_4_0">
@@ -66,69 +49,19 @@
public class AptBuilder implements ModelBuilder {
@Inject
private static Logger LOG ;
- private boolean initialized = false;
- private CdkContext context;
- private StandardJavaFileManager fileManager;
- private JavaCompiler javaCompiler;
- private Locale locale;
- private Iterable<String> options;
+ @Inject
+ private Processor cdkProcessor;
+ @Inject
+ @Source(StandardSources.JAVA_SOURCES)
+ private Iterable<File> sources;
+
+ @Inject
+ private CompilationTaskFactory taskFactory;
- /**
- * <p class="changed_added_4_0">Builder method that creates and
initializes compiler instance.
- * That instance can be reused for consecuence processing.</p>
- * @param context
- * @return
- */
- @Override
- public void init(CdkContext context) {
- this.context = context;
- JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
-
- setJavaCompiler(javaCompiler);
-
- ArrayList<String> options = new ArrayList<String>();
-
- options.add("-proc:only");
- options.add("-implicit:class");
- options.add("-verbose");
-
- CdkClassLoader classPathLoader = context.getLoader();
-
- setOptions(options);
-
- // TODO - provide source files locale.
- setLocale(Locale.getDefault());
-
- // TODO -set locale and charset for platform-independent processing. Provide own
diagnostics listener.
-
- StandardJavaFileManager stdFileManager =
javaCompiler.getStandardFileManager(null, null, null);
- try {
- stdFileManager.setLocation(StandardLocation.CLASS_PATH,
classPathLoader.getFiles());
- File outputFolder =
context.getOutputFolder(StandardOutputs.COMPONENT_CLASSES);
- if (null != outputFolder) {
-
stdFileManager.setLocation(StandardLocation.SOURCE_OUTPUT,Collections.singleton(outputFolder));
- }
- Iterable<File> sourceFolders =
context.getSourceFolders(StandardSources.JAVA_SOURCES);
-
- if (null != sourceFolders && sourceFolders.iterator().hasNext()) {
- stdFileManager.setLocation(StandardLocation.SOURCE_PATH, sourceFolders);
- }
- } catch (IOException e) {
- throw new CdkException(e);
- }
- setFileManager(stdFileManager);
- initialized = true;
- }
-
public void build() throws CdkException {
- if (!initialized) {
- throw new CdkException("Annotation processor is not initialized");
- }
- CdkProcessor processor = context.getWorker(CdkProcessor.class);
-
- process(context.getSources(StandardSources.JAVA_SOURCES), processor);
+ process(sources, cdkProcessor);
}
/**
@@ -138,103 +71,16 @@
* @throws AptException
*/
protected void process(Iterable<File> sources, Processor... processors) throws
AptException {
- final List<String> messages = Lists.newArrayList();
- DiagnosticListener<JavaFileObject> listener = new
DiagnosticListener<JavaFileObject>() {
- @Override
- public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
- LOG.debug("LOG: " + diagnostic.getMessage(null));
-
- if (Kind.ERROR.equals(diagnostic.getKind())) {
- messages.add(diagnostic.getMessage(null));
- }
- }
- };
-
- Iterable<? extends JavaFileObject> sourceObjects =
getFileManager().getJavaFileObjectsFromFiles(sources);
-
- if (sourceObjects != null && sourceObjects.iterator().hasNext()) {
- CompilationTask task = getJavaCompiler().getTask(null, getFileManager(),
listener, getOptions(), null,
- sourceObjects);
-
+ if (sources != null && sources.iterator().hasNext()) {
+ CompilationTask task = taskFactory.getTask(sources);
task.setProcessors(Arrays.asList(processors));
- task.setLocale(locale);
if (!task.call()) {
- throw new AptException("Compilation error: " + messages);
+ throw new AptException("Compilation error");
}
} else {
LOG.info("No compilation units found, skipping Java sources
processing");
}
}
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the options
- */
- protected Iterable<String> getOptions() {
- return options;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param options
- * the options to set
- */
- protected void setOptions(Iterable<String> options) {
- this.options = options;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the fileManager
- */
- protected StandardJavaFileManager getFileManager() {
- return fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param fileManager the fileManager to set
- */
- protected void setFileManager(StandardJavaFileManager fileManager) {
- this.fileManager = fileManager;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param javaCompiler the javaCompiler to set
- */
- protected void setJavaCompiler(JavaCompiler javaCompiler) {
- this.javaCompiler = javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @return the javaCompiler
- */
- protected JavaCompiler getJavaCompiler() {
- return javaCompiler;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the locale
- */
- public Locale getLocale() {
- return locale;
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @param locale the locale to set
- */
- public void setLocale(Locale locale) {
- this.locale = locale;
- }
-}
+ }
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,54 @@
+/*
+ * $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.apt;
+
+import javax.annotation.processing.Processor;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class AptModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<CdkAnnotationProcessor> setBinder =
Multibinder.newSetBinder(binder(),CdkAnnotationProcessor.class);
+ setBinder.addBinding().to(ComponentProcessor.class);
+ setBinder.addBinding().to(FacesComponentProcessor.class);
+ setBinder.addBinding().to(BehaviorProcessor.class);
+ setBinder.addBinding().to(RendererProcessor.class);
+ setBinder.addBinding().to(ConverterProcessor.class);
+ setBinder.addBinding().to(ValidatorProcessor.class);
+ bind(Processor.class).to(CdkProcessor.class);
+ bind(CompilationTaskFactory.class).to(TaskFactoryImpl.class);
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/AptModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CdkProcessor.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -36,9 +36,9 @@
import org.richfaces.cdk.CdkProcessingException;
import org.richfaces.cdk.CdkWorker;
import org.richfaces.cdk.ModelValidator;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.CdkContext.OutputType;
import com.google.common.collect.ImmutableList;
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,39 @@
+/*
+ * $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.apt;
+
+import java.io.File;
+
+import javax.tools.JavaCompiler.CompilationTask;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public interface CompilationTaskFactory {
+
+ CompilationTask getTask(Iterable<File> sources) throws AptException;
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/CompilationTaskFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,157 @@
+/*
+ * $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.apt;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Collections;
+import java.util.Locale;
+
+import javax.inject.Inject;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import javax.tools.Diagnostic.Kind;
+import javax.tools.JavaCompiler.CompilationTask;
+
+import org.richfaces.cdk.CdkClassLoader;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.Logger;
+import org.richfaces.cdk.OutputFolder;
+import org.richfaces.cdk.Source;
+import org.richfaces.cdk.StandardOutputFolders;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+
+import com.google.common.collect.ImmutableCollection;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TaskFactoryImpl implements CompilationTaskFactory {
+
+ private final class DiagnosticListenerImplementation implements
DiagnosticListener<JavaFileObject> {
+
+ @Override
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ StringBuilder message = new StringBuilder(diagnostic.getMessage(locale));
+ JavaFileObject source = diagnostic.getSource();
+ if (null != source) {
+ message.append(", in the
file:").append(source.getName()).append(" at line ").append(
+ diagnostic.getLineNumber()).append(" in column
").append(diagnostic.getColumnNumber());
+ }
+ Kind kind = diagnostic.getKind();
+ if (Kind.ERROR.equals(kind)) {
+ LOG.error(message);
+ } else if (Kind.MANDATORY_WARNING.equals(kind) || Kind.WARNING.equals(kind))
{
+ LOG.warn(message);
+ } else if (Kind.NOTE.equals(kind)) {
+ LOG.info(message);
+ } else {
+ LOG.debug(message);
+ }
+ }
+ }
+
+ private static final ImmutableCollection<String> options =
ImmutableList.of("-proc:only","-implicit:class","-verbose");
+
+ @Inject
+ private Logger LOG;
+
+ @Inject
+ private Locale locale;
+
+ @Inject
+ private Charset charset;
+
+ @Inject
+ private CdkClassLoader classPathLoader;
+
+ @Inject
+ @OutputFolder(StandardOutputFolders.JAVA_CLASSES)
+ private File outputFolder;
+
+ @Inject
+ @Source(StandardSources.JAVA_SOURCES)
+ private Iterable<File> sourceFolders;
+
+ private JavaCompiler javaCompiler;
+
+ private StandardJavaFileManager fileManager;
+
+ private DiagnosticListener<JavaFileObject> diagnosticListener = new
DiagnosticListenerImplementation();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.cdk.apt.CompilationTaskFactory#getTask(java.lang.Iterable)
+ */
+ @Override
+ public CompilationTask getTask(Iterable<File> sources) throws AptException {
+ diagnosticListener = new DiagnosticListenerImplementation();
+ Iterable<? extends JavaFileObject> sourceObjects =
getFileManager().getJavaFileObjectsFromFiles(sources);
+ CompilationTask task =
+ getJavaCompiler().getTask(null, getFileManager(), diagnosticListener,
options, null, sourceObjects);
+ task.setLocale(locale);
+ return task;
+ }
+
+ private StandardJavaFileManager getFileManager() {
+ if (fileManager == null) {
+ fileManager = javaCompiler.getStandardFileManager(diagnosticListener, locale,
charset);
+ try {
+ fileManager.setLocation(StandardLocation.CLASS_PATH,
classPathLoader.getFiles());
+ if (null != outputFolder) {
+
fileManager.setLocation(StandardLocation.SOURCE_OUTPUT,Collections.singleton(outputFolder));
+ }
+
+ if (null != sourceFolders && sourceFolders.iterator().hasNext())
{
+ fileManager.setLocation(StandardLocation.SOURCE_PATH,
sourceFolders);
+ }
+ } catch (IOException e) {
+ throw new CdkException("Cannot configure JavaFileManager for
compilator",e);
+ }
+
+ }
+ return fileManager;
+ }
+
+ private JavaCompiler getJavaCompiler() {
+ if (javaCompiler == null) {
+ javaCompiler = ToolProvider.getSystemJavaCompiler();
+ }
+ return javaCompiler;
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/apt/TaskFactoryImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,44 @@
+/*
+ * $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.freemarker;
+
+import com.google.inject.AbstractModule;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class FreeMakerModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMakerModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/FreeMarkerRenderer.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -29,9 +29,9 @@
import freemarker.template.Template;
import freemarker.template.TemplateException;
import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContext.OutputType;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.model.LibraryVisitor;
import org.richfaces.cdk.model.Trackable;
import org.richfaces.cdk.model.Visitable;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/freemarker/ValidatorTaglibGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -22,8 +22,8 @@
package org.richfaces.cdk.freemarker;
-import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.model.ComponentLibrary;
import org.richfaces.cdk.model.ValidatorModel;
@@ -53,7 +53,7 @@
}
@Override
- protected CdkContext.OutputType getOutputType() {
+ protected OutputType getOutputType() {
return StandardOutputs.TAG_LIBRARY;
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/BehaviorClassGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -29,6 +29,7 @@
import org.richfaces.cdk.CdkWriter;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import java.io.File;
@@ -68,7 +69,7 @@
}
@Override
- protected CdkContext.OutputType getOutputType() {
+ protected OutputType getOutputType() {
return StandardOutputs.BEHAVIOR_CLASSES;
}
}
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,50 @@
+/*
+ * $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.generate.java;
+
+import org.richfaces.cdk.CdkWriter;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ClassGeneratorModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<CdkWriter> setBinder =
Multibinder.newSetBinder(binder(),CdkWriter.class);
+ setBinder.addBinding().to(ComponentClassGenerator.class);
+ setBinder.addBinding().to(ConverterClassGenerator.class);
+ setBinder.addBinding().to(ValidatorClassGenerator.class);
+ setBinder.addBinding().to(BehaviorClassGenerator.class);
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ClassGeneratorModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ComponentClassGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -28,8 +28,8 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
-import org.richfaces.cdk.CdkContext.OutputType;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.ComponentLibrary;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ConverterClassGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,6 +25,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -63,7 +64,7 @@
}
@Override
- protected CdkContext.OutputType getOutputType() {
+ protected OutputType getOutputType() {
return StandardOutputs.CONVERTER_CLASSES;
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/generate/java/ValidatorClassGenerator.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,6 +25,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.freemarker.FreeMarkerRenderer;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -63,7 +64,7 @@
}
@Override
- protected CdkContext.OutputType getOutputType() {
+ protected OutputType getOutputType() {
return StandardOutputs.VALIDATOR_CLASSES;
}
}
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,44 @@
+/*
+ * $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.model;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.Singleton;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class ModelModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ bind(ComponentLibrary.class).in(Singleton.class);
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/model/ModelModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
(rev 0)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -0,0 +1,49 @@
+/*
+ * $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.templatecompiler;
+
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.ModelBuilder;
+
+import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class TemplateModule extends AbstractModule {
+
+ /* (non-Javadoc)
+ * @see com.google.inject.AbstractModule#configure()
+ */
+ @Override
+ protected void configure() {
+ Multibinder<ModelBuilder> modelBinder = Multibinder.newSetBinder(binder(),
ModelBuilder.class);
+ modelBinder.addBinding().to(RendererTemplateParser.class);
+
Multibinder.newSetBinder(binder(),CdkWriter.class).addBinding().to(RendererClassGenerator.class);
+ }
+
+}
Property changes on:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/TemplateModule.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/CdkEntityResolver.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -25,7 +25,7 @@
import com.google.common.collect.ImmutableMap;
import org.richfaces.cdk.CdkContext;
-import org.richfaces.cdk.CdkContext.SourceType;
+import org.richfaces.cdk.SourceType;
import org.richfaces.cdk.StandardSources;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
Modified:
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/main/java/org/richfaces/cdk/xmlconfig/XmlModule.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -22,9 +22,13 @@
package org.richfaces.cdk.xmlconfig;
-import org.xml.sax.EntityResolver;
+import org.richfaces.cdk.CdkWriter;
+import org.richfaces.cdk.ModelBuilder;
+import org.xml.sax.ext.EntityResolver2;
import com.google.inject.AbstractModule;
+import com.google.inject.multibindings.Multibinder;
+import com.sun.xml.bind.marshaller.NamespacePrefixMapper;
/**
* @author asmirnov
@@ -38,8 +42,12 @@
*/
@Override
protected void configure() {
- bind(EntityResolver.class).to(CdkEntityResolver.class);
+ bind(EntityResolver2.class).to(CdkEntityResolver.class);
bind(JAXB.class).to(JAXBBinding.class);
+ bind(NamespacePrefixMapper.class).to(FacesConfigNamespacePreffixMapper.class);
+ Multibinder<ModelBuilder> modelBinder = Multibinder.newSetBinder(binder(),
ModelBuilder.class);
+ modelBinder.addBinding().to(FacesConfigParser.class);
+
Multibinder.newSetBinder(binder(),CdkWriter.class).addBinding().to(FacesConfigGenerator.class);
}
}
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/apt/CdkProcessorTest.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -58,9 +58,9 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardOutputs;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.CdkContext.OutputType;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.Component;
import org.richfaces.cdk.apt.SourceUtils.BeanProperty;
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/FreeMarkerRendererTest.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -10,8 +10,8 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardSources;
-import org.richfaces.cdk.CdkContext.OutputType;
import org.richfaces.cdk.model.ComponentModel;
import org.richfaces.cdk.model.Visitable;
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/freemarker/ValidatorTaglibGeneratorTest.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -30,6 +30,7 @@
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.ComponentLibrary;
@@ -114,7 +115,7 @@
CdkContext cdkContext = createMock(CdkContext.class);
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType)
anyObject())).andStubReturn(null);
+ expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType)
anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
replay(cdkContext);
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/generate/java/AbstractClassGeneratorTest.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -29,6 +29,7 @@
import org.junit.Assert;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardSources;
import org.richfaces.cdk.model.ClassDescription;
import org.richfaces.cdk.model.EventName;
@@ -52,7 +53,7 @@
CdkContext cdkContext = createMock(CdkContext.class);
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType)
anyObject())).andStubReturn(null);
+ expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType)
anyObject())).andStubReturn(null);
expect(cdkContext.getLoader()).andStubReturn(createClassLoader());
replay(cdkContext);
Modified:
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java
===================================================================
---
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-01-27
23:19:55 UTC (rev 16370)
+++
root/cdk/branches/guice/plugins/generator/src/test/java/org/richfaces/cdk/xmlconfig/CdkResolverTest.java 2010-01-28
01:49:03 UTC (rev 16371)
@@ -10,6 +10,7 @@
import org.richfaces.cdk.CdkClassLoader;
import org.richfaces.cdk.CdkContext;
import org.richfaces.cdk.CdkTestBase;
+import org.richfaces.cdk.OutputType;
import org.richfaces.cdk.StandardSources;
import org.xml.sax.InputSource;
@@ -73,7 +74,7 @@
CdkContext cdkContext = createMock(CdkContext.class);
expect(cdkContext.getSourceFolders(StandardSources.JAVA_SOURCES)).andStubReturn(testSourceDirectory);
- expect(cdkContext.getOutputFolder((org.richfaces.cdk.CdkContext.OutputType)
anyObject())).andStubReturn(null);
+ expect(cdkContext.getOutputFolder((org.richfaces.cdk.OutputType)
anyObject())).andStubReturn(null);
return cdkContext;
}