[richfaces-svn-commits] JBoss Rich Faces SVN: r14575 - in branches/jsf2.0/cdk: generator/src/main/java/org/ajax4jsf/builder/component and 49 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Tue Jun 9 18:53:30 EDT 2009
Author: alexsmirnov
Date: 2009-06-09 18:53:29 -0400 (Tue, 09 Jun 2009)
New Revision: 14575
Added:
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ActionSource2PropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentModelBuilder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ELPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ExpressionPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PrimitivePropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourceType.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBeanEntry.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigParser.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesDependenciesGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/A4JRendererElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/Attribute.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/BodyElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/DeclarationElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsArray.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/JSTLElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/RootElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElementBase.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CDATAElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CommentElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLAttributes.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLTags.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HtmlAttributesFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/PIElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/TextElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/AppTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/config/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCreateMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateThemeMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java
Removed:
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ActionSource2PropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ExpressionPropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/velocity/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/ant/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/A4JRendererElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/Attribute.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/BodyElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/DeclarationElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsArray.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/JSTLElementsFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/RootElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElementBase.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CDATAElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CommentElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLAttributes.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLTags.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HtmlAttributesFactory.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/PIElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/TextElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/attribute/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils/
branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/velocity/
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java
branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/AppTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/config/
branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/
branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/velocity/
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java
Modified:
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/ELPropertyAccessorMethodBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessorMethodBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutatorMethodBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/VelocityMethodBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/AttachedStateDescriptor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateDescriptor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateManager.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/PrimitiveStateDescriptor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/SimplePropertyDescriptor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/BuilderConfig.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassVisitor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassWalkingLogic.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/EventBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/FunctionBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/JsfBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ListenerBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/LoaderHolder.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ParsingException.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/PropertyBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/RendererBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagHandlerBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/BlankRendererGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ClassPatternSet.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator2.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTagGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterTagGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FaceletsTaglibGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FacesConfigGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/GeneratorException.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/InnerGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/JSFGeneratorConfiguration.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerTagGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/Logger.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RenderKitBean.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererCompilationContext.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagHandlerGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TaglibGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorTagGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/XMLConfigGenerator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/Argument.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/ClassImport.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaClass.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaComment.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaField.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaImport.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/MethodBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/AntFileResourceLoader.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/BuilderContext.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/ClasspathTemplateLoader.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/NamesListComparator.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBody.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/AntCompilationContext.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/TemplateCompilerTask.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/AbstractCompilationContext.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationContext.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationException.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/StringUtils.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/TemplateCompiler.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/Variable.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/CompiledEL.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELParser.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ICompiledEL.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/IELCompiler.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/HtmlAttribute.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/PassThruWithExclusions.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Declaration.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectiveInclude.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectivePage.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Expression.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Scriptlet.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ForEachTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/IFTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ObjectTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/SetTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FCallTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FClientIDTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FInsertChildren.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FResourceTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderResourceElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderScriptsElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderStylesElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/InsertComponent.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/Parameter.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/ParameterProcessor.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/UInsertFacetTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/VcpBodyTemplateElement.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/AntFileResourceLoader.java
branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/BuilderContext.java
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/plexus/components.xml
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/component.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componenttest.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/renderer.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/tag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/ComponentTemplate.vm
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/config/ClassWalkingLogicTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClass.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClassStubBuilderTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseClass.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseInterface.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/ClassPatternSetTest.java
branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyTest.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyAttachedLibraryMojo.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/META-INF/plexus/components.xml
branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/component/config.xml
branches/jsf2.0/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
Log:
rename CDK packages to 'org.richfaces'
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ActionSource2PropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ActionSource2PropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ActionSource2PropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,111 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import java.util.Arrays;
-import java.util.List;
-
-import javax.faces.component.ActionSource2;
-import javax.faces.el.MethodBinding;
-
-import org.ajax4jsf.builder.component.methods.VelocityMethodBody;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaLanguageElement;
-import org.ajax4jsf.builder.model.JavaMethod;
-
-/**
- * @author Maksim Kaszynski
- *
- */
- at SuppressWarnings("deprecation")
-public class ActionSource2PropertyProcessor extends ComponentPropertyProcessor {
-
- private static final List<String> ACCEPTED_NAMES = Arrays.asList("action", "actionListener", "actionExpression");
-
- @Override
- public boolean accept(PropertyBean propertyBean, JavaClass javaClass,
- JSFGeneratorConfiguration configuration) {
-
- boolean result = !propertyBean.isExist();
-
- if (result) {
- result = ActionSource2.class.isAssignableFrom(javaClass.getSuperClass());
- if (result) {
- result = ACCEPTED_NAMES.contains(propertyBean.getName());
- }
- }
-
- return result;
- }
-
- @Override
- public void process(PropertyBean propertyBean, JavaClass javaClass,
- JSFGeneratorConfiguration configuration) {
-
- JavaField field = getField(propertyBean, configuration);
- JavaMethod accessor = getAccessor(configuration, propertyBean, field);
- JavaMethod mutator = getMutator(configuration, propertyBean, field);
-
- if("action".equals(propertyBean.getName())) {
-
- try {
- accessor.setMethodBody(new VelocityMethodBody(configuration) {
- @Override
- public String getTemplate() {
- return "snippets/get-action.vm";
- }
- });
- mutator.setMethodBody(new VelocityMethodBody(configuration) {
- @Override
- public String getTemplate() {
- return "snippets/set-action.vm";
- }
- });
-
- } catch (GeneratorException e) {
- e.printStackTrace();
- }
-
- } else {
- javaClass.addField(field);
- }
-
- if (field.getType().getName().equals(MethodBinding.class.getName())) {
-
- for(JavaLanguageElement el : new JavaLanguageElement[] {field, accessor, mutator}) {
- el.addAnnotation(SuppressWarnings.class, "\"deprecation\"");
- }
-
- }
-
-
- //Do not add variable
- javaClass.addMethod(accessor);
- javaClass.addMethod(mutator);
-
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,206 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import static org.ajax4jsf.builder.model.Argument.arg;
-
-import java.util.Collection;
-
-import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
-
-import org.ajax4jsf.builder.component.state.ComponentStateManager;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.RendererBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaConstructor;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.JavaPackage;
-import org.ajax4jsf.builder.model.MethodBody;
-
-/**
- * Build component class model from configs
- * @author Maksim Kaszynski
- *
- */
-public class ComponentModelBuilder {
-
- private PropertyProcessor[] propertyProcessors = {
- new ActionSource2PropertyProcessor(),
- new ExpressionPropertyProcessor(),
- new PrimitivePropertyProcessor(),
- new ELPropertyProcessor(),
- new ComponentPropertyProcessor()};
-
- public JavaClass build(ComponentBean componentBean, JSFGeneratorConfiguration configuration) {
-
- String superclassname =
- componentBean.getSuperclass();
-
- JavaClass javaClass =
- new JavaClass(componentBean.getSimpleClassName(),
- new JavaPackage(componentBean.getPackageName()));
-
- try {
- Class<?> superClass =
- Class.forName(superclassname, false, configuration.getClassLoader());
-
- javaClass.setSuperClass(superClass);
-
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- javaClass.setSuperClass(UIComponentBase.class);
- }
-
- javaClass.addModifier(JavaModifier.PUBLIC);
-
- javaClass.addField(getComponentFamily(componentBean));
- javaClass.addField(getComponentType(componentBean));
-
- javaClass.addMethod(getConstructor(componentBean, javaClass));
-
- Collection<PropertyBean> properties = componentBean.getProperties();
-
- for (PropertyBean propertyBean : properties) {
- PropertyProcessor proc = null;
-
- for (int i = 0; i < propertyProcessors.length && proc == null; i++) {
-
- PropertyProcessor processor =
- propertyProcessors[i];
-
- if (processor.accept(propertyBean, javaClass, configuration)) {
- proc = processor;
- }
- }
-
- if (proc != null) {
- proc.process(propertyBean, javaClass, configuration);
- }
- }
-
- javaClass.addMethod(getComponentFamilyMethod(componentBean));
-
- ComponentStateManager stateManager = new ComponentStateManager(javaClass);
-
- JavaMethod saveState = getSaveStateTemplate();
- try {
- saveState.setMethodBody(stateManager.getSaveStateMethodBody(configuration));
- } catch (GeneratorException e) {
- e.printStackTrace();
- }
- javaClass.addMethod(saveState);
-
- JavaMethod restoreState = getRestoreStateTemplate();
- try {
- restoreState.setMethodBody(stateManager.getRestoreStateMethodBody(configuration));
- } catch (GeneratorException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- javaClass.addMethod(restoreState);
-
-
-
- return javaClass;
-
- }
-
- private JavaMethod getComponentFamilyMethod(ComponentBean componentBean) {
- JavaMethod javaMethod = new JavaMethod("getFamily", String.class);
- javaMethod.addModifier(JavaModifier.PUBLIC);
- javaMethod.setMethodBody(new MethodBody() {
- @Override
- public String toCode() {
- return "return COMPONENT_FAMILY;";
- }
- });
- return javaMethod;
- }
-
- private JavaMethod getRestoreStateTemplate() {
- JavaMethod method =
- new JavaMethod("restoreState",
- Void.TYPE,
- arg("context", FacesContext.class),
- arg("state", Object.class));
- method.addModifier(JavaModifier.PUBLIC);
- method.addAnnotation(Override.class);
-
- return method;
- }
-
- private JavaMethod getSaveStateTemplate() {
- JavaMethod method =
- new JavaMethod("saveState",
- Object.class,
- arg("context", FacesContext.class));
- method.addModifier(JavaModifier.PUBLIC);
- method.addAnnotation(Override.class);
- method.setMethodBody(new MethodBody() {
- @Override
- public String toCode() {
- return "return super.saveState(context);";
- }
- });
- return method;
- }
-
- private JavaField getComponentType(ComponentBean componentBean) {
- JavaField field = new JavaField(String.class, "COMPONENT_TYPE");
- field.addModifier(JavaModifier.PUBLIC);
- field.addModifier(JavaModifier.STATIC);
- field.addModifier(JavaModifier.FINAL);
- field.setValue("\"" + componentBean.getName() + "\"");
- return field;
- }
- private JavaField getComponentFamily(ComponentBean componentBean) {
- JavaField field = new JavaField(String.class, "COMPONENT_FAMILY");
- field.addModifier(JavaModifier.PUBLIC);
- field.addModifier(JavaModifier.STATIC);
- field.addModifier(JavaModifier.FINAL);
- field.setValue("\"" + componentBean.getFamily() + "\"");
- return field;
- }
-
- private JavaMethod getConstructor(ComponentBean componentBean, JavaClass javaClass) {
- final RendererBean renderer = componentBean.getRenderer();
- JavaMethod method = new JavaConstructor(javaClass);
- method.addModifier(JavaModifier.PUBLIC);
- method.setMethodBody(new MethodBody(method) {
- @Override
- public String toCode() {
- if (renderer != null) {
- return "setRendererType(\"" + renderer.getName() + "\");";
- }
- return super.toCode();
- }
- });
-
- return method;
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,133 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaComment;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaLanguageElement;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.JavaPrimitive;
-import org.ajax4jsf.builder.model.MethodBody;
-
-/**
- * Default property handler - a fallback one.
- * @author Maksim Kaszynski
- *
- */
-public class ComponentPropertyProcessor implements PropertyProcessor {
-
- public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
- return !propertyBean.isExist();
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.render.PropertyProcessor#process(org.ajax4jsf.builder.config.PropertyBean, org.ajax4jsf.builder.model.JavaClass)
- */
- public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
- JavaField field = getField(propertyBean, configuration);
-
- javaClass.addField(field);
- javaClass.addMethod(getAccessor(configuration, propertyBean, field));
- javaClass.addMethod(getMutator(configuration, propertyBean, field));
- }
-
- protected JavaField getField(PropertyBean propertyBean, JSFGeneratorConfiguration configuration) {
- String name = propertyBean.getName();
- String defaultvalue = propertyBean.getDefaultvalue();
- Class<?> propertyClass = getType(propertyBean, configuration.getClassLoader());
- JavaField field = new JavaField(propertyClass, "_" + name, defaultvalue);
- field.getComments().add(new JavaComment(propertyBean.getXmlEncodedDescription()));
- field.getModifiers().add(JavaModifier.PRIVATE);
-
- if (propertyBean.isTransient()) {
- field.addModifier(JavaModifier.TRANSIENT);
- }
-
- handleDeprecation(field.getType(), field);
- return field;
- }
-
- protected Class<?> getType(PropertyBean propertyBean, ClassLoader classLoader) {
- if (propertyBean.isSimpleType()) {
- try {
- Class<?> clazz = JavaPrimitive.forName(propertyBean.getClassname());
- return clazz;
- } catch (Exception e) {
- e.printStackTrace();
- }
- } else {
- try {
- Class<?> clazz = Class.forName(propertyBean.getClassname(), false, classLoader);
- return clazz;
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- return Object.class;
- }
-
- protected JavaMethod getAccessor(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
- JavaMethod accessor =
- new JavaMethod(propertyBean.getGetterName(), field.getType());
-
- accessor.setMethodBody(new MethodBody() {
- @Override
- public String toCode() {
- return "return " + field.getName() + ";";
- }
- });
-
- accessor.addModifier(JavaModifier.PUBLIC);
- handleDeprecation(field.getType(), accessor);
-
- return accessor;
- }
-
- protected JavaMethod getMutator(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
- JavaMethod mutator =
- new JavaMethod(propertyBean.getSetterName(),
- new Argument(field.getName(), field.getType()));
-
- mutator.setMethodBody(new MethodBody(mutator) {
- @Override
- public String toCode() {
- return "this." + field.getName() + " = " + field.getName() + ";";
- }
- });
-
- handleDeprecation(field.getType(), mutator);
- mutator.addModifier(JavaModifier.PUBLIC);
- return mutator;
- }
-
- protected void handleDeprecation(Class<?> type, JavaLanguageElement element) {
- if (type.isAnnotationPresent(Deprecated.class)) {
- element.addAnnotation(SuppressWarnings.class, "\"deprecation\"");
- }
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,65 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import org.ajax4jsf.builder.component.methods.ELPropertyAccessorMethodBody;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.MethodBody;
-
-/**
- * Processing of EL-enabled properties
- * @author Maksim Kaszynski
- *
- */
-public class ELPropertyProcessor extends ComponentPropertyProcessor {
-
- @Override
- public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
- return !(propertyBean.isExist() || propertyBean.isSimpleType()) && propertyBean.isEl() ;
- }
-
- @Override
- protected JavaMethod getAccessor(JSFGeneratorConfiguration config, PropertyBean propertyBean, JavaField field) {
- field.setValue("null");
-
- JavaMethod accessor = super.getAccessor(config, propertyBean, field);
-
- try {
- ELPropertyAccessorMethodBody propertyAccessorMethodBody =
- new ELPropertyAccessorMethodBody(config, propertyBean, field);
-
- accessor.setMethodBody(propertyAccessorMethodBody);
-
- } catch (GeneratorException e) {
- accessor.setMethodBody(new MethodBody());
- e.printStackTrace();
- }
-
- return accessor;
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ExpressionPropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ExpressionPropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ExpressionPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,73 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import javax.el.Expression;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.ValueBinding;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-
-/**
- * @author Maksim Kaszynski
- *
- */
- at SuppressWarnings("deprecation")
-public class ExpressionPropertyProcessor extends ComponentPropertyProcessor {
-
- private static final Class<?>[] acceptedClasses = {
- MethodBinding.class,
- ValueBinding.class,
- Expression.class};
-
- @Override
- public boolean accept(PropertyBean propertyBean, JavaClass javaClass,
- JSFGeneratorConfiguration configuration) {
-
- boolean result =
- !propertyBean.isExist() &&
- propertyBean.isEl() &&
- propertyBean.isElonly();
-
- if (result) {
- Class<?> type =
- getType(propertyBean, configuration.getClassLoader());
-
- result = false;
-
- for (Class<?> clazz : acceptedClasses) {
- if (clazz.isAssignableFrom(type)) {
- result = true;
- break;
- }
- }
-
-
- }
-
-
-
- return result;
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,141 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
-
-import org.ajax4jsf.builder.component.methods.VelocityMethodBody;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.JavaPrimitive;
-import org.ajax4jsf.builder.model.MethodBody;
-
-/**
- * Handle primitive properties
- * @author Maksim Kaszynski
- *
- */
-public class PrimitivePropertyProcessor extends ComponentPropertyProcessor {
-
- class PrimitiveELPropertyAccessorMethodBody extends VelocityMethodBody {
-
- public PrimitiveELPropertyAccessorMethodBody(
- JSFGeneratorConfiguration configuration, JavaField field, JavaField field2, PropertyBean property)
- throws GeneratorException {
- super(configuration);
- getContext().put("field1", field);
- getContext().put("field2", field2);
- getContext().put("wrapperClass", JavaPrimitive.wrapperType(field.getType()));
- getContext().put("property", property);
- addType(ValueExpression.class);
- addType(ELException.class);
- addType(FacesException.class);
- }
-
- @Override
- public String getTemplate() {
- return "snippets/primitive-el-property-accessor.vm";
- }
- }
-
- class PrimitivePropertyAccessorMethodBody extends VelocityMethodBody {
-
- public PrimitivePropertyAccessorMethodBody(
- JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
- throws GeneratorException {
- super(configuration);
- getContext().put("field1", field);
- getContext().put("field2", field2);
- }
-
- @Override
- public String getTemplate() {
- return "snippets/primitive-property-accessor.vm";
- }
- }
-
- class PrimitivePropertyMutatorMethodBody extends VelocityMethodBody {
-
- public PrimitivePropertyMutatorMethodBody(
- JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
- throws GeneratorException {
- super(configuration);
- getContext().put("field1", field);
- getContext().put("field2", field2);
- }
-
- @Override
- public String getTemplate() {
- return "snippets/primitive-property-mutator.vm";
- }
- }
-
- @Override
- public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
- return propertyBean.isSimpleType() && super.accept(propertyBean, javaClass, configuration);
- }
-
- @Override
- public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
- JavaField field = getField(propertyBean, configuration);
- JavaField field2 = new JavaField(boolean.class, field.getName() + "Set", "false");
- field2.addModifier(JavaModifier.PRIVATE);
- if (propertyBean.isTransient()) {
- field2.addModifier(JavaModifier.TRANSIENT);
- }
- JavaMethod accessor = getAccessor(configuration, propertyBean, field);
- MethodBody accessorMethodBody;
-
- try {
- if (propertyBean.isEl()) {
- accessorMethodBody = new PrimitiveELPropertyAccessorMethodBody(configuration, field, field2, propertyBean);
- } else {
- accessorMethodBody = new PrimitivePropertyAccessorMethodBody(configuration, field, field2);
- }
- accessor.setMethodBody(accessorMethodBody);
- } catch (GeneratorException e) {
- e.printStackTrace();
- }
-
- JavaMethod mutator = getMutator(configuration, propertyBean, field);
-
- try {
- PrimitivePropertyMutatorMethodBody mutatorBody = new PrimitivePropertyMutatorMethodBody(configuration, field, field2);
- mutator.setMethodBody(mutatorBody);
- } catch (GeneratorException e) {
- e.printStackTrace();
- }
-
- javaClass.addField(field);
- javaClass.addField(field2);
- javaClass.addMethod(accessor);
- javaClass.addMethod(mutator);
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,36 +0,0 @@
-/**
- * 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.ajax4jsf.builder.component;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-
-/**
- * Process single property - add field to class, accessor, mutator, etc.
- * @author Maksim Kaszynski
- *
- */
-public interface PropertyProcessor {
- boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration);
- void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration);
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/A4JRendererElementsFactory.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/A4JRendererElementsFactory.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/A4JRendererElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,175 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.html.CDATAElement;
-import org.ajax4jsf.templatecompiler.elements.html.CommentElement;
-import org.ajax4jsf.templatecompiler.elements.html.PIElement;
-import org.ajax4jsf.templatecompiler.elements.html.TextElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.AjaxRenderedAreaElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.HeaderScriptsElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.HeaderStylesElement;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.w3c.dom.Node;
-
-/**
- * Tag processors factory.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author:
- * maksimkaszynski $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:44 $
- *
- */
-public class A4JRendererElementsFactory implements ElementsFactory {
-
- private static final Log log = LogFactory.getLog(A4JRendererElementsFactory.class);
-
- public static final String TEMPLATES_PATH = "META-INF/templates";
-
- public static final String TEMPLATES_TEMPLATECOMPILER_PATH = TEMPLATES_PATH+"/templatecompiler";
-
- private final static String DEFAULT_CLASS_ELEMENT_PROCESSOR = "org.ajax4jsf.templatecompiler.elements.html.HTMLElement";
-
- private final static Class[] paramClasses = new Class[] { Node.class,
- CompilationContext.class };
-
- private final static HashMap<String, String> mapClasses = new HashMap<String, String>();
-
- static {
- mapClasses
- .put("c:set",
- "org.ajax4jsf.templatecompiler.elements.std.SetTemplateElement");
- mapClasses
- .put("c:object",
- "org.ajax4jsf.templatecompiler.elements.std.ObjectTemplateElement");
- mapClasses.put("c:if",
- "org.ajax4jsf.templatecompiler.elements.std.IFTemplateElement");
- mapClasses
- .put("c:forEach",
- "org.ajax4jsf.templatecompiler.elements.std.ForEachTemplateElement");
- mapClasses
- .put("f:clientid",
- "org.ajax4jsf.templatecompiler.elements.vcp.FClientIDTemplateElement");
- mapClasses
- .put("f:clientId",
- "org.ajax4jsf.templatecompiler.elements.vcp.FClientIDTemplateElement");
- mapClasses.put("f:insertComponent",
- "org.ajax4jsf.templatecompiler.elements.vcp.InsertComponent");
-
- mapClasses
- .put("f:call",
- "org.ajax4jsf.templatecompiler.elements.vcp.FCallTemplateElement");
- mapClasses
- .put("f:resource",
- "org.ajax4jsf.templatecompiler.elements.vcp.FResourceTemplateElement");
-
- mapClasses
- .put("u:insertFacet",
- "org.ajax4jsf.templatecompiler.elements.vcp.UInsertFacetTemplateElement");
-
- mapClasses
- .put("vcp:body",
- "org.ajax4jsf.templatecompiler.elements.vcp.VcpBodyTemplateElement");
- mapClasses.put("vcp:mock", "");
-
- mapClasses.put("jsp:scriptlet",
- "org.ajax4jsf.templatecompiler.elements.jsp.Scriptlet");
- mapClasses.put("jsp:declaration",
- "org.ajax4jsf.templatecompiler.elements.jsp.Declaration");
- mapClasses.put("jsp:directive.page",
- "org.ajax4jsf.templatecompiler.elements.jsp.DirectivePage");
- mapClasses.put("jsp:expression",
- "org.ajax4jsf.templatecompiler.elements.jsp.Expression");
- mapClasses.put("h:styles", HeaderStylesElement.class.getName());
- mapClasses.put("h:scripts", HeaderScriptsElement.class.getName());
- mapClasses.put("f:template", RootElement.class.getName());
- mapClasses.put("f:root", RootElement.class.getName());
- mapClasses.put("jsp:root", RootElement.class.getName());
- mapClasses.put("ajax:update", AjaxRenderedAreaElement.class.getName());
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.elements.ElementsFactory#getProcessor(org.w3c.dom.Node, org.ajax4jsf.templatecompiler.builder.CompilationContext)
- */
- public TemplateElement getProcessor(final Node nodeElement,
- final CompilationContext componentBean) throws CompilationException {
- TemplateElement returnValue = null;
-
- short nodeType = nodeElement.getNodeType();
- if (Node.CDATA_SECTION_NODE == nodeType) {
- returnValue =new CDATAElement(nodeElement, componentBean);
- } else if (Node.TEXT_NODE == nodeType) {
- returnValue =new TextElement(nodeElement, componentBean);
- } else if (Node.COMMENT_NODE == nodeType) {
- returnValue =new CommentElement(nodeElement, componentBean);
- } else if (Node.PROCESSING_INSTRUCTION_NODE == nodeType) {
- returnValue =new PIElement(nodeElement, componentBean);
- } else if (Node.ELEMENT_NODE == nodeType) {
- String className = (String) mapClasses.get(nodeElement.getNodeName());
-
- if (className == null) {
- className = DEFAULT_CLASS_ELEMENT_PROCESSOR;
- }
-
- if (!className.equals("")) {
- Class class1;
- try {
- log.debug("loading class: " + className);
-
- class1 = Class.forName(className);
- Object[] objects = new Object[2];
- objects[0] = nodeElement;
- objects[1] = componentBean;
-
- returnValue = (TemplateElement) class1.getConstructor(
- paramClasses).newInstance(objects);
- } catch (InstantiationException e) {
- throw new CompilationException("InstantiationException: "
- + e.getLocalizedMessage(), e);
- } catch (IllegalAccessException e) {
- throw new CompilationException("IllegalAccessException: "
- + e.getLocalizedMessage(), e);
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- throw new CompilationException("InvocationTargetException: "
- + e.getMessage(), e);
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- } catch (ClassNotFoundException e) {
- throw new CompilationException(" error loading class: "
- + e.getLocalizedMessage());
- }
- }
- }
- return returnValue;
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/Attribute.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/Attribute.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/Attribute.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,40 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-/**
- * Interface for HTLM-attributes.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/26 20:48:44 $
- *
- */
-public interface Attribute {
- public void copyValues(final Attribute src);
-
- public String getName();
-
- public String getValue();
-
- public String getCode();
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/BodyElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/BodyElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/BodyElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,31 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-/**
- * Marker interface for central body element ( for renderer, contain encodeChildren method content )
- * @author shura
- *
- */
-public interface BodyElement {
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/DeclarationElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/DeclarationElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/DeclarationElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,32 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-/**
- * Marker interdace for {@link TemplateElement} processed as declaration, outside
- * of encode... methods
- * @author shura
- *
- */
-public interface DeclarationElement {
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsArray.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsArray.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsArray.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,55 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-
-/**
- * @author ayukhovich at exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:45 $
- *
- */
-class ElementsArray extends ArrayList<TemplateElement> {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public String toCode() throws CompilationException {
- StringBuffer buf = new StringBuffer();
-
- Iterator<TemplateElement> i = iterator();
- boolean hasNext = i.hasNext();
- while (hasNext) {
- TemplateElement o = i.next();
- if (o != null) {
- buf.append(o.toCode());
- }
- hasNext = i.hasNext();
- } // while
- return buf.toString();
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsFactory.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsFactory.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,37 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public interface ElementsFactory {
-
- public abstract TemplateElement getProcessor(final Node nodeElement,
- final CompilationContext componentBean) throws CompilationException;
-
-}
\ No newline at end of file
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/JSTLElementsFactory.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/JSTLElementsFactory.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/JSTLElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,43 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class JSTLElementsFactory implements ElementsFactory {
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.elements.ElementsFactory#getProcessor(org.w3c.dom.Node, org.ajax4jsf.templatecompiler.builder.CompilationContext)
- */
- public TemplateElement getProcessor(Node nodeElement,
- CompilationContext componentBean) throws CompilationException {
- // TODO Auto-generated method stub
- return null;
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/RootElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/RootElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/RootElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,196 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import java.util.Iterator;
-import java.util.ListIterator;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.vcp.VcpBodyTemplateElement;
-import org.apache.velocity.VelocityContext;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class RootElement extends TemplateElementBase {
-
- private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/ComponentTemplate.vm";
- private static final String ENCODE_BEGIN_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeBegin.vm";
- private static final String ENCODE_END_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeEnd.vm";
- private static final String ENCODE_CHILDREN_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeChildren.vm";
-
- final private static String regexComponent = "(.*)" + VcpBodyTemplateElement.STR_VCB_BODY + "(.*)"
- + VcpBodyTemplateElement.STR_VCB_BODY + "(.*)";
-
- final private static Pattern patternComponent = Pattern.compile(
- regexComponent, Pattern.UNIX_LINES + Pattern.DOTALL);
-
- /**
- * @param element
- * @param componentBean
- */
- public RootElement(Node element, CompilationContext componentBean) {
- super(element, componentBean);
- // TODO apply global attributes
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() throws CompilationException {
- VelocityContext context = new VelocityContext();
- context.put("component", this.getComponentBean());
- return this.getComponentBean().processTemplate(getTemplateName(), context);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElementBase#toCode()
- */
- public String toCode() throws CompilationException {
- VelocityContext context = new VelocityContext();
- context.put("component", this.getComponentBean());
- StringBuffer code = new StringBuffer();
- String beginElement = this.getBeginElement();
- if (null != beginElement) {
- code.append(beginElement);
- code.append("\n");
- }
- StringBuffer declarationsCode = new StringBuffer();
- StringBuffer methodCode = new StringBuffer();
- for (ListIterator<TemplateElement> iter = getSubElements().listIterator(); iter.hasNext();) {
- TemplateElement element = iter.next();
- String toCode = element.toCode();
- if(element instanceof DeclarationElement){
- declarationsCode.append(toCode);
- } /*else if(element instanceof BodyElement){
- // All collected code put to encodeBegin method.
- if (methodCode.length()>0) {
- context.put("body", methodCode.toString());
- code.append(this.getComponentBean().processTemplate(
- getEncodeBeginTemplateName(), context));
- }
- // If body contain any code, create encodeChildren method.
- if (toCode.length()>0) {
- context.put("body", toCode);
- code.append(this.getComponentBean().processTemplate(
- getEncodeChildrenTemplateName(), context));
- }
- methodCode = new StringBuffer();
- } */
- else {
- methodCode.append(toCode);
- }
- }
-
- if (methodCode.length()>0) {
-
- Matcher matcher = patternComponent.matcher(methodCode);
-
- String strEncodeBegin;
- String strEncodeChildren;
- String strEncodeEnd;
-
- if (matcher.find()) {
- strEncodeBegin = matcher.group(1);
- // put content before body element to encodeBegin
- if (strEncodeBegin.trim().length()>0) {
- context.put("body", strEncodeBegin);
- code.append(this.getComponentBean().processTemplate(
- getEncodeBeginTemplateName(), context));
- }
- strEncodeChildren = matcher.group(2);
- if (strEncodeChildren.trim().length()>0 ) {
- // put content of body element
- context.put("body", strEncodeChildren);
- code.append(this.getComponentBean().processTemplate(
- getEncodeChildrenTemplateName(), context));
- }
-
- strEncodeEnd = matcher.group(3);
- if(strEncodeEnd.trim().length()>0){
- // All code after body put to encodeEnd method.
- context.put("body", strEncodeEnd);
- code.append(this.getComponentBean().processTemplate(
- getEncodeEndTemplateName(), context));
- }
- } else {
- // All collected code put to encodeEnd method.
- context.put("body", methodCode.toString());
- code.append(this.getComponentBean().processTemplate(
- getEncodeEndTemplateName(), context));
- }
- }
- if(declarationsCode.length()>0){
- code.append(declarationsCode);
- }
- String endElement = this.getEndElement();
- if (endElement != null) {
- code.append(endElement);
- code.append("\n");
- }
- return code.toString();
- }
-
- /**
- * @return
- */
- protected String getEncodeBeginTemplateName() {
- return ENCODE_BEGIN_TEMPLATE;
- }
-
- /**
- * @return
- */
- protected String getEncodeEndTemplateName() {
- return ENCODE_END_TEMPLATE;
- }
- /**
- * @return
- */
- protected String getEncodeChildrenTemplateName() {
- return ENCODE_CHILDREN_TEMPLATE;
- }
- /**
- * @return
- */
- protected String getTemplateName() {
- return TEMPLATE;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() throws CompilationException {
- // TODO Auto-generated method stub
- return "\n}";
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,51 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import java.util.ArrayList;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-
-/**
- * Intarace for tag processors.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:43 $
- *
- */
-public interface TemplateElement {
- public String getBeginElement() throws CompilationException;
-
- public String getEndElement() throws CompilationException;
-
- public boolean isSkipBody();
-
- public void addSubElement(TemplateElement e);
-
- public String toCode() throws CompilationException;
-
- /**
- * @return the subElements
- */
- public ArrayList<TemplateElement> getSubElements();
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElementBase.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElementBase.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElementBase.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,93 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.w3c.dom.Node;
-
-/**
- * Abstract base class for tag processors.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:44 $
- */
-public abstract class TemplateElementBase implements TemplateElement {
-
-
- private CompilationContext componentBean;
-
- private ElementsArray subElements = new ElementsArray();
-
-
- public TemplateElementBase(final Node element,
- final CompilationContext componentBean) {
- this.componentBean = componentBean;
- };
-
- public boolean isSkipBody() {
- // by default, children process by compiler.
- return false;
- }
-
- public void addSubElement(TemplateElement e) {
- this.subElements.add(e);
- }
-
- public String toCode() throws CompilationException {
- StringBuffer buf = new StringBuffer();
-
- String beginElement = this.getBeginElement();
- if (null != beginElement) {
- buf.append(beginElement);
- buf.append("\n");
- }
-
- if (this.subElements.size() != 0) {
- buf.append(this.subElements.toCode());
- }
-
- String endElement = this.getEndElement();
- if (endElement != null) {
- buf.append(endElement);
- buf.append("\n");
- }
-
- return buf.toString();
- }
-
- /**
- * @return the componentBean
- */
- public CompilationContext getComponentBean() {
- return componentBean;
- }
-
- /**
- * @return the subElements
- */
- public ElementsArray getSubElements() {
- return this.subElements;
- }
-
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CDATAElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CDATAElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CDATAElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,69 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class CDATAElement extends TemplateElementBase {
-
- private String htmlText;
-
- public CDATAElement(Node element, CompilationContext componentBean) {
- super(element, componentBean);
- this.htmlText = element.getNodeValue();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() {
- StringBuffer retValue = new StringBuffer();
- if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
- retValue.append(" writer.write(\"<![CDATA[\");\n");
- retValue.append(" writer.write(convertToString(").append(
- ELParser.compileEL(this.htmlText, this.getComponentBean()))
- .append("));\n");
- retValue.append(" writer.write(\"]]>\");\n");
- }
- return retValue.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() {
- // Do nothitg - text not have childs
- return null;
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CommentElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CommentElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CommentElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,70 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.util.Formatter;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class CommentElement extends TemplateElementBase {
-
- private String htmlText;
-
- public CommentElement(Node element, CompilationContext componentBean) {
- super(element, componentBean);
- this.htmlText = element.getNodeValue();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() {
- String retValue = null;
- if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
- Object[] params = { ELParser.compileEL(this.htmlText, this.getComponentBean()) };
- retValue = new Formatter().format(
- "writer.writeComment(convertToString(%s));\n", params)
- .toString();
- }
- return retValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() {
- // Do nothitg - text not have childs
- return null;
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLAttributes.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLAttributes.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLAttributes.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,63 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.ajax4jsf.templatecompiler.elements.Attribute;
-
-/**
- * Processing HTLM-attributes.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:41 $
- *
- */
-public class HTMLAttributes {
- private LinkedHashMap attributesMap = new LinkedHashMap();
-
-
- public void addAttribute(String nameAttribute, String valueAttribute) {
-
- Attribute attribute = HtmlAttributesFactory.getProcessor(
- nameAttribute, valueAttribute);
-
- if (attribute != null) {
- Attribute oldElemet = (Attribute) this.attributesMap.get(attribute
- .getName());
-
- if (oldElemet != null) {
- oldElemet.copyValues(attribute);
- } else {
- this.attributesMap.put(attribute.getName(), attribute);
- }
- } else {
- System.out.println("attribute is null");
- }
- }
-
- public Map getAttributes() {
- return this.attributesMap;
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,187 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Formatter;
-import java.util.List;
-import java.util.TreeSet;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.apache.velocity.VelocityContext;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * Processing template HTLM-attributes.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:42 $
- *
- */
-public class HTMLElement extends TemplateElementBase {
- final static private String PRE_TAG_NAME = "pre";
-
- private static final String PASS_THRU_ATTR = "x:passThruWithExclusions";
-
- private static final List<String> DEFAULT_EXCLUSIONS = Arrays.asList("class", "id");
-
- private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH
- + "/HTMLElement.vm";
-
- private String htmlTag;
-
- private String htmlText;
-
- private HTMLAttributes htmlAttributes = new HTMLAttributes();
-
- private Collection<String> passThruAttributes = null;
-
- private CompilationContext componentBean;
-
- /**
- *
- * @param element
- * @param variables
- */
- public HTMLElement(final Node element,
- final CompilationContext componentBean) {
- super(element, componentBean);
-
- this.passThruAttributes = null;
- this.htmlTag = element.getNodeName();
- this.componentBean = componentBean;
- processingAttributes(element.getAttributes());
- }
-
- /**
- * @return string contain
- * @throws CompilationException
- */
- public String getBeginElement() throws CompilationException {
- VelocityContext context = new VelocityContext();
- context.put("htmlTag", this.htmlTag);
- context.put("htmlAttributes", this.htmlAttributes.getAttributes());
- context.put("passThruAttributes", this.passThruAttributes);
- if (this.htmlText != null) {
- context.put("htmlText", this.htmlText);
- }
- return this.componentBean.processTemplate(getTemplateName(), context);
-
- }
-
- /**
- * @return
- */
- protected String getTemplateName() {
- // TODO Auto-generated method stub
- return TEMPLATE;
- }
-
- /**
- * @return
- */
- public String getEndElement() {
- String sReturnValue;
-
- Object[] objects = new Object[1];
- objects[0] = this.htmlTag;
-
- sReturnValue = new Formatter().format("writer.endElement(\"%s\");",
- objects).toString();
- return sReturnValue;
- }
-
- /**
- *
- * @param attributes
- */
- public void processingAttributes(NamedNodeMap attributes) {
- if (attributes == null) {
- return;
- }
-
- for (int iElement = 0; iElement != attributes.getLength(); iElement++) {
- Node attribute = attributes.item(iElement);
- String attributeName = attribute.getNodeName();
- String attributeValue = attribute.getNodeValue();
-
- if (attributeName.equals(PASS_THRU_ATTR)) {
- processingPassThruAtrribute(attributeValue);
- } else {
- this.htmlAttributes.addAttribute(attributeName, ELParser
- .compileEL(attributeValue, this.componentBean));
- }
-
- } // for
- }
-
- /**
- *
- * @param listPassThruAttributes
- */
- private void processingPassThruAtrribute(String listPassThruAttributes) {
-
- passThruAttributes =
- new TreeSet<String>(HTMLTags.getAttributes(this.htmlTag));
-
- String[] excludeAttributes = listPassThruAttributes.split(",");
-
- passThruAttributes.removeAll(DEFAULT_EXCLUSIONS);
-
- for (String attribute : excludeAttributes) {
- passThruAttributes.remove(attribute);
- }
-
- }
-
- /**
- * Set a body text for HTML-tag
- *
- * @param nodeText
- */
- public void setText(final String nodeText) {
- String tempStr = null;
- // if TAG is not PRE test do not trim
- if (nodeText.trim().length() != 0) {
- if (this.htmlTag.compareToIgnoreCase(PRE_TAG_NAME) == 0) {
- tempStr = nodeText;
- } else {
- tempStr = nodeText.trim();
- }
- }
-
- if (null != tempStr) {
- if (null == this.htmlText) {
- this.htmlText = ELParser.compileEL(tempStr, this.componentBean);
- } else {
- this.htmlText = this.htmlText
- + ELParser.compileEL(tempStr, this.componentBean);
- }
- }
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLTags.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLTags.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLTags.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,107 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.Map.Entry;
-
-import org.richfaces.dtd.DocumentDefinition;
-import org.richfaces.dtd.DocumentDefinitionFactory;
-import org.richfaces.dtd.Element;
-
-
-/**
- * @author yukhovich
- * @author Maksim Kaszynski
- */
-public class HTMLTags {
- /**
- *
- */
-
- private static final String HTML_SCHEMA = "META-INF/schema/html/xhtml1-transitional.dtd";
-
- private static final URL HTML_DTD = HTMLTags.class.getClassLoader().getResource(HTML_SCHEMA);
-
- @SuppressWarnings("unchecked")
- public static Set<String> getAttributes(String tagName) {
- Set<String> atrs = Collections.emptySet();
-
- DocumentDefinition dtd =
- DocumentDefinitionFactory.instance().getDocumentDefinition(HTML_DTD);
-
- if (dtd != null) {
- Element element = dtd.getElement(tagName);
-
- if (element != null) {
- atrs = element.getAttributes().keySet();
- }
- }
-
- return atrs;
-
- }
-
- /**
- * Look for tags.bin, and compare with it
- * @param args
- * @throws Exception
- */
- public static void main(String [] args) throws Exception{
- InputStream stream = HTMLTags.class.getClassLoader().getResourceAsStream("META-INF/templates/templatecompiler/tags.bin");
-
- ObjectInputStream stream2 = new ObjectInputStream(stream);
-
- @SuppressWarnings("unchecked")
- Map<String, List<String>> m =
- (Map<String, List<String>>) stream2.readObject();
-
- Set<String> newAttrs = new TreeSet<String>();
-
- Set<Entry<String,List<String>>> entrySet = m.entrySet();
- for (Entry<String, List<String>> entry : entrySet) {
- String element = entry.getKey();
-
- Set<String> attributes = HTMLTags.getAttributes(element);
- List<String> attributeList = entry.getValue();
-
- if (attributeList != null && attributes != null) {
- attributes.removeAll(attributeList);
- }
- newAttrs.addAll(attributes);
-
- System.out.println(element + attributes);
-
- }
-
- System.out.println(newAttrs);
- }
-
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HtmlAttributesFactory.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HtmlAttributesFactory.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HtmlAttributesFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,93 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.HashMap;
-
-import org.ajax4jsf.templatecompiler.elements.Attribute;
-
-/**
- * Factory for processing HTLM-attributes.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author:
- * alexeyyukhovich $)
- * @version $Revision: 1.1.2.1 $ $Date: 2007/02/26 20:48:42 $
- *
- */
-public class HtmlAttributesFactory {
- private final static String DEFAULT_CLASS_ATTRIBUTE_PROCESSOR = "org.ajax4jsf.templatecompiler.elements.html.attribute.HtmlAttribute";
-
- private final static Class[] paramClasses = new Class[] { String.class,
- String.class };
-
- private final static HashMap mapClasses = new HashMap();
-
- static {
- // mapClasses.put("x:passThruWithExclusions",
- // "org.ajax4jsf.templatecompiler.elements.html.attribute.PassThruWithExclusions");
- mapClasses.put("x:otherParameters", "");
- }
-
- public static Attribute getProcessor(String attributeName,
- String attributeValue) {
- Attribute returnValue = null;
-
- String className = (String) mapClasses.get(attributeName);
-
- if (className == null) {
- className = DEFAULT_CLASS_ATTRIBUTE_PROCESSOR;
- }
-
- if (!className.equals("")) {
- Class class1;
- try {
- class1 = Class.forName(className);
- try {
- try {
- Object[] objects = new Object[2];
- objects[0] = attributeName;
- objects[1] = attributeValue;
- returnValue = (Attribute) class1.getConstructor(
- paramClasses).newInstance(objects);
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (SecurityException e) {
- e.printStackTrace();
- } catch (InvocationTargetException e) {
- e.printStackTrace();
- } catch (NoSuchMethodException e) {
- e.printStackTrace();
- }
- } catch (ClassNotFoundException e1) {
- e1.printStackTrace();
- }
- }
-
- return returnValue;
- }
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/PIElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/PIElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/PIElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,68 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class PIElement extends TemplateElementBase {
-
- private String htmlText;
-
- public PIElement(Node element, CompilationContext componentBean) {
- super(element, componentBean);
- this.htmlText = element.getNodeValue();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() {
- StringBuffer retValue = new StringBuffer();
- if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
- retValue.append(" writer.write(\"<![CDATA[\");\n");
- retValue.append(" writer.write(").append(
- ELParser.compileEL(this.htmlText, this.getComponentBean())).append(");\n");
- retValue.append(" writer.write(\"]]>\");\n");
- }
- return null; // retValue.toString();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() {
- // Do nothitg - text not have childs
- return null;
- }
-
-}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/TextElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/TextElement.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/TextElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,70 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.elements.html;
-
-import java.util.Formatter;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.w3c.dom.Node;
-
-/**
- * @author shura
- *
- */
-public class TextElement extends TemplateElementBase {
-
- private String htmlText;
-
- public TextElement(Node element, CompilationContext componentBean) {
- super(element, componentBean);
- this.htmlText = element.getNodeValue().trim();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() {
- String retValue = null;
- if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
- Object[] params = { ELParser.compileEL(this.htmlText, this.getComponentBean()) };
- retValue = new Formatter().format(
- "writer.writeText(convertToString(%s),null);\n", params)
- .toString();
- }
- return retValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() {
- // Do nothitg - text not have childs
- return null;
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ActionSource2PropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ActionSource2PropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ActionSource2PropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ActionSource2PropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,111 @@
+/**
+ * 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.builder.component;
+
+import java.util.Arrays;
+import java.util.List;
+
+import javax.faces.component.ActionSource2;
+import javax.faces.el.MethodBinding;
+
+import org.richfaces.builder.component.methods.VelocityMethodBody;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaLanguageElement;
+import org.richfaces.builder.model.JavaMethod;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+ at SuppressWarnings("deprecation")
+public class ActionSource2PropertyProcessor extends ComponentPropertyProcessor {
+
+ private static final List<String> ACCEPTED_NAMES = Arrays.asList("action", "actionListener", "actionExpression");
+
+ @Override
+ public boolean accept(PropertyBean propertyBean, JavaClass javaClass,
+ JSFGeneratorConfiguration configuration) {
+
+ boolean result = !propertyBean.isExist();
+
+ if (result) {
+ result = ActionSource2.class.isAssignableFrom(javaClass.getSuperClass());
+ if (result) {
+ result = ACCEPTED_NAMES.contains(propertyBean.getName());
+ }
+ }
+
+ return result;
+ }
+
+ @Override
+ public void process(PropertyBean propertyBean, JavaClass javaClass,
+ JSFGeneratorConfiguration configuration) {
+
+ JavaField field = getField(propertyBean, configuration);
+ JavaMethod accessor = getAccessor(configuration, propertyBean, field);
+ JavaMethod mutator = getMutator(configuration, propertyBean, field);
+
+ if("action".equals(propertyBean.getName())) {
+
+ try {
+ accessor.setMethodBody(new VelocityMethodBody(configuration) {
+ @Override
+ public String getTemplate() {
+ return "snippets/get-action.vm";
+ }
+ });
+ mutator.setMethodBody(new VelocityMethodBody(configuration) {
+ @Override
+ public String getTemplate() {
+ return "snippets/set-action.vm";
+ }
+ });
+
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+
+ } else {
+ javaClass.addField(field);
+ }
+
+ if (field.getType().getName().equals(MethodBinding.class.getName())) {
+
+ for(JavaLanguageElement el : new JavaLanguageElement[] {field, accessor, mutator}) {
+ el.addAnnotation(SuppressWarnings.class, "\"deprecation\"");
+ }
+
+ }
+
+
+ //Do not add variable
+ javaClass.addMethod(accessor);
+ javaClass.addMethod(mutator);
+
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentModelBuilder.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentModelBuilder.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentModelBuilder.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentModelBuilder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,206 @@
+/**
+ * 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.builder.component;
+
+import static org.richfaces.builder.model.Argument.*;
+
+import java.util.Collection;
+
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+
+import org.richfaces.builder.component.state.ComponentStateManager;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.RendererBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaConstructor;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaPackage;
+import org.richfaces.builder.model.MethodBody;
+
+/**
+ * Build component class model from configs
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentModelBuilder {
+
+ private PropertyProcessor[] propertyProcessors = {
+ new ActionSource2PropertyProcessor(),
+ new ExpressionPropertyProcessor(),
+ new PrimitivePropertyProcessor(),
+ new ELPropertyProcessor(),
+ new ComponentPropertyProcessor()};
+
+ public JavaClass build(ComponentBean componentBean, JSFGeneratorConfiguration configuration) {
+
+ String superclassname =
+ componentBean.getSuperclass();
+
+ JavaClass javaClass =
+ new JavaClass(componentBean.getSimpleClassName(),
+ new JavaPackage(componentBean.getPackageName()));
+
+ try {
+ Class<?> superClass =
+ Class.forName(superclassname, false, configuration.getClassLoader());
+
+ javaClass.setSuperClass(superClass);
+
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ javaClass.setSuperClass(UIComponentBase.class);
+ }
+
+ javaClass.addModifier(JavaModifier.PUBLIC);
+
+ javaClass.addField(getComponentFamily(componentBean));
+ javaClass.addField(getComponentType(componentBean));
+
+ javaClass.addMethod(getConstructor(componentBean, javaClass));
+
+ Collection<PropertyBean> properties = componentBean.getProperties();
+
+ for (PropertyBean propertyBean : properties) {
+ PropertyProcessor proc = null;
+
+ for (int i = 0; i < propertyProcessors.length && proc == null; i++) {
+
+ PropertyProcessor processor =
+ propertyProcessors[i];
+
+ if (processor.accept(propertyBean, javaClass, configuration)) {
+ proc = processor;
+ }
+ }
+
+ if (proc != null) {
+ proc.process(propertyBean, javaClass, configuration);
+ }
+ }
+
+ javaClass.addMethod(getComponentFamilyMethod(componentBean));
+
+ ComponentStateManager stateManager = new ComponentStateManager(javaClass);
+
+ JavaMethod saveState = getSaveStateTemplate();
+ try {
+ saveState.setMethodBody(stateManager.getSaveStateMethodBody(configuration));
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+ javaClass.addMethod(saveState);
+
+ JavaMethod restoreState = getRestoreStateTemplate();
+ try {
+ restoreState.setMethodBody(stateManager.getRestoreStateMethodBody(configuration));
+ } catch (GeneratorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ javaClass.addMethod(restoreState);
+
+
+
+ return javaClass;
+
+ }
+
+ private JavaMethod getComponentFamilyMethod(ComponentBean componentBean) {
+ JavaMethod javaMethod = new JavaMethod("getFamily", String.class);
+ javaMethod.addModifier(JavaModifier.PUBLIC);
+ javaMethod.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return COMPONENT_FAMILY;";
+ }
+ });
+ return javaMethod;
+ }
+
+ private JavaMethod getRestoreStateTemplate() {
+ JavaMethod method =
+ new JavaMethod("restoreState",
+ Void.TYPE,
+ arg("context", FacesContext.class),
+ arg("state", Object.class));
+ method.addModifier(JavaModifier.PUBLIC);
+ method.addAnnotation(Override.class);
+
+ return method;
+ }
+
+ private JavaMethod getSaveStateTemplate() {
+ JavaMethod method =
+ new JavaMethod("saveState",
+ Object.class,
+ arg("context", FacesContext.class));
+ method.addModifier(JavaModifier.PUBLIC);
+ method.addAnnotation(Override.class);
+ method.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return super.saveState(context);";
+ }
+ });
+ return method;
+ }
+
+ private JavaField getComponentType(ComponentBean componentBean) {
+ JavaField field = new JavaField(String.class, "COMPONENT_TYPE");
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addModifier(JavaModifier.STATIC);
+ field.addModifier(JavaModifier.FINAL);
+ field.setValue("\"" + componentBean.getName() + "\"");
+ return field;
+ }
+ private JavaField getComponentFamily(ComponentBean componentBean) {
+ JavaField field = new JavaField(String.class, "COMPONENT_FAMILY");
+ field.addModifier(JavaModifier.PUBLIC);
+ field.addModifier(JavaModifier.STATIC);
+ field.addModifier(JavaModifier.FINAL);
+ field.setValue("\"" + componentBean.getFamily() + "\"");
+ return field;
+ }
+
+ private JavaMethod getConstructor(ComponentBean componentBean, JavaClass javaClass) {
+ final RendererBean renderer = componentBean.getRenderer();
+ JavaMethod method = new JavaConstructor(javaClass);
+ method.addModifier(JavaModifier.PUBLIC);
+ method.setMethodBody(new MethodBody(method) {
+ @Override
+ public String toCode() {
+ if (renderer != null) {
+ return "setRendererType(\"" + renderer.getName() + "\");";
+ }
+ return super.toCode();
+ }
+ });
+
+ return method;
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentPropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ComponentPropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentPropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ComponentPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,133 @@
+/**
+ * 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.builder.component;
+
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.Argument;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaComment;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaLanguageElement;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaPrimitive;
+import org.richfaces.builder.model.MethodBody;
+
+/**
+ * Default property handler - a fallback one.
+ * @author Maksim Kaszynski
+ *
+ */
+public class ComponentPropertyProcessor implements PropertyProcessor {
+
+ public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ return !propertyBean.isExist();
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.builder.render.PropertyProcessor#process(org.richfaces.builder.config.PropertyBean, org.richfaces.builder.model.JavaClass)
+ */
+ public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ JavaField field = getField(propertyBean, configuration);
+
+ javaClass.addField(field);
+ javaClass.addMethod(getAccessor(configuration, propertyBean, field));
+ javaClass.addMethod(getMutator(configuration, propertyBean, field));
+ }
+
+ protected JavaField getField(PropertyBean propertyBean, JSFGeneratorConfiguration configuration) {
+ String name = propertyBean.getName();
+ String defaultvalue = propertyBean.getDefaultvalue();
+ Class<?> propertyClass = getType(propertyBean, configuration.getClassLoader());
+ JavaField field = new JavaField(propertyClass, "_" + name, defaultvalue);
+ field.getComments().add(new JavaComment(propertyBean.getXmlEncodedDescription()));
+ field.getModifiers().add(JavaModifier.PRIVATE);
+
+ if (propertyBean.isTransient()) {
+ field.addModifier(JavaModifier.TRANSIENT);
+ }
+
+ handleDeprecation(field.getType(), field);
+ return field;
+ }
+
+ protected Class<?> getType(PropertyBean propertyBean, ClassLoader classLoader) {
+ if (propertyBean.isSimpleType()) {
+ try {
+ Class<?> clazz = JavaPrimitive.forName(propertyBean.getClassname());
+ return clazz;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ try {
+ Class<?> clazz = Class.forName(propertyBean.getClassname(), false, classLoader);
+ return clazz;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ return Object.class;
+ }
+
+ protected JavaMethod getAccessor(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
+ JavaMethod accessor =
+ new JavaMethod(propertyBean.getGetterName(), field.getType());
+
+ accessor.setMethodBody(new MethodBody() {
+ @Override
+ public String toCode() {
+ return "return " + field.getName() + ";";
+ }
+ });
+
+ accessor.addModifier(JavaModifier.PUBLIC);
+ handleDeprecation(field.getType(), accessor);
+
+ return accessor;
+ }
+
+ protected JavaMethod getMutator(JSFGeneratorConfiguration configuration, PropertyBean propertyBean, final JavaField field) {
+ JavaMethod mutator =
+ new JavaMethod(propertyBean.getSetterName(),
+ new Argument(field.getName(), field.getType()));
+
+ mutator.setMethodBody(new MethodBody(mutator) {
+ @Override
+ public String toCode() {
+ return "this." + field.getName() + " = " + field.getName() + ";";
+ }
+ });
+
+ handleDeprecation(field.getType(), mutator);
+ mutator.addModifier(JavaModifier.PUBLIC);
+ return mutator;
+ }
+
+ protected void handleDeprecation(Class<?> type, JavaLanguageElement element) {
+ if (type.isAnnotationPresent(Deprecated.class)) {
+ element.addAnnotation(SuppressWarnings.class, "\"deprecation\"");
+ }
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ELPropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ELPropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ELPropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ELPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,65 @@
+/**
+ * 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.builder.component;
+
+import org.richfaces.builder.component.methods.ELPropertyAccessorMethodBody;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.MethodBody;
+
+/**
+ * Processing of EL-enabled properties
+ * @author Maksim Kaszynski
+ *
+ */
+public class ELPropertyProcessor extends ComponentPropertyProcessor {
+
+ @Override
+ public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ return !(propertyBean.isExist() || propertyBean.isSimpleType()) && propertyBean.isEl() ;
+ }
+
+ @Override
+ protected JavaMethod getAccessor(JSFGeneratorConfiguration config, PropertyBean propertyBean, JavaField field) {
+ field.setValue("null");
+
+ JavaMethod accessor = super.getAccessor(config, propertyBean, field);
+
+ try {
+ ELPropertyAccessorMethodBody propertyAccessorMethodBody =
+ new ELPropertyAccessorMethodBody(config, propertyBean, field);
+
+ accessor.setMethodBody(propertyAccessorMethodBody);
+
+ } catch (GeneratorException e) {
+ accessor.setMethodBody(new MethodBody());
+ e.printStackTrace();
+ }
+
+ return accessor;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ExpressionPropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/ExpressionPropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ExpressionPropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/ExpressionPropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,73 @@
+/**
+ * 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.builder.component;
+
+import javax.el.Expression;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.ValueBinding;
+
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+ at SuppressWarnings("deprecation")
+public class ExpressionPropertyProcessor extends ComponentPropertyProcessor {
+
+ private static final Class<?>[] acceptedClasses = {
+ MethodBinding.class,
+ ValueBinding.class,
+ Expression.class};
+
+ @Override
+ public boolean accept(PropertyBean propertyBean, JavaClass javaClass,
+ JSFGeneratorConfiguration configuration) {
+
+ boolean result =
+ !propertyBean.isExist() &&
+ propertyBean.isEl() &&
+ propertyBean.isElonly();
+
+ if (result) {
+ Class<?> type =
+ getType(propertyBean, configuration.getClassLoader());
+
+ result = false;
+
+ for (Class<?> clazz : acceptedClasses) {
+ if (clazz.isAssignableFrom(type)) {
+ result = true;
+ break;
+ }
+ }
+
+
+ }
+
+
+
+ return result;
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PrimitivePropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PrimitivePropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PrimitivePropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PrimitivePropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,141 @@
+/**
+ * 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.builder.component;
+
+import javax.el.ELException;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+
+import org.richfaces.builder.component.methods.VelocityMethodBody;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaPrimitive;
+import org.richfaces.builder.model.MethodBody;
+
+/**
+ * Handle primitive properties
+ * @author Maksim Kaszynski
+ *
+ */
+public class PrimitivePropertyProcessor extends ComponentPropertyProcessor {
+
+ class PrimitiveELPropertyAccessorMethodBody extends VelocityMethodBody {
+
+ public PrimitiveELPropertyAccessorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2, PropertyBean property)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ getContext().put("wrapperClass", JavaPrimitive.wrapperType(field.getType()));
+ getContext().put("property", property);
+ addType(ValueExpression.class);
+ addType(ELException.class);
+ addType(FacesException.class);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-el-property-accessor.vm";
+ }
+ }
+
+ class PrimitivePropertyAccessorMethodBody extends VelocityMethodBody {
+
+ public PrimitivePropertyAccessorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-property-accessor.vm";
+ }
+ }
+
+ class PrimitivePropertyMutatorMethodBody extends VelocityMethodBody {
+
+ public PrimitivePropertyMutatorMethodBody(
+ JSFGeneratorConfiguration configuration, JavaField field, JavaField field2)
+ throws GeneratorException {
+ super(configuration);
+ getContext().put("field1", field);
+ getContext().put("field2", field2);
+ }
+
+ @Override
+ public String getTemplate() {
+ return "snippets/primitive-property-mutator.vm";
+ }
+ }
+
+ @Override
+ public boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ return propertyBean.isSimpleType() && super.accept(propertyBean, javaClass, configuration);
+ }
+
+ @Override
+ public void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration) {
+ JavaField field = getField(propertyBean, configuration);
+ JavaField field2 = new JavaField(boolean.class, field.getName() + "Set", "false");
+ field2.addModifier(JavaModifier.PRIVATE);
+ if (propertyBean.isTransient()) {
+ field2.addModifier(JavaModifier.TRANSIENT);
+ }
+ JavaMethod accessor = getAccessor(configuration, propertyBean, field);
+ MethodBody accessorMethodBody;
+
+ try {
+ if (propertyBean.isEl()) {
+ accessorMethodBody = new PrimitiveELPropertyAccessorMethodBody(configuration, field, field2, propertyBean);
+ } else {
+ accessorMethodBody = new PrimitivePropertyAccessorMethodBody(configuration, field, field2);
+ }
+ accessor.setMethodBody(accessorMethodBody);
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+
+ JavaMethod mutator = getMutator(configuration, propertyBean, field);
+
+ try {
+ PrimitivePropertyMutatorMethodBody mutatorBody = new PrimitivePropertyMutatorMethodBody(configuration, field, field2);
+ mutator.setMethodBody(mutatorBody);
+ } catch (GeneratorException e) {
+ e.printStackTrace();
+ }
+
+ javaClass.addField(field);
+ javaClass.addField(field2);
+ javaClass.addMethod(accessor);
+ javaClass.addMethod(mutator);
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PropertyProcessor.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/PropertyProcessor.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PropertyProcessor.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/PropertyProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,36 @@
+/**
+ * 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.builder.component;
+
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+
+/**
+ * Process single property - add field to class, accessor, mutator, etc.
+ * @author Maksim Kaszynski
+ *
+ */
+public interface PropertyProcessor {
+ boolean accept(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration);
+ void process(PropertyBean propertyBean, JavaClass javaClass, JSFGeneratorConfiguration configuration);
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/ELPropertyAccessorMethodBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/ELPropertyAccessorMethodBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/ELPropertyAccessorMethodBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,16 +19,16 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
import javax.el.ELException;
import javax.el.ValueExpression;
import javax.faces.FacesException;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaField;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaField;
/**
* Render accessor for EL-enabled property
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessorMethodBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleAccessorMethodBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleAccessorMethodBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.MethodBody;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.MethodBody;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
+import org.richfaces.builder.model.Argument;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutatorMethodBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/SimpleMutatorMethodBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/SimpleMutatorMethodBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.MethodBody;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.MethodBody;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/VelocityMethodBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/methods/VelocityMethodBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/methods/VelocityMethodBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,15 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.methods;
+package org.richfaces.builder.component.methods;
import java.io.StringWriter;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.MethodBody;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.MethodBody;
/**
* Render method body by using Velocity
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/AttachedStateDescriptor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/AttachedStateDescriptor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/AttachedStateDescriptor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.state;
+package org.richfaces.builder.component.state;
-import org.ajax4jsf.builder.model.JavaField;
+import org.richfaces.builder.model.JavaField;
/**
* Save attached state,
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateDescriptor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateDescriptor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateDescriptor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.state;
+package org.richfaces.builder.component.state;
-import org.ajax4jsf.builder.model.JavaField;
+import org.richfaces.builder.model.JavaField;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateManager.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/ComponentStateManager.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/ComponentStateManager.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,21 +19,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.state;
+package org.richfaces.builder.component.state;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
-import org.ajax4jsf.builder.component.methods.VelocityMethodBody;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.MethodBody;
+import org.richfaces.builder.component.methods.VelocityMethodBody;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.MethodBody;
/**
* Class responsible for generating save/restore state methods.
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/PrimitiveStateDescriptor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/PrimitiveStateDescriptor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/PrimitiveStateDescriptor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.state;
+package org.richfaces.builder.component.state;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaPrimitive;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaPrimitive;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/SimplePropertyDescriptor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/component/state/SimplePropertyDescriptor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/component/state/SimplePropertyDescriptor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.component.state;
+package org.richfaces.builder.component.state;
-import org.ajax4jsf.builder.model.JavaField;
+import org.richfaces.builder.model.JavaField;
/**
* @author Maksim Kaszynski
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/BuilderConfig.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/BuilderConfig.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/BuilderConfig.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.beans.PropertyDescriptor;
import java.io.File;
@@ -34,11 +34,11 @@
import javax.naming.ConfigurationException;
-import org.ajax4jsf.builder.generator.Logger;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.digester.Digester;
import org.apache.commons.digester.ExtendedBaseRules;
import org.apache.tools.ant.BuildException;
+import org.richfaces.builder.generator.Logger;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.ext.EntityResolver2;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassVisitor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ClassVisitor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassVisitor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassWalkingLogic.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ClassWalkingLogic.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ClassWalkingLogic.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* @author Maksim Kaszynski
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,381 +0,0 @@
-package org.ajax4jsf.builder.config;
-
-import java.beans.PropertyDescriptor;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.naming.ConfigurationException;
-
-import org.apache.commons.beanutils.PropertyUtils;
-
-public class ComponentBaseBean extends JsfBean {
-
- private static final String[] ignorableComponentProperties = {
- "class",
- "attributes",
- "childCount",
- "children",
- "facets",
- "facetsAndChildren",
- "family",
- "parent",
- "rendererType",
- "rendersChildren",
- "submittedValue",
- "transient"};
- private static final String[] enabledTagProperties = {
- "binding"
- };
- private static final String[] attachedStateProperties = {
- "javax.faces.component.StateHolder",
- "java.util.List",
- "javax.faces.el.MethodBinding",
- "javax.faces.el.ValueBinding",
- "javax.el.MethodExpression",
- "javax.el.ValueExpression",
- "javax.faces.convert.Converter"
- };
-
-
- /**
- * JSP ( facelets ? ) tag description for component
- */
- private TagBean _tag;
- private TagHandlerBean _taghandler;
- /**
- * Descriptions of component JavaBean properties
- */
- private Map<String,PropertyBean> properties = new TreeMap<String,PropertyBean>();
- /**
- * Flag for generate component instance class
- */
- private boolean generate = true;
-
- /**
- * @return Returns the tag.
- */
- public TagBean getTag() {
- return _tag;
- }
-
- /**
- * @param tag The tag to set.
- */
- public void setTag(TagBean tag) {
- _tag = tag;
- tag.setParent(this);
- }
-
- /**
- * @return Returns the generate.
- */
- public boolean isGenerate() {
- return this.generate;
- }
-
- /**
- * @param generate The generate to set.
- */
- public void setGenerate(boolean generate) {
- this.generate = generate;
- }
-
- /**
- * @return Returns the tagSupport.
- */
- public TagHandlerBean getTaghandler() {
- return this._taghandler;
- }
-
- /**
- * @param tagSupport The tagSupport to set.
- */
- public void setTaghandler(TagHandlerBean tagSupport) {
- this._taghandler = tagSupport;
- }
-
- /**
- * @return Returns the properties.
- */
- public Collection<PropertyBean> getProperties() {
- return properties.values();
- }
-
- /**
- * @param name
- * @return true if component have property with given name
- */
- public boolean containProperty(String name) {
- return properties.containsKey(name);
- }
-
- public PropertyBean getProperty(String name){
- return properties.get(name);
- }
-
- /**
- * Append property to component. If property with name exist, replace it
- * @param property
- */
- public void addProperty(PropertyBean property) {
- this.properties.put(property.getName(),property);
- property.setParent(this);
- }
-
- /**
- * Subclasses should extend this method to provide specifc checks
- *
- * Check existing and default properties
- * For properties filled from configuration, attempt to set additional parameters.
- * If base class have any bean properties, append it to configured
- * @throws ConfigurationException
- */
- public void checkProperties() throws ParsingException {
- try {
- getLog().debug("Parse properties for Component "+getName()+" with superclass "+getSuperclass());
- if (getSuperclass() != null)
- {
- Class <?> superClass = getLoader().loadClass(getSuperclass());
-
- new ClassWalkingLogic(superClass)
- .walk(new ClassVisitor() {
- public void visit(Class<?> clazz) {
- checkPropertiesForClass(clazz);
- }
- });
- }
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for component "+getName(), e);
- }
- if (null != getTag()) {
- try {
- Class superClass = getLoader().loadClass(getTag().getSuperclass());
- PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
- // for all properties, add it to component. If property have not abstract getter/setter ,
- // add it with exist = true . If property in list of hidden names, set hidden = true.
- for (int i = 0; i < properties.length; i++) {
- PropertyDescriptor descriptor = properties[i];
- Method writeMethod = descriptor.getWriteMethod();
- if(containProperty(descriptor.getName())){
- if (null != writeMethod && !Modifier.isAbstract(writeMethod.getModifiers()) && Modifier.isPublic(writeMethod.getModifiers()) ) {
- ((PropertyBean) this.properties.get(descriptor
- .getName())).setExistintag(true);
- }
- } else if (null != writeMethod && Modifier.isPublic(writeMethod.getModifiers())) {
- if (Arrays.asList(enabledTagProperties).contains(
- descriptor.getName())) {
- Class type = descriptor.getPropertyType();
- getLog().debug("Register tag property "
- + descriptor.getName() + " with type name "
- + type.getCanonicalName() );
- PropertyBean property = new PropertyBean();
- property.setName(descriptor.getName());
- property.setDescription(descriptor
- .getShortDescription());
- property
- .setDisplayname(descriptor.getDisplayName());
- property.setClassname(descriptor.getPropertyType()
- .getCanonicalName());
- property.setExist(true);
- if (!Modifier
- .isAbstract(writeMethod.getModifiers())) {
- property.setExistintag(true);
- }
- addProperty(property);
- }
- }
- }
- } catch (ClassNotFoundException e) {
- // TODO Auto-generated catch block
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- }
-
- }
- }
-
-
-
-
- /**
- * @param superClass
- */
- private void checkPropertiesForClass(Class<?> superClass) {
- getLog().debug("Check properties for class "+superClass.getName());
- // get all property descriptors
- PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
- // for all properties, add it to component. If property have not abstract getter/setter ,
- // add it with exist = true . If property in list of hidden names, set hidden = true.
- PropertyBean property;
- for (int i = 0; i < properties.length; i++) {
- PropertyDescriptor descriptor = properties[i];
- if(!containProperty(descriptor.getName())){
- if(isIgnorableProperty(superClass, descriptor.getName())) {
- continue;
- }
- Class<?> type = descriptor.getPropertyType();
- getLog().debug("Register property "+descriptor.getName()+" with type name "+type.getCanonicalName());
- property = new PropertyBean();
- property.setName(descriptor.getName());
- property.setDescription(descriptor.getShortDescription());
- property.setDisplayname(descriptor.getDisplayName());
- property.setClassname(descriptor.getPropertyType().getCanonicalName());
- property.setExist(true);
- addProperty(property);
- } else {
- // Load and check property.
- getLog().debug("Check property "+descriptor.getName());
- property = (PropertyBean) this.properties.get(descriptor.getName());
- if(property.getClassname() == null) {
- property.setClassname(descriptor.getPropertyType().getCanonicalName());
- } else {
- if(!property.getClassname().equals(descriptor.getPropertyType().getCanonicalName())){
- String message = "Class "+property.getClassname()+" for property "+property.getName()+" not equals with real bean property type: "+descriptor.getPropertyType().getCanonicalName();
- getLog().error(message);
- //throw new IllegalArgumentException(message);
- }
- }
- if (property.getDescription() == null) {
- property.setDescription(descriptor.getShortDescription());
- }
- if(property.getDisplayname() == null){
- property.setDisplayname(descriptor.getDisplayName());
- }
- property.setExist(true);
- }
- Method getter = descriptor.getReadMethod();
- Method setter = descriptor.getWriteMethod();
- // Abstract methods
- if(null != setter && null != getter ){
- if( (Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())) || superClass.isInterface()){
- getLog().debug("Detect as abstract property "+descriptor.getName());
- property.setExist(false);
- }
- }
-
- if(null == setter || (! Modifier.isPublic(setter.getModifiers())) ){
- getLog().debug("Detect as hidden property "+descriptor.getName());
- property.setHidden(true);
- }
- if (isAttachedProperty(property)) {
- property.setAttachedstate(true);
- }
- if (property.isInstanceof("javax.faces.el.MethodBinding") ||
- property.isInstanceof("javax.faces.el.ValueBinding")) {
- property.setElonly(true);
- }
-
- }
- }
-
- private boolean isIgnorableProperty(Class<?> base, String name) {
- return Arrays.asList(ignorableComponentProperties).contains(name);
- }
-
- private boolean isAttachedProperty(PropertyBean prop) {
- for (int i = 0; i < attachedStateProperties.length; i++) {
- String clazz = attachedStateProperties[i];
- if(prop.isInstanceof(clazz)) {
- return true;
- }
- }
- return false;
- }
-
- public boolean isStateHolderRequired() {
- getLog().info("isStateHolderRequired");
- for (PropertyBean propertyBean : getProperties())
- {
- getLog().info("Property " + propertyBean.getName() + "/" + propertyBean.isTransient());
- if (!propertyBean.isTransient())
- {
- return true;
- }
- }
- return false;
- }
-
- public boolean isSuperclassImplementsStateHolder()
- {
- try {
- Class superClass = getLoader().loadClass(getSuperclass());
- return (StateHolder.class.isAssignableFrom(superClass));
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- return false;
- }
- }
-
- public boolean isSuperSaveStateMethodExists()
- {
- try {
- Class superClass = getLoader().loadClass(getSuperclass());
- Class[] signature = {FacesContext.class};
- try {
- Method m = superClass.getMethod("saveState", signature);
- return !Modifier.isAbstract(m.getModifiers());
- } catch (NoSuchMethodException e) {
- return false;
- }
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- return false;
- }
- }
-
- public boolean isSuperRestoreStateMethodExists()
- {
- try {
- Class superClass = getLoader().loadClass(getSuperclass());
- Class[] signature = {FacesContext.class, Object.class};
- try {
- Method m = superClass.getMethod("restoreState", signature);
- return !Modifier.isAbstract(m.getModifiers());
- } catch (NoSuchMethodException e) {
- return false;
- }
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- return false;
- }
- }
-
- public boolean isSuperIsTransientMethodExists()
- {
- try {
- Class superClass = getLoader().loadClass(getSuperclass());
- Class[] signature = new Class[0];
- try {
- Method m = superClass.getMethod("isTransient", signature);
- return !Modifier.isAbstract(m.getModifiers());
- } catch (NoSuchMethodException e) {
- return false;
- }
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- return false;
- }
- }
-
- public boolean isSuperSetTransientMethodExists()
- {
- try {
- Class superClass = getLoader().loadClass(getSuperclass());
- Class[] signature = {boolean.class};
- try {
- Method m = superClass.getMethod("setTransient", signature);
- return !Modifier.isAbstract(m.getModifiers());
- } catch (NoSuchMethodException e) {
- return false;
- }
- } catch (ClassNotFoundException e) {
- getLog().error("superclass not found for tag "+getTag().getName(), e);
- return false;
- }
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBaseBean.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBaseBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,402 @@
+/**
+ * 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.builder.config;
+
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+
+import javax.faces.component.StateHolder;
+import javax.faces.context.FacesContext;
+import javax.naming.ConfigurationException;
+
+import org.apache.commons.beanutils.PropertyUtils;
+
+public class ComponentBaseBean extends JsfBean {
+
+ private static final String[] ignorableComponentProperties = {
+ "class",
+ "attributes",
+ "childCount",
+ "children",
+ "facets",
+ "facetsAndChildren",
+ "family",
+ "parent",
+ "rendererType",
+ "rendersChildren",
+ "submittedValue",
+ "transient"};
+ private static final String[] enabledTagProperties = {
+ "binding"
+ };
+ private static final String[] attachedStateProperties = {
+ "javax.faces.component.StateHolder",
+ "java.util.List",
+ "javax.faces.el.MethodBinding",
+ "javax.faces.el.ValueBinding",
+ "javax.el.MethodExpression",
+ "javax.el.ValueExpression",
+ "javax.faces.convert.Converter"
+ };
+
+
+ /**
+ * JSP ( facelets ? ) tag description for component
+ */
+ private TagBean _tag;
+ private TagHandlerBean _taghandler;
+ /**
+ * Descriptions of component JavaBean properties
+ */
+ private Map<String,PropertyBean> properties = new TreeMap<String,PropertyBean>();
+ /**
+ * Flag for generate component instance class
+ */
+ private boolean generate = true;
+
+ /**
+ * @return Returns the tag.
+ */
+ public TagBean getTag() {
+ return _tag;
+ }
+
+ /**
+ * @param tag The tag to set.
+ */
+ public void setTag(TagBean tag) {
+ _tag = tag;
+ tag.setParent(this);
+ }
+
+ /**
+ * @return Returns the generate.
+ */
+ public boolean isGenerate() {
+ return this.generate;
+ }
+
+ /**
+ * @param generate The generate to set.
+ */
+ public void setGenerate(boolean generate) {
+ this.generate = generate;
+ }
+
+ /**
+ * @return Returns the tagSupport.
+ */
+ public TagHandlerBean getTaghandler() {
+ return this._taghandler;
+ }
+
+ /**
+ * @param tagSupport The tagSupport to set.
+ */
+ public void setTaghandler(TagHandlerBean tagSupport) {
+ this._taghandler = tagSupport;
+ }
+
+ /**
+ * @return Returns the properties.
+ */
+ public Collection<PropertyBean> getProperties() {
+ return properties.values();
+ }
+
+ /**
+ * @param name
+ * @return true if component have property with given name
+ */
+ public boolean containProperty(String name) {
+ return properties.containsKey(name);
+ }
+
+ public PropertyBean getProperty(String name){
+ return properties.get(name);
+ }
+
+ /**
+ * Append property to component. If property with name exist, replace it
+ * @param property
+ */
+ public void addProperty(PropertyBean property) {
+ this.properties.put(property.getName(),property);
+ property.setParent(this);
+ }
+
+ /**
+ * Subclasses should extend this method to provide specifc checks
+ *
+ * Check existing and default properties
+ * For properties filled from configuration, attempt to set additional parameters.
+ * If base class have any bean properties, append it to configured
+ * @throws ConfigurationException
+ */
+ public void checkProperties() throws ParsingException {
+ try {
+ getLog().debug("Parse properties for Component "+getName()+" with superclass "+getSuperclass());
+ if (getSuperclass() != null)
+ {
+ Class <?> superClass = getLoader().loadClass(getSuperclass());
+
+ new ClassWalkingLogic(superClass)
+ .walk(new ClassVisitor() {
+ public void visit(Class<?> clazz) {
+ checkPropertiesForClass(clazz);
+ }
+ });
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for component "+getName(), e);
+ }
+ if (null != getTag()) {
+ try {
+ Class superClass = getLoader().loadClass(getTag().getSuperclass());
+ PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
+ // for all properties, add it to component. If property have not abstract getter/setter ,
+ // add it with exist = true . If property in list of hidden names, set hidden = true.
+ for (int i = 0; i < properties.length; i++) {
+ PropertyDescriptor descriptor = properties[i];
+ Method writeMethod = descriptor.getWriteMethod();
+ if(containProperty(descriptor.getName())){
+ if (null != writeMethod && !Modifier.isAbstract(writeMethod.getModifiers()) && Modifier.isPublic(writeMethod.getModifiers()) ) {
+ ((PropertyBean) this.properties.get(descriptor
+ .getName())).setExistintag(true);
+ }
+ } else if (null != writeMethod && Modifier.isPublic(writeMethod.getModifiers())) {
+ if (Arrays.asList(enabledTagProperties).contains(
+ descriptor.getName())) {
+ Class type = descriptor.getPropertyType();
+ getLog().debug("Register tag property "
+ + descriptor.getName() + " with type name "
+ + type.getCanonicalName() );
+ PropertyBean property = new PropertyBean();
+ property.setName(descriptor.getName());
+ property.setDescription(descriptor
+ .getShortDescription());
+ property
+ .setDisplayname(descriptor.getDisplayName());
+ property.setClassname(descriptor.getPropertyType()
+ .getCanonicalName());
+ property.setExist(true);
+ if (!Modifier
+ .isAbstract(writeMethod.getModifiers())) {
+ property.setExistintag(true);
+ }
+ addProperty(property);
+ }
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ // TODO Auto-generated catch block
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ }
+
+ }
+ }
+
+
+
+
+ /**
+ * @param superClass
+ */
+ private void checkPropertiesForClass(Class<?> superClass) {
+ getLog().debug("Check properties for class "+superClass.getName());
+ // get all property descriptors
+ PropertyDescriptor[] properties = PropertyUtils.getPropertyDescriptors(superClass);
+ // for all properties, add it to component. If property have not abstract getter/setter ,
+ // add it with exist = true . If property in list of hidden names, set hidden = true.
+ PropertyBean property;
+ for (int i = 0; i < properties.length; i++) {
+ PropertyDescriptor descriptor = properties[i];
+ if(!containProperty(descriptor.getName())){
+ if(isIgnorableProperty(superClass, descriptor.getName())) {
+ continue;
+ }
+ Class<?> type = descriptor.getPropertyType();
+ getLog().debug("Register property "+descriptor.getName()+" with type name "+type.getCanonicalName());
+ property = new PropertyBean();
+ property.setName(descriptor.getName());
+ property.setDescription(descriptor.getShortDescription());
+ property.setDisplayname(descriptor.getDisplayName());
+ property.setClassname(descriptor.getPropertyType().getCanonicalName());
+ property.setExist(true);
+ addProperty(property);
+ } else {
+ // Load and check property.
+ getLog().debug("Check property "+descriptor.getName());
+ property = (PropertyBean) this.properties.get(descriptor.getName());
+ if(property.getClassname() == null) {
+ property.setClassname(descriptor.getPropertyType().getCanonicalName());
+ } else {
+ if(!property.getClassname().equals(descriptor.getPropertyType().getCanonicalName())){
+ String message = "Class "+property.getClassname()+" for property "+property.getName()+" not equals with real bean property type: "+descriptor.getPropertyType().getCanonicalName();
+ getLog().error(message);
+ //throw new IllegalArgumentException(message);
+ }
+ }
+ if (property.getDescription() == null) {
+ property.setDescription(descriptor.getShortDescription());
+ }
+ if(property.getDisplayname() == null){
+ property.setDisplayname(descriptor.getDisplayName());
+ }
+ property.setExist(true);
+ }
+ Method getter = descriptor.getReadMethod();
+ Method setter = descriptor.getWriteMethod();
+ // Abstract methods
+ if(null != setter && null != getter ){
+ if( (Modifier.isAbstract(getter.getModifiers()) && Modifier.isAbstract(setter.getModifiers())) || superClass.isInterface()){
+ getLog().debug("Detect as abstract property "+descriptor.getName());
+ property.setExist(false);
+ }
+ }
+
+ if(null == setter || (! Modifier.isPublic(setter.getModifiers())) ){
+ getLog().debug("Detect as hidden property "+descriptor.getName());
+ property.setHidden(true);
+ }
+ if (isAttachedProperty(property)) {
+ property.setAttachedstate(true);
+ }
+ if (property.isInstanceof("javax.faces.el.MethodBinding") ||
+ property.isInstanceof("javax.faces.el.ValueBinding")) {
+ property.setElonly(true);
+ }
+
+ }
+ }
+
+ private boolean isIgnorableProperty(Class<?> base, String name) {
+ return Arrays.asList(ignorableComponentProperties).contains(name);
+ }
+
+ private boolean isAttachedProperty(PropertyBean prop) {
+ for (int i = 0; i < attachedStateProperties.length; i++) {
+ String clazz = attachedStateProperties[i];
+ if(prop.isInstanceof(clazz)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isStateHolderRequired() {
+ getLog().info("isStateHolderRequired");
+ for (PropertyBean propertyBean : getProperties())
+ {
+ getLog().info("Property " + propertyBean.getName() + "/" + propertyBean.isTransient());
+ if (!propertyBean.isTransient())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean isSuperclassImplementsStateHolder()
+ {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ return (StateHolder.class.isAssignableFrom(superClass));
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ return false;
+ }
+ }
+
+ public boolean isSuperSaveStateMethodExists()
+ {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ Class[] signature = {FacesContext.class};
+ try {
+ Method m = superClass.getMethod("saveState", signature);
+ return !Modifier.isAbstract(m.getModifiers());
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ return false;
+ }
+ }
+
+ public boolean isSuperRestoreStateMethodExists()
+ {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ Class[] signature = {FacesContext.class, Object.class};
+ try {
+ Method m = superClass.getMethod("restoreState", signature);
+ return !Modifier.isAbstract(m.getModifiers());
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ return false;
+ }
+ }
+
+ public boolean isSuperIsTransientMethodExists()
+ {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ Class[] signature = new Class[0];
+ try {
+ Method m = superClass.getMethod("isTransient", signature);
+ return !Modifier.isAbstract(m.getModifiers());
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ return false;
+ }
+ }
+
+ public boolean isSuperSetTransientMethodExists()
+ {
+ try {
+ Class superClass = getLoader().loadClass(getSuperclass());
+ Class[] signature = {boolean.class};
+ try {
+ Method m = superClass.getMethod("setTransient", signature);
+ return !Modifier.isAbstract(m.getModifiers());
+ } catch (NoSuchMethodException e) {
+ return false;
+ }
+ } catch (ClassNotFoundException e) {
+ getLog().error("superclass not found for tag "+getTag().getName(), e);
+ return false;
+ }
+ }
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ComponentBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ComponentBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.util.HashSet;
import java.util.Set;
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,26 +0,0 @@
-package org.ajax4jsf.builder.config;
-
-public class ConverterBean extends ComponentBaseBean {
-
- private String forclass;
-
- // Map the id onto name
-
- public String getId() {
- return super.getName();
- }
-
- public void setId(String id)
- {
- super.setName(id);
- }
-
- public String getForclass() {
- return forclass;
- }
-
- public void setForclass(String forclass) {
- this.forclass = forclass;
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ConverterBean.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ConverterBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,47 @@
+/**
+ * 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.builder.config;
+
+public class ConverterBean extends ComponentBaseBean {
+
+ private String forclass;
+
+ // Map the id onto name
+
+ public String getId() {
+ return super.getName();
+ }
+
+ public void setId(String id)
+ {
+ super.setName(id);
+ }
+
+ public String getForclass() {
+ return forclass;
+ }
+
+ public void setForclass(String forclass) {
+ this.forclass = forclass;
+ }
+
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/EventBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/EventBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/EventBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* @author shura
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/FunctionBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/FunctionBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/FunctionBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/JsfBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/JsfBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/JsfBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Collections;
import java.util.List;
-import org.ajax4jsf.builder.generator.Logger;
+import org.richfaces.builder.generator.Logger;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ListenerBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ListenerBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ListenerBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.util.ArrayList;
import java.util.List;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/LoaderHolder.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/LoaderHolder.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/LoaderHolder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
-import org.ajax4jsf.builder.generator.Logger;
+import org.richfaces.builder.generator.Logger;
/**
* @author asmirnov at exadel.com (latest modification by $Author: ishabalov $)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ParsingException.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ParsingException.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ParsingException.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* @author asmirnov at exadel.com (latest modification by $Author: ishabalov $)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/PropertyBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/PropertyBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/PropertyBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.util.HashMap;
import java.util.Map;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/RendererBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/RendererBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/RendererBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* JavaBean to hold renderer configuration properties
@@ -64,7 +64,7 @@
*/
public RendererBean() {
super();
- setSuperclass("org.ajax4jsf.renderkit.RendererBase");
+ setSuperclass("org.richfaces.renderkit.RendererBase");
}
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* Java Bean for hold JSP tag configuration
@@ -42,7 +42,7 @@
*/
public TagBean() {
super();
- setSuperclass("org.ajax4jsf.webapp.taglib.UIComponentTagBase");
+ setSuperclass("org.richfaces.webapp.taglib.UIComponentTagBase");
}
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagHandlerBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagHandlerBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagHandlerBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
/**
* Bean for handle facelets tag class properties.
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,19 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.config;
-
-/**
- * @author Administrator
- *
- */
-public class TagTestClassHolder extends TestClassHolder {
-
- /**
- *
- */
- public TagTestClassHolder() {
- setSuperclassname("org.ajax4jsf.tests.AbstractJspTestCase");
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TagTestClassHolder.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TagTestClassHolder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,37 @@
+/**
+ * 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.builder.config;
+
+/**
+ * @author Administrator
+ *
+ */
+public class TagTestClassHolder extends TestClassHolder {
+
+ /**
+ *
+ */
+ public TagTestClassHolder() {
+ setSuperclassname("org.richfaces.tests.AbstractJspTestCase");
+ }
+
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TestClassHolder.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,43 +0,0 @@
-package org.ajax4jsf.builder.config;
-
-/**
- * Simple holder for test class name and test superclass name
- * @author dbiatenia
- *
- */
-public class TestClassHolder {
-
- private String _classname;
-
- private String _superclassname = "org.ajax4jsf.tests.AbstractAjax4JsfTestCase";
-
- public String getClassname() {
- return _classname;
- }
-
- public void setClassname(String classname) {
- this._classname = classname;
- }
-
- public String getSuperclassname() {
- return _superclassname;
- }
-
- public void setSuperclassname(String superclassname) {
- this._superclassname = superclassname;
- }
-
- /**
- * Convert full class name to simple.
- * @return class name without package name.
- */
- public String getSimpleClassName() {
- int lastPoint = getClassname().lastIndexOf('.');
- if (lastPoint>0) {
- return getClassname().substring(lastPoint+1);
- }
- return getClassname();
- }
-
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/TestClassHolder.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/TestClassHolder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,64 @@
+/**
+ * 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.builder.config;
+
+/**
+ * Simple holder for test class name and test superclass name
+ * @author dbiatenia
+ *
+ */
+public class TestClassHolder {
+
+ private String _classname;
+
+ private String _superclassname = "org.richfaces.tests.AbstractAjax4JsfTestCase";
+
+ public String getClassname() {
+ return _classname;
+ }
+
+ public void setClassname(String classname) {
+ this._classname = classname;
+ }
+
+ public String getSuperclassname() {
+ return _superclassname;
+ }
+
+ public void setSuperclassname(String superclassname) {
+ this._superclassname = superclassname;
+ }
+
+ /**
+ * Convert full class name to simple.
+ * @return class name without package name.
+ */
+ public String getSimpleClassName() {
+ int lastPoint = getClassname().lastIndexOf('.');
+ if (lastPoint>0) {
+ return getClassname().substring(lastPoint+1);
+ }
+ return getClassname();
+ }
+
+
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,17 +0,0 @@
-package org.ajax4jsf.builder.config;
-
-public class ValidatorBean extends ComponentBaseBean {
-
-
- // Map the id onto name
-
- public String getId() {
- return super.getName();
- }
-
- public void setId(String id)
- {
- super.setName(id);
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/config/ValidatorBean.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/config/ValidatorBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,38 @@
+/**
+ * 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.builder.config;
+
+public class ValidatorBean extends ComponentBaseBean {
+
+
+ // Map the id onto name
+
+ public String getId() {
+ return super.getName();
+ }
+
+ public void setId(String id)
+ {
+ super.setName(id);
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator)
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/AbstractClassStubBuilder.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,113 +0,0 @@
-/**
- * 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.ajax4jsf.builder.generator;
-
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import net.sf.cglib.core.ClassEmitter;
-import net.sf.cglib.core.CodeEmitter;
-import net.sf.cglib.core.EmitUtils;
-import net.sf.cglib.core.MethodInfo;
-import net.sf.cglib.core.ReflectUtils;
-import net.sf.cglib.core.Signature;
-import net.sf.cglib.proxy.Enhancer;
-import net.sf.cglib.proxy.MethodInterceptor;
-
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.Constants;
-import org.objectweb.asm.Type;
-
-/**
- * @author Nick - mailto:nbelaevski at exadel.com
- * created 20.04.2007
- *
- */
-public class AbstractClassStubBuilder {
- public static <T> T buildStub(final Class<T> clazz, MethodInterceptor interceptor,
- ClassLoader classLoader) {
- Enhancer enhancer = new Enhancer() {
- @Override
- public void generateClass(ClassVisitor v) throws Exception {
- ClassEmitter ce = new ClassEmitter(v);
- ce.begin_class(Constants.V1_4,
- Constants.ACC_PUBLIC,
- getClassName(),
- Type.getType(clazz),
- null,
- null);
- EmitUtils.null_constructor(ce);
- List methods = new ArrayList();
- getMethods(clazz, null, methods);
-
- for (Iterator iterator = methods.iterator(); iterator
- .hasNext();) {
- Method method = (Method) iterator.next();
-
- if (Modifier.isAbstract(method.getModifiers())) {
- MethodInfo methodInfo = ReflectUtils.getMethodInfo(method);
- Signature signature = methodInfo.getSignature();
- Type returnType = signature.getReturnType();
-
- CodeEmitter e = ce.begin_method(method.getModifiers() & ~Modifier.ABSTRACT,
- signature, methodInfo.getExceptionTypes(),
- methodInfo.getAttribute());
-
- e.zero_or_null(returnType);
- e.return_value();
-
- Type[] argumentTypes = methodInfo.getSignature().getArgumentTypes();
- int size = 0;
- if (argumentTypes != null) {
- for (int i = 0; i < argumentTypes.length; i++) {
- size += argumentTypes[i].getSize();
- }
- }
-
- // 1 is for this
- e.visitMaxs(returnType.getSize(), size + 1);
-
- e.end_method();
- }
- }
-
- ce.end_class();
- }
- };
- enhancer.setSuperclass(clazz);
- enhancer.setCallbackType(MethodInterceptor.class);
- enhancer.setClassLoader(classLoader != null ?
- classLoader : clazz.getClassLoader());
- Class<T> instrumentedClass = enhancer.createClass();
-
- Enhancer enhancer2 = new Enhancer();
- enhancer2.setSuperclass(instrumentedClass);
- enhancer2.setCallback(interceptor);
- enhancer2.setClassLoader(instrumentedClass.getClassLoader());
-
- return (T) enhancer2.create();
- }
-}
-
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/AbstractClassStubBuilder.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/AbstractClassStubBuilder.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,180 @@
+/**
+ * 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.builder.generator;
+
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import net.sf.cglib.core.ClassEmitter;
+import net.sf.cglib.core.CodeEmitter;
+import net.sf.cglib.core.EmitUtils;
+import net.sf.cglib.core.MethodInfo;
+import net.sf.cglib.core.ReflectUtils;
+import net.sf.cglib.core.Signature;
+import net.sf.cglib.proxy.Callback;
+import net.sf.cglib.proxy.Enhancer;
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.NoOp;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Constants;
+import org.objectweb.asm.Type;
+
+/**
+ * @author Nick - mailto:nbelaevski at exadel.com
+ * created 20.04.2007
+ *
+ */
+public class AbstractClassStubBuilder {
+
+ public static Object buildInterfaceStub(final Class<?> clazz, ClassLoader classLoader) throws InstantiationException, IllegalAccessException {
+ Enhancer enhancer = new Enhancer() {
+ public void generateClass(ClassVisitor v) throws Exception {
+ ClassEmitter ce = new ClassEmitter(v);
+ ce.begin_class(Constants.V1_5,
+ Constants.ACC_PUBLIC,
+ getClassName(),
+ null,
+ new Type[]{Type.getType(clazz)},
+ null);
+ EmitUtils.null_constructor(ce);
+ List methods = new ArrayList();
+ getMethods(Object.class, new Class[]{clazz}, methods);
+
+ for (Iterator iterator = methods.iterator(); iterator
+ .hasNext();) {
+ Method method = (Method) iterator.next();
+
+ if (Modifier.isAbstract(method.getModifiers())) {
+ MethodInfo methodInfo = ReflectUtils.getMethodInfo(method);
+ Signature signature = methodInfo.getSignature();
+ Type returnType = signature.getReturnType();
+
+ CodeEmitter e = ce.begin_method(method.getModifiers() & ~Modifier.ABSTRACT,
+ signature, methodInfo.getExceptionTypes(),
+ methodInfo.getAttribute());
+
+ e.zero_or_null(returnType);
+ e.return_value();
+
+ Type[] argumentTypes = methodInfo.getSignature().getArgumentTypes();
+ int size = 0;
+ if (argumentTypes != null) {
+ for (int i = 0; i < argumentTypes.length; i++) {
+ size += argumentTypes[i].getSize();
+ }
+ }
+
+ // 1 is for this
+ e.visitMaxs(returnType.getSize(), size + 1);
+
+ e.end_method();
+ }
+ }
+
+ ce.end_class();
+ }
+ };
+
+ enhancer.setCallbackType(NoOp.class);
+ enhancer.setInterfaces(new Class[]{clazz});
+ enhancer.setClassLoader(classLoader != null ?
+ classLoader : clazz.getClassLoader());
+
+ return enhancer.createClass().newInstance();
+ }
+
+ public static <T> T buildStub(final Class<T> clazz, MethodInterceptor interceptor,
+ ClassLoader classLoader) {
+ Class<T> instrumentedClass;
+
+ if ((Modifier.ABSTRACT & clazz.getModifiers()) != 0) {
+ Enhancer enhancer = new Enhancer() {
+ @Override
+ public void generateClass(ClassVisitor v) throws Exception {
+ ClassEmitter ce = new ClassEmitter(v);
+ ce.begin_class(Constants.V1_5,
+ Constants.ACC_PUBLIC,
+ getClassName(),
+ Type.getType(clazz),
+ null,
+ null);
+ EmitUtils.null_constructor(ce);
+ List methods = new ArrayList();
+ getMethods(clazz, null, methods);
+
+ for (Iterator iterator = methods.iterator(); iterator
+ .hasNext();) {
+ Method method = (Method) iterator.next();
+
+ if (Modifier.isAbstract(method.getModifiers())) {
+ MethodInfo methodInfo = ReflectUtils.getMethodInfo(method);
+ Signature signature = methodInfo.getSignature();
+ Type returnType = signature.getReturnType();
+
+ CodeEmitter e = ce.begin_method(method.getModifiers() & ~Modifier.ABSTRACT,
+ signature, methodInfo.getExceptionTypes(),
+ methodInfo.getAttribute());
+
+ e.zero_or_null(returnType);
+ e.return_value();
+
+ Type[] argumentTypes = methodInfo.getSignature().getArgumentTypes();
+ int size = 0;
+ if (argumentTypes != null) {
+ for (int i = 0; i < argumentTypes.length; i++) {
+ size += argumentTypes[i].getSize();
+ }
+ }
+
+ // 1 is for this
+ e.visitMaxs(returnType.getSize(), size + 1);
+
+ e.end_method();
+ }
+ }
+
+ ce.end_class();
+ }
+ };
+ enhancer.setSuperclass(clazz);
+ enhancer.setCallbackType(MethodInterceptor.class);
+ enhancer.setClassLoader(classLoader != null ?
+ classLoader : clazz.getClassLoader());
+ instrumentedClass = enhancer.createClass();
+ } else {
+ instrumentedClass = clazz;
+ }
+
+ Enhancer enhancer2 = new Enhancer();
+ enhancer2.setSuperclass(instrumentedClass);
+ enhancer2.setCallback(interceptor);
+ enhancer2.setClassLoader(instrumentedClass.getClassLoader());
+
+ return (T) enhancer2.create();
+ }
+}
+
+
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/BlankRendererGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/BlankRendererGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/BlankRendererGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,17 +29,17 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
/**
* Class implement functionality for generate base renderers java files,
* for manual extention. If renderer property override in config file set to true,
* override existing renderers files.
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ClassPatternSet.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ClassPatternSet.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ClassPatternSet.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.util.ArrayList;
import java.util.List;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,16 +29,16 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
/**
* Class implement functionality for generate component java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator2.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentGenerator2.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentGenerator2.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -28,11 +28,11 @@
import java.io.Writer;
import java.util.List;
-import org.ajax4jsf.builder.component.ComponentModelBuilder;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.render.JavaClassRenderer;
+import org.richfaces.builder.component.ComponentModelBuilder;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.render.JavaClassRenderer;
/**
* @author Maksim Kaszynski
@@ -47,7 +47,7 @@
super(task,log);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.InnerGenerator#createFiles(org.ajax4jsf.builder.config.BuilderConfig)
+ * @see org.richfaces.builder.generator.InnerGenerator#createFiles(org.richfaces.builder.config.BuilderConfig)
*/
@Override
public void createFiles(BuilderConfig config) throws GeneratorException {
@@ -85,7 +85,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.InnerGenerator#getDefaultTemplateName()
+ * @see org.richfaces.builder.generator.InnerGenerator#getDefaultTemplateName()
*/
@Override
protected String getDefaultTemplateName() {
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTagGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTagGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTagGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,17 +29,17 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.TagBean;
/**
* Class implement functionality for generate jap tags java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,87 +0,0 @@
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-public class ComponentTestGenerator extends InnerGenerator{
-
- private static final String COMPONENT_FILE_TEMPLATE = "componenttest.vm";
-
- public ComponentTestGenerator(JSFGeneratorConfiguration config, Logger log) {
- super(config, log);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- context.put("generator",this);
-
- context.put("testDataGenerator", new TestDataGenerator(getClassLoader(), getLog()));
-
- // Put common properties
- for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- if(component.getTest() != null){
- info("Create component test class file for component "+component.getClassname());
- if (component.isGenerate()) {
- context.put("component", component);
- context.put("renderer", component.getRenderer());
- context.put("package", component.getPackageName());
- Set<String> importClasses = new HashSet<String>();
- for (Iterator it = component.getProperties().iterator(); it
- .hasNext();) {
- PropertyBean property = (PropertyBean) it.next();
- // For non-primitive types, add import declaration.
- if (!property.isSimpleType() && !property.isExist()) {
- importClasses.add(property.getClassname());
- }
- }
- importClasses.add(component.getTest().getSuperclassname());
- context.put("imports", importClasses);
- String resultPath = component.getTest().getClassname().replace('.', '/')
- + ".java";
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- javaFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Component Java file ", e);
- }
- }
-
- }
- }
-
- }
-
- @Override
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return COMPONENT_FILE_TEMPLATE;
- }
-
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ComponentTestGenerator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ComponentTestGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,108 @@
+/**
+ * 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.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
+
+public class ComponentTestGenerator extends InnerGenerator{
+
+ private static final String COMPONENT_FILE_TEMPLATE = "componenttest.vm";
+
+ public ComponentTestGenerator(JSFGeneratorConfiguration config, Logger log) {
+ super(config, log);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ context.put("generator",this);
+
+ context.put("testDataGenerator", new TestDataGenerator(getClassLoader(), getLog()));
+
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ if(component.getTest() != null){
+ info("Create component test class file for component "+component.getClassname());
+ if (component.isGenerate()) {
+ context.put("component", component);
+ context.put("renderer", component.getRenderer());
+ context.put("package", component.getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator it = component.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isExist()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(component.getTest().getSuperclassname());
+ context.put("imports", importClasses);
+ String resultPath = component.getTest().getClassname().replace('.', '/')
+ + ".java";
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component Java file ", e);
+ }
+ }
+
+ }
+ }
+
+ }
+
+ @Override
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FILE_TEMPLATE;
+ }
+
+
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,12 +29,12 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ConverterBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ConverterBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.ValidatorBean;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterTagGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ConverterTagGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ConverterTagGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,18 +29,18 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ConverterBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ConverterBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.TagBean;
+import org.richfaces.builder.config.ValidatorBean;
/**
* Class implement functionality for generate jsp tags for validators
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FaceletsTaglibGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FaceletsTaglibGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FaceletsTaglibGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,15 +29,15 @@
import java.util.Iterator;
import java.util.List;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBaseBean;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.ConverterBean;
-import org.ajax4jsf.builder.config.FunctionBean;
-import org.ajax4jsf.builder.config.ListenerBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBaseBean;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.ConverterBean;
+import org.richfaces.builder.config.FunctionBean;
+import org.richfaces.builder.config.ListenerBean;
+import org.richfaces.builder.config.ValidatorBean;
/**
* @author asmirnov at exadel.com (latest modification by $Author: ishabalov $)
@@ -262,7 +262,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ * @see org.richfaces.builder.generator.XMLConfigGenerator#getRootTag()
*/
protected String getRootTag() {
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FacesConfigGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/FacesConfigGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/FacesConfigGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -28,13 +28,13 @@
import java.util.ArrayList;
import java.util.List;
-import org.ajax4jsf.builder.config.BuilderConfig;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
/**
* Class implement functionality for generate faces-config file inner element of
- * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
+ * {@link org.richfaces.builder.ant.JSFGeneratorTask} use in ant build.xml :
* <jsfgenerator ... > .... <facesconfig ... /> ....
* </jsfgenerator> attributes: facesconfig - name of faces-config file
* include - name of file, included in config renderkitid - name of renderkit
@@ -167,7 +167,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ * @see org.richfaces.builder.generator.XMLConfigGenerator#getRootTag()
*/
protected String getRootTag() {
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/GeneratorException.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/GeneratorException.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/GeneratorException.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
/**
* @author shura
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/InnerGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/InnerGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/InnerGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,22 +19,22 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.File;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.ComponentBaseBean;
-import org.ajax4jsf.builder.generator.ClassPatternSet.PatternEntry;
import org.apache.tools.ant.BuildException;
import org.apache.velocity.Template;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBaseBean;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.generator.ClassPatternSet.PatternEntry;
/**
* Base class for all JSF generators - component java file ,
* faces-config.xml , jsp tag java file , renderer template, jsp & facelets taglib
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/JSFGeneratorConfiguration.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/JSFGeneratorConfiguration.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/JSFGeneratorConfiguration.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.File;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -27,11 +27,11 @@
import java.io.Writer;
import java.util.List;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ListenerBean;
-import org.ajax4jsf.builder.config.TagHandlerBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ListenerBean;
+import org.richfaces.builder.config.TagHandlerBean;
/**
* @author Nick - mailto:nbelaevski at exadel.com
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerTagGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ListenerTagGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ListenerTagGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -27,11 +27,11 @@
import java.io.Writer;
import java.util.List;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ListenerBean;
-import org.ajax4jsf.builder.config.TagBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ListenerBean;
+import org.richfaces.builder.config.TagBean;
/**
*
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/Logger.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/Logger.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/Logger.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
/**
* @author shura
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RenderKitBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RenderKitBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RenderKitBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
/**
- * Child element for {@link org.ajax4jsf.builder.generator.FacesConfigGenerator}
+ * Child element for {@link org.richfaces.builder.generator.FacesConfigGenerator}
* <facesconfig ... >
* <renderkit renderkitid="..." renderkitclass="..." [package="..."] > for generate any of render-kits at time.
* .....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererCompilationContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererCompilationContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererCompilationContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
-import org.ajax4jsf.templatecompiler.builder.AbstractCompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
import org.apache.velocity.Template;
+import org.richfaces.templatecompiler.builder.AbstractCompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
/**
* @author shura
@@ -50,7 +50,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String)
*/
public void debug(String content) {
_log.debug(content);
@@ -60,7 +60,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String,
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String,
* java.lang.Throwable)
*/
public void debug(String content, Throwable error) {
@@ -70,7 +70,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String)
*/
public void error(String content) {
_log.error(content);
@@ -79,7 +79,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String,
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String,
* java.lang.Throwable)
*/
public void error(String content, Throwable error) {
@@ -90,7 +90,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String)
*/
public void info(String content) {
_log.info(content);
@@ -100,7 +100,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String,
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String,
* java.lang.Throwable)
*/
public void info(String content, Throwable error) {
@@ -111,7 +111,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String)
*/
public void warn(String content) {
_log.warn(content);
@@ -121,7 +121,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String,
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String,
* java.lang.Throwable)
*/
public void warn(String content, Throwable error) {
@@ -131,7 +131,7 @@
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
*/
public Template getTemplate(String name) throws CompilationException {
// TODO Auto-generated method stub
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/RendererGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/RendererGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,19 +29,19 @@
import java.io.Writer;
import java.util.Iterator;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBaseBean;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.RendererBean;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBaseBean;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.RendererBean;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.TemplateCompiler;
/**
* Class implement functionality for generate base renderers java files, for
* manual extention. If renderer property override in config file set to true,
* override existing renderers files. inner element of
- * {@link org.ajax4jsf.builder.ant.JSFGeneratorTask} use in ant build.xml :
+ * {@link org.richfaces.builder.ant.JSFGeneratorTask} use in ant build.xml :
* <jsfgenerator ... > .... <renderers ... /> ....
* </jsfgenerator> attributes: package - optional Java package name for
* override from configuration, used for create set of differern render-kits in
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourceType.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourceType.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourceType.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourceType.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,30 @@
+/**
+ * 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.builder.generator;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public enum ResourceType {
+ SCRIPT, STYLE
+}
+
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,474 +0,0 @@
-/**
- * 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.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.io.Writer;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-import net.sf.cglib.proxy.MethodInterceptor;
-import net.sf.cglib.proxy.MethodProxy;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.RendererBean;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
-import org.ajax4jsf.templatecompiler.elements.RootElement;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.FResourceTemplateElement;
-import org.ajax4jsf.templatecompiler.elements.vcp.HeaderResourceElement;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * @author Nick - mailto:nbelaevski at exadel.com
- * created 17.04.2007
- *
- */
-public class ResourcesConfigGenerator extends FacesConfigGenerator {
-
- private File resourcesConfig;
- private File templatesDirectory;
-
- private static final SAXParserFactory parserFactory = SAXParserFactory.newInstance();
-
- public ResourcesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
- super(task, log);
- }
-
- private void addResources(ResourcesConfigGeneratorBean configBean, TemplateElement templateElement,
- String packageName, RendererBean renderer, BuilderConfig builderConfig) throws ClassNotFoundException {
- if (templateElement instanceof FResourceTemplateElement) {
- FResourceTemplateElement resourceTemplateElement = (FResourceTemplateElement) templateElement;
- String name = resourceTemplateElement.getName();
-
- addResource(name, packageName, configBean);
- } else if (templateElement instanceof RootElement) {
- RootElement rootElement = (RootElement) templateElement;
-
- CompilationContext compilationContext = rootElement.getComponentBean();
-
- String classname = renderer.getClassname();
- int idx = classname.lastIndexOf('.');
- if (idx != -1) {
- packageName = classname.substring(0, idx);
- } else {
- packageName = "";
- }
-
- ClassLoader loader = builderConfig.getLoader();
- Class cl = null;
-
- try {
- cl = loader.loadClass(classname);
- } catch (ClassNotFoundException e) {
- String superclass = compilationContext.getBaseclassPackageName() + "." + compilationContext.getBaseclassName();
- if (superclass != null) {
- cl = loader.loadClass(superclass);
- }
- }
-
- if (cl != null) {
- GetResourceInterceptor interceptor = new GetResourceInterceptor();
- Object instance = AbstractClassStubBuilder.buildStub(cl, interceptor,
- builderConfig.getLoader());
-
- try {
- Method method = null;
- Object object = null;
-
- Class<?> cl1 = instance.getClass();
- while (cl1 != null && method == null) {
- try {
- method = cl1.getDeclaredMethod("getStyles", null);
- } catch (NoSuchMethodException e) {
- cl1 = cl1.getSuperclass();
- }
- }
-
- if (method != null) {
- method.setAccessible(true);
- object = method.invoke(instance, null);
- List<String> list = interceptor.getList();
- if (list != null) {
- for (String name : list) {
- addResource(name, packageName, configBean);
- }
- }
- }
-
- interceptor.clearList();
-
- method = null;
- cl1 = instance.getClass();
- while (cl1 != null && method == null) {
- try {
- method = cl1.getDeclaredMethod("getScripts", null);
- } catch (NoSuchMethodException e) {
- cl1 = cl1.getSuperclass();
- }
- }
-
- if (method != null) {
- method.setAccessible(true);
- object = method.invoke(instance, null);
- List<String> list = interceptor.getList();
- if (list != null) {
- for (String name : list) {
- addResource(name, packageName, configBean);
- }
- }
- }
- } catch (SecurityException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (IllegalArgumentException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (IllegalAccessException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- } catch (InvocationTargetException e) {
- builderConfig.getLog().error(e.getMessage(), e);
- }
- }
- } else if (templateElement instanceof HeaderResourceElement) {
- HeaderResourceElement resourceElement = (HeaderResourceElement) templateElement;
- String[] paths = resourceElement.getResourcePaths();
- if (paths != null) {
- for (int i = 0; i < paths.length; i++) {
- String string = paths[i];
-
- addResource(string, packageName, configBean);
- }
- }
- }
-
- ArrayList<TemplateElement> subElements = templateElement.getSubElements();
- for (TemplateElement element : subElements) {
- addResources(configBean, element, packageName, renderer, builderConfig);
- }
- }
-
- private void addResource(String name, String packageName,
- ResourcesConfigGeneratorBean configBean) {
-
- String resolvedPath = resolveResourcePath(name, packageName);
- // remove leading / from resource name.
- if(name.startsWith("/")){
- name = name.substring(1);
- }
- if (resolvedPath != null) {
- configBean.addPathResource(name, resolvedPath);
- } else {
- //couldn't resolve, treat as class name
- configBean.addClassResource(name, name);
- }
- }
-
- private String resolveResourcePath(String name, String packageName) {
- if (name.contains("/")) {
- String resolvedName;
-
- if (!name.startsWith("/")) {
- //need to resolve
- StringBuffer normalizedName = new StringBuffer();
- normalizedName.append(packageName.replace('.', '/'));
-
- if (!packageName.endsWith("/")) {
- normalizedName.append('/');
- }
-
- normalizedName.append(name);
-
- resolvedName = normalizedName.toString();
- } else {
- if (name.length() > 0) {
- resolvedName = name.substring(1);
- } else {
- resolvedName = null;
- }
- }
-
- return resolvedName;
- }
-
- return null;
- }
-
- private void addResources(ResourcesConfigGeneratorBean configBean, RendererBean renderer, BuilderConfig builderConfig) throws CompilationException, IOException, ClassNotFoundException {
- if (null != renderer && renderer.isGenerate()
- && null != renderer.getTemplate()) {
-
- File template;
- if (null != getTemplates()) {
- template = new File(getTemplates(), renderer.getTemplate());
- } else {
- template = new File(renderer.getTemplate());
- }
- CompilationContext rendererBean = new RendererCompilationContext(
- getLog(), getClassLoader(),getConfig());
-
- TemplateCompiler templateCompiler = new TemplateCompiler();
- InputStream templateStream = new FileInputStream(template);
- templateCompiler.processing(templateStream, rendererBean);
-
- TemplateElement root = rendererBean.getTree();
-
- String classname = renderer.getClassname();
- String packageName;
- int idx = classname.lastIndexOf('.');
- if (idx != -1) {
- packageName = classname.substring(0, idx);
- } else {
- packageName = "";
- }
-
- addResources(configBean, root, packageName, renderer, builderConfig);
- }
- }
-
- private void parseXCSSResource(String resourcePath, final ResourcesConfigGeneratorBean bean) throws SAXException, IOException, ParserConfigurationException {
- InputStream resourceStream = getClassLoader().getResourceAsStream(resourcePath);
- if (resourceStream != null) {
- debug("XCSS file exists in classpath");
-
- try {
- SAXParser parser = parserFactory.newSAXParser();
- parser.parse(resourceStream, new DefaultHandler() {
- @Override
- public void startElement(String uri,
- String localName, String name,
- Attributes attributes)
- throws SAXException {
-
- super.startElement(uri, localName, name, attributes);
-
- if ("f:resource".equals(name)) {
- String value = attributes.getValue("f:key");
-
- if (value != null) {
- debug("Adding resource: " + value);
-
- addResource(value, "", bean);
- }
- }
- }
- });
-
- } finally {
- try {
- resourceStream.close();
- } catch (IOException e) {
- getLog().error(e.getLocalizedMessage(), e);
- }
- }
- } else {
- getLog().error("Resource " + resourcePath + " hasn't been found!");
- }
- }
-
- private boolean isXCSSPath(String resourcePath) {
- return resourcePath != null && resourcePath.endsWith(".xcss");
- }
-
- public void createFiles(BuilderConfig config) throws GeneratorException {
- VelocityContext context = new VelocityContext();
- Template template = getTemplate();
- try {
- // Put common properties
-
- final ResourcesConfigGeneratorBean bean = new ResourcesConfigGeneratorBean();
-
- List<ComponentBean> components = config.getComponents();
- for (ComponentBean componentBean : components) {
- RendererBean rendererBean = componentBean.getRenderer();
-
- addResources(bean, rendererBean, config);
- }
-
- List<RendererBean> renderers = config.getRenderers();
- for (RendererBean rendererBean : renderers) {
- addResources(bean, rendererBean, config);
- }
-
- String includedContent = getIncludeContent();
- if (includedContent != null && includedContent.length() != 0) {
- String parseableContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><resource-config>" + includedContent +
- "</resource-config>";
-
- SAXParser parser = parserFactory.newSAXParser();
- parser.parse(new InputSource(new StringReader(parseableContent)), new DefaultHandler() {
- private StringBuilder path;
-
- @Override
- public void startElement(String uri,
- String localName, String name,
- Attributes attributes)
- throws SAXException {
-
- super.startElement(uri, localName, name, attributes);
-
- if ("path".equals(name)) {
- this.path = new StringBuilder();
- }
- }
-
- public void characters(char[] ch, int start, int length) throws SAXException {
- if (this.path != null) {
- this.path.append(ch, start, length);
- }
- };
-
- @Override
- public void endElement(String uri, String localName, String name) throws SAXException {
- super.endElement(uri, localName, name);
-
- if ("resource".equals(name)) {
- if (this.path != null && this.path.length() != 0) {
- String resourcePath = this.path.toString().trim();
- if (isXCSSPath(resourcePath)) {
- debug("XCSS file detected: " + resourcePath);
- try {
- parseXCSSResource(resourcePath, bean);
- } catch (IOException e) {
- throw new SAXException(e.getLocalizedMessage(), e);
- } catch (ParserConfigurationException e) {
- throw new SAXException(e.getLocalizedMessage(), e);
- }
- }
- }
- this.path = null;
- }
- }
- });
- }
-
- Set<String> pathResourcesSet = new LinkedHashSet<String>(bean.getPathResources().values());
- for (Iterator<String> iterator = pathResourcesSet.iterator(); iterator
- .hasNext();) {
- String resourcePath = iterator.next();
-
- if (isXCSSPath(resourcePath)) {
- debug("XCSS file detected: " + resourcePath);
- parseXCSSResource(resourcePath, bean);
- }
- }
-
- context.put("classResources", bean.getClassResources());
- context.put("pathResources", bean.getPathResources());
- context.put("resourcesConfig", this);
-
- File configFile = getResourcesConfig();
- File javaDir = configFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- if (configFile.exists()) {
- configFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(configFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException("Error create new resources-config.xml ",
- e);
- }
- }
-
- protected String getRootTag() {
- return "resource-config";
- }
-
- public File getResourcesConfig() {
- return resourcesConfig;
- }
-
- public void setResourcesConfig(File resourcesConfig) {
- this.resourcesConfig = resourcesConfig;
- }
-
- protected String getDefaultTemplateName() {
- return "resources-config.vm";
- }
-
- public void setTemplates(File templatesDirectory) {
- this.templatesDirectory = templatesDirectory;
- }
-
- public File getTemplates() {
- return this.templatesDirectory;
- }
-}
-
-class GetResourceInterceptor implements MethodInterceptor {
-
- private static final Class<?>[] SIGNATURE = new Class<?>[] {
- String.class
- };
-
- private List<String> list = new ArrayList<String>();
-
- public List<String> getList() {
- return list;
- }
-
- public void clearList() {
- list.clear();
- }
-
- public Object intercept(Object instance, Method method, Object[] args,
- MethodProxy methodProxy) throws Throwable {
-
- if ("getResource".equals(method.getName()) &&
- Arrays.equals(SIGNATURE, method.getParameterTypes())) {
-
- list.add((String) args[0]);
-
- return null;
- } else {
- return methodProxy.invokeSuper(instance, args);
- }
- }
-
-}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGenerator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,270 @@
+/**
+ * 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.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.io.Writer;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ * @author Nick - mailto:nbelaevski at exadel.com created 17.04.2007
+ *
+ */
+public class ResourcesConfigGenerator extends FacesConfigGenerator {
+
+ private File resourcesConfig;
+ private File templatesDirectory;
+ private ResourcesConfigGeneratorBean resourcesConfigGeneratorBean;
+
+ private static final SAXParserFactory parserFactory = SAXParserFactory
+ .newInstance();
+
+ public ResourcesConfigGenerator(JSFGeneratorConfiguration task, Logger log) {
+ super(task, log);
+ }
+
+ private void parseXCSSResource(String resourcePath,
+ final ResourcesConfigGeneratorBean bean) throws SAXException,
+ IOException, ParserConfigurationException {
+ InputStream resourceStream = getClassLoader().getResourceAsStream(
+ resourcePath);
+ if (resourceStream != null) {
+ debug("XCSS file exists in classpath");
+
+ try {
+ SAXParser parser = parserFactory.newSAXParser();
+ parser.parse(resourceStream, new DefaultHandler() {
+ @Override
+ public void startElement(String uri, String localName,
+ String name, Attributes attributes)
+ throws SAXException {
+
+ super.startElement(uri, localName, name, attributes);
+
+ if ("f:resource".equals(name)) {
+ String value = attributes.getValue("f:key");
+
+ if (value != null) {
+ debug("Adding resource: " + value);
+
+ bean.addResource(value, "", null, true);
+ }
+ }
+ }
+ });
+
+ } finally {
+ try {
+ resourceStream.close();
+ } catch (IOException e) {
+ getLog().error(e.getLocalizedMessage(), e);
+ }
+ }
+ } else {
+ getLog().error("Resource " + resourcePath + " hasn't been found!");
+ }
+ }
+
+ private boolean isXCSSPath(String resourcePath) {
+ return resourcePath != null && resourcePath.endsWith(".xcss");
+ }
+
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+ try {
+ // Put common properties
+
+ final ResourcesConfigGeneratorBean bean = new ResourcesConfigGeneratorBean();
+ if (this.resourcesConfigGeneratorBean != null) {
+ bean.merge(resourcesConfigGeneratorBean);
+ }
+
+ String includedContent = getIncludeContent();
+ if (includedContent != null && includedContent.length() != 0) {
+ String parseableContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><resource-config>"
+ + includedContent + "</resource-config>";
+
+ SAXParser parser = parserFactory.newSAXParser();
+ parser.parse(
+ new InputSource(new StringReader(parseableContent)),
+ new DefaultHandler() {
+ private StringBuilder path;
+
+ @Override
+ public void startElement(String uri,
+ String localName, String name,
+ Attributes attributes) throws SAXException {
+
+ super.startElement(uri, localName, name,
+ attributes);
+
+ if ("path".equals(name)) {
+ this.path = new StringBuilder();
+ }
+ }
+
+ public void characters(char[] ch, int start,
+ int length) throws SAXException {
+ if (this.path != null) {
+ this.path.append(ch, start, length);
+ }
+ };
+
+ @Override
+ public void endElement(String uri,
+ String localName, String name)
+ throws SAXException {
+ super.endElement(uri, localName, name);
+
+ if ("resource".equals(name)) {
+ if (this.path != null
+ && this.path.length() != 0) {
+ String resourcePath = this.path
+ .toString().trim();
+ if (isXCSSPath(resourcePath)) {
+ debug("XCSS file detected: "
+ + resourcePath);
+ try {
+ parseXCSSResource(resourcePath,
+ bean);
+ } catch (IOException e) {
+ throw new SAXException(e
+ .getLocalizedMessage(),
+ e);
+ } catch (ParserConfigurationException e) {
+ throw new SAXException(e
+ .getLocalizedMessage(),
+ e);
+ }
+ }
+ }
+ this.path = null;
+ }
+ }
+ });
+ }
+
+ Set<String> pathResourcesSet = new LinkedHashSet<String>();
+ for (ResourcesConfigGeneratorBeanEntry entry : bean.getDependencies()) {
+ if (entry.isPathResource()) {
+ pathResourcesSet.add(entry.getPath());
+ }
+ }
+
+ for (Iterator<String> iterator = pathResourcesSet.iterator(); iterator
+ .hasNext();) {
+ String resourcePath = iterator.next();
+
+ if (isXCSSPath(resourcePath)) {
+ debug("XCSS file detected: " + resourcePath);
+ parseXCSSResource(resourcePath, bean);
+ }
+ }
+
+ Map<String, String> classResources = new HashMap<String, String>();
+ Map<String, String> pathResources = new HashMap<String, String>();
+
+ for (ResourcesConfigGeneratorBeanEntry entry : bean.getDependencies()) {
+ if (entry.isPathResource()) {
+ pathResources.put(entry.getName(), entry.getPath());
+ } else {
+ classResources.put(entry.getName(), entry.getPath());
+ }
+ }
+
+ context.put("classResources", classResources);
+ context.put("pathResources", pathResources);
+ context.put("resourcesConfig", this);
+
+ File configFile = getResourcesConfig();
+ File javaDir = configFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ if (configFile.exists()) {
+ configFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(configFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new resources-config.xml ", e);
+ }
+ }
+
+ protected String getRootTag() {
+ return "resource-config";
+ }
+
+ public File getResourcesConfig() {
+ return resourcesConfig;
+ }
+
+ public void setResourcesConfig(File resourcesConfig) {
+ this.resourcesConfig = resourcesConfig;
+ }
+
+ protected String getDefaultTemplateName() {
+ return "resources-config.vm";
+ }
+
+ public void setTemplates(File templatesDirectory) {
+ this.templatesDirectory = templatesDirectory;
+ }
+
+ public File getTemplates() {
+ return this.templatesDirectory;
+ }
+
+ public void setResourcesConfigGeneratorBean(
+ ResourcesConfigGeneratorBean resourcesConfigGeneratorBean) {
+ this.resourcesConfigGeneratorBean = resourcesConfigGeneratorBean;
+ }
+
+ public ResourcesConfigGeneratorBean getResourcesConfigGeneratorBean() {
+ return resourcesConfigGeneratorBean;
+ }
+}
\ No newline at end of file
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGeneratorBean.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,53 +0,0 @@
-/**
- * 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.ajax4jsf.builder.generator;
-
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * @author Nick - mailto:nbelaevski at exadel.com
- * created 17.04.2007
- *
- */
-public class ResourcesConfigGeneratorBean {
- private HashMap<String, String> classResources = new HashMap<String, String>();
- private HashMap<String, String> pathResources = new HashMap<String, String>();
-
- public void addClassResource(String name, String className) {
- classResources.put(name, className);
- }
-
- public void addPathResource(String name, String path) {
- pathResources.put(name, path);
- }
-
- public Map<String, String> getClassResources() {
- return classResources;
- }
-
- public Map<String, String> getPathResources() {
- return pathResources;
- }
-}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGeneratorBean.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBean.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,93 @@
+/**
+ * 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.builder.generator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Nick - mailto:nbelaevski at exadel.com
+ * created 17.04.2007
+ *
+ */
+public class ResourcesConfigGeneratorBean {
+
+ private List<ResourcesConfigGeneratorBeanEntry> dependencies = new ArrayList<ResourcesConfigGeneratorBeanEntry>();
+
+ private String resolveResourcePath(String name, String packageName) {
+ if (name.contains("/")) {
+ String resolvedName;
+
+ if (!name.startsWith("/")) {
+ // need to resolve
+ StringBuffer normalizedName = new StringBuffer();
+ normalizedName.append(packageName.replace('.', '/'));
+
+ if (!packageName.endsWith("/")) {
+ normalizedName.append('/');
+ }
+
+ normalizedName.append(name);
+
+ resolvedName = normalizedName.toString();
+ } else {
+ if (name.length() > 0) {
+ resolvedName = name.substring(1);
+ } else {
+ resolvedName = null;
+ }
+ }
+
+ return resolvedName;
+ }
+
+ return null;
+ }
+
+ public void addResource(String name, String path, ResourceType type, boolean isDerived) {
+ boolean isPathResource = true;
+ String resolvedPath = resolveResourcePath(name, path);
+
+ // remove leading / from resource name.
+ if (name.startsWith("/")) {
+ name = name.substring(1);
+ }
+
+ if (resolvedPath == null) {
+ // couldn't resolve, treat as class name
+ resolvedPath = name;
+ isPathResource = false;
+ }
+
+ this.dependencies.add(
+ new ResourcesConfigGeneratorBeanEntry(
+ name, resolvedPath, isPathResource, type, isDerived));
+ }
+
+ public List<ResourcesConfigGeneratorBeanEntry> getDependencies() {
+ return dependencies;
+ }
+
+ public void merge(ResourcesConfigGeneratorBean bean) {
+ this.dependencies.addAll(bean.dependencies);
+ }
+}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBeanEntry.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigGeneratorBeanEntry.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBeanEntry.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigGeneratorBeanEntry.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,66 @@
+/**
+ * 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.builder.generator;
+
+public final class ResourcesConfigGeneratorBeanEntry {
+
+ public ResourcesConfigGeneratorBeanEntry(String name, String path, boolean pathResource,
+ ResourceType type, boolean derived) {
+ super();
+ this.name = name;
+ this.path = path;
+ this.pathResource = pathResource;
+ this.type = type;
+ this.derived = derived;
+ }
+
+ private String name;
+
+ private String path;
+
+ private boolean pathResource;
+
+ private ResourceType type;
+
+ private boolean derived;
+
+ public boolean isPathResource() {
+ return pathResource;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public ResourceType getType() {
+ return type;
+ }
+
+ public boolean isDerived() {
+ return derived;
+ }
+}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigParser.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesConfigParser.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigParser.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesConfigParser.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,428 @@
+/**
+ * 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.builder.generator;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import net.sf.cglib.proxy.MethodInterceptor;
+import net.sf.cglib.proxy.MethodProxy;
+
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.RendererBean;
+import org.richfaces.builder.config.TagBean;
+import org.richfaces.builder.config.TagHandlerBean;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.TemplateCompiler;
+import org.richfaces.templatecompiler.elements.RootElement;
+import org.richfaces.templatecompiler.elements.TemplateElement;
+import org.richfaces.templatecompiler.elements.vcp.FResourceTemplateElement;
+import org.richfaces.templatecompiler.elements.vcp.HeaderResourceElement;
+import org.richfaces.templatecompiler.elements.vcp.HeaderScriptsElement;
+import org.richfaces.templatecompiler.elements.vcp.HeaderStylesElement;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class ResourcesConfigParser {
+
+ private JSFGeneratorConfiguration config;
+
+ private Logger log;
+
+ private File templates;
+
+ private ResourcesConfigGeneratorBean resourcesConfigGeneratorBean;
+
+ private Map<String, ResourcesConfigGeneratorBean> componentResourcesMap;
+
+ public ResourcesConfigParser(JSFGeneratorConfiguration config, Logger log) {
+ super();
+
+ this.config = config;
+ this.log = log;
+ this.resourcesConfigGeneratorBean = new ResourcesConfigGeneratorBean();
+ this.componentResourcesMap = new HashMap<String, ResourcesConfigGeneratorBean>();
+ }
+
+ public File getTemplates() {
+ return templates;
+ }
+
+ public void setTemplates(File templates) {
+ this.templates = templates;
+ }
+
+ private void addResources(ResourcesConfigGeneratorBean configBean,
+ TemplateElement templateElement, String packageName,
+ RendererBean renderer, BuilderConfig builderConfig)
+ throws ClassNotFoundException {
+ if (templateElement instanceof FResourceTemplateElement) {
+ FResourceTemplateElement resourceTemplateElement = (FResourceTemplateElement) templateElement;
+ String name = resourceTemplateElement.getName();
+
+ configBean.addResource(name, packageName, null, true);
+ } else if (templateElement instanceof RootElement) {
+ RootElement rootElement = (RootElement) templateElement;
+
+ CompilationContext compilationContext = rootElement
+ .getComponentBean();
+
+ addResource(configBean, renderer, builderConfig, compilationContext);
+ } else if (templateElement instanceof HeaderResourceElement) {
+ HeaderResourceElement resourceElement = (HeaderResourceElement) templateElement;
+
+ ResourceType type = null;
+ if (templateElement instanceof HeaderScriptsElement) {
+ type = ResourceType.SCRIPT;
+ } else if (templateElement instanceof HeaderStylesElement) {
+ type = ResourceType.STYLE;
+ }
+
+ String[] paths = resourceElement.getResourcePaths();
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ String string = paths[i];
+
+ configBean.addResource(string, packageName, type, false);
+ }
+ }
+ }
+
+ ArrayList<TemplateElement> subElements = templateElement
+ .getSubElements();
+ for (TemplateElement element : subElements) {
+ addResources(configBean, element, packageName, renderer,
+ builderConfig);
+ }
+ }
+
+ private String getResourceKey(String packageName, Object resource) {
+ try {
+ Class<? extends Object> resourceClass = resource.getClass();
+ Method method = resourceClass.getMethod("getKey");
+ String resourceKey = (String) method.invoke(resource);
+
+ if (resourceKey != null && !resourceKey.equals(resourceClass.getName())) {
+ ClassLoader loader = config.getClassLoader();
+
+ if (loader.getResource(resourceKey) == null) {
+ String packagePath = packageName.replace('.', '/');
+ if (packagePath.length() != 0) {
+ packagePath += "/";
+ }
+
+ if (loader.getResource(packagePath + resourceKey) == null) {
+ resourceKey = null;
+ }
+ } else {
+ if (!resourceKey.startsWith("/")) {
+ resourceKey = "/" + resourceKey;
+ }
+ }
+ }
+
+ return resourceKey;
+ } catch (Exception e) {
+ log.error(e.getMessage(), e);
+ }
+
+ return null;
+ }
+
+ private String addResource(ResourcesConfigGeneratorBean configBean,
+ RendererBean renderer, BuilderConfig builderConfig,
+ CompilationContext compilationContext)
+ throws ClassNotFoundException {
+ String packageName;
+ String classname = renderer.getClassname();
+ int idx = classname.lastIndexOf('.');
+ if (idx != -1) {
+ packageName = classname.substring(0, idx);
+ } else {
+ packageName = "";
+ }
+
+ ClassLoader loader = builderConfig.getLoader();
+ Class<?> cl = null;
+
+ try {
+ cl = loader.loadClass(classname);
+ } catch (ClassNotFoundException e) {
+ String superclass = compilationContext.getBaseclassPackageName()
+ + "." + compilationContext.getBaseclassName();
+ if (superclass != null) {
+ cl = loader.loadClass(superclass);
+ }
+ }
+
+ if (cl != null) {
+ try {
+ GetResourceInterceptor interceptor = new GetResourceInterceptor(builderConfig.getLoader());
+
+ Object instance = AbstractClassStubBuilder.buildStub(cl,
+ interceptor, builderConfig.getLoader());
+
+ //clear list - some resources could be requested during class/instance initialization
+ Object[] result = null;
+ Method method = null;
+ Set<String> locatedResources = new HashSet<String>();
+
+ Class<?> cl1 = instance.getClass();
+ while (cl1 != null && method == null) {
+ try {
+ method = cl1.getDeclaredMethod("getStyles");
+ } catch (NoSuchMethodException e) {
+ cl1 = cl1.getSuperclass();
+ }
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ result = (Object[]) method.invoke(instance);
+ if (result instanceof Object[]) {
+ for (Object object : result) {
+ String resourceName = interceptor.getResourceName(object);
+
+ if (resourceName == null) {
+ resourceName = getResourceKey(packageName, object);
+ }
+
+ if (resourceName != null) {
+ locatedResources.add(resourceName);
+ configBean.addResource(resourceName, packageName, ResourceType.STYLE,
+ false);
+ }
+ }
+ }
+ }
+
+ method = null;
+ cl1 = instance.getClass();
+ while (cl1 != null && method == null) {
+ try {
+ method = cl1.getDeclaredMethod("getScripts");
+ } catch (NoSuchMethodException e) {
+ cl1 = cl1.getSuperclass();
+ }
+ }
+
+ if (method != null) {
+ method.setAccessible(true);
+ result = (Object[]) method.invoke(instance);
+ if (result instanceof Object[]) {
+ for (Object object : result) {
+ String resourceName = interceptor.getResourceName(object);
+
+ if (resourceName == null) {
+ resourceName = getResourceKey(packageName, object);
+ }
+
+ if (resourceName != null) {
+ locatedResources.add(resourceName);
+ configBean.addResource(resourceName, packageName, ResourceType.SCRIPT,
+ false);
+ }
+ }
+ }
+
+ List<String> list = interceptor.getList();
+ if (list != null) {
+ list.removeAll(locatedResources);
+ for (String resourceName : list) {
+ log.warn("Error detecting resource type: " + resourceName);
+ configBean.addResource(resourceName, packageName, null,
+ false);
+ }
+ }
+ }
+ } catch (SecurityException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (IllegalArgumentException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ } catch (InvocationTargetException e) {
+ builderConfig.getLog().error(e.getMessage(), e);
+ }
+ }
+ return packageName;
+ }
+
+ private void addResources(ResourcesConfigGeneratorBean configBean,
+ RendererBean renderer, BuilderConfig builderConfig)
+ throws CompilationException, IOException, ClassNotFoundException {
+ if (null != renderer) {
+ CompilationContext compilationContext = new RendererCompilationContext(
+ log, config.getClassLoader(), config);
+
+ if (renderer.isGenerate()) {
+ String templateString = renderer.getTemplate();
+ if (templateString != null) {
+ File template;
+ if (null != getTemplates()) {
+ template = new File(getTemplates(), templateString);
+ } else {
+ template = new File(templateString);
+ }
+
+ TemplateCompiler templateCompiler = new TemplateCompiler();
+ InputStream templateStream = new FileInputStream(template);
+ templateCompiler.processing(templateStream,
+ compilationContext);
+
+ TemplateElement root = compilationContext.getTree();
+
+ String classname = renderer.getClassname();
+ String packageName;
+ int idx = classname.lastIndexOf('.');
+ if (idx != -1) {
+ packageName = classname.substring(0, idx);
+ } else {
+ packageName = "";
+ }
+
+ addResources(configBean, root, packageName, renderer,
+ builderConfig);
+ }
+ } else {
+ addResource(configBean, renderer, builderConfig,
+ compilationContext);
+ }
+ }
+ }
+
+ public void parse(BuilderConfig config) throws CompilationException, IOException, ClassNotFoundException {
+ List<ComponentBean> components = config.getComponents();
+ for (ComponentBean componentBean : components) {
+ ResourcesConfigGeneratorBean localBeanInstance = new ResourcesConfigGeneratorBean();
+ RendererBean rendererBean = componentBean.getRenderer();
+
+ addResources(localBeanInstance, rendererBean, config);
+
+ String componentName = null;
+
+ TagBean tag = componentBean.getTag();
+ if (tag != null) {
+ componentName = tag.getName();
+ }
+
+ if (componentName == null) {
+ TagHandlerBean taghandler = componentBean.getTaghandler();
+ if (taghandler != null) {
+ componentName = taghandler.getName();
+ }
+ }
+
+ if (componentName != null) {
+ this.componentResourcesMap.put(componentName, localBeanInstance);
+ }
+
+ this.resourcesConfigGeneratorBean.merge(localBeanInstance);
+ }
+
+ List<RendererBean> renderers = config.getRenderers();
+ for (RendererBean rendererBean : renderers) {
+ addResources(this.resourcesConfigGeneratorBean, rendererBean, config);
+ }
+ }
+
+ public ResourcesConfigGeneratorBean getResourcesConfigGeneratorBean() {
+ return resourcesConfigGeneratorBean;
+ }
+
+ public Map<String, ResourcesConfigGeneratorBean> getComponentResourcesMap() {
+ return componentResourcesMap;
+ }
+}
+
+class GetResourceInterceptor implements MethodInterceptor {
+
+ private static final Class<?>[] SIGNATURE = new Class<?>[] { String.class };
+
+ private ClassLoader classLoader;
+
+ private List<String> list = new ArrayList<String>();
+
+ private Map<String, Object> resources = new HashMap<String, Object>();
+
+ private Map<Object, String> resourcesInverse = new IdentityHashMap<Object, String>();
+
+ public GetResourceInterceptor(ClassLoader loader) {
+ this.classLoader = loader;
+ }
+
+ public List<String> getList() {
+ return list;
+ }
+
+ public String getResourceName(Object resource) {
+ return resourcesInverse.get(resource);
+ }
+
+ public void clearList() {
+ list.clear();
+ }
+
+ public Object intercept(Object instance, Method method, Object[] args,
+ MethodProxy methodProxy) throws Throwable {
+
+ if ("getResource".equals(method.getName())
+ && Arrays.equals(SIGNATURE, method.getParameterTypes())) {
+
+ String resourceName = (String) args[0];
+ list.add(resourceName);
+
+ Object resource = resources.get(resourceName);
+ if (resource == null) {
+ Class<?> returnType = method.getReturnType();
+ if (returnType.isInterface()) {
+ Object interfaceStub = AbstractClassStubBuilder.buildInterfaceStub(returnType, classLoader);
+ resources.put(resourceName, interfaceStub);
+ resourcesInverse.put(interfaceStub, resourceName);
+
+ return interfaceStub;
+ }
+ }
+
+ return null;
+ } else {
+ return methodProxy.invokeSuper(instance, args);
+ }
+ }
+
+}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesDependenciesGenerator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ResourcesDependenciesGenerator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesDependenciesGenerator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ResourcesDependenciesGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,143 @@
+/**
+ * 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.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+
+/**
+ * @author Nick Belaevski
+ * @since 3.3.0
+ */
+public class ResourcesDependenciesGenerator extends InnerGenerator {
+
+ private Map<String, ResourcesConfigGeneratorBean> componentDependencies;
+ private String uri;
+ private File dependencyFile;
+
+ public ResourcesDependenciesGenerator(JSFGeneratorConfiguration config,
+ Logger log) {
+ super(config, log);
+ }
+
+ @Override
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ try {
+ VelocityContext context = new VelocityContext();
+ Template template = getTemplate();
+
+ Map<String, Map<String, Collection<String>>> componentsMap = new HashMap<String, Map<String, Collection<String>>>();
+ for (Entry<String, ResourcesConfigGeneratorBean> entry : componentDependencies.entrySet()) {
+ Map<String, Collection<String>> resourcesMap = new HashMap<String, Collection<String>>();
+ componentsMap.put(entry.getKey(), resourcesMap);
+
+ Collection<String> scripts = new LinkedHashSet<String>();
+ Collection<String> styles = new LinkedHashSet<String>();
+
+ ResourcesConfigGeneratorBean resourcesConfigBean = entry.getValue();
+ List<ResourcesConfigGeneratorBeanEntry> dependencies = resourcesConfigBean.getDependencies();
+ for (ResourcesConfigGeneratorBeanEntry beanEntry : dependencies) {
+ if (beanEntry.isDerived()) {
+ continue;
+ }
+
+ ResourceType type = beanEntry.getType();
+ if (type != null) {
+ switch (type) {
+ case SCRIPT:
+ scripts.add(beanEntry.getPath());
+ break;
+
+ case STYLE:
+ styles.add(beanEntry.getPath());
+ break;
+ }
+ }
+ }
+
+ resourcesMap.put("scripts", scripts);
+ resourcesMap.put("styles", styles);
+ }
+
+ context.put("uri", uri);
+ context.put("components", componentsMap);
+
+ File configFile = getDependencyFile();
+ File javaDir = configFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ if (configFile.exists()) {
+ configFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(configFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(e.getMessage(), e);
+ }
+ }
+
+ @Override
+ protected String getDefaultTemplateName() {
+ return "resources-dependencies.vm";
+ }
+
+ public Map<String, ResourcesConfigGeneratorBean> getComponentDependencies() {
+ return componentDependencies;
+ }
+
+ public void setComponentDependencies(
+ Map<String, ResourcesConfigGeneratorBean> componentDependencies) {
+ this.componentDependencies = componentDependencies;
+ }
+
+ public void setDependencyFile(File dependencyFile) {
+ this.dependencyFile = dependencyFile;
+ }
+
+ public File getDependencyFile() {
+ return dependencyFile;
+ }
+
+ public String getUri() {
+ return uri;
+ }
+
+ public void setUri(String uri) {
+ this.uri = uri;
+ }
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagHandlerGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagHandlerGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagHandlerGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,17 +29,17 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagHandlerBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.TagHandlerBean;
/**
* Class implement functionality for generate facelets tags java files
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,103 +0,0 @@
-package org.ajax4jsf.builder.generator;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagBean;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-
-public class TagTestGenerator extends InnerGenerator{
-
- private static final String COMPONENT_FILE_TEMPLATE = "tagtest.vm";
-
- public TagTestGenerator(JSFGeneratorConfiguration config, Logger log) {
- super(config, log);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public void createFiles(BuilderConfig config) throws GeneratorException {
- // TODO Auto-generated method stub
- System.out.println("Preparing to generate test for tag class... ");
- VelocityContext context = new VelocityContext();
- context.put("generator",this);
- context.put("testDataGenerator", new TestDataGenerator2(getClassLoader(), getLog()));
-
- Template template = getTemplate();
- // Put common properties
- for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
- ComponentBean component = (ComponentBean) iter.next();
- TagBean tag = component.getTag();
- if ( null != tag && null !=tag.getClassname() && tag.isGenerate()
- && tag.getTest() != null) {
- info("Create test class file for tag " + component.getTag().getSimpleClassName());
- context.put("component", component);
- if (null != component.getRenderer()) {
- context.put("renderer", component.getRenderer());
- } else {
- context.put("renderer",Boolean.FALSE);
- }
- context.put("tag", component.getTag());
- context.put("package", component.getTag().getPackageName());
- Set<String> importClasses = new HashSet<String>();
- for (Iterator<PropertyBean> it = component.getProperties().iterator(); it
- .hasNext();) {
- PropertyBean property = (PropertyBean) it.next();
- // For non-primitive types, add import declaration.
- if (!property.isSimpleType() && !property.isHidden()) {
- importClasses.add(property.getClassname());
- }
- }
- importClasses.add(component.getTag().getTest().getSuperclassname());
- context.put("imports", importClasses);
- String resultPath = component.getTag().getTest().getClassname().replace('.', '/')
- + ".java";
- //System.out.println("resultPath - " + resultPath);
- //System.out.println("getDestDir() - " + getDestDir());
- File javaFile = new File(getDestDir(), resultPath);
- File javaDir = javaFile.getParentFile();
- if (!javaDir.exists()) {
- javaDir.mkdirs();
- }
- try {
- if (javaFile.exists()) {
- javaFile.delete();
- }
- Writer out = new BufferedWriter(new FileWriter(javaFile));
- template.merge(context, out);
- out.flush();
- out.close();
- } catch (Exception e) {
- throw new GeneratorException(
- "Error create new Component JSP Tag Test Java file ", e);
- }
- }
- }
- }
-
- @Override
- protected String getDefaultTemplateName() {
- // TODO Auto-generated method stub
- return COMPONENT_FILE_TEMPLATE;
- }
-
- public String getSetterTestName(PropertyBean property){
- String setterName = property.getSetterName();
- String className = property.getSimpleClassName();
- StringBuilder name = new StringBuilder("test");
- name.append(Character.toUpperCase(setterName.charAt(0)));
- name.append(setterName.substring(1));
- name.append(Character.toUpperCase(className.charAt(0)));
- name.append(className.substring(1));
- return name.toString();
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TagTestGenerator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TagTestGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,124 @@
+/**
+ * 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.builder.generator;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.Writer;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.TagBean;
+
+public class TagTestGenerator extends InnerGenerator{
+
+ private static final String COMPONENT_FILE_TEMPLATE = "tagtest.vm";
+
+ public TagTestGenerator(JSFGeneratorConfiguration config, Logger log) {
+ super(config, log);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void createFiles(BuilderConfig config) throws GeneratorException {
+ // TODO Auto-generated method stub
+ System.out.println("Preparing to generate test for tag class... ");
+ VelocityContext context = new VelocityContext();
+ context.put("generator",this);
+ context.put("testDataGenerator", new TestDataGenerator2(getClassLoader(), getLog()));
+
+ Template template = getTemplate();
+ // Put common properties
+ for (Iterator iter = config.getComponents().iterator(); iter.hasNext();) {
+ ComponentBean component = (ComponentBean) iter.next();
+ TagBean tag = component.getTag();
+ if ( null != tag && null !=tag.getClassname() && tag.isGenerate()
+ && tag.getTest() != null) {
+ info("Create test class file for tag " + component.getTag().getSimpleClassName());
+ context.put("component", component);
+ if (null != component.getRenderer()) {
+ context.put("renderer", component.getRenderer());
+ } else {
+ context.put("renderer",Boolean.FALSE);
+ }
+ context.put("tag", component.getTag());
+ context.put("package", component.getTag().getPackageName());
+ Set<String> importClasses = new HashSet<String>();
+ for (Iterator<PropertyBean> it = component.getProperties().iterator(); it
+ .hasNext();) {
+ PropertyBean property = (PropertyBean) it.next();
+ // For non-primitive types, add import declaration.
+ if (!property.isSimpleType() && !property.isHidden()) {
+ importClasses.add(property.getClassname());
+ }
+ }
+ importClasses.add(component.getTag().getTest().getSuperclassname());
+ context.put("imports", importClasses);
+ String resultPath = component.getTag().getTest().getClassname().replace('.', '/')
+ + ".java";
+ //System.out.println("resultPath - " + resultPath);
+ //System.out.println("getDestDir() - " + getDestDir());
+ File javaFile = new File(getDestDir(), resultPath);
+ File javaDir = javaFile.getParentFile();
+ if (!javaDir.exists()) {
+ javaDir.mkdirs();
+ }
+ try {
+ if (javaFile.exists()) {
+ javaFile.delete();
+ }
+ Writer out = new BufferedWriter(new FileWriter(javaFile));
+ template.merge(context, out);
+ out.flush();
+ out.close();
+ } catch (Exception e) {
+ throw new GeneratorException(
+ "Error create new Component JSP Tag Test Java file ", e);
+ }
+ }
+ }
+ }
+
+ @Override
+ protected String getDefaultTemplateName() {
+ // TODO Auto-generated method stub
+ return COMPONENT_FILE_TEMPLATE;
+ }
+
+ public String getSetterTestName(PropertyBean property){
+ String setterName = property.getSetterName();
+ String className = property.getSimpleClassName();
+ StringBuilder name = new StringBuilder("test");
+ name.append(Character.toUpperCase(setterName.charAt(0)));
+ name.append(setterName.substring(1));
+ name.append(Character.toUpperCase(className.charAt(0)));
+ name.append(className.substring(1));
+ return name.toString();
+ }
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TaglibGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TaglibGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TaglibGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,19 +29,19 @@
import java.util.Iterator;
import java.util.List;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ComponentBean;
-import org.ajax4jsf.builder.config.ConverterBean;
-import org.ajax4jsf.builder.config.FunctionBean;
-import org.ajax4jsf.builder.config.ListenerBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ComponentBean;
+import org.richfaces.builder.config.ConverterBean;
+import org.richfaces.builder.config.FunctionBean;
+import org.richfaces.builder.config.ListenerBean;
+import org.richfaces.builder.config.ValidatorBean;
/**
* Class implement functionality for generate jsp taglib .tld file
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
@@ -354,7 +354,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.XMLConfigGenerator#getRootTag()
+ * @see org.richfaces.builder.generator.XMLConfigGenerator#getRootTag()
*/
protected String getRootTag() {
//
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,206 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.generator;
-
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-
-/**
- * @author Nick Belaevski - nbelaevski at exadel.com
- * created 13.04.2007
- *
- */
-public class TestDataGenerator {
-
- private ClassLoader loader;
- private Logger logger;
-
- private static Map<String, String> testData = new HashMap<String, String>();
- static {
- testData.put(Boolean.TYPE.getName(), "true");
- testData.put(Character.TYPE.getName(), "'#'");
- testData.put(Byte.TYPE.getName(), "17");
- testData.put(Short.TYPE.getName(), "18");
- testData.put(Integer.TYPE.getName(), "20");
- testData.put(Long.TYPE.getName(), "26");
- testData.put(Float.TYPE.getName(), "2.05f");
- testData.put(Double.TYPE.getName(), "1.34d");
-
- testData.put(Boolean.class.getName(), "new Boolean(true)");
- testData.put(Character.class.getName(), "new Character('#')");
- testData.put(Byte.class.getName(), "new Byte(17)");
- testData.put(Short.class.getName(), "new Short(18)");
- testData.put(Integer.class.getName(), "new Integer(20)");
- testData.put(Long.class.getName(), "new Long(26)");
- testData.put(Float.class.getName(), "new Float(2.05f)");
- testData.put(Double.class.getName(), "new Double(1.34d)");
-
- testData.put(Date.class.getName(), "java.text.DateFormat.getDateInstance(" +
- "java.text.DateFormat.SHORT, java.util.Locale.US).parse(\"09/08/2007\")");
- }
-
- private static Map<String, String> testData1 = new HashMap<String, String>();
- static {
- testData1.put(Boolean.TYPE.getName(), "false");
- testData1.put(Character.TYPE.getName(), "'*'");
- testData1.put(Byte.TYPE.getName(), "8");
- testData1.put(Short.TYPE.getName(), "26");
- testData1.put(Integer.TYPE.getName(), "15");
- testData1.put(Long.TYPE.getName(), "13");
- testData1.put(Float.TYPE.getName(), "1.05f");
- testData1.put(Double.TYPE.getName(), "1.44d");
-
- testData1.put(Boolean.class.getName(), "new Boolean(false)");
- testData1.put(Character.class.getName(), "new Character('*')");
- testData1.put(Byte.class.getName(), "new Byte(8)");
- testData1.put(Short.class.getName(), "new Short(26)");
- testData1.put(Integer.class.getName(), "new Integer(15)");
- testData1.put(Long.class.getName(), "new Long(13)");
- testData1.put(Float.class.getName(), "new Float(1.05f)");
- testData1.put(Double.class.getName(), "new Double(1.44d)");
-
- testData1.put(Date.class.getName(), "java.text.DateFormat.getDateInstance(" +
- "java.text.DateFormat.SHORT, java.util.Locale.US).parse(\"02/29/2008\")");
- }
-
- private static Map<String, Class> primitiveToWrapper = new HashMap<String, Class>();
- static {
- primitiveToWrapper.put(Boolean.TYPE.getName(), Boolean.class);
- primitiveToWrapper.put(Character.TYPE.getName(), Character.class);
- primitiveToWrapper.put(Byte.TYPE.getName(), Byte.class);
- primitiveToWrapper.put(Short.TYPE.getName(), Short.class);
- primitiveToWrapper.put(Integer.TYPE.getName(), Integer.class);
- primitiveToWrapper.put(Long.TYPE.getName(), Long.class);
- primitiveToWrapper.put(Float.TYPE.getName(), Float.class);
- primitiveToWrapper.put(Double.TYPE.getName(), Double.class);
- }
-
- public TestDataGenerator(ClassLoader loader, Logger logger) {
- super();
- this.loader = loader;
- this.logger = logger;
- }
-
-
- public String getTestVeClass(PropertyBean propertyBean) {
- String type = propertyBean.getClassname();
- Class clazz = primitiveToWrapper.get(propertyBean.getClassname());
- if (clazz == null) {
- try {
- clazz = loader.loadClass(propertyBean.getClassname());
- } catch (ClassNotFoundException e) {
- logger.error(e);
-
- return null;
- }
- }
-
- return clazz.getName();
- }
-
- public String getTestVeData(PropertyBean propertyBean) {
- String veClass = getTestVeClass(propertyBean);
- if (veClass != null) {
- return getTestData(propertyBean.getName(), veClass, 0);
- }
-
- return "";
- }
-
- public String getTestVeData1(PropertyBean propertyBean) {
- String veClass = getTestVeClass(propertyBean);
- if (veClass != null) {
- return getTestData(propertyBean.getName(), veClass, 1);
- }
-
- return "";
- }
-
- private String getTestData(String propertyName, String className, int number) {
-
- String string = number == 0 ? testData.get(className) : testData1.get(className);
-
- if (string != null) {
- return string;
- }
-
- try {
- Class<?> clazz = Class.forName(className, false, loader);
- if (clazz.isAssignableFrom(String.class)) {
- if (number == 0) {
- return "\"" + propertyName + "\"";
- } else {
- return "\"" + propertyName + "_" + propertyName + "\"";
- }
- } else if (clazz.isEnum()) {
- return getEnumData(propertyName, (Class<Enum<?>>)clazz, number);
- }
-
- } catch(Exception e) {
-
- }
-
- return "createTestData_" + number + "_" + propertyName + "()";
- }
-
- private String getEnumData(String propertyName, Class<Enum<?>> clazz, int number) {
- if (clazz.isEnum()) {
- Enum<?>[] enumConstants = clazz.getEnumConstants();
- if (enumConstants.length > 0) {
- if (number >= enumConstants.length) {
- return enumToString(enumConstants[enumConstants.length - 1]);
- }
- return enumToString(enumConstants[number]);
- }
- }
- return "null";
- }
-
- private String enumToString(Enum<?> e) {
- return e.getDeclaringClass().getName() + "." + e;
- }
-
- public String getTestData(PropertyBean propertyBean) {
- return getTestData(propertyBean.getName(), propertyBean.getClassname(), 0);
- }
-
- public String getTestData1(PropertyBean propertyBean) {
- return getTestData(propertyBean.getName(), propertyBean.getClassname(), 1);
- }
- /**
- * Returns true if property
- * @param propertyBean
- * @return
- */
- public boolean isNativelySupported(PropertyBean propertyBean) {
- String classname = propertyBean.getClassname();
- return testData.containsKey(classname) || isAssignabelFromString(propertyBean) || isEnum(propertyBean);
-
- }
-
- protected boolean isAssignabelFromString(PropertyBean bean) {
- String classname = bean.getClassname();
- Class<?> class1;
- try {
- class1 = Class.forName(classname, false, loader);
- } catch (ClassNotFoundException e) {
- return false;
- }
- return class1.isAssignableFrom(String.class);
- }
-
- protected boolean isEnum(PropertyBean bean) {
- String classname = bean.getClassname();
- Class<?> class1;
- try {
- class1 = Class.forName(classname, false, loader);
- } catch (ClassNotFoundException e) {
- return false;
- }
- return class1.isEnum();
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,224 @@
+/**
+ * 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.builder.generator;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.richfaces.builder.config.PropertyBean;
+
+/**
+ * @author Nick Belaevski - nbelaevski at exadel.com
+ * created 13.04.2007
+ *
+ */
+public class TestDataGenerator {
+
+ private ClassLoader loader;
+ private Logger logger;
+
+ private static Map<String, String> testData = new HashMap<String, String>();
+ static {
+ testData.put(Boolean.TYPE.getName(), "true");
+ testData.put(Character.TYPE.getName(), "'#'");
+ testData.put(Byte.TYPE.getName(), "17");
+ testData.put(Short.TYPE.getName(), "18");
+ testData.put(Integer.TYPE.getName(), "20");
+ testData.put(Long.TYPE.getName(), "26");
+ testData.put(Float.TYPE.getName(), "2.05f");
+ testData.put(Double.TYPE.getName(), "1.34d");
+
+ testData.put(Boolean.class.getName(), "new Boolean(true)");
+ testData.put(Character.class.getName(), "new Character('#')");
+ testData.put(Byte.class.getName(), "new Byte(17)");
+ testData.put(Short.class.getName(), "new Short(18)");
+ testData.put(Integer.class.getName(), "new Integer(20)");
+ testData.put(Long.class.getName(), "new Long(26)");
+ testData.put(Float.class.getName(), "new Float(2.05f)");
+ testData.put(Double.class.getName(), "new Double(1.34d)");
+
+ testData.put(Date.class.getName(), "java.text.DateFormat.getDateInstance(" +
+ "java.text.DateFormat.SHORT, java.util.Locale.US).parse(\"09/08/2007\")");
+ }
+
+ private static Map<String, String> testData1 = new HashMap<String, String>();
+ static {
+ testData1.put(Boolean.TYPE.getName(), "false");
+ testData1.put(Character.TYPE.getName(), "'*'");
+ testData1.put(Byte.TYPE.getName(), "8");
+ testData1.put(Short.TYPE.getName(), "26");
+ testData1.put(Integer.TYPE.getName(), "15");
+ testData1.put(Long.TYPE.getName(), "13");
+ testData1.put(Float.TYPE.getName(), "1.05f");
+ testData1.put(Double.TYPE.getName(), "1.44d");
+
+ testData1.put(Boolean.class.getName(), "new Boolean(false)");
+ testData1.put(Character.class.getName(), "new Character('*')");
+ testData1.put(Byte.class.getName(), "new Byte(8)");
+ testData1.put(Short.class.getName(), "new Short(26)");
+ testData1.put(Integer.class.getName(), "new Integer(15)");
+ testData1.put(Long.class.getName(), "new Long(13)");
+ testData1.put(Float.class.getName(), "new Float(1.05f)");
+ testData1.put(Double.class.getName(), "new Double(1.44d)");
+
+ testData1.put(Date.class.getName(), "java.text.DateFormat.getDateInstance(" +
+ "java.text.DateFormat.SHORT, java.util.Locale.US).parse(\"02/29/2008\")");
+ }
+
+ private static Map<String, Class> primitiveToWrapper = new HashMap<String, Class>();
+ static {
+ primitiveToWrapper.put(Boolean.TYPE.getName(), Boolean.class);
+ primitiveToWrapper.put(Character.TYPE.getName(), Character.class);
+ primitiveToWrapper.put(Byte.TYPE.getName(), Byte.class);
+ primitiveToWrapper.put(Short.TYPE.getName(), Short.class);
+ primitiveToWrapper.put(Integer.TYPE.getName(), Integer.class);
+ primitiveToWrapper.put(Long.TYPE.getName(), Long.class);
+ primitiveToWrapper.put(Float.TYPE.getName(), Float.class);
+ primitiveToWrapper.put(Double.TYPE.getName(), Double.class);
+ }
+
+ public TestDataGenerator(ClassLoader loader, Logger logger) {
+ super();
+ this.loader = loader;
+ this.logger = logger;
+ }
+
+
+ public String getTestVeClass(PropertyBean propertyBean) {
+ String type = propertyBean.getClassname();
+ Class clazz = primitiveToWrapper.get(propertyBean.getClassname());
+ if (clazz == null) {
+ try {
+ clazz = loader.loadClass(propertyBean.getClassname());
+ } catch (ClassNotFoundException e) {
+ logger.error(e);
+
+ return null;
+ }
+ }
+
+ return clazz.getName();
+ }
+
+ public String getTestVeData(PropertyBean propertyBean) {
+ String veClass = getTestVeClass(propertyBean);
+ if (veClass != null) {
+ return getTestData(propertyBean.getName(), veClass, 0);
+ }
+
+ return "";
+ }
+
+ public String getTestVeData1(PropertyBean propertyBean) {
+ String veClass = getTestVeClass(propertyBean);
+ if (veClass != null) {
+ return getTestData(propertyBean.getName(), veClass, 1);
+ }
+
+ return "";
+ }
+
+ private String getTestData(String propertyName, String className, int number) {
+
+ String string = number == 0 ? testData.get(className) : testData1.get(className);
+
+ if (string != null) {
+ return string;
+ }
+
+ try {
+ Class<?> clazz = Class.forName(className, false, loader);
+ if (clazz.isAssignableFrom(String.class)) {
+ if (number == 0) {
+ return "\"" + propertyName + "\"";
+ } else {
+ return "\"" + propertyName + "_" + propertyName + "\"";
+ }
+ } else if (clazz.isEnum()) {
+ return getEnumData(propertyName, (Class<Enum<?>>)clazz, number);
+ }
+
+ } catch(Exception e) {
+
+ }
+
+ return "createTestData_" + number + "_" + propertyName + "()";
+ }
+
+ private String getEnumData(String propertyName, Class<Enum<?>> clazz, int number) {
+ if (clazz.isEnum()) {
+ Enum<?>[] enumConstants = clazz.getEnumConstants();
+ if (enumConstants.length > 0) {
+ if (number >= enumConstants.length) {
+ return enumToString(enumConstants[enumConstants.length - 1]);
+ }
+ return enumToString(enumConstants[number]);
+ }
+ }
+ return "null";
+ }
+
+ private String enumToString(Enum<?> e) {
+ return e.getDeclaringClass().getName() + "." + e;
+ }
+
+ public String getTestData(PropertyBean propertyBean) {
+ return getTestData(propertyBean.getName(), propertyBean.getClassname(), 0);
+ }
+
+ public String getTestData1(PropertyBean propertyBean) {
+ return getTestData(propertyBean.getName(), propertyBean.getClassname(), 1);
+ }
+ /**
+ * Returns true if property
+ * @param propertyBean
+ * @return
+ */
+ public boolean isNativelySupported(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ return testData.containsKey(classname) || isAssignabelFromString(propertyBean) || isEnum(propertyBean);
+
+ }
+
+ protected boolean isAssignabelFromString(PropertyBean bean) {
+ String classname = bean.getClassname();
+ Class<?> class1;
+ try {
+ class1 = Class.forName(classname, false, loader);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ return class1.isAssignableFrom(String.class);
+ }
+
+ protected boolean isEnum(PropertyBean bean) {
+ String classname = bean.getClassname();
+ Class<?> class1;
+ try {
+ class1 = Class.forName(classname, false, loader);
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ return class1.isEnum();
+ }
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,56 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.generator;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ajax4jsf.builder.config.PropertyBean;
-
-/**
- * @author Administrator
- *
- */
-public class TestDataGenerator2 extends TestDataGenerator {
-
-
- @SuppressWarnings("serial")
- private static final Map<String, String> testData = new HashMap<String, String>() {
- {
- put(java.util.Date.class.getName(), "new Date()");
- put(java.util.Calendar.class.getName(), "Calendar.getInstance()");
- }
- };
-
- public TestDataGenerator2(ClassLoader loader, Logger logger) {
- super(loader, logger);
- // TODO Auto-generated constructor stub
- }
-
- @Override
- public String getTestData(PropertyBean propertyBean) {
- String classname = propertyBean.getClassname();
- if (testData.containsKey(classname)) {
- return testData.get(classname);
- }
- return super.getTestData(propertyBean);
- }
-
- @Override
- public String getTestData1(PropertyBean propertyBean) {
- String classname = propertyBean.getClassname();
- if (testData.containsKey(classname)) {
- return testData.get(classname);
- }
- return super.getTestData1(propertyBean);
- }
-
- @Override
- /**
- * Disable date types
- */
- public boolean isNativelySupported(PropertyBean propertyBean) {
- return super.isNativelySupported(propertyBean) && !testData.containsKey(propertyBean.getClassname());
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/TestDataGenerator2.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/TestDataGenerator2.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,74 @@
+/**
+ * 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.builder.generator;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.richfaces.builder.config.PropertyBean;
+
+/**
+ * @author Administrator
+ *
+ */
+public class TestDataGenerator2 extends TestDataGenerator {
+
+
+ @SuppressWarnings("serial")
+ private static final Map<String, String> testData = new HashMap<String, String>() {
+ {
+ put(java.util.Date.class.getName(), "new Date()");
+ put(java.util.Calendar.class.getName(), "Calendar.getInstance()");
+ }
+ };
+
+ public TestDataGenerator2(ClassLoader loader, Logger logger) {
+ super(loader, logger);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public String getTestData(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ if (testData.containsKey(classname)) {
+ return testData.get(classname);
+ }
+ return super.getTestData(propertyBean);
+ }
+
+ @Override
+ public String getTestData1(PropertyBean propertyBean) {
+ String classname = propertyBean.getClassname();
+ if (testData.containsKey(classname)) {
+ return testData.get(classname);
+ }
+ return super.getTestData1(propertyBean);
+ }
+
+ @Override
+ /**
+ * Disable date types
+ */
+ public boolean isNativelySupported(PropertyBean propertyBean) {
+ return super.isNativelySupported(propertyBean) && !testData.containsKey(propertyBean.getClassname());
+ }
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,11 +29,11 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.ValidatorBean;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorTagGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/ValidatorTagGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/ValidatorTagGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.BufferedWriter;
import java.io.File;
@@ -29,17 +29,17 @@
import java.util.Iterator;
import java.util.Set;
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.PropertyBean;
-import org.ajax4jsf.builder.config.TagBean;
-import org.ajax4jsf.builder.config.ValidatorBean;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.PropertyBean;
+import org.richfaces.builder.config.TagBean;
+import org.richfaces.builder.config.ValidatorBean;
/**
* Class implement functionality for generate jsp tags for validators
- * inner element of {@link org.ajax4jsf.builder.ant.JSFGeneratorTask}
+ * inner element of {@link org.richfaces.builder.ant.JSFGeneratorTask}
* use in ant build.xml :
* <jsfgenerator ... >
* ....
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/XMLConfigGenerator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/generator/XMLConfigGenerator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/generator/XMLConfigGenerator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.xml.XMLBody;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.XMLBody;
/**
* @author shura
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/Argument.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/Argument.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/Argument.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* Representation of method argument
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/ClassImport.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/ClassImport.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/ClassImport.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaAnnotation.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaAnnotation.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.Arrays;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaClass.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaClass.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaClass.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.Comparator;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaComment.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaComment.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaComment.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* Java comment representation
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaConstructor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaConstructor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaField.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaField.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaField.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* Class field abstraction
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaImport.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaImport.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaImport.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaLanguageElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaLanguageElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.HashSet;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaMethod.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaMethod.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.ArrayList;
import java.util.Arrays;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaModifier.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaModifier.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPackage.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPackage.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/JavaPrimitive.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/JavaPrimitive.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.HashMap;
import java.util.Map;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/MethodBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/MethodBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/MethodBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
import java.util.HashSet;
import java.util.Set;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/model/RuntimeImport.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/model/RuntimeImport.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.model;
+package org.richfaces.builder.model;
/**
* Implementation of import taht cannot be resolved in design time
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaClassRenderer.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaClassRenderer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.render;
+package org.richfaces.builder.render;
import java.io.PrintWriter;
import java.util.List;
@@ -27,14 +27,14 @@
import javax.faces.component.UIComponentBase;
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaClass;
-import org.ajax4jsf.builder.model.JavaField;
-import org.ajax4jsf.builder.model.JavaImport;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.JavaModifier;
-import org.ajax4jsf.builder.model.JavaPackage;
-import org.ajax4jsf.builder.model.MethodBody;
+import org.richfaces.builder.model.Argument;
+import org.richfaces.builder.model.JavaClass;
+import org.richfaces.builder.model.JavaField;
+import org.richfaces.builder.model.JavaImport;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaPackage;
+import org.richfaces.builder.model.MethodBody;
/**
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaFieldRenderer.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaFieldRenderer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.render;
+package org.richfaces.builder.render;
import java.io.PrintWriter;
-import org.ajax4jsf.builder.model.JavaField;
+import org.richfaces.builder.model.JavaField;
/**
* @author Maksim Kaszynski
@@ -32,7 +32,7 @@
public class JavaFieldRenderer extends JavaLanguageElementRenderer<JavaField> {
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.render.JavaLanguageElementRenderer#render(org.ajax4jsf.builder.model.JavaLanguageElement, java.io.PrintWriter)
+ * @see org.richfaces.builder.render.JavaLanguageElementRenderer#render(org.richfaces.builder.model.JavaLanguageElement, java.io.PrintWriter)
*/
@Override
public void render(JavaField field, PrintWriter out) {
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaLanguageElementRenderer.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaLanguageElementRenderer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -18,17 +18,17 @@
* 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.ajax4jsf.builder.render;
+package org.richfaces.builder.render;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import org.ajax4jsf.builder.model.JavaAnnotation;
-import org.ajax4jsf.builder.model.JavaComment;
-import org.ajax4jsf.builder.model.JavaLanguageElement;
-import org.ajax4jsf.builder.model.JavaModifier;
+import org.richfaces.builder.model.JavaAnnotation;
+import org.richfaces.builder.model.JavaComment;
+import org.richfaces.builder.model.JavaLanguageElement;
+import org.richfaces.builder.model.JavaModifier;
/**
*
* @author Maksim Kaszynski
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/render/JavaMethodRenderer.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/render/JavaMethodRenderer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,15 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.render;
+package org.richfaces.builder.render;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
-import org.ajax4jsf.builder.model.Argument;
-import org.ajax4jsf.builder.model.JavaMethod;
-import org.ajax4jsf.builder.model.MethodBody;
+import org.richfaces.builder.model.Argument;
+import org.richfaces.builder.model.JavaMethod;
+import org.richfaces.builder.model.MethodBody;
/**
* @author Maksim Kaszynski
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/velocity)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/AntFileResourceLoader.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/velocity/AntFileResourceLoader.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/AntFileResourceLoader.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.velocity;
+package org.richfaces.builder.velocity;
import java.io.BufferedInputStream;
import java.io.File;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/BuilderContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/velocity/BuilderContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/BuilderContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,15 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.velocity;
+package org.richfaces.builder.velocity;
import java.io.File;
import java.util.Properties;
-import org.ajax4jsf.builder.generator.GeneratorException;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
import org.apache.velocity.app.Velocity;
+import org.richfaces.builder.generator.GeneratorException;
/**
* @author asmirnov at exadel.com (latest modification by $Author: alexsmirnov $)
@@ -72,7 +72,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.ant.JSFGeneratorConfiguration#getTemplate(java.lang.String)
+ * @see org.richfaces.builder.ant.JSFGeneratorConfiguration#getTemplate(java.lang.String)
*/
public static Template getTemplate(String templateName) throws GeneratorException {
try {
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/ClasspathTemplateLoader.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/velocity/ClasspathTemplateLoader.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/velocity/ClasspathTemplateLoader.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.velocity;
+package org.richfaces.builder.velocity;
import java.io.InputStream;
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/NamesListComparator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/NamesListComparator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/NamesListComparator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.xml;
+package org.richfaces.builder.xml;
import java.util.Comparator;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBody.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBody.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBody.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.xml;
+package org.richfaces.builder.xml;
import java.io.IOException;
import java.io.InputStream;
@@ -35,7 +35,7 @@
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;
-import org.ajax4jsf.builder.config.ParsingException;
+import org.richfaces.builder.config.ParsingException;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.Element;
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,130 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.ajax4jsf.builder.config.ParsingException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XMLBodyMerge implements NodeList{
-
- private String xpath;
-
- private List<Node> nodes = new ArrayList<Node>();
-
- private Document document = null;
-
- private XPathExpression keyXpath = null;
-
- private StringBuffer content = new StringBuffer();
-
- private Set<String> keys = new HashSet<String>();
-
-
-
- public XMLBodyMerge(String xpath) {
- super();
- this.xpath = xpath;
- }
-
- public XMLBodyMerge(String xpath, String keyXpath) {
- this(xpath);
- if (keyXpath != null) {
- try {
- XPath newXPath = XPathFactory.newInstance().newXPath();
- this.keyXpath = newXPath.compile(keyXpath);
- } catch (XPathExpressionException e) {
- e.printStackTrace();
- }
- }
- }
-
- public void add(Node node) {
-
- if (keyXpath != null) {
- String key = getKey(node);
- if (key == null || keys.contains(key)) {
- return;
- }
- }
-
- if (document == null) {
- document = node.getOwnerDocument();
- } else {
- node = document.importNode(node, true);
- }
- nodes.add(node);
- }
-
- public void add(XMLBody xmlBody) throws ParsingException {
-
- if (xpath != null) {
- NodeList nodeList = xmlBody.getByXpath(xpath);
- if (nodeList != null) {
- for(int i = 0; i < nodeList.getLength(); i++) {
- add(nodeList.item(i));
- }
- }
- } else {
- content.append(xmlBody.getContent());
- }
-
- }
-
- public int getLength() {
- return nodes.size();
- }
-
- public Node item(int index) {
- if (index < nodes.size()) {
- return nodes.get(index);
- }
- return null;
- }
-
-
- public void sort(Comparator<Node> comparator) {
- Collections.sort(nodes, comparator);
- }
-
- public String getContent() throws Exception{
- StringBuilder buf = new StringBuilder();
- if (content != null) {
- buf.append(content);
- }
- if (document != null) {
- buf.append(new XMLBodySerializer().serialize(this, document));
- }
-
- return buf.toString();
- }
-
- private String getKey(Node node) {
- try {
- NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
- return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
- } catch (Exception e) {
- }
- return null;
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodyMerge.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodyMerge.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,148 @@
+/**
+ * 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.builder.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.richfaces.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMerge implements NodeList{
+
+ private String xpath;
+
+ private List<Node> nodes = new ArrayList<Node>();
+
+ private Document document = null;
+
+ private XPathExpression keyXpath = null;
+
+ private StringBuffer content = new StringBuffer();
+
+ private Set<String> keys = new HashSet<String>();
+
+
+
+ public XMLBodyMerge(String xpath) {
+ super();
+ this.xpath = xpath;
+ }
+
+ public XMLBodyMerge(String xpath, String keyXpath) {
+ this(xpath);
+ if (keyXpath != null) {
+ try {
+ XPath newXPath = XPathFactory.newInstance().newXPath();
+ this.keyXpath = newXPath.compile(keyXpath);
+ } catch (XPathExpressionException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public void add(Node node) {
+
+ if (keyXpath != null) {
+ String key = getKey(node);
+ if (key == null || keys.contains(key)) {
+ return;
+ }
+ }
+
+ if (document == null) {
+ document = node.getOwnerDocument();
+ } else {
+ node = document.importNode(node, true);
+ }
+ nodes.add(node);
+ }
+
+ public void add(XMLBody xmlBody) throws ParsingException {
+
+ if (xpath != null) {
+ NodeList nodeList = xmlBody.getByXpath(xpath);
+ if (nodeList != null) {
+ for(int i = 0; i < nodeList.getLength(); i++) {
+ add(nodeList.item(i));
+ }
+ }
+ } else {
+ content.append(xmlBody.getContent());
+ }
+
+ }
+
+ public int getLength() {
+ return nodes.size();
+ }
+
+ public Node item(int index) {
+ if (index < nodes.size()) {
+ return nodes.get(index);
+ }
+ return null;
+ }
+
+
+ public void sort(Comparator<Node> comparator) {
+ Collections.sort(nodes, comparator);
+ }
+
+ public String getContent() throws Exception{
+ StringBuilder buf = new StringBuilder();
+ if (content != null) {
+ buf.append(content);
+ }
+ if (document != null) {
+ buf.append(new XMLBodySerializer().serialize(this, document));
+ }
+
+ return buf.toString();
+ }
+
+ private String getKey(Node node) {
+ try {
+ NodeList list = (NodeList) keyXpath.evaluate(node, XPathConstants.NODESET);
+ return new XMLBodySerializer().serialize(list, node.getOwnerDocument());
+ } catch (Exception e) {
+ }
+ return null;
+ }
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,60 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import java.io.StringWriter;
-
-import javax.xml.transform.ErrorListener;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.ajax4jsf.builder.config.ParsingException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.NodeList;
-
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XMLBodySerializer {
- public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
- try {
- StringWriter out;
- DocumentFragment fragment = xmlDocument.createDocumentFragment();
- for (int i = 0; i < childNodes.getLength(); i++) {
- fragment.appendChild(childNodes.item(i).cloneNode(true));
- }
- TransformerFactory transformerFactory = TransformerFactory.newInstance();
- Transformer transformer = transformerFactory.newTransformer();
- transformer.setErrorListener(new ErrorListener(){
-
- public void error(TransformerException exception)
- throws TransformerException {
- }
-
- public void fatalError(TransformerException exception)
- throws TransformerException {
- }
-
- public void warning(TransformerException exception)
- throws TransformerException {
- }
-
- });
- transformer.setOutputProperty("indent", "yes");
- transformer.setOutputProperty("omit-xml-declaration", "yes");
- out = new StringWriter();
- StreamResult result = new StreamResult(out);
- transformer.transform(new DOMSource(fragment), result);
- return out.toString();
- } catch (Exception e) {
- throw new ParsingException(e);
- }
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XMLBodySerializer.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XMLBodySerializer.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,78 @@
+/**
+ * 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.builder.xml;
+
+import java.io.StringWriter;
+
+import javax.xml.transform.ErrorListener;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.richfaces.builder.config.ParsingException;
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.NodeList;
+
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializer {
+ public String serialize(NodeList childNodes, Document xmlDocument) throws ParsingException {
+ try {
+ StringWriter out;
+ DocumentFragment fragment = xmlDocument.createDocumentFragment();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ fragment.appendChild(childNodes.item(i).cloneNode(true));
+ }
+ TransformerFactory transformerFactory = TransformerFactory.newInstance();
+ Transformer transformer = transformerFactory.newTransformer();
+ transformer.setErrorListener(new ErrorListener(){
+
+ public void error(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void fatalError(TransformerException exception)
+ throws TransformerException {
+ }
+
+ public void warning(TransformerException exception)
+ throws TransformerException {
+ }
+
+ });
+ transformer.setOutputProperty("indent", "yes");
+ transformer.setOutputProperty("omit-xml-declaration", "yes");
+ out = new StringWriter();
+ StreamResult result = new StreamResult(out);
+ transformer.transform(new DOMSource(fragment), result);
+ return out.toString();
+ } catch (Exception e) {
+ throw new ParsingException(e);
+ }
+ }
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,79 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import java.util.Comparator;
-
-import javax.xml.xpath.XPathExpression;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.w3c.dom.Node;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XPathComparator implements Comparator<Node> {
-
- class XPathCompatorCriterion {
- private XPathExpression expression = null;
-
- public XPathCompatorCriterion(String xPath){
- try {
- expression = XPathFactory.newInstance().newXPath().compile(xPath);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- public String getValue(Object node) throws XPathExpressionException {
- return expression == null ? null : expression.evaluate(node);
- }
- }
-
- private XPathCompatorCriterion [] criteria;
-
- public XPathComparator(String ... criteria) {
- this.criteria = new XPathCompatorCriterion[criteria.length];
- for(int i = 0; i < criteria.length; i++) {
- this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
- }
- }
-
- public int compare(Node o1, Node o2) {
- int result = 0;
-
- for(int i = 0; i < criteria.length && result == 0; i++) {
- String s1 = null;
- String s2 = null;
- try {
- s1 = this.criteria[i].getValue(o1);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- try {
- s2 = this.criteria[i].getValue(o2);
- } catch (XPathExpressionException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- if (s1 != null) {
- if (s2 != null) {
- result = s1.compareTo(s2);
- } else {
- result = 1;
- }
- } else if (s2 != null) {
- result = -1;
- }
- }
-
- return result;
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/builder/xml/XPathComparator.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/builder/xml/XPathComparator.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,97 @@
+/**
+ * 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.builder.xml;
+
+import java.util.Comparator;
+
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.w3c.dom.Node;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparator implements Comparator<Node> {
+
+ class XPathCompatorCriterion {
+ private XPathExpression expression = null;
+
+ public XPathCompatorCriterion(String xPath){
+ try {
+ expression = XPathFactory.newInstance().newXPath().compile(xPath);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public String getValue(Object node) throws XPathExpressionException {
+ return expression == null ? null : expression.evaluate(node);
+ }
+ }
+
+ private XPathCompatorCriterion [] criteria;
+
+ public XPathComparator(String ... criteria) {
+ this.criteria = new XPathCompatorCriterion[criteria.length];
+ for(int i = 0; i < criteria.length; i++) {
+ this.criteria[i] = new XPathCompatorCriterion(criteria[i]);
+ }
+ }
+
+ public int compare(Node o1, Node o2) {
+ int result = 0;
+
+ for(int i = 0; i < criteria.length && result == 0; i++) {
+ String s1 = null;
+ String s2 = null;
+ try {
+ s1 = this.criteria[i].getValue(o1);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ try {
+ s2 = this.criteria[i].getValue(o2);
+ } catch (XPathExpressionException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ if (s1 != null) {
+ if (s2 != null) {
+ result = s1.compareTo(s2);
+ } else {
+ result = 1;
+ }
+ } else if (s2 != null) {
+ result = -1;
+ }
+ }
+
+ return result;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/ant)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/AntCompilationContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/ant/AntCompilationContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/AntCompilationContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.ant;
+package org.richfaces.templatecompiler.ant;
-import org.ajax4jsf.templatecompiler.builder.AbstractCompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
import org.apache.tools.ant.Project;
import org.apache.velocity.Template;
+import org.richfaces.templatecompiler.builder.AbstractCompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
/**
* @author shura
@@ -50,63 +50,63 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String)
*/
public void debug(String content) {
project.log(content, Project.MSG_DEBUG);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String, java.lang.Throwable)
*/
public void debug(String content, Throwable error) {
project.log(content, Project.MSG_DEBUG);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String)
*/
public void error(String content) {
project.log(content, Project.MSG_ERR);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String, java.lang.Throwable)
*/
public void error(String content, Throwable error) {
project.log(content, Project.MSG_ERR);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String)
*/
public void info(String content) {
project.log(content, Project.MSG_INFO);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String, java.lang.Throwable)
*/
public void info(String content, Throwable error) {
project.log(content, Project.MSG_INFO);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String)
*/
public void warn(String content) {
project.log(content, Project.MSG_WARN);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String, java.lang.Throwable)
*/
public void warn(String content, Throwable error) {
project.log(content, Project.MSG_INFO);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
*/
public Template getTemplate(String name) throws CompilationException {
return task.getTemplate(name);
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/TemplateCompilerTask.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/ant/TemplateCompilerTask.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/ant/TemplateCompilerTask.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.ant;
+package org.richfaces.templatecompiler.ant;
import java.io.BufferedWriter;
import java.io.File;
@@ -38,9 +38,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.TemplateCompiler;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.Task;
@@ -51,6 +48,9 @@
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.TemplateCompiler;
/**
* Task template compiler.
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/AbstractCompilationContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/AbstractCompilationContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/AbstractCompilationContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
import java.beans.PropertyDescriptor;
import java.io.StringWriter;
@@ -33,12 +33,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.ajax4jsf.builder.config.ClassVisitor;
-import org.ajax4jsf.builder.config.ClassWalkingLogic;
-import org.ajax4jsf.builder.model.JavaPrimitive;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.ElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
import org.apache.commons.beanutils.MethodUtils;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
@@ -46,6 +40,12 @@
import org.apache.velocity.VelocityContext;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.richfaces.builder.config.ClassVisitor;
+import org.richfaces.builder.config.ClassWalkingLogic;
+import org.richfaces.builder.model.JavaPrimitive;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.ElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElement;
import org.w3c.dom.Node;
/**
@@ -66,7 +66,7 @@
final private static Pattern patternComponent = Pattern.compile(
regexComponent, Pattern.UNIX_LINES + Pattern.DOTALL);
- private final static String DEFAULT_BASE_CLASS = "org.ajax4jsf.renderkit.RendererBase";
+ private final static String DEFAULT_BASE_CLASS = "org.richfaces.renderkit.RendererBase";
private String packageName;
@@ -95,8 +95,8 @@
"java.io.IOException", "javax.faces.component.UIComponent",
"javax.faces.context.FacesContext",
"javax.faces.context.ResponseWriter",
- "org.ajax4jsf.renderkit.ComponentsVariableResolver",
- "org.ajax4jsf.renderkit.ComponentVariables" };
+ "org.richfaces.renderkit.ComponentsVariableResolver",
+ "org.richfaces.renderkit.ComponentVariables" };
private TemplateElement tree;
@@ -369,7 +369,7 @@
addVariable("writer", "javax.faces.context.ResponseWriter");
// addLocalVariable("component", "javax.faces.component.UIComponent" );
addVariable("variables",
- "org.ajax4jsf.renderkit.ComponentVariables");
+ "org.richfaces.renderkit.ComponentVariables");
}
public Class<?> getMethodReturnedClass(Class<?> clazz, String methodName,
@@ -492,7 +492,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#getProcessor(org.w3c.dom.Node)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#getProcessor(org.w3c.dom.Node)
*/
public TemplateElement getProcessor(Node nodeElement) throws CompilationException {
for (Iterator<ElementsFactory> iter = elementFactories.listIterator(); iter.hasNext();) {
@@ -506,7 +506,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#processTemplate(java.lang.String, org.apache.velocity.VelocityContext)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#processTemplate(java.lang.String, org.apache.velocity.VelocityContext)
*/
public String processTemplate(String name, VelocityContext context) throws CompilationException {
StringWriter out = new StringWriter();
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
import java.beans.PropertyDescriptor;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.elements.TemplateElement;
import org.w3c.dom.Node;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationException.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/CompilationException.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/CompilationException.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
/**
* @author shura
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/StringUtils.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/StringUtils.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/StringUtils.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
/**
* String utilites.
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/TemplateCompiler.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/TemplateCompiler.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/TemplateCompiler.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
import java.io.IOException;
import java.io.InputStream;
@@ -29,7 +29,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import org.ajax4jsf.templatecompiler.elements.TemplateElement;
+import org.richfaces.templatecompiler.elements.TemplateElement;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/Variable.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/builder/Variable.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/builder/Variable.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.builder;
+package org.richfaces.templatecompiler.builder;
/**
* Interface for local and global variable references in EL expressions.
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/CompiledEL.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/CompiledEL.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/CompiledEL.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.el;
+package org.richfaces.templatecompiler.el;
import java.util.ArrayList;
import java.util.Iterator;
@@ -59,7 +59,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.el.ICompiledEL#getJavaCode()
+ * @see org.richfaces.templatecompiler.el.ICompiledEL#getJavaCode()
*/
public String getJavaCode() {
int i = 0;
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,717 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.el;
-
-import java.beans.PropertyDescriptor;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.el.PropertyNotFoundException;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import com.sun.el.parser.ArithmeticNode;
-import com.sun.el.parser.AstAnd;
-import com.sun.el.parser.AstBracketSuffix;
-import com.sun.el.parser.AstChoice;
-import com.sun.el.parser.AstDeferredExpression;
-import com.sun.el.parser.AstDiv;
-import com.sun.el.parser.AstDotSuffix;
-import com.sun.el.parser.AstEmpty;
-import com.sun.el.parser.AstEqual;
-import com.sun.el.parser.AstFalse;
-import com.sun.el.parser.AstFunction;
-import com.sun.el.parser.AstGreaterThan;
-import com.sun.el.parser.AstGreaterThanEqual;
-import com.sun.el.parser.AstIdentifier;
-import com.sun.el.parser.AstInteger;
-import com.sun.el.parser.AstLessThan;
-import com.sun.el.parser.AstLessThanEqual;
-import com.sun.el.parser.AstLiteralExpression;
-import com.sun.el.parser.AstMinus;
-import com.sun.el.parser.AstMod;
-import com.sun.el.parser.AstMult;
-import com.sun.el.parser.AstNot;
-import com.sun.el.parser.AstNotEqual;
-import com.sun.el.parser.AstOr;
-import com.sun.el.parser.AstPlus;
-import com.sun.el.parser.AstString;
-import com.sun.el.parser.AstTrue;
-import com.sun.el.parser.AstValue;
-import com.sun.el.parser.BooleanNode;
-import com.sun.el.parser.ELParser;
-import com.sun.el.parser.Node;
-
-/**
- * Compiler EL-expressions.
- *
- * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
- * @version $Revision: 1.1.2.2 $ $Date: 2007/02/21 17:17:12 $
- *
- */
-public class ELCompiler implements IELCompiler {
-
- private static final Log log = LogFactory.getLog(ELCompiler.class);
-
- Map<String, String> functionsMap = new HashMap<String,String>();
-
- static {
- }
-
- /**
- *
- */
- public ELCompiler() {
- super();
- resetVariables();
- }
-
- /**
- *
- */
- public void resetVariables() {
- // maps.put("context", "javax.faces.context.FacesContext" );
- // maps.put("component", "javax.faces.component.UIComponent" );
- // maps.put("a4jSkin", "org.ajax4jsf.framework.skin.Skin" );
-
- this.functionsMap.put("a4jSkin:getParameter",
- "org.ajax4jsf.framework.skin.getParameter");
- }
-
- public String compileEL(String expression, CompilationContext componentBean) {
- Node node = ELParser.parse(expression);
- StringBuffer sbMain = new StringBuffer();
- processNode(node, sbMain, componentBean);
- return sbMain.toString();
- }
-
- /**
- * Processing node
- *
- * @param node
- * @param sbMain
- * @param componentBean
- */
- private void processNode(Node node, StringBuffer sbMain,
- CompilationContext componentBean) {
- int numChildren = node.jjtGetNumChildren();
-
- boolean bNeedConversion = false;
- for (int i = 0; i < numChildren; i++) {
- Node childNode = node.jjtGetChild(i);
- if (childNode instanceof AstLiteralExpression) {
- bNeedConversion = true;
- break;
- }
- }
-
- for (int i = 0; i < numChildren; i++) {
- Node childNode = node.jjtGetChild(i);
-
- if (childNode instanceof AstLiteralExpression) {
- if (childNode.getImage() != null) {
- if (i > 0) {
- sbMain.append(" + ");
- }
- sbMain.append("\"");
- sbMain.append(StringUtils.getEscapedString(childNode
- .getImage()));
- sbMain.append("\"");
-
- if (i < (numChildren - 1)) {
- sbMain.append(" + ");
- }
- }
- } else {
- if (bNeedConversion) {
- sbMain.append("convertToString(");
- }
- boolean processing = processingNode(childNode, sbMain,
- componentBean);
- if (!processing) {
- processNode(childNode, sbMain, componentBean);
- }
- if (bNeedConversion) {
- sbMain.append(")");
- }
- }
-
- }
- }
-
- /**
- *
- * @param node
- * @param sbMain
- * @param componentBean
- * @param cMain
- * @return
- */
- public boolean processingNode(Node node, StringBuffer sbMain,
- CompilationContext componentBean) {
- boolean returnValue = false;
- if (node instanceof ArithmeticNode) {
- returnValue = processingArithmeticNode((ArithmeticNode) node,
- sbMain, componentBean);
- } else if (node instanceof AstIdentifier) {
- returnValue = processingIdentifier((AstIdentifier) node, sbMain,
- componentBean);
- } else if (node instanceof AstValue) {
- returnValue = processingValue((AstValue) node, sbMain,
- componentBean);
- } else if (node instanceof AstInteger) {
- returnValue = processingInteger((AstInteger) node, sbMain);
- } else if (node instanceof AstString) {
- returnValue = processingString((AstString) node, sbMain);
- } else if (node instanceof AstFunction) {
- returnValue = processingFunction((AstFunction) node, sbMain,
- componentBean);
- } else if (node instanceof AstDeferredExpression) {
-
- } else if (node instanceof BooleanNode) {
- returnValue = processingBooleanNode((BooleanNode) node,
- sbMain, componentBean);
- } else if (node instanceof AstNot) {
- returnValue = processingNot((AstNot) node,
- sbMain, componentBean);
- } else if (node instanceof AstChoice) {
- returnValue = processingChoice((AstChoice) node,
- sbMain, componentBean);
- } else if (node instanceof AstEmpty) {
- returnValue = processingEmpty((AstEmpty) node,
- sbMain, componentBean);
- } else {
- StringBuffer sb = new StringBuffer();
- sb.append(node.toString());
- sb.append(" (");
- sb.append(node.getClass().getName());
- sb.append(")");
- log.debug(sb.toString());
- }
-
- return returnValue;
- }
-
- /**
- * Processing 'empty' node
- *
- * @param node
- * @param sb
- * @param cMain
- * @return
- */
- private boolean processingEmpty(AstEmpty node, StringBuffer sbMain,
- CompilationContext componentBean) {
- boolean returnValue = false;
- StringBuffer sb1 = new StringBuffer();
-
- Node node1 = node.jjtGetChild(0);
-
- if (null != node1) {
- if (!(returnValue = processingNode(node1, sb1,
- componentBean))) {
- log.error("Error processing node1: "
- + node1.getImage());
- }
- }
-
- if (returnValue) {
- sbMain.append(" isEmpty( ");
- sbMain.append(sb1);
- sbMain.append(" ) ");
- }
-
- return returnValue;
- }
-
- /**
- * Processing 'choice' node
- *
- * @param node
- * @param sb
- * @param cMain
- * @return
- */
- private boolean processingChoice(AstChoice node, StringBuffer sbMain,
- CompilationContext componentBean) {
- boolean returnValue = true;
-
- StringBuffer sb1 = new StringBuffer();
- StringBuffer sb2 = new StringBuffer();
- StringBuffer sb3 = new StringBuffer();
-
- Node node1 = node.jjtGetChild(0);
-
- if (node1 != null) {
- if (!(returnValue &= processingNode(node1, sb1,
- componentBean))) {
- log.error("Error processing node1: "
- + node1.getImage());
- }
- }
-
- Node node2 = node.jjtGetChild(1);
-
- if (null != node2) {
- if (!(returnValue &= processingNode(node2, sb2,
- componentBean))) {
- log.error("Error processing node2: "
- + node2.getImage());
- }
- }
-
- Node node3 = node.jjtGetChild(2);
-
- if (null != node3) {
- if (!(returnValue &= processingNode(node3, sb3,
- componentBean))) {
- log.error("Error processing node3: "
- + node3.getImage());
- }
- }
-
- if (returnValue) {
- sbMain.append(" ( ");
- sbMain.append(sb1);
- sbMain.append(" ? ");
- sbMain.append(sb2);
- sbMain.append(" : ");
- sbMain.append(sb3);
- sbMain.append(" ) ");
- }
-
- return returnValue;
- }
-
- /**
- * Processing node containing 'not' expression
- *
- * @param node
- * @param sb
- * @param cMain
- * @return
- */
- private boolean processingNot(AstNot node, StringBuffer sbMain,
- CompilationContext componentBean) {
- boolean returnValue = false;
- StringBuffer sb1 = new StringBuffer();
-
- Node node1 = node.jjtGetChild(0);
-
- if (null != node1) {
- if (!(returnValue = processingNode(node1, sb1,
- componentBean))) {
- log.error("Error processing node1: "
- + node1.getImage());
- }
- }
-
- if (returnValue) {
- sbMain.append(" ( ! ");
- sbMain.append(sb1);
- sbMain.append(" ) ");
- }
-
- return returnValue;
- }
-
- /**
- * Processing boolean node
- *
- * @param node
- * @param sb
- * @param cMain
- * @return
- */
- private boolean processingBooleanNode(BooleanNode node,
- StringBuffer sb, CompilationContext componentBean) {
- boolean returnValue = true;
-
- StringBuffer sb1 = new StringBuffer();
- StringBuffer sb2 = new StringBuffer();
-
- if (node instanceof AstFalse) {
- sb.append(" false ");
- return returnValue;
- }
- if (node instanceof AstTrue) {
- sb.append(" true ");
- return returnValue;
- }
-
- Node node1 = node.jjtGetChild(0);
-
- if (node1 != null) {
- if (!(returnValue &= processingNode(node1, sb1,
- componentBean))) {
- log.error("Error processing node1: "
- + node1.getImage());
- }
- }
-
- Node node2 = node.jjtGetChild(1);
-
- if (null != node2) {
- if (!(returnValue &= processingNode(node2, sb2,
- componentBean))) {
- log.error("Error processing node2: "
- + node2.getImage());
- }
- }
-
- if (returnValue) {
- sb.append(" ( ");
- sb.append(sb1);
-
- if (node instanceof AstAnd) {
- sb.append(" && ");
- } else if (node instanceof AstEqual) {
- sb.append(" == ");
- } else if (node instanceof AstGreaterThan) {
- sb.append(" > ");
- } else if (node instanceof AstGreaterThanEqual) {
- sb.append(" >= ");
- } else if (node instanceof AstLessThan) {
- sb.append(" < ");
- } else if (node instanceof AstLessThanEqual) {
- sb.append(" <= ");
- } else if (node instanceof AstNotEqual) {
- sb.append(" != ");
- } else if (node instanceof AstOr) {
- sb.append(" || ");
- }
- sb.append(sb2);
- sb.append(" ) ");
- }
-
- return returnValue;
- }
-
-
- /**
- * Processing arithmetic node
- *
- * @param node
- * @param sb
- * @param cMain
- * @return
- */
- private boolean processingArithmeticNode(ArithmeticNode node,
- StringBuffer sb, CompilationContext componentBean) {
- StringBuffer sb1 = new StringBuffer();
- StringBuffer sb2 = new StringBuffer();
-
- boolean returnValue = true;
-
- Node node1 = node.jjtGetChild(0);
-
- if (node1 != null) {
- if (!(returnValue &= processingNode(node1, sb1,
- componentBean))) {
- log.error("Error processing node1: "
- + node1.getImage());
- }
- }
-
- Node node2 = node.jjtGetChild(1);
-
- if (null != node2) {
- if (!(returnValue &= processingNode(node2, sb2,
- componentBean))) {
- log.error("Error processing node2: "
- + node2.getImage());
- }
- }
-
- if (returnValue) {
- sb.append(" ( ");
- sb.append(sb1);
-
- if (node instanceof AstDiv) {
- sb.append(" / ");
- } else if (node instanceof AstMult) {
- sb.append(" * ");
- } else if (node instanceof AstMod) {
- sb.append(" % ");
- } else if (node instanceof AstPlus) {
- sb.append(" + ");
- } else if (node instanceof AstMinus) {
- sb.append(" - ");
- }
-
- sb.append(sb2);
- sb.append(" ) ");
- }
- return returnValue;
- }
-
- /**
- * Processing node contain integer
- *
- * @param node
- * @param sb
- * @return
- */
- private boolean processingInteger(AstInteger node, StringBuffer sb) {
- sb.append(node.getImage());
- return true;
- }
-
- /**
- * Processing node contain string
- *
- * @param node
- * @param sb
- * @return
- */
- private boolean processingString(AstString node, StringBuffer sb) {
- sb.append("\"");
- sb.append(node.getString());
- sb.append("\"");
- return true;
- }
-
- /**
- *
- * @param node
- * @param sb
- * @return
- */
- private boolean processingFunction(AstFunction node, StringBuffer sb,
- CompilationContext componentBean) {
-
- log.debug("Processing function : " + node.getPrefix());
- log.debug("Processing function : " + node.getLocalName());
- log.debug("Processing function : " + node.getOutputName());
-
- if (node.getPrefix().equals("this")) {
- sb.append(node.getLocalName());
- sb.append("(");
- int numChildren = node.jjtGetNumChildren();
- for (int i = 0; i < numChildren; i++) {
- Node childNode = node.jjtGetChild(i);
- StringBuffer buf = new StringBuffer();
- processingNode(childNode, buf, componentBean);
- if (i != 0) {
- sb.append(",");
- }
- sb.append(buf);
- }
- sb.append(")");
- } else {
- String functionName = node.getOutputName();
- if (this.functionsMap.containsKey(functionName)) {
- sb.append(this.functionsMap.get(functionName));
- sb.append("(");
- int numChildren = node.jjtGetNumChildren();
- for (int i = 0; i < numChildren; i++) {
- Node childNode = node.jjtGetChild(i);
- StringBuffer buf = new StringBuffer();
- processingNode(childNode, buf, componentBean);
- if (i != 0) {
- sb.append(",");
- }
- sb.append(buf);
- }
- sb.append(")");
- } // if
- } // else
- return true;
- }
-
- /**
- *
- * @param node
- * @param sb
- * @return
- */
- private boolean processingIdentifier(AstIdentifier node, StringBuffer sb,
- CompilationContext componentBean) {
- String variableName = node.getImage();
- if (componentBean.containsVariable(variableName)) {
- sb.append(variableName);
- } else {
- sb.append("variables.getVariable(\"");
- sb.append(variableName);
- sb.append("\")");
- }
-
- return true;
- }
-
- /**
- *
- * @param basketSuffix
- * @return
- */
- private String processingBracketSuffix(AstBracketSuffix basketSuffix,
- CompilationContext componentBean) {
- StringBuffer sb = new StringBuffer();
- Node node = basketSuffix.jjtGetChild(0);
- if (node instanceof AstIdentifier) {
- processingIdentifier((AstIdentifier) node, sb, componentBean);
- } else if (node instanceof AstInteger) {
- // sb.append("new Integer(");
- sb.append(node.getImage());
- // sb.append(")");
- } else if (node instanceof AstString) {
- AstString stringNode = (AstString) node;
- sb.append("\"");
- sb.append(stringNode.getString());
- sb.append("\"");
- } else {
- sb.append("\"");
- sb.append(node.getImage());
- sb.append("\"");
- }
- return sb.toString();
- }
-
- /**
- *
- * @param clazz
- * @param propertyName
- * @return
- */
- private PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
- String propertyName, CompilationContext compilationContext) {
- return compilationContext.getPropertyDescriptor(clazz, propertyName);
- }
-
- private boolean processingValue(AstValue node, StringBuffer sb,
- CompilationContext componentBean) {
- String lastIndexValue = "null";
- String lastVariableType = null;
- List<String> names = new ArrayList<String>();
-
- for (int i = 0; i < node.jjtGetNumChildren(); i++) {
- StringBuffer sb1 = new StringBuffer();
- Node subChild = node.jjtGetChild(i);
-
- if (subChild instanceof AstIdentifier) {
- String variableName = subChild.getImage();
- if (componentBean.containsVariable(variableName)) {
- lastVariableType = componentBean.getVariableType(
- variableName).getName();
- names.add(variableName);
- } else {
- processingIdentifier((AstIdentifier) subChild, sb1,
- componentBean);
- }
- } else if (subChild instanceof AstDotSuffix) {
- String propertyName = subChild.getImage();
- log.debug("Object: " + lastVariableType
- + ", property: " + propertyName);
-
- if (lastVariableType != null) {
- try {
-
- Class<?> clazz = componentBean.loadClass(lastVariableType);
-
- PropertyDescriptor propertyDescriptor = getPropertyDescriptor(
- clazz, propertyName, componentBean);
-
- if (propertyDescriptor == null) {
- throw new PropertyNotFoundException("property: "
- + propertyName + " not found in class: "
- + lastVariableType);
- }
-
- log.debug("propertyObject: "
- + propertyDescriptor.getPropertyType()
- .getName());
- StringBuffer tmpbuf = new StringBuffer();
- tmpbuf.append(propertyDescriptor.getReadMethod()
- .getName());
- tmpbuf.append("()");
- names.add(tmpbuf.toString());
-
- lastVariableType = propertyDescriptor.getPropertyType()
- .getName();
- } catch (ClassNotFoundException e) {
- log.error(e.getLocalizedMessage(), e);
- }
-
- } else {
-
- sb1.append("getProperty(");
- sb1.append(lastIndexValue);
- sb1.append(",");
- sb1.append("\"");
- sb1.append(subChild.getImage());
- sb1.append("\")");
- }
- } else if (subChild instanceof AstBracketSuffix) {
- String bracketSuffix = processingBracketSuffix(
- (AstBracketSuffix) subChild, componentBean);
-
- if (lastVariableType != null) {
- StringBuffer tmpbuf = new StringBuffer();
- if (lastVariableType.startsWith("[L")) {
- tmpbuf.append("[");
- tmpbuf.append(bracketSuffix);
- tmpbuf.append("]");
- names.add(tmpbuf.toString());
- }
-
- if ((lastVariableType.compareTo("java.util.List") == 0)
- || (lastVariableType.compareTo("java.util.Map") == 0)) {
- tmpbuf.append("get(");
- tmpbuf.append(bracketSuffix);
- tmpbuf.append(")");
- names.add(tmpbuf.toString());
- }
- } else {
-
- sb1.append("getElelmentByIndex(");
- sb1.append(lastIndexValue);
- sb1.append(",");
- sb1.append(bracketSuffix);
- sb1.append(")");
- }
-
- }
-
- }
-
- if (names.size() != 0) {
- StringBuffer tmpbuf = new StringBuffer();
- for (String element : names) {
- if (tmpbuf.length() != 0) {
- tmpbuf.append(".");
- }
- tmpbuf.append(element);
- }
- sb.append(tmpbuf.toString());
- } else {
- sb.append(lastIndexValue);
- }
-
- return true;
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELCompiler.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELCompiler.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,725 @@
+/**
+ * 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.templatecompiler.el;
+
+import java.beans.PropertyDescriptor;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.el.PropertyNotFoundException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.StringUtils;
+
+import com.sun.el.parser.ArithmeticNode;
+import com.sun.el.parser.AstAnd;
+import com.sun.el.parser.AstBracketSuffix;
+import com.sun.el.parser.AstChoice;
+import com.sun.el.parser.AstDeferredExpression;
+import com.sun.el.parser.AstDiv;
+import com.sun.el.parser.AstDotSuffix;
+import com.sun.el.parser.AstEmpty;
+import com.sun.el.parser.AstEqual;
+import com.sun.el.parser.AstFalse;
+import com.sun.el.parser.AstFunction;
+import com.sun.el.parser.AstGreaterThan;
+import com.sun.el.parser.AstGreaterThanEqual;
+import com.sun.el.parser.AstIdentifier;
+import com.sun.el.parser.AstInteger;
+import com.sun.el.parser.AstLessThan;
+import com.sun.el.parser.AstLessThanEqual;
+import com.sun.el.parser.AstLiteralExpression;
+import com.sun.el.parser.AstMinus;
+import com.sun.el.parser.AstMod;
+import com.sun.el.parser.AstMult;
+import com.sun.el.parser.AstNot;
+import com.sun.el.parser.AstNotEqual;
+import com.sun.el.parser.AstOr;
+import com.sun.el.parser.AstPlus;
+import com.sun.el.parser.AstString;
+import com.sun.el.parser.AstTrue;
+import com.sun.el.parser.AstValue;
+import com.sun.el.parser.BooleanNode;
+import com.sun.el.parser.ELParser;
+import com.sun.el.parser.Node;
+
+/**
+ * Compiler EL-expressions.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/21 17:17:12 $
+ *
+ */
+public class ELCompiler implements IELCompiler {
+
+ private static final Log log = LogFactory.getLog(ELCompiler.class);
+
+ Map<String, String> functionsMap = new HashMap<String,String>();
+
+ static {
+ }
+
+ /**
+ *
+ */
+ public ELCompiler() {
+ super();
+ resetVariables();
+ }
+
+ /**
+ *
+ */
+ public void resetVariables() {
+ // maps.put("context", "javax.faces.context.FacesContext" );
+ // maps.put("component", "javax.faces.component.UIComponent" );
+ // maps.put("a4jSkin", "org.richfaces.framework.skin.Skin" );
+
+ this.functionsMap.put("a4jSkin:getParameter",
+ "org.richfaces.framework.skin.getParameter");
+ }
+
+ public String compileEL(String expression, CompilationContext componentBean) {
+ Node node = ELParser.parse(expression);
+ StringBuffer sbMain = new StringBuffer();
+ processNode(node, sbMain, componentBean);
+ return sbMain.toString();
+ }
+
+ /**
+ * Processing node
+ *
+ * @param node
+ * @param sbMain
+ * @param componentBean
+ */
+ private void processNode(Node node, StringBuffer sbMain,
+ CompilationContext componentBean) {
+ int numChildren = node.jjtGetNumChildren();
+
+ boolean bNeedConversion = false;
+ for (int i = 0; i < numChildren; i++) {
+ Node childNode = node.jjtGetChild(i);
+ if (childNode instanceof AstLiteralExpression) {
+ bNeedConversion = true;
+ break;
+ }
+ }
+
+ for (int i = 0; i < numChildren; i++) {
+ Node childNode = node.jjtGetChild(i);
+
+ if (childNode instanceof AstLiteralExpression) {
+ if (childNode.getImage() != null) {
+ if (i > 0) {
+ sbMain.append(" + ");
+ }
+ sbMain.append("\"");
+ sbMain.append(StringUtils.getEscapedString(childNode
+ .getImage()));
+ sbMain.append("\"");
+
+ if (i < (numChildren - 1)) {
+ sbMain.append(" + ");
+ }
+ }
+ } else {
+ if (bNeedConversion) {
+ sbMain.append("convertToString(");
+ }
+ boolean processing = processingNode(childNode, sbMain,
+ componentBean);
+ if (!processing) {
+ processNode(childNode, sbMain, componentBean);
+ }
+ if (bNeedConversion) {
+ sbMain.append(")");
+ }
+ }
+
+ }
+ }
+
+ /**
+ *
+ * @param node
+ * @param sbMain
+ * @param componentBean
+ * @param cMain
+ * @return
+ */
+ public boolean processingNode(Node node, StringBuffer sbMain,
+ CompilationContext componentBean) {
+ boolean returnValue = false;
+ if (node instanceof ArithmeticNode) {
+ returnValue = processingArithmeticNode((ArithmeticNode) node,
+ sbMain, componentBean);
+ } else if (node instanceof AstIdentifier) {
+ returnValue = processingIdentifier((AstIdentifier) node, sbMain,
+ componentBean);
+ } else if (node instanceof AstValue) {
+ returnValue = processingValue((AstValue) node, sbMain,
+ componentBean);
+ } else if (node instanceof AstInteger) {
+ returnValue = processingInteger((AstInteger) node, sbMain);
+ } else if (node instanceof AstString) {
+ returnValue = processingString((AstString) node, sbMain);
+ } else if (node instanceof AstFunction) {
+ returnValue = processingFunction((AstFunction) node, sbMain,
+ componentBean);
+ } else if (node instanceof AstDeferredExpression) {
+
+ } else if (node instanceof BooleanNode) {
+ returnValue = processingBooleanNode((BooleanNode) node,
+ sbMain, componentBean);
+ } else if (node instanceof AstNot) {
+ returnValue = processingNot((AstNot) node,
+ sbMain, componentBean);
+ } else if (node instanceof AstChoice) {
+ returnValue = processingChoice((AstChoice) node,
+ sbMain, componentBean);
+ } else if (node instanceof AstEmpty) {
+ returnValue = processingEmpty((AstEmpty) node,
+ sbMain, componentBean);
+ } else {
+ StringBuffer sb = new StringBuffer();
+ sb.append(node.toString());
+ sb.append(" (");
+ sb.append(node.getClass().getName());
+ sb.append(")");
+ log.debug(sb.toString());
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Processing 'empty' node
+ *
+ * @param node
+ * @param sb
+ * @param cMain
+ * @return
+ */
+ private boolean processingEmpty(AstEmpty node, StringBuffer sbMain,
+ CompilationContext componentBean) {
+ boolean returnValue = false;
+ StringBuffer sb1 = new StringBuffer();
+
+ Node node1 = node.jjtGetChild(0);
+
+ if (null != node1) {
+ if (!(returnValue = processingNode(node1, sb1,
+ componentBean))) {
+ log.error("Error processing node1: "
+ + node1.getImage());
+ }
+ }
+
+ if (returnValue) {
+ sbMain.append(" isEmpty( ");
+ sbMain.append(sb1);
+ sbMain.append(" ) ");
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Processing 'choice' node
+ *
+ * @param node
+ * @param sb
+ * @param cMain
+ * @return
+ */
+ private boolean processingChoice(AstChoice node, StringBuffer sbMain,
+ CompilationContext componentBean) {
+ boolean returnValue = true;
+
+ StringBuffer sb1 = new StringBuffer();
+ StringBuffer sb2 = new StringBuffer();
+ StringBuffer sb3 = new StringBuffer();
+
+ Node node1 = node.jjtGetChild(0);
+
+ if (node1 != null) {
+ if (!(returnValue &= processingNode(node1, sb1,
+ componentBean))) {
+ log.error("Error processing node1: "
+ + node1.getImage());
+ }
+ }
+
+ Node node2 = node.jjtGetChild(1);
+
+ if (null != node2) {
+ if (!(returnValue &= processingNode(node2, sb2,
+ componentBean))) {
+ log.error("Error processing node2: "
+ + node2.getImage());
+ }
+ }
+
+ Node node3 = node.jjtGetChild(2);
+
+ if (null != node3) {
+ if (!(returnValue &= processingNode(node3, sb3,
+ componentBean))) {
+ log.error("Error processing node3: "
+ + node3.getImage());
+ }
+ }
+
+ if (returnValue) {
+ sbMain.append(" ( ");
+ sbMain.append(sb1);
+ sbMain.append(" ? ");
+ sbMain.append(sb2);
+ sbMain.append(" : ");
+ sbMain.append(sb3);
+ sbMain.append(" ) ");
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Processing node containing 'not' expression
+ *
+ * @param node
+ * @param sb
+ * @param cMain
+ * @return
+ */
+ private boolean processingNot(AstNot node, StringBuffer sbMain,
+ CompilationContext componentBean) {
+ boolean returnValue = false;
+ StringBuffer sb1 = new StringBuffer();
+
+ Node node1 = node.jjtGetChild(0);
+
+ if (null != node1) {
+ if (!(returnValue = processingNode(node1, sb1,
+ componentBean))) {
+ log.error("Error processing node1: "
+ + node1.getImage());
+ }
+ }
+
+ if (returnValue) {
+ sbMain.append(" ( ! ");
+ sbMain.append(sb1);
+ sbMain.append(" ) ");
+ }
+
+ return returnValue;
+ }
+
+ /**
+ * Processing boolean node
+ *
+ * @param node
+ * @param sb
+ * @param cMain
+ * @return
+ */
+ private boolean processingBooleanNode(BooleanNode node,
+ StringBuffer sb, CompilationContext componentBean) {
+ boolean returnValue = true;
+
+ StringBuffer sb1 = new StringBuffer();
+ StringBuffer sb2 = new StringBuffer();
+
+ if (node instanceof AstFalse) {
+ sb.append(" false ");
+ return returnValue;
+ }
+ if (node instanceof AstTrue) {
+ sb.append(" true ");
+ return returnValue;
+ }
+
+ Node node1 = node.jjtGetChild(0);
+
+ if (node1 != null) {
+ if (!(returnValue &= processingNode(node1, sb1,
+ componentBean))) {
+ log.error("Error processing node1: "
+ + node1.getImage());
+ }
+ }
+
+ Node node2 = node.jjtGetChild(1);
+
+ if (null != node2) {
+ if (!(returnValue &= processingNode(node2, sb2,
+ componentBean))) {
+ log.error("Error processing node2: "
+ + node2.getImage());
+ }
+ }
+
+ if (returnValue) {
+ sb.append(" ( ");
+ sb.append(sb1);
+
+ if (node instanceof AstAnd) {
+ sb.append(" && ");
+ } else if (node instanceof AstEqual) {
+ sb.append(" == ");
+ } else if (node instanceof AstGreaterThan) {
+ sb.append(" > ");
+ } else if (node instanceof AstGreaterThanEqual) {
+ sb.append(" >= ");
+ } else if (node instanceof AstLessThan) {
+ sb.append(" < ");
+ } else if (node instanceof AstLessThanEqual) {
+ sb.append(" <= ");
+ } else if (node instanceof AstNotEqual) {
+ sb.append(" != ");
+ } else if (node instanceof AstOr) {
+ sb.append(" || ");
+ }
+ sb.append(sb2);
+ sb.append(" ) ");
+ }
+
+ return returnValue;
+ }
+
+
+ /**
+ * Processing arithmetic node
+ *
+ * @param node
+ * @param sb
+ * @param cMain
+ * @return
+ */
+ private boolean processingArithmeticNode(ArithmeticNode node,
+ StringBuffer sb, CompilationContext componentBean) {
+ StringBuffer sb1 = new StringBuffer();
+ StringBuffer sb2 = new StringBuffer();
+
+ boolean returnValue = true;
+
+ Node node1 = node.jjtGetChild(0);
+
+ if (node1 != null) {
+ if (!(returnValue &= processingNode(node1, sb1,
+ componentBean))) {
+ log.error("Error processing node1: "
+ + node1.getImage());
+ }
+ }
+
+ Node node2 = node.jjtGetChild(1);
+
+ if (null != node2) {
+ if (!(returnValue &= processingNode(node2, sb2,
+ componentBean))) {
+ log.error("Error processing node2: "
+ + node2.getImage());
+ }
+ }
+
+ if (returnValue) {
+ sb.append(" ( ");
+ sb.append(sb1);
+
+ if (node instanceof AstDiv) {
+ sb.append(" / ");
+ } else if (node instanceof AstMult) {
+ sb.append(" * ");
+ } else if (node instanceof AstMod) {
+ sb.append(" % ");
+ } else if (node instanceof AstPlus) {
+ sb.append(" + ");
+ } else if (node instanceof AstMinus) {
+ sb.append(" - ");
+ }
+
+ sb.append(sb2);
+ sb.append(" ) ");
+ }
+ return returnValue;
+ }
+
+ /**
+ * Processing node contain integer
+ *
+ * @param node
+ * @param sb
+ * @return
+ */
+ private boolean processingInteger(AstInteger node, StringBuffer sb) {
+ sb.append(node.getImage());
+ return true;
+ }
+
+ /**
+ * Processing node contain string
+ *
+ * @param node
+ * @param sb
+ * @return
+ */
+ private boolean processingString(AstString node, StringBuffer sb) {
+ sb.append("\"");
+ sb.append(node.getString());
+ sb.append("\"");
+ return true;
+ }
+
+ /**
+ *
+ * @param node
+ * @param sb
+ * @return
+ */
+ private boolean processingFunction(AstFunction node, StringBuffer sb,
+ CompilationContext componentBean) {
+
+ log.debug("Processing function : " + node.getPrefix());
+ log.debug("Processing function : " + node.getLocalName());
+ log.debug("Processing function : " + node.getOutputName());
+
+ String prefix = node.getPrefix();
+ boolean isThis = prefix.equals("this");
+ boolean isUtils = prefix.equals("utils");
+
+ if (isThis || isUtils) {
+ if (isUtils) {
+ sb.append("getUtils().");
+ }
+
+ sb.append(node.getLocalName());
+ sb.append("(");
+ int numChildren = node.jjtGetNumChildren();
+ for (int i = 0; i < numChildren; i++) {
+ Node childNode = node.jjtGetChild(i);
+ StringBuffer buf = new StringBuffer();
+ processingNode(childNode, buf, componentBean);
+ if (i != 0) {
+ sb.append(",");
+ }
+ sb.append(buf);
+ }
+ sb.append(")");
+ } else {
+ String functionName = node.getOutputName();
+ if (this.functionsMap.containsKey(functionName)) {
+ sb.append(this.functionsMap.get(functionName));
+ sb.append("(");
+ int numChildren = node.jjtGetNumChildren();
+ for (int i = 0; i < numChildren; i++) {
+ Node childNode = node.jjtGetChild(i);
+ StringBuffer buf = new StringBuffer();
+ processingNode(childNode, buf, componentBean);
+ if (i != 0) {
+ sb.append(",");
+ }
+ sb.append(buf);
+ }
+ sb.append(")");
+ } // if
+ } // else
+ return true;
+ }
+
+ /**
+ *
+ * @param node
+ * @param sb
+ * @return
+ */
+ private boolean processingIdentifier(AstIdentifier node, StringBuffer sb,
+ CompilationContext componentBean) {
+ String variableName = node.getImage();
+ if (componentBean.containsVariable(variableName)) {
+ sb.append(variableName);
+ } else {
+ sb.append("variables.getVariable(\"");
+ sb.append(variableName);
+ sb.append("\")");
+ }
+
+ return true;
+ }
+
+ /**
+ *
+ * @param basketSuffix
+ * @return
+ */
+ private String processingBracketSuffix(AstBracketSuffix basketSuffix,
+ CompilationContext componentBean) {
+ StringBuffer sb = new StringBuffer();
+ Node node = basketSuffix.jjtGetChild(0);
+ if (node instanceof AstIdentifier) {
+ processingIdentifier((AstIdentifier) node, sb, componentBean);
+ } else if (node instanceof AstInteger) {
+ // sb.append("new Integer(");
+ sb.append(node.getImage());
+ // sb.append(")");
+ } else if (node instanceof AstString) {
+ AstString stringNode = (AstString) node;
+ sb.append("\"");
+ sb.append(stringNode.getString());
+ sb.append("\"");
+ } else {
+ sb.append("\"");
+ sb.append(node.getImage());
+ sb.append("\"");
+ }
+ return sb.toString();
+ }
+
+ /**
+ *
+ * @param clazz
+ * @param propertyName
+ * @return
+ */
+ private PropertyDescriptor getPropertyDescriptor(Class<?> clazz,
+ String propertyName, CompilationContext compilationContext) {
+ return compilationContext.getPropertyDescriptor(clazz, propertyName);
+ }
+
+ private boolean processingValue(AstValue node, StringBuffer sb,
+ CompilationContext componentBean) {
+ String lastIndexValue = "null";
+ String lastVariableType = null;
+ List<String> names = new ArrayList<String>();
+
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ StringBuffer sb1 = new StringBuffer();
+ Node subChild = node.jjtGetChild(i);
+
+ if (subChild instanceof AstIdentifier) {
+ String variableName = subChild.getImage();
+ if (componentBean.containsVariable(variableName)) {
+ lastVariableType = componentBean.getVariableType(
+ variableName).getName();
+ names.add(variableName);
+ } else {
+ processingIdentifier((AstIdentifier) subChild, sb1,
+ componentBean);
+ }
+ } else if (subChild instanceof AstDotSuffix) {
+ String propertyName = subChild.getImage();
+ log.debug("Object: " + lastVariableType
+ + ", property: " + propertyName);
+
+ if (lastVariableType != null) {
+ try {
+
+ Class<?> clazz = componentBean.loadClass(lastVariableType);
+
+ PropertyDescriptor propertyDescriptor = getPropertyDescriptor(
+ clazz, propertyName, componentBean);
+
+ if (propertyDescriptor == null) {
+ throw new PropertyNotFoundException("property: "
+ + propertyName + " not found in class: "
+ + lastVariableType);
+ }
+
+ log.debug("propertyObject: "
+ + propertyDescriptor.getPropertyType()
+ .getName());
+ StringBuffer tmpbuf = new StringBuffer();
+ tmpbuf.append(propertyDescriptor.getReadMethod()
+ .getName());
+ tmpbuf.append("()");
+ names.add(tmpbuf.toString());
+
+ lastVariableType = propertyDescriptor.getPropertyType()
+ .getName();
+ } catch (ClassNotFoundException e) {
+ log.error(e.getLocalizedMessage(), e);
+ }
+
+ } else {
+
+ sb1.append("getProperty(");
+ sb1.append(lastIndexValue);
+ sb1.append(",");
+ sb1.append("\"");
+ sb1.append(subChild.getImage());
+ sb1.append("\")");
+ }
+ } else if (subChild instanceof AstBracketSuffix) {
+ String bracketSuffix = processingBracketSuffix(
+ (AstBracketSuffix) subChild, componentBean);
+
+ if (lastVariableType != null) {
+ StringBuffer tmpbuf = new StringBuffer();
+ if (lastVariableType.startsWith("[L")) {
+ tmpbuf.append("[");
+ tmpbuf.append(bracketSuffix);
+ tmpbuf.append("]");
+ names.add(tmpbuf.toString());
+ }
+
+ if ((lastVariableType.compareTo("java.util.List") == 0)
+ || (lastVariableType.compareTo("java.util.Map") == 0)) {
+ tmpbuf.append("get(");
+ tmpbuf.append(bracketSuffix);
+ tmpbuf.append(")");
+ names.add(tmpbuf.toString());
+ }
+ } else {
+
+ sb1.append("getElelmentByIndex(");
+ sb1.append(lastIndexValue);
+ sb1.append(",");
+ sb1.append(bracketSuffix);
+ sb1.append(")");
+ }
+
+ }
+
+ }
+
+ if (names.size() != 0) {
+ StringBuffer tmpbuf = new StringBuffer();
+ for (String element : names) {
+ if (tmpbuf.length() != 0) {
+ tmpbuf.append(".");
+ }
+ tmpbuf.append(element);
+ }
+ sb.append(tmpbuf.toString());
+ } else {
+ sb.append(lastIndexValue);
+ }
+
+ return true;
+ }
+
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELParser.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ELParser.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ELParser.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.el;
+package org.richfaces.templatecompiler.el;
import java.util.Formatter;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.StringUtils;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.StringUtils;
/**
* EL-parser.
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ICompiledEL.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/ICompiledEL.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/ICompiledEL.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.el;
+package org.richfaces.templatecompiler.el;
/**
* @author yukhovich
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/IELCompiler.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/el/IELCompiler.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/el/IELCompiler.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.el;
+package org.richfaces.templatecompiler.el;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
/**
* EL-parser.
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/A4JRendererElementsFactory.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/A4JRendererElementsFactory.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/A4JRendererElementsFactory.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/A4JRendererElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,175 @@
+/**
+ * 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.templatecompiler.elements;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.html.CDATAElement;
+import org.richfaces.templatecompiler.elements.html.CommentElement;
+import org.richfaces.templatecompiler.elements.html.PIElement;
+import org.richfaces.templatecompiler.elements.html.TextElement;
+import org.richfaces.templatecompiler.elements.vcp.AjaxRenderedAreaElement;
+import org.richfaces.templatecompiler.elements.vcp.HeaderScriptsElement;
+import org.richfaces.templatecompiler.elements.vcp.HeaderStylesElement;
+import org.w3c.dom.Node;
+
+/**
+ * Tag processors factory.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author:
+ * maksimkaszynski $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:44 $
+ *
+ */
+public class A4JRendererElementsFactory implements ElementsFactory {
+
+ private static final Log log = LogFactory.getLog(A4JRendererElementsFactory.class);
+
+ public static final String TEMPLATES_PATH = "META-INF/templates";
+
+ public static final String TEMPLATES_TEMPLATECOMPILER_PATH = TEMPLATES_PATH+"/templatecompiler";
+
+ private final static String DEFAULT_CLASS_ELEMENT_PROCESSOR = "org.richfaces.templatecompiler.elements.html.HTMLElement";
+
+ private final static Class[] paramClasses = new Class[] { Node.class,
+ CompilationContext.class };
+
+ private final static HashMap<String, String> mapClasses = new HashMap<String, String>();
+
+ static {
+ mapClasses
+ .put("c:set",
+ "org.richfaces.templatecompiler.elements.std.SetTemplateElement");
+ mapClasses
+ .put("c:object",
+ "org.richfaces.templatecompiler.elements.std.ObjectTemplateElement");
+ mapClasses.put("c:if",
+ "org.richfaces.templatecompiler.elements.std.IFTemplateElement");
+ mapClasses
+ .put("c:forEach",
+ "org.richfaces.templatecompiler.elements.std.ForEachTemplateElement");
+ mapClasses
+ .put("f:clientid",
+ "org.richfaces.templatecompiler.elements.vcp.FClientIDTemplateElement");
+ mapClasses
+ .put("f:clientId",
+ "org.richfaces.templatecompiler.elements.vcp.FClientIDTemplateElement");
+ mapClasses.put("f:insertComponent",
+ "org.richfaces.templatecompiler.elements.vcp.InsertComponent");
+
+ mapClasses
+ .put("f:call",
+ "org.richfaces.templatecompiler.elements.vcp.FCallTemplateElement");
+ mapClasses
+ .put("f:resource",
+ "org.richfaces.templatecompiler.elements.vcp.FResourceTemplateElement");
+
+ mapClasses
+ .put("u:insertFacet",
+ "org.richfaces.templatecompiler.elements.vcp.UInsertFacetTemplateElement");
+
+ mapClasses
+ .put("vcp:body",
+ "org.richfaces.templatecompiler.elements.vcp.VcpBodyTemplateElement");
+ mapClasses.put("vcp:mock", "");
+
+ mapClasses.put("jsp:scriptlet",
+ "org.richfaces.templatecompiler.elements.jsp.Scriptlet");
+ mapClasses.put("jsp:declaration",
+ "org.richfaces.templatecompiler.elements.jsp.Declaration");
+ mapClasses.put("jsp:directive.page",
+ "org.richfaces.templatecompiler.elements.jsp.DirectivePage");
+ mapClasses.put("jsp:expression",
+ "org.richfaces.templatecompiler.elements.jsp.Expression");
+ mapClasses.put("h:styles", HeaderStylesElement.class.getName());
+ mapClasses.put("h:scripts", HeaderScriptsElement.class.getName());
+ mapClasses.put("f:template", RootElement.class.getName());
+ mapClasses.put("f:root", RootElement.class.getName());
+ mapClasses.put("jsp:root", RootElement.class.getName());
+ mapClasses.put("ajax:update", AjaxRenderedAreaElement.class.getName());
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.templatecompiler.elements.ElementsFactory#getProcessor(org.w3c.dom.Node, org.richfaces.templatecompiler.builder.CompilationContext)
+ */
+ public TemplateElement getProcessor(final Node nodeElement,
+ final CompilationContext componentBean) throws CompilationException {
+ TemplateElement returnValue = null;
+
+ short nodeType = nodeElement.getNodeType();
+ if (Node.CDATA_SECTION_NODE == nodeType) {
+ returnValue =new CDATAElement(nodeElement, componentBean);
+ } else if (Node.TEXT_NODE == nodeType) {
+ returnValue =new TextElement(nodeElement, componentBean);
+ } else if (Node.COMMENT_NODE == nodeType) {
+ returnValue =new CommentElement(nodeElement, componentBean);
+ } else if (Node.PROCESSING_INSTRUCTION_NODE == nodeType) {
+ returnValue =new PIElement(nodeElement, componentBean);
+ } else if (Node.ELEMENT_NODE == nodeType) {
+ String className = (String) mapClasses.get(nodeElement.getNodeName());
+
+ if (className == null) {
+ className = DEFAULT_CLASS_ELEMENT_PROCESSOR;
+ }
+
+ if (!className.equals("")) {
+ Class class1;
+ try {
+ log.debug("loading class: " + className);
+
+ class1 = Class.forName(className);
+ Object[] objects = new Object[2];
+ objects[0] = nodeElement;
+ objects[1] = componentBean;
+
+ returnValue = (TemplateElement) class1.getConstructor(
+ paramClasses).newInstance(objects);
+ } catch (InstantiationException e) {
+ throw new CompilationException("InstantiationException: "
+ + e.getLocalizedMessage(), e);
+ } catch (IllegalAccessException e) {
+ throw new CompilationException("IllegalAccessException: "
+ + e.getLocalizedMessage(), e);
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ throw new CompilationException("InvocationTargetException: "
+ + e.getMessage(), e);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ throw new CompilationException(" error loading class: "
+ + e.getLocalizedMessage());
+ }
+ }
+ }
+ return returnValue;
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/Attribute.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/Attribute.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/Attribute.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/Attribute.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,40 @@
+/**
+ * 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.templatecompiler.elements;
+
+/**
+ * Interface for HTLM-attributes.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author:
+ * alexeyyukhovich $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/26 20:48:44 $
+ *
+ */
+public interface Attribute {
+ public void copyValues(final Attribute src);
+
+ public String getName();
+
+ public String getValue();
+
+ public String getCode();
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/BodyElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/BodyElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/BodyElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/BodyElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,31 @@
+/**
+ * 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.templatecompiler.elements;
+
+/**
+ * Marker interface for central body element ( for renderer, contain encodeChildren method content )
+ * @author shura
+ *
+ */
+public interface BodyElement {
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/DeclarationElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/DeclarationElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/DeclarationElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/DeclarationElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,32 @@
+/**
+ * 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.templatecompiler.elements;
+
+/**
+ * Marker interdace for {@link TemplateElement} processed as declaration, outside
+ * of encode... methods
+ * @author shura
+ *
+ */
+public interface DeclarationElement {
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsArray.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsArray.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsArray.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsArray.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,55 @@
+/**
+ * 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.templatecompiler.elements;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.richfaces.templatecompiler.builder.CompilationException;
+
+/**
+ * @author ayukhovich at exadel.com (latest modification by $Author:
+ * alexeyyukhovich $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:45 $
+ *
+ */
+class ElementsArray extends ArrayList<TemplateElement> {
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public String toCode() throws CompilationException {
+ StringBuffer buf = new StringBuffer();
+
+ Iterator<TemplateElement> i = iterator();
+ boolean hasNext = i.hasNext();
+ while (hasNext) {
+ TemplateElement o = i.next();
+ if (o != null) {
+ buf.append(o.toCode());
+ }
+ hasNext = i.hasNext();
+ } // while
+ return buf.toString();
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsFactory.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/ElementsFactory.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsFactory.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/ElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,37 @@
+/**
+ * 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.templatecompiler.elements;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public interface ElementsFactory {
+
+ public abstract TemplateElement getProcessor(final Node nodeElement,
+ final CompilationContext componentBean) throws CompilationException;
+
+}
\ No newline at end of file
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/JSTLElementsFactory.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/JSTLElementsFactory.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/JSTLElementsFactory.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/JSTLElementsFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,43 @@
+/**
+ * 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.templatecompiler.elements;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class JSTLElementsFactory implements ElementsFactory {
+
+ /* (non-Javadoc)
+ * @see org.richfaces.templatecompiler.elements.ElementsFactory#getProcessor(org.w3c.dom.Node, org.richfaces.templatecompiler.builder.CompilationContext)
+ */
+ public TemplateElement getProcessor(Node nodeElement,
+ CompilationContext componentBean) throws CompilationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/RootElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/RootElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/RootElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/RootElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,196 @@
+/**
+ * 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.templatecompiler.elements;
+
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.vcp.VcpBodyTemplateElement;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class RootElement extends TemplateElementBase {
+
+ private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/ComponentTemplate.vm";
+ private static final String ENCODE_BEGIN_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeBegin.vm";
+ private static final String ENCODE_END_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeEnd.vm";
+ private static final String ENCODE_CHILDREN_TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/EncodeChildren.vm";
+
+ final private static String regexComponent = "(.*)" + VcpBodyTemplateElement.STR_VCB_BODY + "(.*)"
+ + VcpBodyTemplateElement.STR_VCB_BODY + "(.*)";
+
+ final private static Pattern patternComponent = Pattern.compile(
+ regexComponent, Pattern.UNIX_LINES + Pattern.DOTALL);
+
+ /**
+ * @param element
+ * @param componentBean
+ */
+ public RootElement(Node element, CompilationContext componentBean) {
+ super(element, componentBean);
+ // TODO apply global attributes
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() throws CompilationException {
+ VelocityContext context = new VelocityContext();
+ context.put("component", this.getComponentBean());
+ return this.getComponentBean().processTemplate(getTemplateName(), context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.templatecompiler.elements.TemplateElementBase#toCode()
+ */
+ public String toCode() throws CompilationException {
+ VelocityContext context = new VelocityContext();
+ context.put("component", this.getComponentBean());
+ StringBuffer code = new StringBuffer();
+ String beginElement = this.getBeginElement();
+ if (null != beginElement) {
+ code.append(beginElement);
+ code.append("\n");
+ }
+ StringBuffer declarationsCode = new StringBuffer();
+ StringBuffer methodCode = new StringBuffer();
+ for (ListIterator<TemplateElement> iter = getSubElements().listIterator(); iter.hasNext();) {
+ TemplateElement element = iter.next();
+ String toCode = element.toCode();
+ if(element instanceof DeclarationElement){
+ declarationsCode.append(toCode);
+ } /*else if(element instanceof BodyElement){
+ // All collected code put to encodeBegin method.
+ if (methodCode.length()>0) {
+ context.put("body", methodCode.toString());
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeBeginTemplateName(), context));
+ }
+ // If body contain any code, create encodeChildren method.
+ if (toCode.length()>0) {
+ context.put("body", toCode);
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeChildrenTemplateName(), context));
+ }
+ methodCode = new StringBuffer();
+ } */
+ else {
+ methodCode.append(toCode);
+ }
+ }
+
+ if (methodCode.length()>0) {
+
+ Matcher matcher = patternComponent.matcher(methodCode);
+
+ String strEncodeBegin;
+ String strEncodeChildren;
+ String strEncodeEnd;
+
+ if (matcher.find()) {
+ strEncodeBegin = matcher.group(1);
+ // put content before body element to encodeBegin
+ if (strEncodeBegin.trim().length()>0) {
+ context.put("body", strEncodeBegin);
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeBeginTemplateName(), context));
+ }
+ strEncodeChildren = matcher.group(2);
+ if (strEncodeChildren.trim().length()>0 ) {
+ // put content of body element
+ context.put("body", strEncodeChildren);
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeChildrenTemplateName(), context));
+ }
+
+ strEncodeEnd = matcher.group(3);
+ if(strEncodeEnd.trim().length()>0){
+ // All code after body put to encodeEnd method.
+ context.put("body", strEncodeEnd);
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeEndTemplateName(), context));
+ }
+ } else {
+ // All collected code put to encodeEnd method.
+ context.put("body", methodCode.toString());
+ code.append(this.getComponentBean().processTemplate(
+ getEncodeEndTemplateName(), context));
+ }
+ }
+ if(declarationsCode.length()>0){
+ code.append(declarationsCode);
+ }
+ String endElement = this.getEndElement();
+ if (endElement != null) {
+ code.append(endElement);
+ code.append("\n");
+ }
+ return code.toString();
+ }
+
+ /**
+ * @return
+ */
+ protected String getEncodeBeginTemplateName() {
+ return ENCODE_BEGIN_TEMPLATE;
+ }
+
+ /**
+ * @return
+ */
+ protected String getEncodeEndTemplateName() {
+ return ENCODE_END_TEMPLATE;
+ }
+ /**
+ * @return
+ */
+ protected String getEncodeChildrenTemplateName() {
+ return ENCODE_CHILDREN_TEMPLATE;
+ }
+ /**
+ * @return
+ */
+ protected String getTemplateName() {
+ return TEMPLATE;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() throws CompilationException {
+ // TODO Auto-generated method stub
+ return "\n}";
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,51 @@
+/**
+ * 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.templatecompiler.elements;
+
+import java.util.ArrayList;
+
+import org.richfaces.templatecompiler.builder.CompilationException;
+
+/**
+ * Intarace for tag processors.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:43 $
+ *
+ */
+public interface TemplateElement {
+ public String getBeginElement() throws CompilationException;
+
+ public String getEndElement() throws CompilationException;
+
+ public boolean isSkipBody();
+
+ public void addSubElement(TemplateElement e);
+
+ public String toCode() throws CompilationException;
+
+ /**
+ * @return the subElements
+ */
+ public ArrayList<TemplateElement> getSubElements();
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElementBase.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/TemplateElementBase.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElementBase.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/TemplateElementBase.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,93 @@
+/**
+ * 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.templatecompiler.elements;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.w3c.dom.Node;
+
+/**
+ * Abstract base class for tag processors.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:44 $
+ */
+public abstract class TemplateElementBase implements TemplateElement {
+
+
+ private CompilationContext componentBean;
+
+ private ElementsArray subElements = new ElementsArray();
+
+
+ public TemplateElementBase(final Node element,
+ final CompilationContext componentBean) {
+ this.componentBean = componentBean;
+ };
+
+ public boolean isSkipBody() {
+ // by default, children process by compiler.
+ return false;
+ }
+
+ public void addSubElement(TemplateElement e) {
+ this.subElements.add(e);
+ }
+
+ public String toCode() throws CompilationException {
+ StringBuffer buf = new StringBuffer();
+
+ String beginElement = this.getBeginElement();
+ if (null != beginElement) {
+ buf.append(beginElement);
+ buf.append("\n");
+ }
+
+ if (this.subElements.size() != 0) {
+ buf.append(this.subElements.toCode());
+ }
+
+ String endElement = this.getEndElement();
+ if (endElement != null) {
+ buf.append(endElement);
+ buf.append("\n");
+ }
+
+ return buf.toString();
+ }
+
+ /**
+ * @return the componentBean
+ */
+ public CompilationContext getComponentBean() {
+ return componentBean;
+ }
+
+ /**
+ * @return the subElements
+ */
+ public ElementsArray getSubElements() {
+ return this.subElements;
+ }
+
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CDATAElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CDATAElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CDATAElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CDATAElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,69 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class CDATAElement extends TemplateElementBase {
+
+ private String htmlText;
+
+ public CDATAElement(Node element, CompilationContext componentBean) {
+ super(element, componentBean);
+ this.htmlText = element.getNodeValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() {
+ StringBuffer retValue = new StringBuffer();
+ if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
+ retValue.append(" writer.write(\"<![CDATA[\");\n");
+ retValue.append(" writer.write(convertToString(").append(
+ ELParser.compileEL(this.htmlText, this.getComponentBean()))
+ .append("));\n");
+ retValue.append(" writer.write(\"]]>\");\n");
+ }
+ return retValue.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() {
+ // Do nothitg - text not have childs
+ return null;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CommentElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/CommentElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CommentElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/CommentElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,70 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.util.Formatter;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class CommentElement extends TemplateElementBase {
+
+ private String htmlText;
+
+ public CommentElement(Node element, CompilationContext componentBean) {
+ super(element, componentBean);
+ this.htmlText = element.getNodeValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() {
+ String retValue = null;
+ if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
+ Object[] params = { ELParser.compileEL(this.htmlText, this.getComponentBean()) };
+ retValue = new Formatter().format(
+ "writer.writeComment(convertToString(%s));\n", params)
+ .toString();
+ }
+ return retValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() {
+ // Do nothitg - text not have childs
+ return null;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLAttributes.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLAttributes.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLAttributes.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLAttributes.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,63 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.richfaces.templatecompiler.elements.Attribute;
+
+/**
+ * Processing HTLM-attributes.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author:
+ * alexeyyukhovich $)
+ * @version $Revision: 1.1.2.2 $ $Date: 2007/02/26 20:48:41 $
+ *
+ */
+public class HTMLAttributes {
+ private LinkedHashMap attributesMap = new LinkedHashMap();
+
+
+ public void addAttribute(String nameAttribute, String valueAttribute) {
+
+ Attribute attribute = HtmlAttributesFactory.getProcessor(
+ nameAttribute, valueAttribute);
+
+ if (attribute != null) {
+ Attribute oldElemet = (Attribute) this.attributesMap.get(attribute
+ .getName());
+
+ if (oldElemet != null) {
+ oldElemet.copyValues(attribute);
+ } else {
+ this.attributesMap.put(attribute.getName(), attribute);
+ }
+ } else {
+ System.out.println("attribute is null");
+ }
+ }
+
+ public Map getAttributes() {
+ return this.attributesMap;
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,187 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Formatter;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+
+/**
+ * Processing template HTLM-attributes.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author: alexsmirnov $)
+ * @version $Revision: 1.1.2.3 $ $Date: 2007/02/26 20:48:42 $
+ *
+ */
+public class HTMLElement extends TemplateElementBase {
+ final static private String PRE_TAG_NAME = "pre";
+
+ private static final String PASS_THRU_ATTR = "x:passThruWithExclusions";
+
+ private static final List<String> DEFAULT_EXCLUSIONS = Arrays.asList("class", "id");
+
+ private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH
+ + "/HTMLElement.vm";
+
+ private String htmlTag;
+
+ private String htmlText;
+
+ private HTMLAttributes htmlAttributes = new HTMLAttributes();
+
+ private Collection<String> passThruAttributes = null;
+
+ private CompilationContext componentBean;
+
+ /**
+ *
+ * @param element
+ * @param variables
+ */
+ public HTMLElement(final Node element,
+ final CompilationContext componentBean) {
+ super(element, componentBean);
+
+ this.passThruAttributes = null;
+ this.htmlTag = element.getNodeName();
+ this.componentBean = componentBean;
+ processingAttributes(element.getAttributes());
+ }
+
+ /**
+ * @return string contain
+ * @throws CompilationException
+ */
+ public String getBeginElement() throws CompilationException {
+ VelocityContext context = new VelocityContext();
+ context.put("htmlTag", this.htmlTag);
+ context.put("htmlAttributes", this.htmlAttributes.getAttributes());
+ context.put("passThruAttributes", this.passThruAttributes);
+ if (this.htmlText != null) {
+ context.put("htmlText", this.htmlText);
+ }
+ return this.componentBean.processTemplate(getTemplateName(), context);
+
+ }
+
+ /**
+ * @return
+ */
+ protected String getTemplateName() {
+ // TODO Auto-generated method stub
+ return TEMPLATE;
+ }
+
+ /**
+ * @return
+ */
+ public String getEndElement() {
+ String sReturnValue;
+
+ Object[] objects = new Object[1];
+ objects[0] = this.htmlTag;
+
+ sReturnValue = new Formatter().format("writer.endElement(\"%s\");",
+ objects).toString();
+ return sReturnValue;
+ }
+
+ /**
+ *
+ * @param attributes
+ */
+ public void processingAttributes(NamedNodeMap attributes) {
+ if (attributes == null) {
+ return;
+ }
+
+ for (int iElement = 0; iElement != attributes.getLength(); iElement++) {
+ Node attribute = attributes.item(iElement);
+ String attributeName = attribute.getNodeName();
+ String attributeValue = attribute.getNodeValue();
+
+ if (attributeName.equals(PASS_THRU_ATTR)) {
+ processingPassThruAtrribute(attributeValue);
+ } else {
+ this.htmlAttributes.addAttribute(attributeName, ELParser
+ .compileEL(attributeValue, this.componentBean));
+ }
+
+ } // for
+ }
+
+ /**
+ *
+ * @param listPassThruAttributes
+ */
+ private void processingPassThruAtrribute(String listPassThruAttributes) {
+
+ passThruAttributes =
+ new TreeSet<String>(HTMLTags.getAttributes(this.htmlTag));
+
+ String[] excludeAttributes = listPassThruAttributes.split(",");
+
+ passThruAttributes.removeAll(DEFAULT_EXCLUSIONS);
+
+ for (String attribute : excludeAttributes) {
+ passThruAttributes.remove(attribute);
+ }
+
+ }
+
+ /**
+ * Set a body text for HTML-tag
+ *
+ * @param nodeText
+ */
+ public void setText(final String nodeText) {
+ String tempStr = null;
+ // if TAG is not PRE test do not trim
+ if (nodeText.trim().length() != 0) {
+ if (this.htmlTag.compareToIgnoreCase(PRE_TAG_NAME) == 0) {
+ tempStr = nodeText;
+ } else {
+ tempStr = nodeText.trim();
+ }
+ }
+
+ if (null != tempStr) {
+ if (null == this.htmlText) {
+ this.htmlText = ELParser.compileEL(tempStr, this.componentBean);
+ } else {
+ this.htmlText = this.htmlText
+ + ELParser.compileEL(tempStr, this.componentBean);
+ }
+ }
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLTags.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HTMLTags.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLTags.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HTMLTags.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,107 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.Map.Entry;
+
+import org.richfaces.dtd.DocumentDefinition;
+import org.richfaces.dtd.DocumentDefinitionFactory;
+import org.richfaces.dtd.Element;
+
+
+/**
+ * @author yukhovich
+ * @author Maksim Kaszynski
+ */
+public class HTMLTags {
+ /**
+ *
+ */
+
+ private static final String HTML_SCHEMA = "META-INF/schema/html/xhtml1-transitional.dtd";
+
+ private static final URL HTML_DTD = HTMLTags.class.getClassLoader().getResource(HTML_SCHEMA);
+
+ @SuppressWarnings("unchecked")
+ public static Set<String> getAttributes(String tagName) {
+ Set<String> atrs = Collections.emptySet();
+
+ DocumentDefinition dtd =
+ DocumentDefinitionFactory.instance().getDocumentDefinition(HTML_DTD);
+
+ if (dtd != null) {
+ Element element = dtd.getElement(tagName);
+
+ if (element != null) {
+ atrs = element.getAttributes().keySet();
+ }
+ }
+
+ return atrs;
+
+ }
+
+ /**
+ * Look for tags.bin, and compare with it
+ * @param args
+ * @throws Exception
+ */
+ public static void main(String [] args) throws Exception{
+ InputStream stream = HTMLTags.class.getClassLoader().getResourceAsStream("META-INF/templates/templatecompiler/tags.bin");
+
+ ObjectInputStream stream2 = new ObjectInputStream(stream);
+
+ @SuppressWarnings("unchecked")
+ Map<String, List<String>> m =
+ (Map<String, List<String>>) stream2.readObject();
+
+ Set<String> newAttrs = new TreeSet<String>();
+
+ Set<Entry<String,List<String>>> entrySet = m.entrySet();
+ for (Entry<String, List<String>> entry : entrySet) {
+ String element = entry.getKey();
+
+ Set<String> attributes = HTMLTags.getAttributes(element);
+ List<String> attributeList = entry.getValue();
+
+ if (attributeList != null && attributes != null) {
+ attributes.removeAll(attributeList);
+ }
+ newAttrs.addAll(attributes);
+
+ System.out.println(element + attributes);
+
+ }
+
+ System.out.println(newAttrs);
+ }
+
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HtmlAttributesFactory.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/HtmlAttributesFactory.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HtmlAttributesFactory.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/HtmlAttributesFactory.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,93 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+
+import org.richfaces.templatecompiler.elements.Attribute;
+
+/**
+ * Factory for processing HTLM-attributes.
+ *
+ * @author ayukhovich at exadel.com (latest modification by $Author:
+ * alexeyyukhovich $)
+ * @version $Revision: 1.1.2.1 $ $Date: 2007/02/26 20:48:42 $
+ *
+ */
+public class HtmlAttributesFactory {
+ private final static String DEFAULT_CLASS_ATTRIBUTE_PROCESSOR = "org.richfaces.templatecompiler.elements.html.attribute.HtmlAttribute";
+
+ private final static Class[] paramClasses = new Class[] { String.class,
+ String.class };
+
+ private final static HashMap mapClasses = new HashMap();
+
+ static {
+ // mapClasses.put("x:passThruWithExclusions",
+ // "org.richfaces.templatecompiler.elements.html.attribute.PassThruWithExclusions");
+ mapClasses.put("x:otherParameters", "");
+ }
+
+ public static Attribute getProcessor(String attributeName,
+ String attributeValue) {
+ Attribute returnValue = null;
+
+ String className = (String) mapClasses.get(attributeName);
+
+ if (className == null) {
+ className = DEFAULT_CLASS_ATTRIBUTE_PROCESSOR;
+ }
+
+ if (!className.equals("")) {
+ Class class1;
+ try {
+ class1 = Class.forName(className);
+ try {
+ try {
+ Object[] objects = new Object[2];
+ objects[0] = attributeName;
+ objects[1] = attributeValue;
+ returnValue = (Attribute) class1.getConstructor(
+ paramClasses).newInstance(objects);
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ } catch (ClassNotFoundException e1) {
+ e1.printStackTrace();
+ }
+ }
+
+ return returnValue;
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/PIElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/PIElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/PIElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/PIElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,68 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class PIElement extends TemplateElementBase {
+
+ private String htmlText;
+
+ public PIElement(Node element, CompilationContext componentBean) {
+ super(element, componentBean);
+ this.htmlText = element.getNodeValue();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() {
+ StringBuffer retValue = new StringBuffer();
+ if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
+ retValue.append(" writer.write(\"<![CDATA[\");\n");
+ retValue.append(" writer.write(").append(
+ ELParser.compileEL(this.htmlText, this.getComponentBean())).append(");\n");
+ retValue.append(" writer.write(\"]]>\");\n");
+ }
+ return null; // retValue.toString();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() {
+ // Do nothitg - text not have childs
+ return null;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/TextElement.java (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/TextElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/TextElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/TextElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,70 @@
+/**
+ * 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.templatecompiler.elements.html;
+
+import java.util.Formatter;
+
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.Node;
+
+/**
+ * @author shura
+ *
+ */
+public class TextElement extends TemplateElementBase {
+
+ private String htmlText;
+
+ public TextElement(Node element, CompilationContext componentBean) {
+ super(element, componentBean);
+ this.htmlText = element.getNodeValue().trim();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() {
+ String retValue = null;
+ if ((null != this.htmlText) && (this.htmlText.length() > 0)) {
+ Object[] params = { ELParser.compileEL(this.htmlText, this.getComponentBean()) };
+ retValue = new Formatter().format(
+ "writer.writeText(convertToString(%s),null);\n", params)
+ .toString();
+ }
+ return retValue;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() {
+ // Do nothitg - text not have childs
+ return null;
+ }
+
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/attribute)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/HtmlAttribute.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/attribute/HtmlAttribute.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/HtmlAttribute.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.html.attribute;
+package org.richfaces.templatecompiler.elements.html.attribute;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.ajax4jsf.templatecompiler.elements.Attribute;
+import org.richfaces.templatecompiler.elements.Attribute;
/**
* Processing template simple HTLM-attributes.
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/PassThruWithExclusions.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/html/attribute/PassThruWithExclusions.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/html/attribute/PassThruWithExclusions.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.html.attribute;
+package org.richfaces.templatecompiler.elements.html.attribute;
import java.util.Formatter;
-import org.ajax4jsf.templatecompiler.elements.Attribute;
+import org.richfaces.templatecompiler.elements.Attribute;
/**
* Processing template PassThruWithExclusions-attributes.
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Declaration.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/Declaration.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Declaration.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.jsp;
+package org.richfaces.templatecompiler.elements.jsp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectiveInclude.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/DirectiveInclude.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectiveInclude.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.jsp;
+package org.richfaces.templatecompiler.elements.jsp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectivePage.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/DirectivePage.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/DirectivePage.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.jsp;
+package org.richfaces.templatecompiler.elements.jsp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.DOMException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Expression.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/Expression.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Expression.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.jsp;
+package org.richfaces.templatecompiler.elements.jsp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Scriptlet.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/jsp/Scriptlet.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/jsp/Scriptlet.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.jsp;
+package org.richfaces.templatecompiler.elements.jsp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ForEachTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ForEachTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ForEachTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.std;
+package org.richfaces.templatecompiler.elements.std;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/IFTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/IFTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/IFTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.std;
+package org.richfaces.templatecompiler.elements.std;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ObjectTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/ObjectTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/ObjectTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.std;
+package org.richfaces.templatecompiler.elements.std;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/SetTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/std/SetTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/std/SetTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.std;
+package org.richfaces.templatecompiler.elements.std;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp)
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,60 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.templatecompiler.elements.vcp;
-
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
-import org.apache.velocity.VelocityContext;
-import org.w3c.dom.Node;
-
-/**
- * Add comma separated list of ids to Ajax Context's rendered areas collection.
- * @author Maksim Kaszynski
- *
- */
-public class AjaxRenderedAreaElement extends TemplateElementBase {
-
- private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/ajaxRenderedArea.vm";
-
- private String values;
-
- public AjaxRenderedAreaElement(Node element,
- CompilationContext componentBean) {
- super(element, componentBean);
- values = ELParser.compileEL(element.getTextContent(), this.getComponentBean());
- componentBean.addToImport("org.ajax4jsf.context.AjaxContext");
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getBeginElement()
- */
- public String getBeginElement() throws CompilationException {
-
- VelocityContext context = new VelocityContext();
- context.put("areas", this.values);
- return this.getComponentBean().processTemplate(getTemplateName(), context);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.elements.TemplateElement#getEndElement()
- */
- public String getEndElement() throws CompilationException {
-
- return null;
- }
-
- protected String getTemplateName() {
- return TEMPLATE;
- }
-
- @Override
- public boolean isSkipBody() {
- // TODO Auto-generated method stub
- return true;
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/AjaxRenderedAreaElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,78 @@
+/**
+ * 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.templatecompiler.elements.vcp;
+
+import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
+import org.w3c.dom.Node;
+
+/**
+ * Add comma separated list of ids to Ajax Context's rendered areas collection.
+ * @author Maksim Kaszynski
+ *
+ */
+public class AjaxRenderedAreaElement extends TemplateElementBase {
+
+ private static final String TEMPLATE = A4JRendererElementsFactory.TEMPLATES_TEMPLATECOMPILER_PATH+"/ajaxRenderedArea.vm";
+
+ private String values;
+
+ public AjaxRenderedAreaElement(Node element,
+ CompilationContext componentBean) {
+ super(element, componentBean);
+ values = ELParser.compileEL(element.getTextContent(), this.getComponentBean());
+ componentBean.addToImport("org.richfaces.context.AjaxContext");
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getBeginElement()
+ */
+ public String getBeginElement() throws CompilationException {
+
+ VelocityContext context = new VelocityContext();
+ context.put("areas", this.values);
+ return this.getComponentBean().processTemplate(getTemplateName(), context);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.templatecompiler.elements.TemplateElement#getEndElement()
+ */
+ public String getEndElement() throws CompilationException {
+
+ return null;
+ }
+
+ protected String getTemplateName() {
+ return TEMPLATE;
+ }
+
+ @Override
+ public boolean isSkipBody() {
+ // TODO Auto-generated method stub
+ return true;
+ }
+
+}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FCallTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/FCallTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FCallTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
import java.beans.PropertyDescriptor;
import java.util.ArrayList;
@@ -27,15 +27,15 @@
import java.util.Iterator;
import java.util.List;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.commons.beanutils.PropertyUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FClientIDTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/FClientIDTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FClientIDTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
import java.util.Formatter;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FInsertChildren.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/FInsertChildren.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FInsertChildren.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FResourceTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/FResourceTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/FResourceTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,13 +19,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderResourceElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/HeaderResourceElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderResourceElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,17 +19,17 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
@@ -95,7 +95,7 @@
this.resourcePaths = (String[]) paths.toArray(new String[paths.size()]);
}
componentBean
- .addToImport("org.ajax4jsf.resource.InternetResource");
+ .addToImport("org.richfaces.resource.InternetResource");
componentBean.addToDeclaration(getContent());
}
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderScriptsElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/HeaderScriptsElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderScriptsElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
import org.w3c.dom.Node;
/**
@@ -43,7 +43,7 @@
/*
* (non-Javadoc)
*
- * @see org.ajax4jsf.templatecompiler.elements.vcp.HeaderResourceElement#getPropertyName()
+ * @see org.richfaces.templatecompiler.elements.vcp.HeaderResourceElement#getPropertyName()
*/
protected String getPropertyName() {
return "scripts";
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderStylesElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/HeaderStylesElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/HeaderStylesElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
import org.w3c.dom.Node;
/**
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/InsertComponent.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/InsertComponent.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/InsertComponent.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,14 +19,14 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.el.ELParser;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.el.ELParser;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/Parameter.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/Parameter.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/Parameter.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
/**
* container class for storing information about f:parameter-tags.
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/ParameterProcessor.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/ParameterProcessor.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/ParameterProcessor.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
import java.util.ArrayList;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/UInsertFacetTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/UInsertFacetTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/UInsertFacetTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,15 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
import java.io.StringWriter;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
import org.apache.velocity.VelocityContext;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.A4JRendererElementsFactory;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/VcpBodyTemplateElement.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/elements/vcp/VcpBodyTemplateElement.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/elements/vcp/VcpBodyTemplateElement.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,11 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.elements.vcp;
+package org.richfaces.templatecompiler.elements.vcp;
-import org.ajax4jsf.templatecompiler.builder.CompilationContext;
-import org.ajax4jsf.templatecompiler.elements.BodyElement;
-import org.ajax4jsf.templatecompiler.elements.TemplateElementBase;
+import org.richfaces.templatecompiler.builder.CompilationContext;
+import org.richfaces.templatecompiler.elements.BodyElement;
+import org.richfaces.templatecompiler.elements.TemplateElementBase;
import org.w3c.dom.Node;
/**
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils)
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils/CallbackListener.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,59 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.utils;
-
-/*
- * Copyright 2004-2006 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @author Martin Marinschek
- * @version $Revision: 1.1.2.1 $ $Date: 2006/12/20 18:56:39 $ <p/> $Log:
- * CallbackListener.java,v $ Revision 1.1 2006/07/05 08:53:39
- * alexsmirnov Refactor filter system ( move different functions for
- * different classes ). Fix encoding for AJAX responses - forced to
- * UTF-8 Fix issue #5 from tracker Fix error message for xml parsing.
- *
- */
-public interface CallbackListener {
- void openedStartTag(int charIndex, int tagIdentifier);
-
- void closedStartTag(int charIndex, int tagIdentifier);
-
- void openedEndTag(int charIndex, int tagIdentifier);
-
- void closedEndTag(int charIndex, int tagIdentifier);
-
- void attribute(int charIndex, int tagIdentifier, String key, String value);
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils/CallbackListener.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/CallbackListener.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004-2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.richfaces.templatecompiler.utils;
+
+/**
+ * @author Martin Marinschek
+ * @version $Revision: 1.1.2.1 $ $Date: 2006/12/20 18:56:39 $ <p/> $Log:
+ * CallbackListener.java,v $ Revision 1.1 2006/07/05 08:53:39
+ * alexsmirnov Refactor filter system ( move different functions for
+ * different classes ). Fix encoding for AJAX responses - forced to
+ * UTF-8 Fix issue #5 from tracker Fix error message for xml parsing.
+ *
+ */
+public interface CallbackListener {
+ void openedStartTag(int charIndex, int tagIdentifier);
+
+ void closedStartTag(int charIndex, int tagIdentifier);
+
+ void openedEndTag(int charIndex, int tagIdentifier);
+
+ void closedEndTag(int charIndex, int tagIdentifier);
+
+ void attribute(int charIndex, int tagIdentifier, String key, String value);
+}
Deleted: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils/ReducedHTMLParser.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,624 +0,0 @@
-/**
- * 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.ajax4jsf.templatecompiler.utils;
-
-/*
- * Copyright 2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * A class which detects the open/close tags in an HTML document and reports
- * them to a listener class.
- * <p>
- * This is unfortunately necessary when using JSF with JSP, as tags in the body
- * of the document can need to output commands into the document at points
- * earlier than the tag occurred (particularly into the document HEAD section).
- * This can only be implemented by buffering the response and post-processing it
- * to find the relevant HTML tags and modifying the buffer as needed.
- * <p>
- * This class tries to do the parsing as quickly as possible; many of the
- * details of HTML are not relevant for the purposes this class is used for.
- *
- * @version $Revision: 1.1.2.1 $ $Date: 2006/12/20 18:56:39 $
- */
-public class ReducedHTMLParser {
- // IMPLEMENTATION NOTE:
- //
- // Many of the methods on this class are package-scope. This is intended
- // solely for the purpose of unit-testing. This class does not expect
- // other classes in this package to access its methods.
-
- private static final Log log = LogFactory.getLog(ReducedHTMLParser.class);
-
- public static final int BODY_TAG = 0;
-
- public static final int HEAD_TAG = 1;
-
- public static final int SCRIPT_TAG = 2;
-
- private static final int STATE_READY = 0;
-
- private static final int STATE_IN_COMMENT = 1;
-
- private static final int STATE_IN_TAG = 2;
-
- private static final int STATE_IN_MARKED_SECTION = 3;
-
- private static final int STATE_EXPECTING_ETAGO = 4;
-
- private int _offset;
-
- private int _lineNumber;
-
- private CharSequence _seq;
-
- private CallbackListener _listener;
-
- public static void parse(CharSequence seq, CallbackListener l) {
- new ReducedHTMLParser(seq, l).parse();
- }
-
- /**
- * Constructor, package-scope for unit testing.
- *
- * @param s
- * is the sequence of chars to parse.
- * @param l
- * is the listener to invoke callbacks on.
- */
- ReducedHTMLParser(CharSequence s, CallbackListener l) {
- this._seq = s;
- this._listener = l;
- }
-
- /**
- * Return true if there are no more characters to parse.
- */
- boolean isFinished() {
- return this._offset >= this._seq.length();
- }
-
- int getCurrentLineNumber() {
- return this._lineNumber;
- }
-
- /**
- * Advance the current parse position over any whitespace characters.
- */
- void consumeWhitespace() {
- boolean crSeen = false;
-
- while (this._offset < this._seq.length()) {
- char c = this._seq.charAt(this._offset);
- if (!Character.isWhitespace(c)) {
- break;
- }
-
- // Track line number for error messages.
- if (c == '\r') {
- ++this._lineNumber;
- crSeen = true;
- } else if ((c == '\n') && !crSeen) {
- ++this._lineNumber;
- } else {
- crSeen = false;
- }
-
- ++this._offset;
- }
- }
-
- /**
- * Eat up a sequence of non-whitespace characters and return them.
- */
- String consumeNonWhitespace() {
- int wordStart = this._offset;
- while (this._offset < this._seq.length()) {
- char c = this._seq.charAt(this._offset);
- if (Character.isWhitespace(c)) {
- break;
- }
- ++this._offset;
- }
- if (wordStart == this._offset) {
- return null;
- } else {
- return this._seq.subSequence(wordStart, this._offset).toString();
- }
- }
-
- /**
- * If the next chars in the input sequence exactly match the specified
- * string then skip over them and return true.
- * <p>
- * If there is not a match then leave the current parse position unchanged
- * and return false.
- *
- * @param s
- * is the exact string to match.
- * @return true if the input contains exactly the param s
- */
- boolean consumeMatch(String s) {
- if (this._offset + s.length() > this._seq.length()) {
- // seq isn't long enough to contain the specified string
- return false;
- }
-
- int i = 0;
- while (i < s.length()) {
- if (this._seq.charAt(this._offset + i) == s.charAt(i)) {
- ++i;
- } else {
- return false;
- }
- }
-
- this._offset += i;
- return true;
- }
-
- /**
- * Eat up a sequence of chars which form a valid XML element name.
- * <p>
- * TODO: implement this properly in compliance with spec
- */
- String consumeElementName() {
- consumeWhitespace();
- int nameStart = this._offset;
- while (!isFinished()) {
- boolean ok = false;
- char c = this._seq.charAt(this._offset);
- if (Character.isLetterOrDigit(this._seq.charAt(this._offset))) {
- ok = true;
- } else if (c == '_') {
- ok = true;
- } else if (c == '-') {
- ok = true;
- } else if (c == ':') {
- ok = true;
- }
-
- if (!ok) {
- break;
- }
-
- ++this._offset;
- }
-
- if (nameStart == this._offset) {
- return null;
- } else {
- return this._seq.subSequence(nameStart, this._offset).toString();
- }
- }
-
- /**
- * Eat up a sequence of chars which form a valid XML attribute name.
- * <p>
- * TODO: implement this properly in compliance with spec
- */
- String consumeAttrName() {
- // for now, assume elements and attributes have same rules
- return consumeElementName();
- }
-
- /**
- * Eat up a string which is terminated with the specified quote character.
- * This means handling escaped quote chars within the string.
- * <p>
- * This method assumes that the leading quote has already been consumed.
- */
- String consumeString(char quote) {
- // TODO: should we consider a string to be terminated by a newline?
- // that would help with runaway strings but I think that multiline
- // strings *are* allowed...
- //
- // TODO: detect newlines within strings and increment lineNumber.
- // This isn't so important, though; they aren't common and being a
- // few lines out in an error message isn't serious either.
- StringBuffer stringBuf = new StringBuffer();
- boolean escaping = false;
- while (!isFinished()) {
- char c = this._seq.charAt(this._offset);
- ++this._offset;
- if (c == quote) {
- if (!escaping) {
- break;
- } else {
- stringBuf.append(c);
- escaping = false;
- }
- } else if (c == '\\') {
- if (escaping) {
- // append a real backslash
- stringBuf.append(c);
- escaping = false;
- } else {
- escaping = true;
- }
- } else {
- stringBuf.append(c);
- }
- }
- return stringBuf.toString();
- }
-
- /**
- * Assuming we have already encountered "attrname=", consume the value part
- * of the attribute definition. Note that unlike XML, HTML doesn't have to
- * quote its attribute values.
- *
- * @return the attribute value. If the attr-value was quoted, the returned
- * value will not include the quote chars.
- */
- String consumeAttrValue() {
- consumeWhitespace();
- if (consumeMatch("'")) {
- return consumeString('\'');
- } else if (consumeMatch("\"")) {
- return consumeString('"');
- } else {
- return consumeNonWhitespace();
- }
- }
-
- /**
- * Discard all characters in the input until one in the specified string
- * (character-set) is found.
- *
- * @param s
- * is a set of characters that should not be discarded.
- */
- void consumeExcept(String s) {
- boolean crSeen = false;
-
- while (this._offset < this._seq.length()) {
- char c = this._seq.charAt(this._offset);
- if (s.indexOf(c) >= 0) {
- // char is in the exception set
- return;
- }
-
- // Track line number for error messages.
- if (c == '\r') {
- ++this._lineNumber;
- crSeen = true;
- } else if ((c == '\n') && !crSeen) {
- ++this._lineNumber;
- } else {
- crSeen = false;
- }
-
- // Track line number for error messages.
- if (c == '\r') {
- ++this._lineNumber;
- crSeen = true;
- } else if ((c == '\n') && !crSeen) {
- ++this._lineNumber;
- } else {
- crSeen = false;
- }
-
- ++this._offset;
- }
- }
-
- /**
- * Process the entire input buffer, invoking callbacks on the listener
- * object as appropriate.
- */
- void parse() {
- int state = STATE_READY;
-
- int currentTagStart = -1;
- String currentTagName = null;
-
- this._lineNumber = 1;
- this._offset = 0;
- int lastOffset = this._offset - 1;
- while (this._offset < this._seq.length()) {
- // Sanity check; each pass through this loop must increase the
- // offset.
- // Failure to do this means a hang situation has occurred.
- if (this._offset <= lastOffset) {
- // throw new RuntimeException("Infinite loop detected in
- // ReducedHTMLParser");
- log
- .error("Infinite loop detected in ReducedHTMLParser; parsing skipped");
- // return;
- }
- lastOffset = this._offset;
-
- if (state == STATE_READY) {
- // in this state, nothing but "<" has any significance
- consumeExcept("<");
- if (isFinished()) {
- break;
- }
-
- if (consumeMatch("<!--")) {
- // Note that whitespace is *not* permitted in <!--
- state = STATE_IN_COMMENT;
- } else if (consumeMatch("<![")) {
- // Start of a "marked section", eg "<![CDATA" or
- // "<![INCLUDE" or "<![IGNORE". These always terminate
- // with "]]>"
- log.debug("Marked section found at line "
- + getCurrentLineNumber());
- state = STATE_IN_MARKED_SECTION;
- } else if (consumeMatch("<!DOCTYPE")) {
- log
- .debug("DOCTYPE found at line "
- + getCurrentLineNumber());
- // we don't need to actually do anything here; the
- // tag can't contain a bare "<", so the first "<"
- // indicates the start of the next real tag.
- //
- // TODO: Handle case where the DOCTYPE includes an internal
- // DTD. In
- // that case there *will* be embedded < chars in the
- // document. However
- // that's very unlikely to be used in a JSF page, so this is
- // pretty low
- // priority.
- } else if (consumeMatch("<?")) {
- // xml processing instruction or <!DOCTYPE> tag
- // we don't need to actually do anything here; the
- // tag can't contain a bare "<", so the first "<"
- // indicates the start of the next real tag.
- log.debug("PI found at line " + getCurrentLineNumber());
- } else if (consumeMatch("</")) {
- if (!processEndTag()) {
- // message already logged
- return;
- }
-
- // stay in state READY
- state = STATE_READY;
- } else if (consumeMatch("<")) {
- // We can't tell the user that the tag has closed until
- // after we have
- // processed any attributes and found the real end of the
- // tag. So save
- // the current info until the end of this tag.
- currentTagStart = this._offset - 1;
- currentTagName = consumeElementName();
- if (currentTagName == null) {
- log
- .warn("Invalid HTML; bare lessthan sign found at line "
- + getCurrentLineNumber());
- // remain in STATE_READY; this isn't really the start of
- // an xml element.
- } else {
- state = STATE_IN_TAG;
- }
- } else {
- // should never get here
- throw new Error("Internal error at line "
- + getCurrentLineNumber());
- }
-
- continue;
- }
-
- if (state == STATE_IN_COMMENT) {
- // TODO: handle "-- >", which is a valid way to close a
- // comment according to the specs.
-
- // in this state, nothing but "--" has any significance
- consumeExcept("-");
- if (isFinished()) {
- break;
- }
-
- if (consumeMatch("-->")) {
- state = STATE_READY;
- } else {
- // false call; hyphen is not end of comment
- consumeMatch("-");
- }
-
- continue;
- }
-
- if (state == STATE_IN_TAG) {
- consumeWhitespace();
-
- if (consumeMatch("/>")) {
- // ok, end of element
- state = STATE_READY;
- closedTag(currentTagStart, this._offset, currentTagName);
-
- // and reset vars just in case...
- currentTagStart = -1;
- currentTagName = null;
- } else if (consumeMatch(">")) {
- if (currentTagName.equalsIgnoreCase("script")
- || currentTagName.equalsIgnoreCase("style")) {
- // We've just started a special tag which can contain
- // anything except
- // the ETAGO marker ("</"). See
- // http://www.w3.org/TR/REC-html40/appendix/notes.html#notes-specifying-data
- state = STATE_EXPECTING_ETAGO;
- } else {
- state = STATE_READY;
- }
-
- // end of open tag, but not end of element
- openedTag(currentTagStart, this._offset, currentTagName);
-
- // and reset vars just in case...
- currentTagStart = -1;
- currentTagName = null;
- } else {
- // xml attribute
- String attrName = consumeAttrName();
- if (attrName == null) {
- // Oops, we found something quite unexpected in this
- // tag.
- // The best we can do is probably to drop back to
- // looking
- // for "/>", though that does risk us misinterpreting
- // the
- // contents of an attribute's associated string value.
- log
- .warn("Invalid tag found: unexpected input while looking for attr name or '/>'"
- + " at line " + getCurrentLineNumber());
- state = STATE_EXPECTING_ETAGO;
- // and consume one character
- ++this._offset;
- } else {
- consumeWhitespace();
-
- // html can have "stand-alone" attributes with no
- // following equals sign
- if (consumeMatch("=")) {
- String attrValue = consumeAttrValue();
- }
- }
- }
-
- continue;
- }
-
- if (state == STATE_IN_MARKED_SECTION) {
- // in this state, nothing but "]]>" has any significance
- consumeExcept("]");
- if (isFinished()) {
- break;
- }
-
- if (consumeMatch("]]>")) {
- state = STATE_READY;
- } else {
- // false call; ] is not end of cdata section
- consumeMatch("]");
- }
-
- continue;
- }
-
- if (state == STATE_EXPECTING_ETAGO) {
- // The term "ETAGO" is the official spec term for "</".
- consumeExcept("<");
- if (isFinished()) {
- log
- .debug("Malformed input page; input terminated while tag not closed.");
- break;
- }
-
- if (consumeMatch("</")) {
- if (!processEndTag()) {
- return;
- }
- state = STATE_READY;
- } else {
- // false call; < does not start an ETAGO
- consumeMatch("<");
- }
-
- continue;
- }
- }
- }
-
- /**
- * Invoked when "</" has been seen in the input, this method handles the
- * parsing of the end tag and the invocation of the appropriate callback
- * method.
- *
- * @return true if the tag was successfully parsed, and false if there was a
- * fatal parsing error.
- */
- private boolean processEndTag() {
- int tagStart = this._offset - 2;
- String tagName = consumeElementName();
- consumeWhitespace();
- if (!consumeMatch(">")) {
- log.error("Malformed end tag at line " + getCurrentLineNumber()
- + "; skipping parsing");
- return false;
- }
-
- // inform user that the tag has been closed
- closedTag(tagStart, this._offset, tagName);
-
- // We can't verify that the tag names balance because this is HTML
- // we are processing, not XML.
- return true;
- }
-
- /**
- * Invoke a callback method to inform the listener that we have found a
- * start tag.
- *
- * @param startOffset
- * @param endOffset
- * @param tagName
- */
- void openedTag(int startOffset, int endOffset, String tagName) {
- // log.debug("Found open tag at " + startOffset + ":" + endOffset + ":"
- // + tagName);
-
- if ("head".equalsIgnoreCase(tagName)) {
- this._listener.openedStartTag(startOffset, HEAD_TAG);
- this._listener.closedStartTag(endOffset, HEAD_TAG);
- } else if ("body".equalsIgnoreCase(tagName)) {
- this._listener.openedStartTag(startOffset, BODY_TAG);
- this._listener.closedStartTag(endOffset, BODY_TAG);
- } else if ("script".equalsIgnoreCase(tagName)) {
- this._listener.openedStartTag(startOffset, SCRIPT_TAG);
- this._listener.closedStartTag(endOffset, SCRIPT_TAG);
- }
- }
-
- void closedTag(int startOffset, int endOffset, String tagName) {
- // log.debug("Found close tag at " + startOffset + ":" + endOffset + ":"
- // + tagName);
-
- if ("head".equalsIgnoreCase(tagName)) {
- this._listener.openedEndTag(startOffset, HEAD_TAG);
- this._listener.closedEndTag(endOffset, HEAD_TAG);
- } else if ("body".equalsIgnoreCase(tagName)) {
- this._listener.openedEndTag(startOffset, BODY_TAG);
- this._listener.closedEndTag(endOffset, BODY_TAG);
- } else if ("script".equalsIgnoreCase(tagName)) {
- this._listener.openedEndTag(startOffset, SCRIPT_TAG);
- this._listener.closedEndTag(endOffset, SCRIPT_TAG);
- }
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java (from rev 14245, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/utils/ReducedHTMLParser.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/utils/ReducedHTMLParser.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,603 @@
+/*
+ * Copyright 2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.richfaces.templatecompiler.utils;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * A class which detects the open/close tags in an HTML document and reports
+ * them to a listener class.
+ * <p>
+ * This is unfortunately necessary when using JSF with JSP, as tags in the body
+ * of the document can need to output commands into the document at points
+ * earlier than the tag occurred (particularly into the document HEAD section).
+ * This can only be implemented by buffering the response and post-processing it
+ * to find the relevant HTML tags and modifying the buffer as needed.
+ * <p>
+ * This class tries to do the parsing as quickly as possible; many of the
+ * details of HTML are not relevant for the purposes this class is used for.
+ *
+ * @version $Revision: 1.1.2.1 $ $Date: 2006/12/20 18:56:39 $
+ */
+public class ReducedHTMLParser {
+ // IMPLEMENTATION NOTE:
+ //
+ // Many of the methods on this class are package-scope. This is intended
+ // solely for the purpose of unit-testing. This class does not expect
+ // other classes in this package to access its methods.
+
+ private static final Log log = LogFactory.getLog(ReducedHTMLParser.class);
+
+ public static final int BODY_TAG = 0;
+
+ public static final int HEAD_TAG = 1;
+
+ public static final int SCRIPT_TAG = 2;
+
+ private static final int STATE_READY = 0;
+
+ private static final int STATE_IN_COMMENT = 1;
+
+ private static final int STATE_IN_TAG = 2;
+
+ private static final int STATE_IN_MARKED_SECTION = 3;
+
+ private static final int STATE_EXPECTING_ETAGO = 4;
+
+ private int _offset;
+
+ private int _lineNumber;
+
+ private CharSequence _seq;
+
+ private CallbackListener _listener;
+
+ public static void parse(CharSequence seq, CallbackListener l) {
+ new ReducedHTMLParser(seq, l).parse();
+ }
+
+ /**
+ * Constructor, package-scope for unit testing.
+ *
+ * @param s
+ * is the sequence of chars to parse.
+ * @param l
+ * is the listener to invoke callbacks on.
+ */
+ ReducedHTMLParser(CharSequence s, CallbackListener l) {
+ this._seq = s;
+ this._listener = l;
+ }
+
+ /**
+ * Return true if there are no more characters to parse.
+ */
+ boolean isFinished() {
+ return this._offset >= this._seq.length();
+ }
+
+ int getCurrentLineNumber() {
+ return this._lineNumber;
+ }
+
+ /**
+ * Advance the current parse position over any whitespace characters.
+ */
+ void consumeWhitespace() {
+ boolean crSeen = false;
+
+ while (this._offset < this._seq.length()) {
+ char c = this._seq.charAt(this._offset);
+ if (!Character.isWhitespace(c)) {
+ break;
+ }
+
+ // Track line number for error messages.
+ if (c == '\r') {
+ ++this._lineNumber;
+ crSeen = true;
+ } else if ((c == '\n') && !crSeen) {
+ ++this._lineNumber;
+ } else {
+ crSeen = false;
+ }
+
+ ++this._offset;
+ }
+ }
+
+ /**
+ * Eat up a sequence of non-whitespace characters and return them.
+ */
+ String consumeNonWhitespace() {
+ int wordStart = this._offset;
+ while (this._offset < this._seq.length()) {
+ char c = this._seq.charAt(this._offset);
+ if (Character.isWhitespace(c)) {
+ break;
+ }
+ ++this._offset;
+ }
+ if (wordStart == this._offset) {
+ return null;
+ } else {
+ return this._seq.subSequence(wordStart, this._offset).toString();
+ }
+ }
+
+ /**
+ * If the next chars in the input sequence exactly match the specified
+ * string then skip over them and return true.
+ * <p>
+ * If there is not a match then leave the current parse position unchanged
+ * and return false.
+ *
+ * @param s
+ * is the exact string to match.
+ * @return true if the input contains exactly the param s
+ */
+ boolean consumeMatch(String s) {
+ if (this._offset + s.length() > this._seq.length()) {
+ // seq isn't long enough to contain the specified string
+ return false;
+ }
+
+ int i = 0;
+ while (i < s.length()) {
+ if (this._seq.charAt(this._offset + i) == s.charAt(i)) {
+ ++i;
+ } else {
+ return false;
+ }
+ }
+
+ this._offset += i;
+ return true;
+ }
+
+ /**
+ * Eat up a sequence of chars which form a valid XML element name.
+ * <p>
+ * TODO: implement this properly in compliance with spec
+ */
+ String consumeElementName() {
+ consumeWhitespace();
+ int nameStart = this._offset;
+ while (!isFinished()) {
+ boolean ok = false;
+ char c = this._seq.charAt(this._offset);
+ if (Character.isLetterOrDigit(this._seq.charAt(this._offset))) {
+ ok = true;
+ } else if (c == '_') {
+ ok = true;
+ } else if (c == '-') {
+ ok = true;
+ } else if (c == ':') {
+ ok = true;
+ }
+
+ if (!ok) {
+ break;
+ }
+
+ ++this._offset;
+ }
+
+ if (nameStart == this._offset) {
+ return null;
+ } else {
+ return this._seq.subSequence(nameStart, this._offset).toString();
+ }
+ }
+
+ /**
+ * Eat up a sequence of chars which form a valid XML attribute name.
+ * <p>
+ * TODO: implement this properly in compliance with spec
+ */
+ String consumeAttrName() {
+ // for now, assume elements and attributes have same rules
+ return consumeElementName();
+ }
+
+ /**
+ * Eat up a string which is terminated with the specified quote character.
+ * This means handling escaped quote chars within the string.
+ * <p>
+ * This method assumes that the leading quote has already been consumed.
+ */
+ String consumeString(char quote) {
+ // TODO: should we consider a string to be terminated by a newline?
+ // that would help with runaway strings but I think that multiline
+ // strings *are* allowed...
+ //
+ // TODO: detect newlines within strings and increment lineNumber.
+ // This isn't so important, though; they aren't common and being a
+ // few lines out in an error message isn't serious either.
+ StringBuffer stringBuf = new StringBuffer();
+ boolean escaping = false;
+ while (!isFinished()) {
+ char c = this._seq.charAt(this._offset);
+ ++this._offset;
+ if (c == quote) {
+ if (!escaping) {
+ break;
+ } else {
+ stringBuf.append(c);
+ escaping = false;
+ }
+ } else if (c == '\\') {
+ if (escaping) {
+ // append a real backslash
+ stringBuf.append(c);
+ escaping = false;
+ } else {
+ escaping = true;
+ }
+ } else {
+ stringBuf.append(c);
+ }
+ }
+ return stringBuf.toString();
+ }
+
+ /**
+ * Assuming we have already encountered "attrname=", consume the value part
+ * of the attribute definition. Note that unlike XML, HTML doesn't have to
+ * quote its attribute values.
+ *
+ * @return the attribute value. If the attr-value was quoted, the returned
+ * value will not include the quote chars.
+ */
+ String consumeAttrValue() {
+ consumeWhitespace();
+ if (consumeMatch("'")) {
+ return consumeString('\'');
+ } else if (consumeMatch("\"")) {
+ return consumeString('"');
+ } else {
+ return consumeNonWhitespace();
+ }
+ }
+
+ /**
+ * Discard all characters in the input until one in the specified string
+ * (character-set) is found.
+ *
+ * @param s
+ * is a set of characters that should not be discarded.
+ */
+ void consumeExcept(String s) {
+ boolean crSeen = false;
+
+ while (this._offset < this._seq.length()) {
+ char c = this._seq.charAt(this._offset);
+ if (s.indexOf(c) >= 0) {
+ // char is in the exception set
+ return;
+ }
+
+ // Track line number for error messages.
+ if (c == '\r') {
+ ++this._lineNumber;
+ crSeen = true;
+ } else if ((c == '\n') && !crSeen) {
+ ++this._lineNumber;
+ } else {
+ crSeen = false;
+ }
+
+ // Track line number for error messages.
+ if (c == '\r') {
+ ++this._lineNumber;
+ crSeen = true;
+ } else if ((c == '\n') && !crSeen) {
+ ++this._lineNumber;
+ } else {
+ crSeen = false;
+ }
+
+ ++this._offset;
+ }
+ }
+
+ /**
+ * Process the entire input buffer, invoking callbacks on the listener
+ * object as appropriate.
+ */
+ void parse() {
+ int state = STATE_READY;
+
+ int currentTagStart = -1;
+ String currentTagName = null;
+
+ this._lineNumber = 1;
+ this._offset = 0;
+ int lastOffset = this._offset - 1;
+ while (this._offset < this._seq.length()) {
+ // Sanity check; each pass through this loop must increase the
+ // offset.
+ // Failure to do this means a hang situation has occurred.
+ if (this._offset <= lastOffset) {
+ // throw new RuntimeException("Infinite loop detected in
+ // ReducedHTMLParser");
+ log
+ .error("Infinite loop detected in ReducedHTMLParser; parsing skipped");
+ // return;
+ }
+ lastOffset = this._offset;
+
+ if (state == STATE_READY) {
+ // in this state, nothing but "<" has any significance
+ consumeExcept("<");
+ if (isFinished()) {
+ break;
+ }
+
+ if (consumeMatch("<!--")) {
+ // Note that whitespace is *not* permitted in <!--
+ state = STATE_IN_COMMENT;
+ } else if (consumeMatch("<![")) {
+ // Start of a "marked section", eg "<![CDATA" or
+ // "<![INCLUDE" or "<![IGNORE". These always terminate
+ // with "]]>"
+ log.debug("Marked section found at line "
+ + getCurrentLineNumber());
+ state = STATE_IN_MARKED_SECTION;
+ } else if (consumeMatch("<!DOCTYPE")) {
+ log
+ .debug("DOCTYPE found at line "
+ + getCurrentLineNumber());
+ // we don't need to actually do anything here; the
+ // tag can't contain a bare "<", so the first "<"
+ // indicates the start of the next real tag.
+ //
+ // TODO: Handle case where the DOCTYPE includes an internal
+ // DTD. In
+ // that case there *will* be embedded < chars in the
+ // document. However
+ // that's very unlikely to be used in a JSF page, so this is
+ // pretty low
+ // priority.
+ } else if (consumeMatch("<?")) {
+ // xml processing instruction or <!DOCTYPE> tag
+ // we don't need to actually do anything here; the
+ // tag can't contain a bare "<", so the first "<"
+ // indicates the start of the next real tag.
+ log.debug("PI found at line " + getCurrentLineNumber());
+ } else if (consumeMatch("</")) {
+ if (!processEndTag()) {
+ // message already logged
+ return;
+ }
+
+ // stay in state READY
+ state = STATE_READY;
+ } else if (consumeMatch("<")) {
+ // We can't tell the user that the tag has closed until
+ // after we have
+ // processed any attributes and found the real end of the
+ // tag. So save
+ // the current info until the end of this tag.
+ currentTagStart = this._offset - 1;
+ currentTagName = consumeElementName();
+ if (currentTagName == null) {
+ log
+ .warn("Invalid HTML; bare lessthan sign found at line "
+ + getCurrentLineNumber());
+ // remain in STATE_READY; this isn't really the start of
+ // an xml element.
+ } else {
+ state = STATE_IN_TAG;
+ }
+ } else {
+ // should never get here
+ throw new Error("Internal error at line "
+ + getCurrentLineNumber());
+ }
+
+ continue;
+ }
+
+ if (state == STATE_IN_COMMENT) {
+ // TODO: handle "-- >", which is a valid way to close a
+ // comment according to the specs.
+
+ // in this state, nothing but "--" has any significance
+ consumeExcept("-");
+ if (isFinished()) {
+ break;
+ }
+
+ if (consumeMatch("-->")) {
+ state = STATE_READY;
+ } else {
+ // false call; hyphen is not end of comment
+ consumeMatch("-");
+ }
+
+ continue;
+ }
+
+ if (state == STATE_IN_TAG) {
+ consumeWhitespace();
+
+ if (consumeMatch("/>")) {
+ // ok, end of element
+ state = STATE_READY;
+ closedTag(currentTagStart, this._offset, currentTagName);
+
+ // and reset vars just in case...
+ currentTagStart = -1;
+ currentTagName = null;
+ } else if (consumeMatch(">")) {
+ if (currentTagName.equalsIgnoreCase("script")
+ || currentTagName.equalsIgnoreCase("style")) {
+ // We've just started a special tag which can contain
+ // anything except
+ // the ETAGO marker ("</"). See
+ // http://www.w3.org/TR/REC-html40/appendix/notes.html#notes-specifying-data
+ state = STATE_EXPECTING_ETAGO;
+ } else {
+ state = STATE_READY;
+ }
+
+ // end of open tag, but not end of element
+ openedTag(currentTagStart, this._offset, currentTagName);
+
+ // and reset vars just in case...
+ currentTagStart = -1;
+ currentTagName = null;
+ } else {
+ // xml attribute
+ String attrName = consumeAttrName();
+ if (attrName == null) {
+ // Oops, we found something quite unexpected in this
+ // tag.
+ // The best we can do is probably to drop back to
+ // looking
+ // for "/>", though that does risk us misinterpreting
+ // the
+ // contents of an attribute's associated string value.
+ log
+ .warn("Invalid tag found: unexpected input while looking for attr name or '/>'"
+ + " at line " + getCurrentLineNumber());
+ state = STATE_EXPECTING_ETAGO;
+ // and consume one character
+ ++this._offset;
+ } else {
+ consumeWhitespace();
+
+ // html can have "stand-alone" attributes with no
+ // following equals sign
+ if (consumeMatch("=")) {
+ String attrValue = consumeAttrValue();
+ }
+ }
+ }
+
+ continue;
+ }
+
+ if (state == STATE_IN_MARKED_SECTION) {
+ // in this state, nothing but "]]>" has any significance
+ consumeExcept("]");
+ if (isFinished()) {
+ break;
+ }
+
+ if (consumeMatch("]]>")) {
+ state = STATE_READY;
+ } else {
+ // false call; ] is not end of cdata section
+ consumeMatch("]");
+ }
+
+ continue;
+ }
+
+ if (state == STATE_EXPECTING_ETAGO) {
+ // The term "ETAGO" is the official spec term for "</".
+ consumeExcept("<");
+ if (isFinished()) {
+ log
+ .debug("Malformed input page; input terminated while tag not closed.");
+ break;
+ }
+
+ if (consumeMatch("</")) {
+ if (!processEndTag()) {
+ return;
+ }
+ state = STATE_READY;
+ } else {
+ // false call; < does not start an ETAGO
+ consumeMatch("<");
+ }
+
+ continue;
+ }
+ }
+ }
+
+ /**
+ * Invoked when "</" has been seen in the input, this method handles the
+ * parsing of the end tag and the invocation of the appropriate callback
+ * method.
+ *
+ * @return true if the tag was successfully parsed, and false if there was a
+ * fatal parsing error.
+ */
+ private boolean processEndTag() {
+ int tagStart = this._offset - 2;
+ String tagName = consumeElementName();
+ consumeWhitespace();
+ if (!consumeMatch(">")) {
+ log.error("Malformed end tag at line " + getCurrentLineNumber()
+ + "; skipping parsing");
+ return false;
+ }
+
+ // inform user that the tag has been closed
+ closedTag(tagStart, this._offset, tagName);
+
+ // We can't verify that the tag names balance because this is HTML
+ // we are processing, not XML.
+ return true;
+ }
+
+ /**
+ * Invoke a callback method to inform the listener that we have found a
+ * start tag.
+ *
+ * @param startOffset
+ * @param endOffset
+ * @param tagName
+ */
+ void openedTag(int startOffset, int endOffset, String tagName) {
+ // log.debug("Found open tag at " + startOffset + ":" + endOffset + ":"
+ // + tagName);
+
+ if ("head".equalsIgnoreCase(tagName)) {
+ this._listener.openedStartTag(startOffset, HEAD_TAG);
+ this._listener.closedStartTag(endOffset, HEAD_TAG);
+ } else if ("body".equalsIgnoreCase(tagName)) {
+ this._listener.openedStartTag(startOffset, BODY_TAG);
+ this._listener.closedStartTag(endOffset, BODY_TAG);
+ } else if ("script".equalsIgnoreCase(tagName)) {
+ this._listener.openedStartTag(startOffset, SCRIPT_TAG);
+ this._listener.closedStartTag(endOffset, SCRIPT_TAG);
+ }
+ }
+
+ void closedTag(int startOffset, int endOffset, String tagName) {
+ // log.debug("Found close tag at " + startOffset + ":" + endOffset + ":"
+ // + tagName);
+
+ if ("head".equalsIgnoreCase(tagName)) {
+ this._listener.openedEndTag(startOffset, HEAD_TAG);
+ this._listener.closedEndTag(endOffset, HEAD_TAG);
+ } else if ("body".equalsIgnoreCase(tagName)) {
+ this._listener.openedEndTag(startOffset, BODY_TAG);
+ this._listener.closedEndTag(endOffset, BODY_TAG);
+ } else if ("script".equalsIgnoreCase(tagName)) {
+ this._listener.openedEndTag(startOffset, SCRIPT_TAG);
+ this._listener.closedEndTag(endOffset, SCRIPT_TAG);
+ }
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity (from rev 14075, branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/velocity)
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/AntFileResourceLoader.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/velocity/AntFileResourceLoader.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/AntFileResourceLoader.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.velocity;
+package org.richfaces.templatecompiler.velocity;
import java.io.BufferedInputStream;
import java.io.File;
Modified: branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/BuilderContext.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/java/org/ajax4jsf/templatecompiler/velocity/BuilderContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/main/java/org/richfaces/templatecompiler/velocity/BuilderContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.templatecompiler.velocity;
+package org.richfaces.templatecompiler.velocity;
import org.apache.velocity.context.AbstractContext;
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/plexus/components.xml 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/plexus/components.xml 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,17 +1,17 @@
<component-set>
<components>
<component>
- <role>org.ajax4jsf.templatecompiler.elements.ElementsFactory</role>
+ <role>org.richfaces.templatecompiler.elements.ElementsFactory</role>
<role-hint>a4j</role-hint>
<implementation>
- org.ajax4jsf.templatecompiler.elements.A4JRendererElementsFactory
+ org.richfaces.templatecompiler.elements.A4JRendererElementsFactory
</implementation>
</component>
<component>
- <role>org.ajax4jsf.templatecompiler.elements.ElementsFactory</role>
+ <role>org.richfaces.templatecompiler.elements.ElementsFactory</role>
<role-hint>jstl</role-hint>
<implementation>
- org.ajax4jsf.templatecompiler.elements.JSTLElementsFactory
+ org.richfaces.templatecompiler.elements.JSTLElementsFactory
</implementation>
</component>
</components>
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/component.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/component.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/component.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -15,7 +15,7 @@
import java.io.IOException;
import javax.faces.FacesException;
-import org.ajax4jsf.framework.util.base64.Codec;
+import org.richfaces.framework.util.base64.Codec;
#end
/**
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componentTag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -54,7 +54,7 @@
// Release
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#release()
*/
public void release()
{
@@ -68,7 +68,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componenttest.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componenttest.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/componenttest.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -16,14 +16,14 @@
import javax.faces.el.ValueBinding;
import javax.faces.component.UIViewRoot;
-import org.ajax4jsf.tests.MockValueBinding;
+import org.richfaces.tests.MockValueBinding;
//import ${component.classname};
#if(${generator.key})
import java.io.IOException;
import javax.faces.FacesException;
-import org.ajax4jsf.framework.util.base64.Codec;
+import org.richfaces.framework.util.base64.Codec;
#end
public class $component.test.simpleClassName extends $component.test.superclassname {
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/listener_tag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -39,7 +39,7 @@
import org.apache.commons.beanutils.ConvertUtils;
-import org.ajax4jsf.Messages;
+import org.richfaces.Messages;
public class $tag.simpleClassName extends TagSupport {
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/renderer.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/renderer.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/renderer.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -15,7 +15,7 @@
public class ${renderer.simpleClassName} extends ${renderer.superclass} {
/**
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ * @see org.richfaces.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
// Expected component class for rendering
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/tag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/tag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/tag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -59,7 +59,7 @@
// Release
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#release()
*/
public void release()
{
@@ -73,7 +73,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates/templatecompiler/ComponentTemplate.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -45,14 +45,14 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.ComponentsVariableResolver;
-import org.ajax4jsf.renderkit.ComponentVariables;
+import org.richfaces.renderkit.ComponentsVariableResolver;
+import org.richfaces.renderkit.ComponentVariables;
#end
#if($component.fullBaseclass)
import $component.fullBaseclass;
#else
-import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.renderkit.RendererBase;
#end
#if($component.baseclassName)
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componentTag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -31,7 +31,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/componenttest.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -17,14 +17,14 @@
import javax.faces.el.ValueBinding;
import javax.faces.component.UIViewRoot;
-import org.ajax4jsf.tests.MockValueBinding;
+import org.richfaces.tests.MockValueBinding;
//import ${component.classname};
#if(${generator.key})
import java.io.IOException;
import javax.faces.FacesException;
-import org.ajax4jsf.framework.util.base64.Codec;
+import org.richfaces.framework.util.base64.Codec;
#end
public class $component.test.simpleClassName extends $component.test.superclassname {
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/listener_tag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -39,7 +39,7 @@
import org.apache.commons.beanutils.ConvertUtils;
-import org.ajax4jsf.Messages;
+import org.richfaces.Messages;
public class $tag.simpleClassName extends TagSupport {
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/renderer.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -15,7 +15,7 @@
public class ${renderer.simpleClassName} extends ${renderer.superclass} {
/**
- * @see org.ajax4jsf.renderkit.RendererBase#getComponentClass()
+ * @see org.richfaces.renderkit.RendererBase#getComponentClass()
*/
protected Class getComponentClass() {
// Expected component class for rendering
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tag.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tag.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -59,7 +59,7 @@
// Release
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#release()
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#release()
*/
public void release()
{
@@ -73,7 +73,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
+ * @see org.richfaces.components.taglib.html.HtmlCommandButtonTagBase#setProperties(javax.faces.component.UIComponent)
*/
protected void setProperties(UIComponent component)
{
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/tagtest.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -5,7 +5,7 @@
package ${tag.packageName};
import static org.easymock.classextension.EasyMock.*;
-import static org.ajax4jsf.tests.JsfMock.*;
+import static org.richfaces.tests.JsfMock.*;
#foreach($import in $imports)
import $import ;
@@ -38,12 +38,12 @@
import javax.servlet.jsp.el.ExpressionEvaluator;
import javax.servlet.jsp.el.VariableResolver;
import javax.servlet.jsp.tagext.Tag;
-import org.ajax4jsf.tests.MockMethodExpression;
+import org.richfaces.tests.MockMethodExpression;
import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
import java.util.ArrayList;
-import org.ajax4jsf.tests.Condition;
+import org.richfaces.tests.Condition;
/**
* @author Maksim Kaszynski
@@ -146,7 +146,7 @@
verify(component);
#elseif($prop.isInstanceof("javax.el.ValueExpression"))
- final ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ final ValueExpression expression = new org.richfaces.tests.MockValueExpression("#{bean.${prop.name}}");
component.${prop.setterName}(same(expression));
expectLastCall().once();
replay(component);
@@ -154,7 +154,7 @@
tag.setProperties(component);
verify(component);
#elseif($prop.isInstanceof("javax.faces.el.ValueBinding"))
- final ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ final ValueExpression expression = new org.richfaces.tests.MockValueExpression("#{bean.${prop.name}}");
component.${prop.setterName}(vbEqToVe(expression));
//Then test literal one
expectLastCall().once();
@@ -165,7 +165,7 @@
verify(component);
#elseif($prop.el)
//el=true
- ValueExpression expression = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ ValueExpression expression = new org.richfaces.tests.MockValueExpression("#{bean.${prop.name}}");
component.setValueExpression(eq("${prop.name}"), same(expression));
expectLastCall().once();
replay(component);
@@ -174,7 +174,7 @@
verify(component);
#if($prop.name == 'converter' || $prop.name == 'rowKeyConverter')
String converterType = this.getClass().getName();
- expression = new org.ajax4jsf.tests.LiteralValueExpression(converterType);
+ expression = new org.richfaces.tests.LiteralValueExpression(converterType);
reset(component);
component.${prop.setterName}(isA(MyConverter.class));
tag.${prop.setterName}(expression);
@@ -185,7 +185,7 @@
//In case of literal VE
${prop.classname} _${prop.name} = ${testDataGenerator.getTestVeData($prop)};
reset(component);
- expression = new org.ajax4jsf.tests.LiteralValueExpression(_${prop.name});
+ expression = new org.richfaces.tests.LiteralValueExpression(_${prop.name});
component.${prop.setterName}(eq(_${prop.name}));
expectLastCall().once();
@@ -196,7 +196,7 @@
try {
//Now test evaluation of literal
- expression = new org.ajax4jsf.tests.ConstantlyFailingLiteralValueExpression();
+ expression = new org.richfaces.tests.ConstantlyFailingLiteralValueExpression();
tag.${prop.setterName}(expression);
tag.setProperties(component);
fail("An exception should be thrown");
@@ -247,10 +247,10 @@
#if( !$prop.existintag && !$prop.hidden)
//First check EL-properties (value and method expressions)
#if($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
- MethodExpression ${prop.name}Me = new org.ajax4jsf.tests.MockMethodExpression("#{bean.${prop.name}}", null, null);
+ MethodExpression ${prop.name}Me = new org.richfaces.tests.MockMethodExpression("#{bean.${prop.name}}", null, null);
tag.${prop.setterName}(${prop.name}Me);
#elseif ($prop.el)
- ValueExpression ${prop.name}Ve = new org.ajax4jsf.tests.MockValueExpression("#{bean.${prop.name}}");
+ ValueExpression ${prop.name}Ve = new org.richfaces.tests.MockValueExpression("#{bean.${prop.name}}");
tag.${prop.setterName}(${prop.name}Ve);
#end
#end
@@ -269,10 +269,10 @@
//First check EL-properties (value and method expressions)
#if($prop.isInstanceof("javax.el.MethodExpression") || $prop.isInstanceof("javax.faces.el.MethodBinding"))
#if (!$prop.elonly)
- tag.${prop.setterName}(new org.ajax4jsf.tests.MockMethodExpression("${prop.name}", null, null));
+ tag.${prop.setterName}(new org.richfaces.tests.MockMethodExpression("${prop.name}", null, null));
#end
#elseif ($prop.el && !$prop.elonly && ${testDataGenerator.isNativelySupported($prop)})
- tag.${prop.setterName}(new org.ajax4jsf.tests.LiteralValueExpression(String.valueOf(${testDataGenerator.getTestVeData($prop)})));
+ tag.${prop.setterName}(new org.richfaces.tests.LiteralValueExpression(String.valueOf(${testDataGenerator.getTestVeData($prop)})));
#elseif (!$prop.el && ${testDataGenerator.isNativelySupported($prop)})
tag.${prop.setterName}(String.valueOf(${testDataGenerator.getTestVeData($prop)}));
#end
Modified: branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/ComponentTemplate.vm
===================================================================
--- branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/ComponentTemplate.vm 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/main/resources/META-INF/templates12/templatecompiler/ComponentTemplate.vm 2009-06-09 22:53:29 UTC (rev 14575)
@@ -45,14 +45,14 @@
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import org.ajax4jsf.renderkit.ComponentsVariableResolver;
-import org.ajax4jsf.renderkit.ComponentVariables;
+import org.richfaces.renderkit.ComponentsVariableResolver;
+import org.richfaces.renderkit.ComponentVariables;
#end
#if($component.fullBaseclass)
import $component.fullBaseclass;
#else
-import org.ajax4jsf.renderkit.RendererBase;
+import org.richfaces.renderkit.RendererBase;
#end
#if($component.baseclassName)
Deleted: branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/AppTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/AppTest.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/AppTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,59 +0,0 @@
-/**
- * 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.ajax4jsf;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Unit test for simple App.
- */
-public class AppTest
- extends TestCase
-{
- /**
- * Create the test case
- *
- * @param testName name of the test case
- */
- public AppTest( String testName )
- {
- super( testName );
- }
-
- /**
- * @return the suite of tests being tested
- */
- public static Test suite()
- {
- return new TestSuite( AppTest.class );
- }
-
- /**
- * Rigourous Test :-)
- */
- public void testApp()
- {
- assertTrue( true );
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/AppTest.java (from rev 14075, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/AppTest.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/AppTest.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/AppTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,59 @@
+/**
+ * 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;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ */
+public class AppTest
+ extends TestCase
+{
+ /**
+ * Create the test case
+ *
+ * @param testName name of the test case
+ */
+ public AppTest( String testName )
+ {
+ super( testName );
+ }
+
+ /**
+ * @return the suite of tests being tested
+ */
+ public static Test suite()
+ {
+ return new TestSuite( AppTest.class );
+ }
+
+ /**
+ * Rigourous Test :-)
+ */
+ public void testApp()
+ {
+ assertTrue( true );
+ }
+}
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/config (from rev 14075, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/config)
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/config/ClassWalkingLogicTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/config/ClassWalkingLogicTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/config/ClassWalkingLogicTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.config;
+package org.richfaces.builder.config;
import java.util.ArrayList;
import java.util.List;
@@ -29,6 +29,9 @@
import javax.faces.component.UIComponent;
import javax.faces.component.html.HtmlCommandButton;
+import org.richfaces.builder.config.ClassVisitor;
+import org.richfaces.builder.config.ClassWalkingLogic;
+
import junit.framework.TestCase;
/**
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator (from rev 14075, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator)
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClass.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/AbstractClass.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClass.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClassStubBuilderTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/AbstractClassStubBuilderTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/AbstractClassStubBuilderTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,12 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
import java.lang.reflect.Method;
+import org.richfaces.builder.generator.AbstractClassStubBuilder;
+
import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import junit.framework.TestCase;
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseClass.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/BaseClass.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseClass.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,49 +19,49 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
public abstract class BaseClass implements BaseInterface {
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test()
+ * @see org.richfaces.builder.generator.BaseInterface#test()
*/
public abstract float test();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test1()
+ * @see org.richfaces.builder.generator.BaseInterface#test1()
*/
public abstract double test1();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test2()
+ * @see org.richfaces.builder.generator.BaseInterface#test2()
*/
public abstract short test2();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test3()
+ * @see org.richfaces.builder.generator.BaseInterface#test3()
*/
public abstract long test3();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test4()
+ * @see org.richfaces.builder.generator.BaseInterface#test4()
*/
public abstract float test4();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test5()
+ * @see org.richfaces.builder.generator.BaseInterface#test5()
*/
public abstract int test5();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test6()
+ * @see org.richfaces.builder.generator.BaseInterface#test6()
*/
public abstract String test6();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test7()
+ * @see org.richfaces.builder.generator.BaseInterface#test7()
*/
public abstract void test7();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test8()
+ * @see org.richfaces.builder.generator.BaseInterface#test8()
*/
public abstract boolean test8();
/* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.BaseInterface#test9()
+ * @see org.richfaces.builder.generator.BaseInterface#test9()
*/
public abstract char test9();
}
\ No newline at end of file
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseInterface.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/BaseInterface.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/BaseInterface.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
public interface BaseInterface {
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/ClassPatternSetTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/generator/ClassPatternSetTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/generator/ClassPatternSetTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,8 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.generator;
+package org.richfaces.builder.generator;
+import org.richfaces.builder.generator.ClassPatternSet;
+
import junit.framework.TestCase;
/**
@@ -56,7 +58,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#setExcludes(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#setExcludes(java.lang.String)}.
*/
public void testSetExcludes() {
patterns.setExcludes("a");
@@ -66,7 +68,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#setExcludes(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#setExcludes(java.lang.String)}.
*/
public void testSetExcludes1() {
patterns.setExcludes("a,b");
@@ -77,7 +79,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#setIncludes(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#setIncludes(java.lang.String)}.
*/
public void testSetIncludes() {
patterns.setIncludes("a");
@@ -87,7 +89,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
*/
public void testMatchClassExclude() {
patterns.setExcludes("**.Abst*,b.**");
@@ -97,7 +99,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
*/
public void testMatchClassInclude() {
patterns.setIncludes("**.UI*,a.**");
@@ -107,7 +109,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#matchClass(java.lang.String)}.
*/
public void testMatchClassIncExclude() {
patterns.setExcludes("**.Abst*,b.**");
@@ -118,7 +120,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#matchPath(java.lang.String, java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#matchPath(java.lang.String, java.lang.String)}.
*/
public void testMatchPath() {
assertTrue(patterns.matchPath("**.D", "a.b.D"));
@@ -128,7 +130,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#match(java.lang.String, java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#match(java.lang.String, java.lang.String)}.
*/
public void testMatch() {
assertTrue(patterns.match("a", "a"));
@@ -147,7 +149,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.generator.ClassPatternSet#tokenizePathAsArray(java.lang.String)}.
+ * Test method for {@link org.richfaces.builder.generator.ClassPatternSet#tokenizePathAsArray(java.lang.String)}.
*/
public void testTokenizePathAsArray() {
String[] strings = patterns.tokenizePathAsArray("a.b.c");
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml (from rev 14075, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml)
Deleted: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,64 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import junit.framework.TestCase;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XMLBodyMergeTest extends TestCase {
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.w3c.dom.Node)}.
- */
- public void testAddNode() {
- XMLBodyMerge merge = new XMLBodyMerge("//node()");
-
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#add(org.ajax4jsf.builder.xml.XMLBody)}.
- */
- public void testAddXMLBody() {
- //fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getLength()}.
- */
- public void testGetLength() {
- //fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#item(int)}.
- */
- public void testItem() {
- //fail("Not yet implemented");
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodyMerge#getContent()}.
- */
- public void testGetContent() {
- //fail("Not yet implemented");
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java (from rev 14245, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyMergeTest.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyMergeTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,84 @@
+/**
+ * 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.builder.xml;
+
+import org.richfaces.builder.xml.XMLBodyMerge;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodyMergeTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodyMerge#add(org.w3c.dom.Node)}.
+ */
+ public void testAddNode() {
+ XMLBodyMerge merge = new XMLBodyMerge("//node()");
+
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodyMerge#add(org.richfaces.builder.xml.XMLBody)}.
+ */
+ public void testAddXMLBody() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodyMerge#getLength()}.
+ */
+ public void testGetLength() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodyMerge#item(int)}.
+ */
+ public void testItem() {
+ //fail("Not yet implemented");
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodyMerge#getContent()}.
+ */
+ public void testGetContent() {
+ //fail("Not yet implemented");
+ }
+
+}
Deleted: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,73 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.ajax4jsf.builder.config.ParsingException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import junit.framework.TestCase;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XMLBodySerializerTest extends TestCase {
-
- private XMLBodySerializer serializer;
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- serializer = new XMLBodySerializer();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- serializer = null;
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
- */
- public void testSerialize() throws ParsingException{
- String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
- + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
- + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
- + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
-
- NodeList singleElementList = body.getByXpath("/faces-config");
- assertEquals(1, singleElementList.getLength());
- Node node = singleElementList.item(0);
- assertNotNull(node);
- assertEquals("faces-config", node.getNodeName());
- String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
- String expected = "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
- assertEquals(expected, actual);
-
- NodeList children = node.getChildNodes();
- actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
- expected = "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
- assertEquals(expected, actual);
-
-
- }
-
-}
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java (from rev 14245, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodySerializerTest.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodySerializerTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,93 @@
+/**
+ * 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.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.XMLBody;
+import org.richfaces.builder.xml.XMLBodySerializer;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XMLBodySerializerTest extends TestCase {
+
+ private XMLBodySerializer serializer;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ serializer = new XMLBodySerializer();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ serializer = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.richfaces.builder.xml.XMLBodySerializer#serialize(org.w3c.dom.NodeList, org.w3c.dom.Document)}.
+ */
+ public void testSerialize() throws ParsingException{
+ String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
+ + "<!DOCTYPE faces-config PUBLIC \"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN\"\n"
+ + " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ + "<faces-config>\n" + " <component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>\n"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+
+ NodeList singleElementList = body.getByXpath("/faces-config");
+ assertEquals(1, singleElementList.getLength());
+ Node node = singleElementList.item(0);
+ assertNotNull(node);
+ assertEquals("faces-config", node.getNodeName());
+ String actual = serializer.serialize(singleElementList, node.getOwnerDocument()).replaceAll("\\s", "");
+ String expected = "<faces-config><component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component></faces-config>";
+ assertEquals(expected, actual);
+
+ NodeList children = node.getChildNodes();
+ actual = serializer.serialize(children, node.getOwnerDocument()).replaceAll("\\s", "");
+ expected = "<component><test>blabla</test></component><component><test>blabla</test></component><component><test>blabla2</test></component>";
+ assertEquals(expected, actual);
+
+
+ }
+
+}
Modified: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XMLBodyTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XMLBodyTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.xml;
+package org.richfaces.builder.xml;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@@ -27,7 +27,8 @@
import junit.framework.TestCase;
-import org.ajax4jsf.builder.config.ParsingException;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.XMLBody;
/**
* @author shura
@@ -55,7 +56,7 @@
/**
* Test method for
- * {@link org.ajax4jsf.builder.xml.XMLBody#loadXML(java.io.InputStream)}.
+ * {@link org.richfaces.builder.xml.XMLBody#loadXML(java.io.InputStream)}.
*
* @throws ParsingException
*/
@@ -65,11 +66,11 @@
+ " \"http://java.sun.com/dtd/web-facesconfig_1_1.dtd\">\n"
+ "<faces-config>\n"
+ " <component>\n"
- + " <component-type>org.ajax4jsf.ajax.Test</component-type>\n"
- + " <component-class>org.ajax4jsf.ajax.html.Test</component-class>\n"
+ + " <component-type>org.richfaces.ajax.Test</component-type>\n"
+ + " <component-class>org.richfaces.ajax.html.Test</component-class>\n"
+ "\n" + " <component-extension>\n"
- + " <component-family>org.ajax4jsf.Test</component-family>\n"
- + " <renderer-type>org.ajax4jsf.Test</renderer-type>\n"
+ + " <component-family>org.richfaces.Test</component-family>\n"
+ + " <renderer-type>org.richfaces.Test</renderer-type>\n"
+ " </component-extension>\n" + " </component>\n"
+ "</faces-config>";
InputStream in = new ByteArrayInputStream(xml.getBytes());
@@ -79,7 +80,7 @@
/**
* Test method for
- * {@link org.ajax4jsf.builder.xml.XMLBody#isRootName(java.lang.String)}.
+ * {@link org.richfaces.builder.xml.XMLBody#isRootName(java.lang.String)}.
*
* @throws ParsingException
*/
@@ -97,7 +98,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBody#getDoctype()}.
+ * Test method for {@link org.richfaces.builder.xml.XMLBody#getDoctype()}.
*
* @throws ParsingException
*/
@@ -117,7 +118,7 @@
/**
* Test method for
- * {@link org.ajax4jsf.builder.xml.XMLBody#getRootNameSpace()}.
+ * {@link org.richfaces.builder.xml.XMLBody#getRootNameSpace()}.
*
* @throws ParsingException
*/
@@ -132,7 +133,7 @@
}
/**
- * Test method for {@link org.ajax4jsf.builder.xml.XMLBody#getContent()}.
+ * Test method for {@link org.richfaces.builder.xml.XMLBody#getContent()}.
*
* @throws ParsingException
*/
Deleted: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,75 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.xml;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import junit.framework.TestCase;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class XPathComparatorTest extends TestCase {
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCompare() throws Exception{
- String xml = "<faces-config>" +
- "<component><test>blabla1</test></component>" +
- "<component><test>blabla</test></component>" +
- "<renderer><foo>blabla2</foo></renderer>" +
- "<component><test>blabla2</test></component>"
- + "</faces-config>";
- InputStream in = new ByteArrayInputStream(xml.getBytes());
- XMLBody body = new XMLBody();
- body.loadXML(in);
- NodeList list = body.getByXpath("//component|//renderer");
- assertEquals(4, list.getLength());
- Node node0 = list.item(0);
- Node node1 = list.item(1);
- Node node2 = list.item(2);
- Node node3 = list.item(3);
-
- XPathComparator dummyComparator = new XPathComparator();
- assertEquals(0, dummyComparator.compare(node0, node1));
- assertEquals(0, dummyComparator.compare(node1, node2));
- assertEquals(0, dummyComparator.compare(node0, node2));
- assertEquals(0, dummyComparator.compare(node0, node3));
- assertEquals(0, dummyComparator.compare(node2, node3));
- assertEquals(0, dummyComparator.compare(node1, node0));
- assertEquals(0, dummyComparator.compare(node2, node1));
- assertEquals(0, dummyComparator.compare(node2, node0));
-
- XPathComparator simpleComparator = new XPathComparator("local-name()");
- assertEquals(0, simpleComparator.compare(node0, node1));
- assertEquals(0, simpleComparator.compare(node0, node3));
- assertTrue(simpleComparator.compare(node0, node2) < 0);
- assertTrue(simpleComparator.compare(node2, node1) > 0);
-
- XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
- assertTrue(advancedComparator.compare(node0, node2) < 0);
- assertTrue(advancedComparator.compare(node2, node1) > 0);
- assertTrue(advancedComparator.compare(node0, node1) > 0);
- assertTrue(advancedComparator.compare(node1, node0) < 0);
-
-
- }
-}
Copied: branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java (from rev 14245, branches/jsf2.0/cdk/generator/src/test/java/org/ajax4jsf/builder/xml/XPathComparatorTest.java)
===================================================================
--- branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java (rev 0)
+++ branches/jsf2.0/cdk/generator/src/test/java/org/richfaces/builder/xml/XPathComparatorTest.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,95 @@
+/**
+ * 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.builder.xml;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.richfaces.builder.xml.XMLBody;
+import org.richfaces.builder.xml.XPathComparator;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class XPathComparatorTest extends TestCase {
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ public void testCompare() throws Exception{
+ String xml = "<faces-config>" +
+ "<component><test>blabla1</test></component>" +
+ "<component><test>blabla</test></component>" +
+ "<renderer><foo>blabla2</foo></renderer>" +
+ "<component><test>blabla2</test></component>"
+ + "</faces-config>";
+ InputStream in = new ByteArrayInputStream(xml.getBytes());
+ XMLBody body = new XMLBody();
+ body.loadXML(in);
+ NodeList list = body.getByXpath("//component|//renderer");
+ assertEquals(4, list.getLength());
+ Node node0 = list.item(0);
+ Node node1 = list.item(1);
+ Node node2 = list.item(2);
+ Node node3 = list.item(3);
+
+ XPathComparator dummyComparator = new XPathComparator();
+ assertEquals(0, dummyComparator.compare(node0, node1));
+ assertEquals(0, dummyComparator.compare(node1, node2));
+ assertEquals(0, dummyComparator.compare(node0, node2));
+ assertEquals(0, dummyComparator.compare(node0, node3));
+ assertEquals(0, dummyComparator.compare(node2, node3));
+ assertEquals(0, dummyComparator.compare(node1, node0));
+ assertEquals(0, dummyComparator.compare(node2, node1));
+ assertEquals(0, dummyComparator.compare(node2, node0));
+
+ XPathComparator simpleComparator = new XPathComparator("local-name()");
+ assertEquals(0, simpleComparator.compare(node0, node1));
+ assertEquals(0, simpleComparator.compare(node0, node3));
+ assertTrue(simpleComparator.compare(node0, node2) < 0);
+ assertTrue(simpleComparator.compare(node2, node1) > 0);
+
+ XPathComparator advancedComparator = new XPathComparator("local-name()", "test/text()", "foo/text()");
+ assertTrue(advancedComparator.compare(node0, node2) < 0);
+ assertTrue(advancedComparator.compare(node2, node1) > 0);
+ assertTrue(advancedComparator.compare(node0, node1) > 0);
+ assertTrue(advancedComparator.compare(node1, node0) < 0);
+
+
+ }
+}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven (from rev 14075, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven)
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenCompilationContext.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenCompilationContext.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,15 +19,15 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.maven;
+package org.richfaces.builder.maven;
-import org.ajax4jsf.templatecompiler.builder.CompilationException;
-import org.ajax4jsf.templatecompiler.builder.AbstractCompilationContext;
-import org.ajax4jsf.templatecompiler.elements.ElementsFactory;
import org.apache.velocity.Template;
import org.apache.velocity.app.VelocityEngine;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.richfaces.templatecompiler.builder.AbstractCompilationContext;
+import org.richfaces.templatecompiler.builder.CompilationException;
+import org.richfaces.templatecompiler.elements.ElementsFactory;
/**
* @author shura
@@ -49,63 +49,63 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String)
*/
public void debug(String content) {
logger.debug(content);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#debug(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#debug(java.lang.String, java.lang.Throwable)
*/
public void debug(String content, Throwable error) {
logger.debug(content, error);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String)
*/
public void error(String content) {
logger.error(content);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#error(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#error(java.lang.String, java.lang.Throwable)
*/
public void error(String content, Throwable error) {
logger.error(content, error);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String)
*/
public void info(String content) {
logger.info(content);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#info(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#info(java.lang.String, java.lang.Throwable)
*/
public void info(String content, Throwable error) {
logger.info(content, error);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String)
*/
public void warn(String content) {
logger.warn(content);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#warn(java.lang.String, java.lang.Throwable)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#warn(java.lang.String, java.lang.Throwable)
*/
public void warn(String content, Throwable error) {
logger.warn(content, error);
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#getElementsFactory()
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#getElementsFactory()
*/
public ElementsFactory getElementsFactory() {
// TODO Auto-generated method stub
@@ -113,7 +113,7 @@
}
/* (non-Javadoc)
- * @see org.ajax4jsf.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
+ * @see org.richfaces.templatecompiler.builder.CompilationContext#getTemplate(java.lang.String)
*/
public Template getTemplate(String name) throws CompilationException {
try {
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenLogger.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenLogger.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,10 +19,10 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.maven;
+package org.richfaces.builder.maven;
-import org.ajax4jsf.builder.generator.Logger;
import org.apache.maven.plugin.logging.Log;
+import org.richfaces.builder.generator.Logger;
/**
* @author shura
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,120 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.maven;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.xml.XMLBody;
-import org.ajax4jsf.builder.xml.XMLBodyMerge;
-import org.ajax4jsf.builder.xml.XPathComparator;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.logging.Log;
-import org.codehaus.plexus.util.DirectoryScanner;
-
-/**
- * Class is used to locate and merge several xml files
- * @author Maksim Kaszynski
- *
- */
-public class MavenXMLMerge {
-
- class DirectoryItem {
- private File baseDir;
- private String [] includes;
- public DirectoryItem(File baseDir, String[] includes) {
- super();
- this.baseDir = baseDir;
- this.includes = includes;
- }
-
- }
-
- private boolean namespaceAware = false;
-
- private Log log;
-
- private String xPath;
-
- private String keyXPath;
-
- private String [] sortBy = {};
-
- private List<DirectoryItem> directories = new ArrayList<DirectoryItem>();
-
- public MavenXMLMerge() {
- }
-
- public void addDirectory(File dir, String [] includes) {
- directories.add(new DirectoryItem(dir, includes));
- }
-
- public void setSortBy(String ... sortBy) {
- this.sortBy = sortBy;
- }
-
- public void performMerge(XMLMergeCallback callback) throws MojoExecutionException {
- XMLBodyMerge merge = new XMLBodyMerge(xPath, keyXPath);
-
- for (DirectoryItem item : directories) {
- DirectoryScanner ds = new DirectoryScanner();
- ds.setFollowSymlinks(true);
- ds.setBasedir(item.baseDir);
- ds.setIncludes(item.includes);
- ds.addDefaultExcludes();
- ds.scan();
- String[] files = ds.getIncludedFiles();
- for (String file : files) {
- File sourceFile = new File(item.baseDir, file);
- if (log != null){
- log.info("Process file " + sourceFile.getPath());
- }
- try {
- XMLBody configBody = new XMLBody();
- configBody.loadXML(new FileInputStream(sourceFile), namespaceAware);
- merge.add(configBody);
-
- } catch (FileNotFoundException e) {
- throw new MojoExecutionException("Could't read file "
- + sourceFile.getPath(), e);
- } catch (ParsingException e) {
- throw new MojoExecutionException(
- "Error parsing config file "
- + sourceFile.getPath(), e);
- }
-
- }
- }
-
- if (sortBy != null) {
- merge.sort(new XPathComparator(sortBy));
- }
-
- try {
- callback.onMergeComplete(merge.getContent());
- } catch (Exception e) {
- throw new MojoExecutionException("Exception uring XML merge", e);
- }
- }
-
- public void setNamespaceAware(boolean namespaceAware) {
- this.namespaceAware = namespaceAware;
- }
-
- public void setLog(Log log) {
- this.log = log;
- }
-
- public void setXPath(String path) {
- xPath = path;
- }
-
- public void setKeyXPath(String keyXPath) {
- this.keyXPath = keyXPath;
- }
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/MavenXMLMerge.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/MavenXMLMerge.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,138 @@
+/**
+ * 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.builder.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.logging.Log;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.XMLBody;
+import org.richfaces.builder.xml.XMLBodyMerge;
+import org.richfaces.builder.xml.XPathComparator;
+
+/**
+ * Class is used to locate and merge several xml files
+ * @author Maksim Kaszynski
+ *
+ */
+public class MavenXMLMerge {
+
+ class DirectoryItem {
+ private File baseDir;
+ private String [] includes;
+ public DirectoryItem(File baseDir, String[] includes) {
+ super();
+ this.baseDir = baseDir;
+ this.includes = includes;
+ }
+
+ }
+
+ private boolean namespaceAware = false;
+
+ private Log log;
+
+ private String xPath;
+
+ private String keyXPath;
+
+ private String [] sortBy = {};
+
+ private List<DirectoryItem> directories = new ArrayList<DirectoryItem>();
+
+ public MavenXMLMerge() {
+ }
+
+ public void addDirectory(File dir, String [] includes) {
+ directories.add(new DirectoryItem(dir, includes));
+ }
+
+ public void setSortBy(String ... sortBy) {
+ this.sortBy = sortBy;
+ }
+
+ public void performMerge(XMLMergeCallback callback) throws MojoExecutionException {
+ XMLBodyMerge merge = new XMLBodyMerge(xPath, keyXPath);
+
+ for (DirectoryItem item : directories) {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(item.baseDir);
+ ds.setIncludes(item.includes);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (String file : files) {
+ File sourceFile = new File(item.baseDir, file);
+ if (log != null){
+ log.info("Process file " + sourceFile.getPath());
+ }
+ try {
+ XMLBody configBody = new XMLBody();
+ configBody.loadXML(new FileInputStream(sourceFile), namespaceAware);
+ merge.add(configBody);
+
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + sourceFile.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + sourceFile.getPath(), e);
+ }
+
+ }
+ }
+
+ if (sortBy != null) {
+ merge.sort(new XPathComparator(sortBy));
+ }
+
+ try {
+ callback.onMergeComplete(merge.getContent());
+ } catch (Exception e) {
+ throw new MojoExecutionException("Exception uring XML merge", e);
+ }
+ }
+
+ public void setNamespaceAware(boolean namespaceAware) {
+ this.namespaceAware = namespaceAware;
+ }
+
+ public void setLog(Log log) {
+ this.log = log;
+ }
+
+ public void setXPath(String path) {
+ xPath = path;
+ }
+
+ public void setKeyXPath(String keyXPath) {
+ this.keyXPath = keyXPath;
+ }
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,56 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.maven;
-
-import java.io.File;
-import java.io.FileWriter;
-
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class VelocityTaglibMergeCallBack implements XMLMergeCallback {
-
- private File target;
-
- private String template;
-
- private VelocityComponent velocity;
-
- private VelocityContext initialContext;
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.maven.XMLMergeCallback#onMergeComplete(java.lang.String)
- */
- public void onMergeComplete(String mergedContent) throws Exception{
-
- VelocityContext velocityContext;
-
- if (initialContext != null) {
- velocityContext = new VelocityContext(initialContext);
- } else {
- velocityContext = new VelocityContext();
- }
-
- VelocityEngine velocityEngine = velocity.getEngine();
- Template template2 = velocityEngine.getTemplate(template);
-
- File parentFile = target.getParentFile();
- if (!parentFile.exists()) {
- parentFile.mkdirs();
- }
-
- FileWriter fileWriter = new FileWriter(target);
-
- template2.merge(velocityContext, fileWriter);
- fileWriter.flush();
- fileWriter.close();
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/VelocityTaglibMergeCallBack.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/VelocityTaglibMergeCallBack.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,74 @@
+/**
+ * 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.builder.maven;
+
+import java.io.File;
+import java.io.FileWriter;
+
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class VelocityTaglibMergeCallBack implements XMLMergeCallback {
+
+ private File target;
+
+ private String template;
+
+ private VelocityComponent velocity;
+
+ private VelocityContext initialContext;
+
+ /* (non-Javadoc)
+ * @see org.richfaces.builder.maven.XMLMergeCallback#onMergeComplete(java.lang.String)
+ */
+ public void onMergeComplete(String mergedContent) throws Exception{
+
+ VelocityContext velocityContext;
+
+ if (initialContext != null) {
+ velocityContext = new VelocityContext(initialContext);
+ } else {
+ velocityContext = new VelocityContext();
+ }
+
+ VelocityEngine velocityEngine = velocity.getEngine();
+ Template template2 = velocityEngine.getTemplate(template);
+
+ File parentFile = target.getParentFile();
+ if (!parentFile.exists()) {
+ parentFile.mkdirs();
+ }
+
+ FileWriter fileWriter = new FileWriter(target);
+
+ template2.merge(velocityContext, fileWriter);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,13 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.maven;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public interface XMLMergeCallback {
- void onMergeComplete(String mergedContent) throws Exception;
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/maven/XMLMergeCallback.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/maven/XMLMergeCallback.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,31 @@
+/**
+ * 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.builder.maven;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public interface XMLMergeCallback {
+ void onMergeComplete(String mergedContent) throws Exception;
+
+}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo (from rev 14075, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo)
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,341 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.lang.reflect.Method;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.artifact.DependencyResolutionRequiredException;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
-import org.apache.velocity.exception.MethodInvocationException;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.codehaus.plexus.velocity.DefaultVelocityComponent;
-import org.codehaus.plexus.velocity.VelocityComponent;
-
-/**
- * @author shura
- *
- */
-public abstract class AbstractCDKMojo extends AbstractMojo {
-
- /**
- * Top maven project.
- *
- * @parameter expression="${project}"
- * @readonly
- */
- protected MavenProject project;
- /**
- *
- * @parameter
- */
- protected String key;
- /**
- * Place for component configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/component"
- */
- protected File componentConfigDirectory;
- /**
- * Place for validator configuration XML files. All '*.xml' files wil be
- * parsed as component config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/validator"
- */
- protected File validatorConfigDirectory;
-
- /**
- * Place for converter configuration XML files. All '*.xml' files wil be
- * parsed as components config. All '*.ent' files will be processed as
- * include configurations.
- *
- * @parameter expression="src/main/config/converter"
- */
- protected File converterConfigDirectory;
-
- /**
- * Place for faces configuration XML files
- *
- * @parameter expression="src/main/config/faces"
- */
- protected File facesConfigInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/taglib"
- */
- protected File taglibInclude;
- /**
- * Place for component configuration XML files
- *
- * @parameter expression="src/main/config/resources"
- */
- protected File resourcesInclude;
- /**
- *
- * @parameter expression="src/main/templates"
- */
- protected File templatesDirectory;
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/java"
- */
- protected File outputJavaDirectory;
-
- /**
- * @parameter expression="${project.build.directory}/generated-component/test"
- */
- protected File outputTestsDirectory;
-
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.directory}/generated-component/resources"
- */
- protected File outputResourcesDirectory;
- /**
- * @parameter
- */
- protected Library library;
- /**
- * The source directories containing the sources to be compiled.
- *
- * @parameter expression="${project.compileSourceRoots}"
- * @required
- * @readonly
- */
- protected List compileSourceRoots;
- /**
- * Project classpath.
- *
- * @parameter expression="${project.compileClasspathElements}"
- * @required
- * @readonly
- */
- protected List classpathElements;
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- protected File outputDirectory;
- /**
- * @component
- */
- protected VelocityComponent velocity;
- /**
- * Check library configuration, and fill all empty values to default.
- *
- * @return
- */
- protected Taglib checkLibraryConfig() {
- if (null != library) {
- getLog().debug("Library prefix is " + library.getPrefix());
- } else {
- library = new Library();
- }
- if (null == library.getPrefix()) {
- library.setPrefix(project.getGroupId());
-
- }
- getLog().debug("Default prefix for a generated packages: "+library.getPrefix());
- if (null == library.getDescription()) {
- library.setDescription(project.getDescription());
- }
- getLog().debug("Library description: "+library.getDescription());
- if( null == library.getJsfVersion()){
- String version = Library.JSF11;
- // Check version-specific methods in UIComponent class
- try {
- Class<?> componentClass = createProjectClassLoader(project, false).loadClass("javax.faces.component.UIComponent");
- Method[] methods = componentClass.getDeclaredMethods();
- for (int i = 0; i < methods.length; i++) {
- if("encodeAll".equals(methods[i].getName())){
- version = Library.JSF12;
- break;
- }
- }
- } catch (ClassNotFoundException e) {
- // Ignore - by defaule, generate codes for JSF 1.1
- }
- library.setJsfVersion(version);
- }
-
- //velocity = new DefaultVelocityComponent();
-
- getLog().debug("Generate files for a JSF "+library.getJsfVersion());
- Renderkit[] renderkits = library.getRenderkits();
- if (null != renderkits) {
- for (int i = 0; i < renderkits.length; i++) {
- Renderkit renderkit = renderkits[i];
- getLog().debug("Renderkit name is " + renderkit.getName());
- if(null == renderkit.getPackage()){
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- }
- }
- } else {
- renderkits = new Renderkit[1];
- Renderkit renderkit = new Renderkit();
- renderkit.setMarkup("html");
- renderkit.setName("HTML_BASIC");
- renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
- renderkits[0] = renderkit;
- library.setRenderkits(renderkits);
- }
- Taglib taglib = library.getTaglib();
- if (null != taglib) {
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- } else {
- taglib = new Taglib();
- library.setTaglib(taglib);
- }
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(project.getDescription());
-
- }
- if( null == taglib.getJspVersion()){
- // Jsf 1.2 can use JSP 2.1 only, other - 2.0
- taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12)?"2.1":"1.2");
- }
- if (null == taglib.getUri()) {
- String url = project.getUrl();
- if (null == url) {
- url = "http://";
- String[] parts = project.getGroupId().split(".");
- for (int i = parts.length - 1; i >= 0; i--) {
- url = url + parts[i];
- if (i > 0) {
- url = url + ".";
- }
- }
- url = url + "/" + project.getArtifactId();
- }
- taglib.setUri(url);
-
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(project.getArtifactId());
-
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
- if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
- for (int i = 0; i < library.getTaglibs().length; i++) {
- Taglib t = library.getTaglibs()[i];
- checkTaglib(t);
- }
- }
- return taglib;
- }
-
- protected void writeParsedTemplate(String templateName, VelocityContext context, File configFile) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception {
- File dir = configFile.getParentFile();
- if(!dir.exists()){
- dir.mkdirs();
- }
- VelocityEngine engine = velocity.getEngine();
- FileWriter fileWriter = new FileWriter(configFile);
- Template velocityTemplate = engine.getTemplate(templateName);
- velocityTemplate.merge(context, fileWriter);
- fileWriter.flush();
- fileWriter.close();
- }
-
- protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
- ClassLoader classLoader = Thread.currentThread()
- .getContextClassLoader();
- try {
- List<?> compileClasspathElements = project
- .getCompileClasspathElements();
- String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[compileClasspathElements.size() + 1];
- int i = 0;
- urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<?> iter = compileClasspathElements.iterator(); iter
- .hasNext();) {
- String element = (String) iter.next();
- urls[i++] = new File(element).toURI().toURL();
- }
-
- if (useCCL) {
- classLoader = new URLClassLoader(urls, classLoader);
- } else {
- classLoader = new URLClassLoader(urls);
- }
- } catch (MalformedURLException e) {
- getLog().error("Bad URL in classpath", e);
- } catch (DependencyResolutionRequiredException e) {
- getLog().error("Dependencies not resolved ", e);
- }
-
- return classLoader;
- }
-
- protected ClassLoader createProjectClassLoader(MavenProject project) {
- return createProjectClassLoader(project, true);
- }
-
- protected void checkTaglib(Taglib taglib) {
- if (null == taglib.getDisplayName()) {
- taglib.setDisplayName(library.getTaglib().getDisplayName());
- }
- if (null == taglib.getShortName()) {
- taglib.setShortName(library.getTaglib().getShortName());
- }
- if (null == taglib.getJspVersion()) {
- taglib.setJspVersion(library.getTaglib().getJspVersion());
- }
- if (null == taglib.getUri()) {
- taglib.setUri(library.getTaglib().getUri() + "/"
- + taglib.getShortName());
- }
- if(null == taglib.getTaglib()){
- taglib.setTaglib(taglib.getShortName());
- }
- getLog().debug("Taglib uri is " + taglib.getUri());
- getLog().debug("Taglib shortname is " + taglib.getShortName());
-
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCDKMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,361 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.VelocityContext;
+import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.exception.MethodInvocationException;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.codehaus.plexus.velocity.VelocityComponent;
+
+/**
+ * @author shura
+ *
+ */
+public abstract class AbstractCDKMojo extends AbstractMojo {
+
+ /**
+ * Top maven project.
+ *
+ * @parameter expression="${project}"
+ * @readonly
+ */
+ protected MavenProject project;
+ /**
+ *
+ * @parameter
+ */
+ protected String key;
+ /**
+ * Place for component configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/component"
+ */
+ protected File componentConfigDirectory;
+ /**
+ * Place for validator configuration XML files. All '*.xml' files wil be
+ * parsed as component config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/validator"
+ */
+ protected File validatorConfigDirectory;
+
+ /**
+ * Place for converter configuration XML files. All '*.xml' files wil be
+ * parsed as components config. All '*.ent' files will be processed as
+ * include configurations.
+ *
+ * @parameter expression="src/main/config/converter"
+ */
+ protected File converterConfigDirectory;
+
+ /**
+ * Place for faces configuration XML files
+ *
+ * @parameter expression="src/main/config/faces"
+ */
+ protected File facesConfigInclude;
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/taglib"
+ */
+ protected File taglibInclude;
+ /**
+ * Place for component configuration XML files
+ *
+ * @parameter expression="src/main/config/resources"
+ */
+ protected File resourcesInclude;
+ /**
+ *
+ * @parameter expression="src/main/templates"
+ */
+ protected File templatesDirectory;
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/java"
+ */
+ protected File outputJavaDirectory;
+
+ /**
+ * @parameter expression="${project.build.directory}/generated-component/test"
+ */
+ protected File outputTestsDirectory;
+
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.directory}/generated-component/resources"
+ */
+ protected File outputResourcesDirectory;
+ /**
+ * @parameter
+ */
+ protected Library library;
+ /**
+ * The source directories containing the sources to be compiled.
+ *
+ * @parameter expression="${project.compileSourceRoots}"
+ * @required
+ * @readonly
+ */
+ protected List compileSourceRoots;
+ /**
+ * Project classpath.
+ *
+ * @parameter expression="${project.compileClasspathElements}"
+ * @required
+ * @readonly
+ */
+ protected List classpathElements;
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.outputDirectory}"
+ * @required
+ * @readonly
+ */
+ protected File outputDirectory;
+ /**
+ * @component
+ */
+ protected VelocityComponent velocity;
+ /**
+ * Check library configuration, and fill all empty values to default.
+ *
+ * @return
+ */
+ protected Taglib checkLibraryConfig() {
+ if (null != library) {
+ getLog().debug("Library prefix is " + library.getPrefix());
+ } else {
+ library = new Library();
+ }
+ if (null == library.getPrefix()) {
+ library.setPrefix(project.getGroupId());
+
+ }
+ getLog().debug("Default prefix for a generated packages: "+library.getPrefix());
+ if (null == library.getDescription()) {
+ library.setDescription(project.getDescription());
+ }
+ getLog().debug("Library description: "+library.getDescription());
+ if( null == library.getJsfVersion()){
+ String version = Library.JSF11;
+ // Check version-specific methods in UIComponent class
+ try {
+ Class<?> componentClass = createProjectClassLoader(project, false).loadClass("javax.faces.component.UIComponent");
+ Method[] methods = componentClass.getDeclaredMethods();
+ for (int i = 0; i < methods.length; i++) {
+ if("encodeAll".equals(methods[i].getName())){
+ version = Library.JSF12;
+ break;
+ }
+ }
+ } catch (ClassNotFoundException e) {
+ // Ignore - by defaule, generate codes for JSF 1.1
+ }
+ library.setJsfVersion(version);
+ }
+
+ //velocity = new DefaultVelocityComponent();
+
+ getLog().debug("Generate files for a JSF "+library.getJsfVersion());
+ Renderkit[] renderkits = library.getRenderkits();
+ if (null != renderkits) {
+ for (int i = 0; i < renderkits.length; i++) {
+ Renderkit renderkit = renderkits[i];
+ getLog().debug("Renderkit name is " + renderkit.getName());
+ if(null == renderkit.getPackage()){
+ renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
+ }
+ }
+ } else {
+ renderkits = new Renderkit[1];
+ Renderkit renderkit = new Renderkit();
+ renderkit.setMarkup("html");
+ renderkit.setName("HTML_BASIC");
+ renderkit.setPackage(library.getPrefix()+".renderkit."+renderkit.getName().toLowerCase());
+ renderkits[0] = renderkit;
+ library.setRenderkits(renderkits);
+ }
+ Taglib taglib = library.getTaglib();
+ if (null != taglib) {
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ } else {
+ taglib = new Taglib();
+ library.setTaglib(taglib);
+ }
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(project.getDescription());
+
+ }
+ if( null == taglib.getJspVersion()){
+ // Jsf 1.2 can use JSP 2.1 only, other - 2.0
+ taglib.setJspVersion(library.getJsfVersion().equals(Library.JSF12)?"2.1":"1.2");
+ }
+ if (null == taglib.getUri()) {
+ String url = project.getUrl();
+ if (null == url) {
+ url = "http://";
+ String[] parts = project.getGroupId().split(".");
+ for (int i = parts.length - 1; i >= 0; i--) {
+ url = url + parts[i];
+ if (i > 0) {
+ url = url + ".";
+ }
+ }
+ url = url + "/" + project.getArtifactId();
+ }
+ taglib.setUri(url);
+
+ }
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(project.getArtifactId());
+
+ }
+ if(null == taglib.getTaglib()){
+ taglib.setTaglib(taglib.getShortName());
+ }
+
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
+ for (int i = 0; i < library.getTaglibs().length; i++) {
+ Taglib t = library.getTaglibs()[i];
+ checkTaglib(t);
+ }
+ }
+ return taglib;
+ }
+
+ private String createTaglibVersionFromProjectVersion() {
+ Artifact artifact = project.getArtifact();
+ String version = artifact.getVersion();
+ Matcher matcher = Pattern.compile("^(\\d+(?:\\.\\d+)*)").matcher(version);
+ if (matcher.find()) {
+ return matcher.group(1);
+ }
+
+ return "1.2";
+ }
+
+ protected void writeParsedTemplate(String templateName, VelocityContext context, File configFile) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException, Exception {
+ File dir = configFile.getParentFile();
+ if(!dir.exists()){
+ dir.mkdirs();
+ }
+ VelocityEngine engine = velocity.getEngine();
+ FileWriter fileWriter = new FileWriter(configFile);
+ Template velocityTemplate = engine.getTemplate(templateName);
+ velocityTemplate.merge(context, fileWriter);
+ fileWriter.flush();
+ fileWriter.close();
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project, boolean useCCL) {
+ ClassLoader classLoader = Thread.currentThread()
+ .getContextClassLoader();
+ try {
+ List<?> compileClasspathElements = project
+ .getCompileClasspathElements();
+ String outputDirectory = project.getBuild().getOutputDirectory();
+ URL[] urls = new URL[compileClasspathElements.size() + 1];
+ int i = 0;
+ urls[i++] = new File(outputDirectory).toURI().toURL();
+ for (Iterator<?> iter = compileClasspathElements.iterator(); iter
+ .hasNext();) {
+ String element = (String) iter.next();
+ urls[i++] = new File(element).toURI().toURL();
+ }
+
+ if (useCCL) {
+ classLoader = new URLClassLoader(urls, classLoader);
+ } else {
+ classLoader = new URLClassLoader(urls);
+ }
+ } catch (MalformedURLException e) {
+ getLog().error("Bad URL in classpath", e);
+ } catch (DependencyResolutionRequiredException e) {
+ getLog().error("Dependencies not resolved ", e);
+ }
+
+ return classLoader;
+ }
+
+ protected ClassLoader createProjectClassLoader(MavenProject project) {
+ return createProjectClassLoader(project, true);
+ }
+
+ protected void checkTaglib(Taglib taglib) {
+ if (null == taglib.getDisplayName()) {
+ taglib.setDisplayName(library.getTaglib().getDisplayName());
+ }
+ if (null == taglib.getShortName()) {
+ taglib.setShortName(library.getTaglib().getShortName());
+ }
+ if (null == taglib.getJspVersion()) {
+ taglib.setJspVersion(library.getTaglib().getJspVersion());
+ }
+ if (null == taglib.getUri()) {
+ taglib.setUri(library.getTaglib().getUri() + "/"
+ + taglib.getShortName());
+ }
+ if(null == taglib.getTaglib()){
+ taglib.setTaglib(taglib.getShortName());
+ }
+ if (null == taglib.getTlibVersion()) {
+ taglib.setTlibVersion(createTaglibVersionFromProjectVersion());
+ }
+ getLog().debug("Taglib uri is " + taglib.getUri());
+ getLog().debug("Taglib shortname is " + taglib.getShortName());
+ getLog().debug("Taglib version is " + taglib.getTlibVersion());
+ }
+
+}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCreateMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AbstractCreateMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCreateMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCreateMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,141 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.aja4jsf.builder.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * @author Nick Belaevski
+ *
+ */
+public abstract class AbstractCreateMojo extends AbstractCDKMojo {
+
+ protected static final String SRC_MAIN_RESOURCES = "src/main/resources";
+
+ protected static final Set<String> JAVA_RESERVED_WORDS;
+
+ static{
+ JAVA_RESERVED_WORDS = new HashSet<String>();
+ JAVA_RESERVED_WORDS.add("abstract");
+ JAVA_RESERVED_WORDS.add("assert");
+ JAVA_RESERVED_WORDS.add("boolean");
+ JAVA_RESERVED_WORDS.add("break");
+ JAVA_RESERVED_WORDS.add("byte");
+ JAVA_RESERVED_WORDS.add("case");
+ JAVA_RESERVED_WORDS.add("catch");
+ JAVA_RESERVED_WORDS.add("char");
+ JAVA_RESERVED_WORDS.add("class");
+ JAVA_RESERVED_WORDS.add("const");
+ JAVA_RESERVED_WORDS.add("continue");
+ JAVA_RESERVED_WORDS.add("default");
+ JAVA_RESERVED_WORDS.add("do");
+ JAVA_RESERVED_WORDS.add("double");
+ JAVA_RESERVED_WORDS.add("else");
+ JAVA_RESERVED_WORDS.add("extends");
+ JAVA_RESERVED_WORDS.add("false");
+ JAVA_RESERVED_WORDS.add("final");
+ JAVA_RESERVED_WORDS.add("finally");
+ JAVA_RESERVED_WORDS.add("float");
+ JAVA_RESERVED_WORDS.add("for");
+ JAVA_RESERVED_WORDS.add("goto");
+ JAVA_RESERVED_WORDS.add("if");
+ JAVA_RESERVED_WORDS.add("implements");
+ JAVA_RESERVED_WORDS.add("import");
+ JAVA_RESERVED_WORDS.add("instanceof");
+ JAVA_RESERVED_WORDS.add("int");
+ JAVA_RESERVED_WORDS.add("interface");
+ JAVA_RESERVED_WORDS.add("long");
+ JAVA_RESERVED_WORDS.add("native");
+ JAVA_RESERVED_WORDS.add("new");
+ JAVA_RESERVED_WORDS.add("null");
+ JAVA_RESERVED_WORDS.add("package");
+ JAVA_RESERVED_WORDS.add("private");
+ JAVA_RESERVED_WORDS.add("protected");
+ JAVA_RESERVED_WORDS.add("public");
+ JAVA_RESERVED_WORDS.add("return");
+ JAVA_RESERVED_WORDS.add("short");
+ JAVA_RESERVED_WORDS.add("static");
+ JAVA_RESERVED_WORDS.add("strictfp");
+ JAVA_RESERVED_WORDS.add("super");
+ JAVA_RESERVED_WORDS.add("switch");
+ JAVA_RESERVED_WORDS.add("synchronized");
+ JAVA_RESERVED_WORDS.add("this");
+ JAVA_RESERVED_WORDS.add("throw");
+ JAVA_RESERVED_WORDS.add("throws");
+ JAVA_RESERVED_WORDS.add("transient");
+ JAVA_RESERVED_WORDS.add("true");
+ JAVA_RESERVED_WORDS.add("try");
+ JAVA_RESERVED_WORDS.add("void");
+ JAVA_RESERVED_WORDS.add("volatile");
+ JAVA_RESERVED_WORDS.add("while");
+ }
+
+ protected void checkAndCreateDirectory(File directory)
+ throws MojoExecutionException {
+ getLog().debug("Checking directory " + directory + " for existence");
+ if (!directory.exists()) {
+ directory.mkdirs();
+ getLog().debug("Directory " + directory + " created");
+ }
+ if (!directory.isDirectory()) {
+ throw new MojoExecutionException("Directory " + directory.getAbsolutePath() + " is not a Directory");
+ }
+ }
+
+ protected void filterJarResource(Resource template, Resource skinResource, File baseDir,
+ VelocityContext context) throws Exception {
+ File newFile = new File(baseDir, skinResource.getPath());
+ if (newFile.exists()) {
+ getLog().debug("File " + newFile + " already exists. Skipping.");
+ } else {
+ try {
+ writeParsedTemplate(template.getPath(), context, newFile);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to write file " + newFile, e);
+ }
+ }
+ }
+
+ protected boolean isValidJavaName(String name) {
+ return !JAVA_RESERVED_WORDS.contains(name);
+ }
+
+ protected boolean isValidPackageName(String packageName) {
+ if (packageName != null) {
+ String[] packageNameSegments = packageName.split("\\.");
+ for (String packageNameSegment : packageNameSegments) {
+ if (!isValidJavaName(packageNameSegment)) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyAttachedLibraryMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyAttachedLibraryMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyAttachedLibraryMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.mojo;
+package org.richfaces.builder.mojo;
import java.io.File;
import java.io.FileInputStream;
@@ -38,11 +38,6 @@
import java.util.Map;
import java.util.Set;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.xml.NamesListComparator;
-import org.ajax4jsf.builder.xml.XMLBody;
-import org.ajax4jsf.builder.xml.XMLBodyMerge;
-import org.ajax4jsf.builder.xml.XPathComparator;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
@@ -63,6 +58,11 @@
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.NamesListComparator;
+import org.richfaces.builder.xml.XMLBody;
+import org.richfaces.builder.xml.XMLBodyMerge;
+import org.richfaces.builder.xml.XPathComparator;
import org.w3c.dom.Node;
/**
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,918 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.xml.NamesListComparator;
-import org.ajax4jsf.builder.xml.XMLBody;
-import org.ajax4jsf.builder.xml.XMLBodyMerge;
-import org.ajax4jsf.builder.xml.XPathComparator;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
-import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.apache.velocity.VelocityContext;
-import org.codehaus.plexus.archiver.UnArchiver;
-import org.codehaus.plexus.archiver.manager.ArchiverManager;
-import org.codehaus.plexus.util.DirectoryScanner;
-import org.w3c.dom.Node;
-
-/**
- * This plugin assembly full components library from modules, included in parent
- * project. Steps to create library : 1. Got parent project, and check modules
- * included in them. 2. For every module , build project and got it properties.
- * 3. Resolve module artifact, check for "jar" type and include/exclude
- * criteria. for accepted modules, unpack it to classes directory, and put
- * config files in separate directories. 4. Append unpacked directory to
- * resources, included in result jar. 5. Merge all META-INF/faces-config.xml ,
- * *.tld, *.taglib.xml , resources-config.xml into ones. 6. append dependencies
- * of included projects to this.
- *
- * @author shura
- * @goal assembly
- * @requiresDependencyResolution compile
- * @phase generate-resources
- */
-public class AssemblyLibraryMojo extends AbstractCDKMojo {
-
- private static final String TEMPLATES_PREFIX = "/templates/";
-
- private static final String TEMPLATES12_PREFIX = "/templates12/";
-
- private static final String FACES_CONFIG_TEMPLATE = "faces-config.vm";
-
- private static final String RESOURCES_CONFIG_TEMPLATE = "resources-config.vm";
-
- private static final String XCSS_TEMPLATE = "xcss.vm";
-
- private static final String TLD_TEMPLATE = "tld.vm";
-
- private static final String TAGLIB_TEMPLATE = "taglib.vm";
-
- private static final String[] TLD_TAG_NAMES = new String[] {
- "description", "display-name", "icon", "tlib-version",
- "short-name", "uri", "validator", "listener", "tag",
- "tag-file", "function", "taglib-extension"
- };
-
- private static final String[] TAGLIB_TAG_NAMES = new String[] {
- "library-class", "namespace", "tag", "function"
- };
-
- private static final Comparator<Node> TLD_COMPARATOR = new NamesListComparator(
- new XPathComparator("listener-class/text()", "name/text()"), TLD_TAG_NAMES);
-
- private static final Comparator<Node> FACELET_COMPARATOR = new NamesListComparator(
- new XPathComparator("function-name/text()", "tag-name/text()"), TAGLIB_TAG_NAMES);
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @component
- */
- private org.apache.maven.artifact.factory.ArtifactFactory factory;
-
- /**
- * Used to look up Artifacts in the remote repository.
- *
- * @component
- */
- private org.apache.maven.artifact.resolver.ArtifactResolver resolver;
-
- /**
- * The local repository.
- *
- * @parameter expression="${localRepository}"
- */
- private ArtifactRepository localRepository;
-
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @component
- */
- private ArchiverManager archiverManager;
-
- /**
- * Project builder
- *
- * @component
- */
- private MavenProjectBuilder mavenProjectBuilder;
-
- /**
- * The reactor projects.
- *
- * @parameter expression="${reactorProjects}"
- * @required
- * @readonly
- */
- private List reactorProjects;
-
- /**
- * The reactor projects.
- *
- * @parameter expression="${project.parent}"
- * @readonly
- */
- private MavenProject parentProject;
-
- /**
- * The list of resources we want to transfer.
- *
- * @parameter default-value="src/main/config"
- */
- private File config;
-
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- * @readonly
- */
- private File buildDirectory;
-
- /**
- * @parameter default-value="${project.build.directory}/modules"
- */
- private File modulesDirectory;
-
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.directory}/pom.xml"
- * @required
- * @readonly
- */
- private File generatedPom;
-
- /**
- * The directory for compiled classes.
- *
- * @parameter expression="${project.build.directory}/src"
- * @required
- * @readonly
- */
- private File modulesSrc;
-
- /**
- * @parameter
- */
- private String templates;
-
- /**
- * @parameter
- */
- private String includeTld = "META-INF/*.tld";
-
- /**
- * @parameter
- */
- private String includeTaglib = "META-INF/*.taglib.xml";
-
- /**
- * @parameter
- */
- private String includeXcss = "**/*.xcss";
-
- /**
- * @parameter
- */
- private String excludeXcss = null;
-
- /**
- * @parameter
- */
- private String commonStyle;
-
- /**
- * @parameter
- */
- private String templateXpath;
-
- /**
- *
- */
- public AssemblyLibraryMojo() {
- // used for plexus init.
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- setupParentProject();
- checkLibraryConfig();
- if (null == templates) {
- templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
- : TEMPLATES_PREFIX;
- }
- List<Model> models = extractModules();
- mergeFacesConfig(models);
- File resourcesConfig = new File(outputDirectory,
- "META-INF/resources-config.xml");
- mergeXML(models, "META-INF/resources-config.xml", null,
- RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
- "name/text()", new VelocityContext(), resourcesConfig, false, null);
- if (null != commonStyle) {
- File commonXcss = new File(outputDirectory, commonStyle);
- mergeXML(models, includeXcss, excludeXcss, XCSS_TEMPLATE,
- templateXpath, null, new VelocityContext(), commonXcss, true, null);
- }
-
- if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
- for (int i = 0; i < library.getTaglibs().length; i++) {
- Taglib taglib = library.getTaglibs()[i];
- List<Model> taglibModels;
- if (taglib.getIncludeModules() == null
- && taglib.getExcludeModules() == null) {
- taglibModels = models;
- } else {
- String[] includeModules = null;
- String[] excludeModules = null;
- if (null != taglib.getIncludeModules()) {
- includeModules = taglib.getIncludeModules().split(",");
- Arrays.sort(includeModules);
- }
- if (null != taglib.getExcludeModules()) {
- excludeModules = taglib.getExcludeModules().split(",");
- Arrays.sort(excludeModules);
- }
- taglibModels = new ArrayList<Model>();
- for (Iterator iterator = models.iterator(); iterator
- .hasNext();) {
- Model model = (Model) iterator.next();
- String id = model.getArtifactId();
- if ((includeModules == null || Arrays.binarySearch(
- includeModules, id) >= 0)
- && (excludeModules == null || Arrays
- .binarySearch(excludeModules, id) < 0)) {
- taglibModels.add(model);
- }
- }
- }
- generateTaglib(taglibModels, taglib);
- }
- } else {
- generateTaglib(models, library.getTaglib());
- }
- }
-
- /**
- * @param models
- * @throws MojoExecutionException
- */
- private void generateTaglib(List<Model> models, Taglib taglib)
- throws MojoExecutionException {
- getLog().debug(
- "Assembly taglib for uri " + taglib.getUri()
- + " with short name " + taglib.getShortName());
- VelocityContext taglibContext = new VelocityContext();
- taglibContext.put("taglib", taglib);
- // Build includes/excludes Xpath condition
- String nameTag = "name";
- createTagCondition(taglib, nameTag);
- File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
- + ".tld");
- getLog().debug("Write JSP taglib " + tld.getPath());
- String commonXPath = "/taglib/tag"
- + createTagCondition(taglib, "name") + " | /taglib/listener | /taglib/function";
-
- mergeXML(models, includeTld, null, TLD_TEMPLATE, commonXPath,
- "listener-class/text() | name/text()", new VelocityContext(taglibContext), tld, false, TLD_COMPARATOR);
-
-
- File faceletsTaglib = new File(outputDirectory, "META-INF/"
- + taglib.getTaglib() + ".taglib.xml");
- commonXPath = "/facelet-taglib/tag"
- + createTagCondition(taglib, "tag-name")
- + " | /facelet-taglib/function";
-
- mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, commonXPath, "tag-name/text() | function-name/text()", new VelocityContext(
- taglibContext), faceletsTaglib, false, FACELET_COMPARATOR);
- getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
- }
-
- /**
- * @param taglib
- * @param nameTag
- */
- private String createTagCondition(Taglib taglib, String nameTag) {
- StringBuffer condition = new StringBuffer();
- if (taglib.getIncludeTags() != null || taglib.getExcludeTags() != null) {
- condition.append('[');
- if (taglib.getIncludeTags() != null) {
- condition.append('(');
- String[] includes = taglib.getIncludeTags().split(",");
- for (int i = 0; i < includes.length; i++) {
- String includeTag = includes[i];
- if (i != 0) {
- condition.append(" or ");
- }
- condition.append("normalize-space(").append(nameTag)
- .append(")='").append(includeTag).append("'");
- }
- condition.append(')');
- }
- if (taglib.getIncludeTags() != null
- && taglib.getExcludeTags() != null) {
- condition.append(" and ");
- }
- if (taglib.getExcludeTags() != null) {
- condition.append('(');
- String[] excludes = taglib.getExcludeTags().split(",");
- for (int i = 0; i < excludes.length; i++) {
- String includeTag = excludes[i];
- if (i != 0) {
- condition.append(" and ");
- }
- condition.append("normalize-space(").append(nameTag)
- .append(")!='").append(includeTag).append("'");
- }
- condition.append(')');
- }
- condition.append(']');
- }
- return condition.toString();
- }
-
- /**
- * @return
- * @throws MojoExecutionException
- */
- private List<Model> extractModules() throws MojoExecutionException {
- List<String> modules = parentProject.getModules();
- List<Model> models = new ArrayList<Model>(modules.size());
- Map<String, Dependency> projectsDependencies = new HashMap<String, Dependency>();
- for (Iterator<String> iter = modules.iterator(); iter.hasNext();) {
- String moduleName = iter.next();
- getLog().info("Parent project have module " + moduleName);
- Model model;
- File f = new File(parentProject.getBasedir(), moduleName
- + "/pom.xml");
- if (f.exists()) {
- try {
- model = mavenProjectBuilder.build(f, localRepository, null)
- .getModel();
- } catch (ProjectBuildingException e) {
- throw new MojoExecutionException(
- "Unable to read local module-POM", e);
- }
- } else {
- getLog().warn("No filesystem module-POM available");
-
- model = new Model();
- model.setName(moduleName);
- model.setUrl(moduleName);
- }
- if (project.getGroupId().equals(model.getGroupId())
- && "jar".equals(model.getPackaging())
- && (!project.getArtifactId().equals(model.getArtifactId()))) {
- // TODO - check include/exclude
- getLog().debug(
- "Project " + model.getName()
- + " included to library set");
- List<Dependency> dependencies = model.getDependencies();
- for (Iterator<Dependency> iterator = dependencies.iterator(); iterator
- .hasNext();) {
- Dependency dependency = iterator.next();
- getLog().debug(
- dependency.getClass().getName() + " : "
- + dependency + " with key: "
- + dependency.getManagementKey());
- if (!"test".equals(dependency.getScope())) {
- projectsDependencies.put(dependency.getManagementKey(),
- dependency);
-
- }
- }
- models.add(model);
- }
- }
- // Remove modules projects from dependencise
- Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
- for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
- Model model = (Model) iter.next();
- for (Iterator<Dependency> iterator = projectsDependencies.values().iterator(); iterator
- .hasNext();) {
- Dependency dependency = (Dependency) iterator.next();
- if (model.getGroupId().equals(dependency.getGroupId())
- && model.getArtifactId().equals(
- dependency.getArtifactId())) {
- getLog().debug(
- "Remove dependency of library module "
- + dependency.getManagementKey());
- unwanted.add(dependency.getManagementKey());
- }
- }
- // Got module and unpack it to target directory.
- Artifact artifact = factory.createBuildArtifact(model.getGroupId(),
- model.getArtifactId(), model.getVersion(), model
- .getPackaging());
- File moduleDir = new File(modulesDirectory, model.getArtifactId());
- unpackArtifact(artifact, moduleDir, true);
- artifact = factory
- .createArtifactWithClassifier(model.getGroupId(), model
- .getArtifactId(), model.getVersion(), "jar",
- "sources");
- unpackArtifact(artifact, modulesSrc, false);
- }
- // Add projects dependencies to this project
- projectsDependencies.keySet().removeAll(unwanted);
- setupGeneratedProject(projectsDependencies);
- return models;
- }
-
- /**
- * @param projectsDependencies
- * @throws MojoExecutionException
- */
- private void setupGeneratedProject(
- Map<String, Dependency> projectsDependencies)
- throws MojoExecutionException {
- Model generatedProject;
- try {
- MavenXpp3Reader reader = new MavenXpp3Reader();
- generatedProject = reader.read(new FileReader(project.getFile()));
- } catch (Exception e1) {
- throw new MojoExecutionException("Unable to read local POM", e1);
- }
- generatedProject.getDependencies()
- .addAll(projectsDependencies.values());
- writePom(generatedProject);
- project.setDependencies(new ArrayList<Dependency>(projectsDependencies.values()));
- // project.setFile(generatedPom);
- }
-
- /**
- * Check parent project, build if nesessary.
- *
- * @throws MojoFailureException
- */
- protected void setupParentProject() throws MojoFailureException {
- // Parent project not set for a custom lifecycles. Try to load artifact.
- if (null == parentProject || null == parentProject.getFile()) {
- Parent parentModel = project.getModel().getParent();
- if (null != parentModel) {
- String relativePath = parentModel.getRelativePath();
- File parentPom = new File(project.getFile().getAbsoluteFile()
- .getParentFile(), relativePath);
- if (parentPom.isDirectory()) {
- parentPom = new File(parentPom, "pom.xml");
- }
- if (parentPom.exists()) {
- try {
- parentProject = mavenProjectBuilder.build(parentPom,
- localRepository, null);
- if (null == parentProject) {
- throw new MojoFailureException(
- "Components library project must have parent pom with components modules");
- }
- } catch (ProjectBuildingException e) {
- throw new MojoFailureException(
- "Error get parent project for a components library");
- }
- } else {
- throw new MojoFailureException(
- "Parent project pom file not found for a components library");
- }
- } else {
- throw new MojoFailureException(
- "Components library project must have parent pom with components modules");
- }
-
- }
- }
-
- /**
- * @param models
- * @throws MojoExecutionException
- */
- private void mergeFacesConfig(List<Model> models) throws MojoExecutionException {
- StringBuffer facesConfig = new StringBuffer();
- for (int i = 0; i < library.getRenderkits().length; i++) {
- Renderkit kit = library.getRenderkits()[i];
- kit.setContent(new StringBuffer());
- }
- // Process all faces-config.xml from modules
- for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
- Model model = iter.next();
- File moduleFacesConfig = new File(modulesDirectory, model
- .getArtifactId()
- + "/META-INF/faces-config.xml");
- processFacesConfigFile(facesConfig, moduleFacesConfig);
- }
- // Process faces-config from project resources
- if (null !=config) {
- processFacesConfigFile(facesConfig, new File(config, "META-INF/faces-config.xml"));
- }
- VelocityContext context = new VelocityContext();
- context.put("content", facesConfig.toString());
- context.put("library", library);
- context.put("renderkits", Arrays.asList(library.getRenderkits()));
- try {
- writeParsedTemplate(templates + FACES_CONFIG_TEMPLATE, context,
- new File(outputDirectory, "META-INF/faces-config.xml"));
- } catch (Exception e) {
- throw new MojoExecutionException(
- "Error to process faces-config template", e);
- }
- }
-
- /**
- * @param config
- * @param moduleFacesConfig
- * @throws MojoExecutionException
- */
- private void processFacesConfigFile(StringBuffer config,
- File moduleFacesConfig) throws MojoExecutionException {
- if (moduleFacesConfig.exists()) {
- getLog().info(
- "Process "+moduleFacesConfig.getName());
- XMLBody configBody = new XMLBody();
- try {
- configBody.loadXML(new FileInputStream(moduleFacesConfig));
- config
- .append(configBody
- .getContent("/faces-config/*[name()!=\'render-kit\']"));
- for (int i = 0; i < library.getRenderkits().length; i++) {
- Renderkit kit = library.getRenderkits()[i];
- kit
- .getContent()
- .append(
- configBody
- .getContent("/faces-config/render-kit[child::render-kit-id='"
- + kit.getName()
- + "']/renderer"));
- }
- } catch (FileNotFoundException e) {
- throw new MojoExecutionException(
- "Could't read faces-config file", e);
- } catch (ParsingException e) {
- throw new MojoExecutionException(
- "Error parsing faces-config file", e);
- }
- }
- }
-
- /**
- * Merge XML files from extracted models to one in build directory.
- *
- * @param models
- * models collected in library.
- * @param includes
- * relative path to config file in models/output.
- * @param templateName -
- * name of velocity template for result file.
- * @param commonXpath -
- * XPath expression fof common part of result file.
- * @param keyXPath -
- * XPath expression for key part of common parts
- * @param context -
- * Velocity context for template processing.
- * @param namespaceAware TODO
- * @param keySet -
- * {@link Set} to check for duplicate keys. Must not be null
- * @throws MojoExecutionException
- */
- private void mergeXML(List<Model> models, String includes, String excludes, String templateName,
- String commonXpath, String keyXPath, VelocityContext context,
- File target, boolean namespaceAware, Comparator<Node> comparator) throws MojoExecutionException {
- StringBuffer content = new StringBuffer();
- String[] split = includes.split(",");
- String[] excludesSplit = excludes != null ? excludes.split(",") : null;
- XMLBodyMerge xBodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
- for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
- Model model = iter.next();
- File moduleDir = new File(modulesDirectory, model.getArtifactId());
- mergeXMLdir(moduleDir, namespaceAware, split, excludesSplit, xBodyMerge);
- }
- if(null!=config){
- mergeXMLdir(config, namespaceAware, split, excludesSplit, xBodyMerge);
- }
-
- if (comparator != null) {
- xBodyMerge.sort(comparator);
- }
- try {
- content.append(xBodyMerge.getContent());
- } catch (Exception e1) {
- throw new MojoExecutionException("XML Merge Exception Occured", e1);
- }
- if (content.length() > 0) {
- context.put("content", content.toString());
- context.put("library", library);
- context.put("models", models);
- try {
- writeParsedTemplate(templates + templateName, context, target);
- } catch (Exception e) {
- throw new MojoExecutionException("Error to process template "
- + templateName + " for files " + includes, e);
- }
-
- }
- }
-
- /**
- * @param moduleDir
- * @param commonXpath
- * @param keyXPath
- * @param namespaceAware
- * @param keySet
- * @param content
- * @param xmls
- * @param split
- * @throws IllegalStateException
- * @throws MojoExecutionException
- */
- private void mergeXMLdir(File moduleDir, boolean namespaceAware, String[] split, String[] excludesSplit, XMLBodyMerge xBodyMerge)
- throws IllegalStateException, MojoExecutionException {
- DirectoryScanner ds = new DirectoryScanner();
- ds.setFollowSymlinks(true);
- ds.setBasedir(moduleDir);
- ds.setIncludes(split);
- ds.setExcludes(excludesSplit);
- ds.addDefaultExcludes();
- ds.scan();
- String[] files = ds.getIncludedFiles();
- for (int i = 0; i < files.length; i++) {
- File moduleFacesConfig = new File(moduleDir, files[i]);
- getLog().info(
- "Process " + files[i] );
- XMLBody configBody = new XMLBody();
- try {
- configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
- xBodyMerge.add(configBody);
- } catch (FileNotFoundException e) {
- throw new MojoExecutionException("Could't read file "
- + moduleFacesConfig.getPath(), e);
- } catch (ParsingException e) {
- throw new MojoExecutionException(
- "Error parsing config file "
- + moduleFacesConfig.getPath(), e);
- }
- }
- }
-
- private void unpackArtifact(Artifact artifact, File moduleDir,
- boolean isResource) throws MojoExecutionException {
- try {
- resolver.resolve(artifact, Collections.EMPTY_LIST, localRepository);
- unpack(artifact.getFile(), moduleDir);
- if (isResource) {
- Resource resource = new Resource();
- resource.setDirectory(moduleDir.getPath());
- resource.addExclude("META-INF/faces-config.xml");
- resource.addExclude("META-INF/resources-config.xml");
- resource.addExclude("META-INF/*.taglib.xml");
- resource.addExclude("META-INF/*.tld");
- project.addResource(resource);
-
- }
- } catch (ArtifactResolutionException e) {
- getLog().error("Error with resolve artifact " + artifact, e);
- } catch (ArtifactNotFoundException e) {
- getLog().error("Not found artifact " + artifact, e);
- }
- }
-
- private List<MavenProject> populateReactorProjects() {
- List<MavenProject> projects = new ArrayList<MavenProject>();
- if (reactorProjects != null && reactorProjects.size() > 1) {
- Iterator reactorItr = reactorProjects.iterator();
-
- while (reactorItr.hasNext()) {
- MavenProject reactorProject = (MavenProject) reactorItr.next();
-
- if (reactorProject != null
- && reactorProject.getParent() != null
- && project.getArtifactId().equals(
- reactorProject.getParent().getArtifactId())) {
- String name = reactorProject.getGroupId() + ":"
- + reactorProject.getArtifactId();
- getLog().info("Have reactor project with name " + name);
- projects.add(reactorProject);
- }
- }
- }
- return projects;
- }
-
- /**
- * Unpacks the archive file.
- *
- * @param file
- * File to be unpacked.
- * @param location
- * Location where to put the unpacked files.
- */
- private void unpack(File file, File location) throws MojoExecutionException {
-
- getLog().debug(
- "Unpack file " + file.getAbsolutePath() + " to: "
- + location.getAbsolutePath());
- try {
- location.mkdirs();
-
- UnArchiver unArchiver;
-
- unArchiver = archiverManager.getUnArchiver(file);
-
- unArchiver.setSourceFile(file);
-
- unArchiver.setDestDirectory(location);
-
- unArchiver.setOverwrite(true);
-
- unArchiver.extract();
-
- } catch (Exception e) {
- throw new MojoExecutionException("Error unpacking file: " + file
- + " to: " + location + "\r\n" + e.toString(), e);
- }
- }
-
- private void writePom(Model pom) throws MojoExecutionException {
- MavenXpp3Writer pomWriter = new MavenXpp3Writer();
- try {
- FileWriter out = new FileWriter(generatedPom);
- pomWriter.write(out, pom);
- } catch (IOException e) {
- throw new MojoExecutionException("Error for write generated pom", e);
- }
-
- }
-
- /**
- * @return the archiverManager
- */
- public ArchiverManager getArchiverManager() {
- return this.archiverManager;
- }
-
- /**
- * @param archiverManager
- * the archiverManager to set
- */
- public void setArchiverManager(ArchiverManager archiverManager) {
- this.archiverManager = archiverManager;
- }
-
- /**
- * @return the buildDirectory
- */
- public File getBuildDirectory() {
- return this.buildDirectory;
- }
-
- /**
- * @param buildDirectory
- * the buildDirectory to set
- */
- public void setBuildDirectory(File buildDirectory) {
- this.buildDirectory = buildDirectory;
- }
-
- /**
- * @return the factory
- */
- public org.apache.maven.artifact.factory.ArtifactFactory getFactory() {
- return this.factory;
- }
-
- /**
- * @param factory
- * the factory to set
- */
- public void setFactory(
- org.apache.maven.artifact.factory.ArtifactFactory factory) {
- this.factory = factory;
- }
-
- /**
- * @return the localRepository
- */
- public ArtifactRepository getLocalRepository() {
- return this.localRepository;
- }
-
- /**
- * @param localRepository
- * the localRepository to set
- */
- public void setLocalRepository(ArtifactRepository localRepository) {
- this.localRepository = localRepository;
- }
-
- /**
- * @return the mavenProjectBuilder
- */
- public MavenProjectBuilder getMavenProjectBuilder() {
- return this.mavenProjectBuilder;
- }
-
- /**
- * @param mavenProjectBuilder
- * the mavenProjectBuilder to set
- */
- public void setMavenProjectBuilder(MavenProjectBuilder mavenProjectBuilder) {
- this.mavenProjectBuilder = mavenProjectBuilder;
- }
-
- /**
- * @return the parentProject
- */
- public MavenProject getParentProject() {
- return this.parentProject;
- }
-
- /**
- * @param parentProject
- * the parentProject to set
- */
- public void setParentProject(MavenProject parentProject) {
- this.parentProject = parentProject;
- }
-
- /**
- * @return the reactorProjects
- */
- public List getReactorProjects() {
- return this.reactorProjects;
- }
-
- /**
- * @param reactorProjects
- * the reactorProjects to set
- */
- public void setReactorProjects(List reactorProjects) {
- this.reactorProjects = reactorProjects;
- }
-
- /**
- * @return the resolver
- */
- public org.apache.maven.artifact.resolver.ArtifactResolver getResolver() {
- return this.resolver;
- }
-
- /**
- * @param resolver
- * the resolver to set
- */
- public void setResolver(
- org.apache.maven.artifact.resolver.ArtifactResolver resolver) {
- this.resolver = resolver;
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/AssemblyLibraryMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AssemblyLibraryMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,942 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Model;
+import org.apache.maven.model.Parent;
+import org.apache.maven.model.Resource;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.apache.velocity.VelocityContext;
+import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.NamesListComparator;
+import org.richfaces.builder.xml.XMLBody;
+import org.richfaces.builder.xml.XMLBodyMerge;
+import org.richfaces.builder.xml.XPathComparator;
+import org.w3c.dom.Node;
+
+/**
+ * This plugin assembly full components library from modules, included in parent
+ * project. Steps to create library : 1. Got parent project, and check modules
+ * included in them. 2. For every module , build project and got it properties.
+ * 3. Resolve module artifact, check for "jar" type and include/exclude
+ * criteria. for accepted modules, unpack it to classes directory, and put
+ * config files in separate directories. 4. Append unpacked directory to
+ * resources, included in result jar. 5. Merge all META-INF/faces-config.xml ,
+ * *.tld, *.taglib.xml, *.component-dependencies.xml , resources-config.xml into ones.
+ * 6. append dependencies of included projects to this.
+ *
+ * @author shura
+ * @goal assembly
+ * @requiresDependencyResolution compile
+ * @phase generate-resources
+ */
+public class AssemblyLibraryMojo extends AbstractCDKMojo {
+
+ private static final String TEMPLATES_PREFIX = "/templates/";
+
+ private static final String TEMPLATES12_PREFIX = "/templates12/";
+
+ private static final String FACES_CONFIG_TEMPLATE = "faces-config.vm";
+
+ private static final String RESOURCES_CONFIG_TEMPLATE = "resources-config.vm";
+
+ private static final String COMPONENT_DEPENDENCIES_TEMPLATE = "component-dependencies.vm";
+
+ private static final String XCSS_TEMPLATE = "xcss.vm";
+
+ private static final String TLD_TEMPLATE = "tld.vm";
+
+ private static final String TAGLIB_TEMPLATE = "taglib.vm";
+
+ private static final String[] TLD_TAG_NAMES = new String[] {
+ "description", "display-name", "icon", "tlib-version",
+ "short-name", "uri", "validator", "listener", "tag",
+ "tag-file", "function", "taglib-extension"
+ };
+
+ private static final String[] TAGLIB_TAG_NAMES = new String[] {
+ "library-class", "namespace", "tag", "function"
+ };
+
+ private static final String[] DEPENDENCIES_TAG_NAMES = new String[] {
+ "component"
+ };
+
+ private static final Comparator<Node> TLD_COMPARATOR = new NamesListComparator(
+ new XPathComparator("listener-class/text()", "name/text()"), TLD_TAG_NAMES);
+
+ private static final Comparator<Node> FACELET_COMPARATOR = new NamesListComparator(
+ new XPathComparator("function-name/text()", "tag-name/text()"), TAGLIB_TAG_NAMES);
+
+ private static final Comparator<Node> DEPENDENCIES_COMPARATOR = new NamesListComparator(
+ new XPathComparator("name/text()"), DEPENDENCIES_TAG_NAMES);
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @component
+ */
+ private org.apache.maven.artifact.factory.ArtifactFactory factory;
+
+ /**
+ * Used to look up Artifacts in the remote repository.
+ *
+ * @component
+ */
+ private org.apache.maven.artifact.resolver.ArtifactResolver resolver;
+
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component
+ */
+ private ArchiverManager archiverManager;
+
+ /**
+ * Project builder
+ *
+ * @component
+ */
+ private MavenProjectBuilder mavenProjectBuilder;
+
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${reactorProjects}"
+ * @required
+ * @readonly
+ */
+ private List reactorProjects;
+
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${project.parent}"
+ * @readonly
+ */
+ private MavenProject parentProject;
+
+ /**
+ * The list of resources we want to transfer.
+ *
+ * @parameter default-value="src/main/config"
+ */
+ private File config;
+
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.directory}"
+ * @required
+ * @readonly
+ */
+ private File buildDirectory;
+
+ /**
+ * @parameter default-value="${project.build.directory}/modules"
+ */
+ private File modulesDirectory;
+
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.directory}/pom.xml"
+ * @required
+ * @readonly
+ */
+ private File generatedPom;
+
+ /**
+ * The directory for compiled classes.
+ *
+ * @parameter expression="${project.build.directory}/src"
+ * @required
+ * @readonly
+ */
+ private File modulesSrc;
+
+ /**
+ * @parameter
+ */
+ private String templates;
+
+ /**
+ * @parameter
+ */
+ private String includeTld = "META-INF/*.tld";
+
+ /**
+ * @parameter
+ */
+ private String includeTaglib = "META-INF/*.taglib.xml";
+
+ /**
+ * @parameter
+ */
+ private String includeDependencies = "META-INF/*.component-dependencies.xml";
+
+ /**
+ * @parameter
+ */
+ private String includeXcss = "**/*.xcss";
+
+ /**
+ * @parameter
+ */
+ private String excludeXcss = null;
+
+ /**
+ * @parameter
+ */
+ private String commonStyle;
+
+ /**
+ * @parameter
+ */
+ private String templateXpath;
+
+ /**
+ *
+ */
+ public AssemblyLibraryMojo() {
+ // used for plexus init.
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ setupParentProject();
+ checkLibraryConfig();
+ if (null == templates) {
+ templates = Library.JSF12.equals(library.getJsfVersion()) ? TEMPLATES12_PREFIX
+ : TEMPLATES_PREFIX;
+ }
+ List<Model> models = extractModules();
+ mergeFacesConfig(models);
+ File resourcesConfig = new File(outputDirectory,
+ "META-INF/resources-config.xml");
+ mergeXML(models, "META-INF/resources-config.xml", null,
+ RESOURCES_CONFIG_TEMPLATE, "/resource-config/resource",
+ "name/text()", new VelocityContext(), resourcesConfig, false, null);
+
+ if (null != commonStyle) {
+ File commonXcss = new File(outputDirectory, commonStyle);
+ mergeXML(models, includeXcss, excludeXcss, XCSS_TEMPLATE,
+ templateXpath, null, new VelocityContext(), commonXcss, true, null);
+ }
+
+ if (null != library.getTaglibs() && library.getTaglibs().length > 0) {
+ for (int i = 0; i < library.getTaglibs().length; i++) {
+ Taglib taglib = library.getTaglibs()[i];
+ List<Model> taglibModels;
+ if (taglib.getIncludeModules() == null
+ && taglib.getExcludeModules() == null) {
+ taglibModels = models;
+ } else {
+ String[] includeModules = null;
+ String[] excludeModules = null;
+ if (null != taglib.getIncludeModules()) {
+ includeModules = taglib.getIncludeModules().split(",");
+ Arrays.sort(includeModules);
+ }
+ if (null != taglib.getExcludeModules()) {
+ excludeModules = taglib.getExcludeModules().split(",");
+ Arrays.sort(excludeModules);
+ }
+ taglibModels = new ArrayList<Model>();
+ for (Iterator iterator = models.iterator(); iterator
+ .hasNext();) {
+ Model model = (Model) iterator.next();
+ String id = model.getArtifactId();
+ if ((includeModules == null || Arrays.binarySearch(
+ includeModules, id) >= 0)
+ && (excludeModules == null || Arrays
+ .binarySearch(excludeModules, id) < 0)) {
+ taglibModels.add(model);
+ }
+ }
+ }
+ generateTaglibAndDependencies(taglibModels, taglib);
+ }
+ } else {
+ generateTaglibAndDependencies(models, library.getTaglib());
+ }
+ }
+
+ /**
+ * @param models
+ * @throws MojoExecutionException
+ */
+ private void generateTaglibAndDependencies(List<Model> models, Taglib taglib)
+ throws MojoExecutionException {
+ getLog().debug(
+ "Assembly taglib for uri " + taglib.getUri()
+ + " with short name " + taglib.getShortName());
+ VelocityContext taglibContext = new VelocityContext();
+ taglibContext.put("taglib", taglib);
+ // Build includes/excludes Xpath condition
+ String nameTag = "name";
+ createTagCondition(taglib, nameTag);
+ File tld = new File(outputDirectory, "META-INF/" + taglib.getTaglib()
+ + ".tld");
+ getLog().debug("Write JSP taglib " + tld.getPath());
+ String commonXPath = "/taglib/tag"
+ + createTagCondition(taglib, "name") + " | /taglib/listener | /taglib/function";
+
+ mergeXML(models, includeTld, null, TLD_TEMPLATE, commonXPath,
+ "listener-class/text() | name/text()", new VelocityContext(taglibContext), tld, false, TLD_COMPARATOR);
+
+
+ File faceletsTaglib = new File(outputDirectory, "META-INF/"
+ + taglib.getTaglib() + ".taglib.xml");
+ commonXPath = "/facelet-taglib/tag"
+ + createTagCondition(taglib, "tag-name")
+ + " | /facelet-taglib/function";
+
+ mergeXML(models, includeTaglib, null, TAGLIB_TEMPLATE, commonXPath, "tag-name/text() | function-name/text()", new VelocityContext(
+ taglibContext), faceletsTaglib, false, FACELET_COMPARATOR);
+ getLog().debug("Write Facelets taglib " + faceletsTaglib.getPath());
+
+ File dependenciesFile = new File(outputDirectory, "META-INF/"
+ + taglib.getTaglib() + ".component-dependencies.xml");
+ commonXPath = "/components/component" + createTagCondition(taglib, "name");
+
+ mergeXML(models, includeDependencies, null, COMPONENT_DEPENDENCIES_TEMPLATE, commonXPath, "name/text()", new VelocityContext(
+ taglibContext), dependenciesFile, false, DEPENDENCIES_COMPARATOR);
+ getLog().debug("Write dependencies file " + dependenciesFile.getPath());
+ }
+
+ /**
+ * @param taglib
+ * @param nameTag
+ */
+ private String createTagCondition(Taglib taglib, String nameTag) {
+ StringBuffer condition = new StringBuffer();
+ if (taglib.getIncludeTags() != null || taglib.getExcludeTags() != null) {
+ condition.append('[');
+ if (taglib.getIncludeTags() != null) {
+ condition.append('(');
+ String[] includes = taglib.getIncludeTags().split(",");
+ for (int i = 0; i < includes.length; i++) {
+ String includeTag = includes[i];
+ if (i != 0) {
+ condition.append(" or ");
+ }
+ condition.append("normalize-space(").append(nameTag)
+ .append(")='").append(includeTag).append("'");
+ }
+ condition.append(')');
+ }
+ if (taglib.getIncludeTags() != null
+ && taglib.getExcludeTags() != null) {
+ condition.append(" and ");
+ }
+ if (taglib.getExcludeTags() != null) {
+ condition.append('(');
+ String[] excludes = taglib.getExcludeTags().split(",");
+ for (int i = 0; i < excludes.length; i++) {
+ String includeTag = excludes[i];
+ if (i != 0) {
+ condition.append(" and ");
+ }
+ condition.append("normalize-space(").append(nameTag)
+ .append(")!='").append(includeTag).append("'");
+ }
+ condition.append(')');
+ }
+ condition.append(']');
+ }
+ return condition.toString();
+ }
+
+ /**
+ * @return
+ * @throws MojoExecutionException
+ */
+ private List<Model> extractModules() throws MojoExecutionException {
+ List<String> modules = parentProject.getModules();
+ List<Model> models = new ArrayList<Model>(modules.size());
+ Map<String, Dependency> projectsDependencies = new HashMap<String, Dependency>();
+ for (Iterator<String> iter = modules.iterator(); iter.hasNext();) {
+ String moduleName = iter.next();
+ getLog().info("Parent project have module " + moduleName);
+ Model model;
+ File f = new File(parentProject.getBasedir(), moduleName
+ + "/pom.xml");
+ if (f.exists()) {
+ try {
+ model = mavenProjectBuilder.build(f, localRepository, null)
+ .getModel();
+ } catch (ProjectBuildingException e) {
+ throw new MojoExecutionException(
+ "Unable to read local module-POM", e);
+ }
+ } else {
+ getLog().warn("No filesystem module-POM available");
+
+ model = new Model();
+ model.setName(moduleName);
+ model.setUrl(moduleName);
+ }
+ if (project.getGroupId().equals(model.getGroupId())
+ && "jar".equals(model.getPackaging())
+ && (!project.getArtifactId().equals(model.getArtifactId()))) {
+ // TODO - check include/exclude
+ getLog().debug(
+ "Project " + model.getName()
+ + " included to library set");
+ List<Dependency> dependencies = model.getDependencies();
+ for (Iterator<Dependency> iterator = dependencies.iterator(); iterator
+ .hasNext();) {
+ Dependency dependency = iterator.next();
+ getLog().debug(
+ dependency.getClass().getName() + " : "
+ + dependency + " with key: "
+ + dependency.getManagementKey());
+ if (!"test".equals(dependency.getScope())) {
+ projectsDependencies.put(dependency.getManagementKey(),
+ dependency);
+
+ }
+ }
+ models.add(model);
+ }
+ }
+ // Remove modules projects from dependencise
+ Set<String> unwanted = new HashSet<String>(projectsDependencies.size());
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = (Model) iter.next();
+ for (Iterator<Dependency> iterator = projectsDependencies.values().iterator(); iterator
+ .hasNext();) {
+ Dependency dependency = (Dependency) iterator.next();
+ if (model.getGroupId().equals(dependency.getGroupId())
+ && model.getArtifactId().equals(
+ dependency.getArtifactId())) {
+ getLog().debug(
+ "Remove dependency of library module "
+ + dependency.getManagementKey());
+ unwanted.add(dependency.getManagementKey());
+ }
+ }
+ // Got module and unpack it to target directory.
+ Artifact artifact = factory.createBuildArtifact(model.getGroupId(),
+ model.getArtifactId(), model.getVersion(), model
+ .getPackaging());
+ File moduleDir = new File(modulesDirectory, model.getArtifactId());
+ unpackArtifact(artifact, moduleDir, true);
+ artifact = factory
+ .createArtifactWithClassifier(model.getGroupId(), model
+ .getArtifactId(), model.getVersion(), "jar",
+ "sources");
+ unpackArtifact(artifact, modulesSrc, false);
+ }
+ // Add projects dependencies to this project
+ projectsDependencies.keySet().removeAll(unwanted);
+ setupGeneratedProject(projectsDependencies);
+ return models;
+ }
+
+ /**
+ * @param projectsDependencies
+ * @throws MojoExecutionException
+ */
+ private void setupGeneratedProject(
+ Map<String, Dependency> projectsDependencies)
+ throws MojoExecutionException {
+ Model generatedProject;
+ try {
+ MavenXpp3Reader reader = new MavenXpp3Reader();
+ generatedProject = reader.read(new FileReader(project.getFile()));
+ } catch (Exception e1) {
+ throw new MojoExecutionException("Unable to read local POM", e1);
+ }
+ generatedProject.getDependencies()
+ .addAll(projectsDependencies.values());
+ writePom(generatedProject);
+ project.setDependencies(new ArrayList<Dependency>(projectsDependencies.values()));
+ // project.setFile(generatedPom);
+ }
+
+ /**
+ * Check parent project, build if nesessary.
+ *
+ * @throws MojoFailureException
+ */
+ protected void setupParentProject() throws MojoFailureException {
+ // Parent project not set for a custom lifecycles. Try to load artifact.
+ if (null == parentProject || null == parentProject.getFile()) {
+ Parent parentModel = project.getModel().getParent();
+ if (null != parentModel) {
+ String relativePath = parentModel.getRelativePath();
+ File parentPom = new File(project.getFile().getAbsoluteFile()
+ .getParentFile(), relativePath);
+ if (parentPom.isDirectory()) {
+ parentPom = new File(parentPom, "pom.xml");
+ }
+ if (parentPom.exists()) {
+ try {
+ parentProject = mavenProjectBuilder.build(parentPom,
+ localRepository, null);
+ if (null == parentProject) {
+ throw new MojoFailureException(
+ "Components library project must have parent pom with components modules");
+ }
+ } catch (ProjectBuildingException e) {
+ throw new MojoFailureException(
+ "Error get parent project for a components library");
+ }
+ } else {
+ throw new MojoFailureException(
+ "Parent project pom file not found for a components library");
+ }
+ } else {
+ throw new MojoFailureException(
+ "Components library project must have parent pom with components modules");
+ }
+
+ }
+ }
+
+ /**
+ * @param models
+ * @throws MojoExecutionException
+ */
+ private void mergeFacesConfig(List<Model> models) throws MojoExecutionException {
+ StringBuffer facesConfig = new StringBuffer();
+ for (int i = 0; i < library.getRenderkits().length; i++) {
+ Renderkit kit = library.getRenderkits()[i];
+ kit.setContent(new StringBuffer());
+ }
+ // Process all faces-config.xml from modules
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
+ File moduleFacesConfig = new File(modulesDirectory, model
+ .getArtifactId()
+ + "/META-INF/faces-config.xml");
+ processFacesConfigFile(facesConfig, moduleFacesConfig);
+ }
+ // Process faces-config from project resources
+ if (null !=config) {
+ processFacesConfigFile(facesConfig, new File(config, "META-INF/faces-config.xml"));
+ }
+ VelocityContext context = new VelocityContext();
+ context.put("content", facesConfig.toString());
+ context.put("library", library);
+ context.put("renderkits", Arrays.asList(library.getRenderkits()));
+ try {
+ writeParsedTemplate(templates + FACES_CONFIG_TEMPLATE, context,
+ new File(outputDirectory, "META-INF/faces-config.xml"));
+ } catch (Exception e) {
+ throw new MojoExecutionException(
+ "Error to process faces-config template", e);
+ }
+ }
+
+ /**
+ * @param config
+ * @param moduleFacesConfig
+ * @throws MojoExecutionException
+ */
+ private void processFacesConfigFile(StringBuffer config,
+ File moduleFacesConfig) throws MojoExecutionException {
+ if (moduleFacesConfig.exists()) {
+ getLog().info(
+ "Process "+moduleFacesConfig.getName());
+ XMLBody configBody = new XMLBody();
+ try {
+ configBody.loadXML(new FileInputStream(moduleFacesConfig));
+ config
+ .append(configBody
+ .getContent("/faces-config/*[name()!=\'render-kit\']"));
+ for (int i = 0; i < library.getRenderkits().length; i++) {
+ Renderkit kit = library.getRenderkits()[i];
+ kit
+ .getContent()
+ .append(
+ configBody
+ .getContent("/faces-config/render-kit[child::render-kit-id='"
+ + kit.getName()
+ + "']/renderer"));
+ }
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException(
+ "Could't read faces-config file", e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing faces-config file", e);
+ }
+ }
+ }
+
+ /**
+ * Merge XML files from extracted models to one in build directory.
+ *
+ * @param models
+ * models collected in library.
+ * @param includes
+ * relative path to config file in models/output.
+ * @param templateName -
+ * name of velocity template for result file.
+ * @param commonXpath -
+ * XPath expression fof common part of result file.
+ * @param keyXPath -
+ * XPath expression for key part of common parts
+ * @param context -
+ * Velocity context for template processing.
+ * @param namespaceAware TODO
+ * @param keySet -
+ * {@link Set} to check for duplicate keys. Must not be null
+ * @throws MojoExecutionException
+ */
+ private void mergeXML(List<Model> models, String includes, String excludes, String templateName,
+ String commonXpath, String keyXPath, VelocityContext context,
+ File target, boolean namespaceAware, Comparator<Node> comparator) throws MojoExecutionException {
+ StringBuffer content = new StringBuffer();
+ String[] split = includes.split(",");
+ String[] excludesSplit = excludes != null ? excludes.split(",") : null;
+ XMLBodyMerge xBodyMerge = new XMLBodyMerge(commonXpath, keyXPath);
+ for (Iterator<Model> iter = models.iterator(); iter.hasNext();) {
+ Model model = iter.next();
+ File moduleDir = new File(modulesDirectory, model.getArtifactId());
+ mergeXMLdir(moduleDir, namespaceAware, split, excludesSplit, xBodyMerge);
+ }
+ if(null!=config){
+ mergeXMLdir(config, namespaceAware, split, excludesSplit, xBodyMerge);
+ }
+
+ if (comparator != null) {
+ xBodyMerge.sort(comparator);
+ }
+ try {
+ content.append(xBodyMerge.getContent());
+ } catch (Exception e1) {
+ throw new MojoExecutionException("XML Merge Exception Occured", e1);
+ }
+ if (content.length() > 0) {
+ context.put("content", content.toString());
+ context.put("library", library);
+ context.put("models", models);
+ try {
+ writeParsedTemplate(templates + templateName, context, target);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error to process template "
+ + templateName + " for files " + includes, e);
+ }
+
+ }
+ }
+
+ /**
+ * @param moduleDir
+ * @param commonXpath
+ * @param keyXPath
+ * @param namespaceAware
+ * @param keySet
+ * @param content
+ * @param xmls
+ * @param split
+ * @throws IllegalStateException
+ * @throws MojoExecutionException
+ */
+ private void mergeXMLdir(File moduleDir, boolean namespaceAware, String[] split, String[] excludesSplit, XMLBodyMerge xBodyMerge)
+ throws IllegalStateException, MojoExecutionException {
+ DirectoryScanner ds = new DirectoryScanner();
+ ds.setFollowSymlinks(true);
+ ds.setBasedir(moduleDir);
+ ds.setIncludes(split);
+ ds.setExcludes(excludesSplit);
+ ds.addDefaultExcludes();
+ ds.scan();
+ String[] files = ds.getIncludedFiles();
+ for (int i = 0; i < files.length; i++) {
+ File moduleFacesConfig = new File(moduleDir, files[i]);
+ getLog().info(
+ "Process " + files[i] );
+ XMLBody configBody = new XMLBody();
+ try {
+ configBody.loadXML(new FileInputStream(moduleFacesConfig),namespaceAware);
+ xBodyMerge.add(configBody);
+ } catch (FileNotFoundException e) {
+ throw new MojoExecutionException("Could't read file "
+ + moduleFacesConfig.getPath(), e);
+ } catch (ParsingException e) {
+ throw new MojoExecutionException(
+ "Error parsing config file "
+ + moduleFacesConfig.getPath(), e);
+ }
+ }
+ }
+
+ private void unpackArtifact(Artifact artifact, File moduleDir,
+ boolean isResource) throws MojoExecutionException {
+ try {
+ resolver.resolve(artifact, Collections.EMPTY_LIST, localRepository);
+ unpack(artifact.getFile(), moduleDir);
+ if (isResource) {
+ Resource resource = new Resource();
+ resource.setDirectory(moduleDir.getPath());
+ resource.addExclude("META-INF/faces-config.xml");
+ resource.addExclude("META-INF/resources-config.xml");
+ resource.addExclude("META-INF/*.taglib.xml");
+ resource.addExclude("META-INF/*.component-dependencies.xml");
+ resource.addExclude("META-INF/*.tld");
+ project.addResource(resource);
+
+ }
+ } catch (ArtifactResolutionException e) {
+ getLog().error("Error with resolve artifact " + artifact, e);
+ } catch (ArtifactNotFoundException e) {
+ getLog().error("Not found artifact " + artifact, e);
+ }
+ }
+
+ private List<MavenProject> populateReactorProjects() {
+ List<MavenProject> projects = new ArrayList<MavenProject>();
+ if (reactorProjects != null && reactorProjects.size() > 1) {
+ Iterator reactorItr = reactorProjects.iterator();
+
+ while (reactorItr.hasNext()) {
+ MavenProject reactorProject = (MavenProject) reactorItr.next();
+
+ if (reactorProject != null
+ && reactorProject.getParent() != null
+ && project.getArtifactId().equals(
+ reactorProject.getParent().getArtifactId())) {
+ String name = reactorProject.getGroupId() + ":"
+ + reactorProject.getArtifactId();
+ getLog().info("Have reactor project with name " + name);
+ projects.add(reactorProject);
+ }
+ }
+ }
+ return projects;
+ }
+
+ /**
+ * Unpacks the archive file.
+ *
+ * @param file
+ * File to be unpacked.
+ * @param location
+ * Location where to put the unpacked files.
+ */
+ private void unpack(File file, File location) throws MojoExecutionException {
+
+ getLog().debug(
+ "Unpack file " + file.getAbsolutePath() + " to: "
+ + location.getAbsolutePath());
+ try {
+ location.mkdirs();
+
+ UnArchiver unArchiver;
+
+ unArchiver = archiverManager.getUnArchiver(file);
+
+ unArchiver.setSourceFile(file);
+
+ unArchiver.setDestDirectory(location);
+
+ unArchiver.setOverwrite(true);
+
+ unArchiver.extract();
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error unpacking file: " + file
+ + " to: " + location + "\r\n" + e.toString(), e);
+ }
+ }
+
+ private void writePom(Model pom) throws MojoExecutionException {
+ MavenXpp3Writer pomWriter = new MavenXpp3Writer();
+ try {
+ FileWriter out = new FileWriter(generatedPom);
+ pomWriter.write(out, pom);
+ } catch (IOException e) {
+ throw new MojoExecutionException("Error for write generated pom", e);
+ }
+
+ }
+
+ /**
+ * @return the archiverManager
+ */
+ public ArchiverManager getArchiverManager() {
+ return this.archiverManager;
+ }
+
+ /**
+ * @param archiverManager
+ * the archiverManager to set
+ */
+ public void setArchiverManager(ArchiverManager archiverManager) {
+ this.archiverManager = archiverManager;
+ }
+
+ /**
+ * @return the buildDirectory
+ */
+ public File getBuildDirectory() {
+ return this.buildDirectory;
+ }
+
+ /**
+ * @param buildDirectory
+ * the buildDirectory to set
+ */
+ public void setBuildDirectory(File buildDirectory) {
+ this.buildDirectory = buildDirectory;
+ }
+
+ /**
+ * @return the factory
+ */
+ public org.apache.maven.artifact.factory.ArtifactFactory getFactory() {
+ return this.factory;
+ }
+
+ /**
+ * @param factory
+ * the factory to set
+ */
+ public void setFactory(
+ org.apache.maven.artifact.factory.ArtifactFactory factory) {
+ this.factory = factory;
+ }
+
+ /**
+ * @return the localRepository
+ */
+ public ArtifactRepository getLocalRepository() {
+ return this.localRepository;
+ }
+
+ /**
+ * @param localRepository
+ * the localRepository to set
+ */
+ public void setLocalRepository(ArtifactRepository localRepository) {
+ this.localRepository = localRepository;
+ }
+
+ /**
+ * @return the mavenProjectBuilder
+ */
+ public MavenProjectBuilder getMavenProjectBuilder() {
+ return this.mavenProjectBuilder;
+ }
+
+ /**
+ * @param mavenProjectBuilder
+ * the mavenProjectBuilder to set
+ */
+ public void setMavenProjectBuilder(MavenProjectBuilder mavenProjectBuilder) {
+ this.mavenProjectBuilder = mavenProjectBuilder;
+ }
+
+ /**
+ * @return the parentProject
+ */
+ public MavenProject getParentProject() {
+ return this.parentProject;
+ }
+
+ /**
+ * @param parentProject
+ * the parentProject to set
+ */
+ public void setParentProject(MavenProject parentProject) {
+ this.parentProject = parentProject;
+ }
+
+ /**
+ * @return the reactorProjects
+ */
+ public List getReactorProjects() {
+ return this.reactorProjects;
+ }
+
+ /**
+ * @param reactorProjects
+ * the reactorProjects to set
+ */
+ public void setReactorProjects(List reactorProjects) {
+ this.reactorProjects = reactorProjects;
+ }
+
+ /**
+ * @return the resolver
+ */
+ public org.apache.maven.artifact.resolver.ArtifactResolver getResolver() {
+ return this.resolver;
+ }
+
+ /**
+ * @param resolver
+ * the resolver to set
+ */
+ public void setResolver(
+ org.apache.maven.artifact.resolver.ArtifactResolver resolver) {
+ this.resolver = resolver;
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,296 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.beans.PropertyDescriptor;
-import java.io.File;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.beanutils.PropertyUtils;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.model.Parent;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.MavenProjectBuilder;
-import org.apache.maven.project.ProjectBuildingException;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.archiver.manager.ArchiverManager;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
-
-/**
- * Compile all xml templates, matched given pattern to Java classes. Sources
- * will be created in {@link AbstractCDKMojo#outputJavaDirectory}
- *
- * @goal compile
- * @requiresDependencyResolution compile
- * @phase generate-sources
- * @author shura
- *
- */
-public class CompileMojo extends AbstractCDKMojo implements Contextualizable {
-
- /**
- * Project executed by first compile lifecycle.
- *
- * @parameter expression="${executedProject}"
- * @readonly
- */
- private MavenProject executedProject;
-
- /**
- * The reactor projects.
- *
- * @parameter expression="${project.parent}"
- * @readonly
- */
- private MavenProject parentProject;
- /**
- * @parameter default-value=${project.groupId}
- */
- private String defaultPackage;
-
- /**
- * A list of inclusion filters for the compiler. By default, include all
- * files in templates directory.
- *
- * @parameter
- */
- private String[] includes;
-
- /**
- * A list of exclusion filters for the compiler. None by default.
- *
- * @parameter
- */
- private String[] excludes;
-
- /**
- * The local repository.
- *
- * @parameter expression="${localRepository}"
- */
- private ArtifactRepository localRepository;
-
- /**
- * To look up Archiver/UnArchiver implementations
- *
- * @component
- */
- private ArchiverManager archiverManager;
-
- /**
- * Project builder
- *
- * @component
- */
- private MavenProjectBuilder mavenProjectBuilder;
- private PlexusContainer container;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- // VelocityTemplates.init();
- try {
- List components = container
- .lookupList("org.ajax4jsf.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = components.iterator(); iter.hasNext();) {
- Object element = iter.next();
- System.out.println(element.getClass().getName());
-
- }
- System.out.println("Components Map");
- Map componentsMap = container
- .lookupMap("org.ajax4jsf.templatecompiler.elements.ElementsFactory");
- for (Iterator iter = componentsMap.entrySet().iterator(); iter
- .hasNext();) {
- Map.Entry element = (Map.Entry) iter.next();
- System.out.println(element.getKey() + ":"
- + element.getValue().getClass().getName());
- }
- } catch (ComponentLookupException e) {
- throw new MojoExecutionException(
- "Error lookup ElementFactory components");
- }
- Parent parentModel = project.getModel().getParent();
- if (null != parentModel) {
- String relativePath = parentModel.getRelativePath();
- File parentPom = new File(project.getFile().getParentFile(), relativePath);
- if (parentPom.isDirectory()) {
- parentPom = new File(parentPom, "pom.xml");
- }
- if (parentPom.exists()) {
- try {
- parentProject = mavenProjectBuilder.build(parentPom,
- localRepository, null);
- } catch (ProjectBuildingException e) {
- throw new MojoExecutionException("Error get parent project for a components library",e);
- }
- } else {
- throw new MojoFailureException("Parent project pom file "+parentPom.getAbsolutePath()+" is not found for a components library");
- }
- }else {
- throw new MojoFailureException("Components library project must have parent pom with components modules");
- }
- getLog().info("Parent Project object :\n" + toLog(parentProject) + "\n");
- getLog().info("Project object :\n" + toLog(project) + "\n");
- getLog().info("Project object Model :\n" + toLog(project.getModel()) + "\n");
- getLog().info("Project object Parent Model :\n" + toLog(project.getModel().getParent()) + "\n");
-
- getLog().info(
- "Executed Project object :\n" + toLog(executedProject) + "\n");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
- */
- public void contextualize(Context context) throws ContextException {
- this.container = (PlexusContainer) context
- .get(PlexusConstants.PLEXUS_KEY);
-
- }
-
- private void logBean(Object bean) {
- StringBuffer content = new StringBuffer();
- }
-
- /**
- * Convert any Java Object to JavaScript representation ( as possible ).
- *
- * @param obj
- * @return
- * @throws MojoExecutionException
- */
- public String toLog(Object obj) throws MojoExecutionException {
- if (null == obj) {
- return "null";
- } else if (obj.getClass().isArray()) {
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (int i = 0; i < Array.getLength(obj); i++) {
- Object element = Array.get(obj, i);
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Collection) {
- // Collections put as JavaScript array.
- Collection collection = (Collection) obj;
- StringBuffer ret = new StringBuffer("[");
- boolean first = true;
- for (Iterator iter = collection.iterator(); iter.hasNext();) {
- Object element = iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(toLog(element));
- first = false;
- }
- return ret.append("]\n").toString();
- } else if (obj instanceof Map) {
- // Maps put as JavaScript hash.
- Map map = (Map) obj;
-
- StringBuffer ret = new StringBuffer("{");
- boolean first = true;
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
- Object key = (Object) iter.next();
- if (!first) {
- ret.append(',');
- }
- ret.append(key);
- ret.append(":");
- ret.append(toLog(map.get(key)));
- first = false;
- }
- return ret.append("}\n").toString();
- } else if (obj instanceof Number || obj instanceof Boolean) {
- // numbers and boolean put as-is, without conversion
- return obj.toString();
- } else if (obj instanceof String) {
- // all other put as encoded strings.
- StringBuffer ret = new StringBuffer();
- addEncodedString(ret, obj);
- return ret.append("\n").toString();
- }
- // All other objects threaded as Java Beans.
- try {
- StringBuffer ret = new StringBuffer("{");
- PropertyDescriptor[] propertyDescriptors = PropertyUtils
- .getPropertyDescriptors(obj);
- boolean first = true;
- for (int i = 0; i < propertyDescriptors.length; i++) {
- PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
- String key = propertyDescriptor.getName();
- if ("class".equals(key)
- || propertyDescriptor.getReadMethod() == null) {
- continue;
- }
- if (!first) {
- ret.append(",\n\t");
- }
- addEncodedString(ret, key);
- ret.append(":");
- try {
- ret.append(String.valueOf(PropertyUtils.getProperty(obj,
- key)));
-
- } catch (InvocationTargetException e) {
- ret.append("Not ACCESIBLE");
- }// ret.append(toLog(PropertyUtils.getProperty(obj, key)));
- first = false;
- }
- return ret.append("}\n").toString();
- } catch (Exception e) {
- throw new MojoExecutionException(
- "Error in conversion Java Object to String", e);
- }
- }
-
- public void addEncodedString(StringBuffer buff, Object obj) {
- buff.append("'");
- buff.append(obj);
- buff.append("'");
-
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CompileMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CompileMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,294 @@
+/**
+ * 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.builder.mojo;
+
+import java.beans.PropertyDescriptor;
+import java.io.File;
+import java.lang.reflect.Array;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.model.Parent;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.MavenProjectBuilder;
+import org.apache.maven.project.ProjectBuildingException;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+/**
+ * Compile all xml templates, matched given pattern to Java classes. Sources
+ * will be created in {@link AbstractCDKMojo#outputJavaDirectory}
+ *
+ * @goal compile
+ * @requiresDependencyResolution compile
+ * @phase generate-sources
+ * @author shura
+ *
+ */
+public class CompileMojo extends AbstractCDKMojo implements Contextualizable {
+
+ /**
+ * Project executed by first compile lifecycle.
+ *
+ * @parameter expression="${executedProject}"
+ * @readonly
+ */
+ private MavenProject executedProject;
+
+ /**
+ * The reactor projects.
+ *
+ * @parameter expression="${project.parent}"
+ * @readonly
+ */
+ private MavenProject parentProject;
+ /**
+ * @parameter default-value=${project.groupId}
+ */
+ private String defaultPackage;
+
+ /**
+ * A list of inclusion filters for the compiler. By default, include all
+ * files in templates directory.
+ *
+ * @parameter
+ */
+ private String[] includes;
+
+ /**
+ * A list of exclusion filters for the compiler. None by default.
+ *
+ * @parameter
+ */
+ private String[] excludes;
+
+ /**
+ * The local repository.
+ *
+ * @parameter expression="${localRepository}"
+ */
+ private ArtifactRepository localRepository;
+
+ /**
+ * To look up Archiver/UnArchiver implementations
+ *
+ * @component
+ */
+ private ArchiverManager archiverManager;
+
+ /**
+ * Project builder
+ *
+ * @component
+ */
+ private MavenProjectBuilder mavenProjectBuilder;
+ private PlexusContainer container;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ // VelocityTemplates.init();
+ try {
+ List components = container
+ .lookupList("org.richfaces.templatecompiler.elements.ElementsFactory");
+ for (Iterator iter = components.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ System.out.println(element.getClass().getName());
+
+ }
+ System.out.println("Components Map");
+ Map componentsMap = container
+ .lookupMap("org.richfaces.templatecompiler.elements.ElementsFactory");
+ for (Iterator iter = componentsMap.entrySet().iterator(); iter
+ .hasNext();) {
+ Map.Entry element = (Map.Entry) iter.next();
+ System.out.println(element.getKey() + ":"
+ + element.getValue().getClass().getName());
+ }
+ } catch (ComponentLookupException e) {
+ throw new MojoExecutionException(
+ "Error lookup ElementFactory components");
+ }
+ Parent parentModel = project.getModel().getParent();
+ if (null != parentModel) {
+ String relativePath = parentModel.getRelativePath();
+ File parentPom = new File(project.getFile().getParentFile(), relativePath);
+ if (parentPom.isDirectory()) {
+ parentPom = new File(parentPom, "pom.xml");
+ }
+ if (parentPom.exists()) {
+ try {
+ parentProject = mavenProjectBuilder.build(parentPom,
+ localRepository, null);
+ } catch (ProjectBuildingException e) {
+ throw new MojoExecutionException("Error get parent project for a components library",e);
+ }
+ } else {
+ throw new MojoFailureException("Parent project pom file "+parentPom.getAbsolutePath()+" is not found for a components library");
+ }
+ }else {
+ throw new MojoFailureException("Components library project must have parent pom with components modules");
+ }
+ getLog().info("Parent Project object :\n" + toLog(parentProject) + "\n");
+ getLog().info("Project object :\n" + toLog(project) + "\n");
+ getLog().info("Project object Model :\n" + toLog(project.getModel()) + "\n");
+ getLog().info("Project object Parent Model :\n" + toLog(project.getModel().getParent()) + "\n");
+
+ getLog().info(
+ "Executed Project object :\n" + toLog(executedProject) + "\n");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
+ */
+ public void contextualize(Context context) throws ContextException {
+ this.container = (PlexusContainer) context
+ .get(PlexusConstants.PLEXUS_KEY);
+
+ }
+
+ private void logBean(Object bean) {
+ StringBuffer content = new StringBuffer();
+ }
+
+ /**
+ * Convert any Java Object to JavaScript representation ( as possible ).
+ *
+ * @param obj
+ * @return
+ * @throws MojoExecutionException
+ */
+ public String toLog(Object obj) throws MojoExecutionException {
+ if (null == obj) {
+ return "null";
+ } else if (obj.getClass().isArray()) {
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+ for (int i = 0; i < Array.getLength(obj); i++) {
+ Object element = Array.get(obj, i);
+ if (!first) {
+ ret.append(',');
+ }
+ ret.append(toLog(element));
+ first = false;
+ }
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Collection) {
+ // Collections put as JavaScript array.
+ Collection collection = (Collection) obj;
+ StringBuffer ret = new StringBuffer("[");
+ boolean first = true;
+ for (Iterator iter = collection.iterator(); iter.hasNext();) {
+ Object element = iter.next();
+ if (!first) {
+ ret.append(',');
+ }
+ ret.append(toLog(element));
+ first = false;
+ }
+ return ret.append("]\n").toString();
+ } else if (obj instanceof Map) {
+ // Maps put as JavaScript hash.
+ Map map = (Map) obj;
+
+ StringBuffer ret = new StringBuffer("{");
+ boolean first = true;
+ for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
+ Object key = (Object) iter.next();
+ if (!first) {
+ ret.append(',');
+ }
+ ret.append(key);
+ ret.append(":");
+ ret.append(toLog(map.get(key)));
+ first = false;
+ }
+ return ret.append("}\n").toString();
+ } else if (obj instanceof Number || obj instanceof Boolean) {
+ // numbers and boolean put as-is, without conversion
+ return obj.toString();
+ } else if (obj instanceof String) {
+ // all other put as encoded strings.
+ StringBuffer ret = new StringBuffer();
+ addEncodedString(ret, obj);
+ return ret.append("\n").toString();
+ }
+ // All other objects threaded as Java Beans.
+ try {
+ StringBuffer ret = new StringBuffer("{");
+ PropertyDescriptor[] propertyDescriptors = PropertyUtils
+ .getPropertyDescriptors(obj);
+ boolean first = true;
+ for (int i = 0; i < propertyDescriptors.length; i++) {
+ PropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ String key = propertyDescriptor.getName();
+ if ("class".equals(key)
+ || propertyDescriptor.getReadMethod() == null) {
+ continue;
+ }
+ if (!first) {
+ ret.append(",\n\t");
+ }
+ addEncodedString(ret, key);
+ ret.append(":");
+ try {
+ ret.append(String.valueOf(PropertyUtils.getProperty(obj,
+ key)));
+
+ } catch (InvocationTargetException e) {
+ ret.append("Not ACCESIBLE");
+ }// ret.append(toLog(PropertyUtils.getProperty(obj, key)));
+ first = false;
+ }
+ return ret.append("}\n").toString();
+ } catch (Exception e) {
+ throw new MojoExecutionException(
+ "Error in conversion Java Object to String", e);
+ }
+ }
+
+ public void addEncodedString(StringBuffer buff, Object obj) {
+ buff.append("'");
+ buff.append(obj);
+ buff.append("'");
+
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CreateComponentMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,149 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.maven.model.Plugin;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.velocity.VelocityContext;
-
-/**
- * @author shura
- * @goal create
- *
- */
-public class CreateComponentMojo extends AbstractCDKMojo {
-
- private static final String TEMPLATES_PREFIX = "/component/";
-
- private static final String CONFIG_TEMPLATE = TEMPLATES_PREFIX+"config.xml";
-
- private static final String CLASS_TEMPLATE = TEMPLATES_PREFIX+"UIClass.java";
-
- private static final String RENDERER_TEMPLATE = TEMPLATES_PREFIX+"template.jspx";
-
- /**
- * @parameter expression="${name}"
- * @required
- */
- private String name ;
-
- /**
- * @parameter expression="${markup}"
- */
- private String markup ;
-
- /**
- * @parameter expression="${baseClass}" default-value="javax.faces.component.UIComponentBase"
- */
- private String baseClass ;
-
- /**
- * Directory where the output Java Files will be located.
- *
- * @parameter expression="${project.build.plugins}"
- * @required
- * @readonly
- */
- private List plugins ;
-
- /* (non-Javadoc)
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- if(project.getFile()!= null){
- boolean found= false;
- Plugin plugin = null;
- // Search for this plugin in project pom
- for (Iterator iter = plugins.iterator(); iter.hasNext();) {
- plugin = (Plugin) iter.next();
- if("maven-cdk-plugin".equals(plugin.getArtifactId())) {
-
- String groupId;
- if ("3.1.0".compareTo(plugin.getVersion()) > 0) {
- groupId = "org.ajax4jsf.cdk";
- } else {
- groupId = "org.richfaces.cdk";
- }
-
- if (groupId.equals(plugin.getGroupId())) {
- found = true;
- break;
- }
- }
- }
- if(found){
- try {
- createComponent(plugin);
- } catch (Exception e) {
- throw new MojoExecutionException("Error on create component",e);
- }
- } else {
- throw new MojoFailureException("This project is not configured for JSF components generation");
- }
- } else {
- throw new MojoFailureException("Goal 'create' must be run in existing project directory");
- }
-
- }
-
- /**
- * @param plugin
- * @throws Exception
- */
- private void createComponent(Plugin plugin) throws Exception {
- checkLibraryConfig();
- String className = Character.toUpperCase(name.charAt(0))+name.substring(1);
- VelocityContext context = new VelocityContext();
- context.put("name", name);
- context.put("className", className);
- String basePackage = baseClass.substring(0, baseClass.lastIndexOf('.'));
- String baseClassName = baseClass.substring(baseClass.lastIndexOf('.')+1);
- context.put("baseClass", baseClass);
- context.put("basePackage", basePackage);
- context.put("baseClassName", baseClassName);
- String prefix = library.getPrefix();
- context.put("package", prefix);
- context.put("prefix", prefix);
- String path = prefix.replace('.', '/');
- context.put("path", path);
- if(null == markup){
- markup = library.getRenderkits()[0].getMarkup();
- }
- context.put("markup", markup);
- String markupName = Character.toUpperCase(markup.charAt(0))+markup.substring(1);
- context.put("markupName", markupName);
- // Create component configuration file.
- File configFile = new File(componentConfigDirectory,name+".xml");
- writeParsedTemplate(CONFIG_TEMPLATE, context, configFile);
- File classFile = new File(project.getBuild().getSourceDirectory()+"/"+path+"/component/UI"+className+".java");
- writeParsedTemplate(CLASS_TEMPLATE, context, classFile);
- File templFile = new File(templatesDirectory,path+"/"+markup+className+".jspx");
- writeParsedTemplate(RENDERER_TEMPLATE, context, templFile);
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CreateComponentMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateComponentMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,148 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.model.Plugin;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * @author shura
+ * @goal create
+ *
+ */
+public class CreateComponentMojo extends AbstractCDKMojo {
+
+ private static final String TEMPLATES_PREFIX = "/component/";
+
+ private static final String CONFIG_TEMPLATE = TEMPLATES_PREFIX+"config.xml";
+
+ private static final String CLASS_TEMPLATE = TEMPLATES_PREFIX+"UIClass.java";
+
+ private static final String RENDERER_TEMPLATE = TEMPLATES_PREFIX+"template.jspx";
+
+ /**
+ * @parameter expression="${name}"
+ * @required
+ */
+ private String name ;
+
+ /**
+ * @parameter expression="${markup}"
+ */
+ private String markup ;
+
+ /**
+ * @parameter expression="${baseClass}" default-value="javax.faces.component.UIComponentBase"
+ */
+ private String baseClass ;
+
+ /**
+ * Directory where the output Java Files will be located.
+ *
+ * @parameter expression="${project.build.plugins}"
+ * @required
+ * @readonly
+ */
+ private List plugins ;
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ if(project.getFile()!= null){
+ boolean found= false;
+ Plugin plugin = null;
+ // Search for this plugin in project pom
+ for (Iterator iter = plugins.iterator(); iter.hasNext();) {
+ plugin = (Plugin) iter.next();
+ if("maven-cdk-plugin".equals(plugin.getArtifactId())) {
+
+ String groupId;
+ if ("3.1.0".compareTo(plugin.getVersion()) > 0) {
+ groupId = "org.richfaces.cdk";
+ } else {
+ groupId = "org.richfaces.cdk";
+ }
+
+ if (groupId.equals(plugin.getGroupId())) {
+ found = true;
+ break;
+ }
+ }
+ }
+ if(found){
+ try {
+ createComponent(plugin);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Error on create component",e);
+ }
+ } else {
+ throw new MojoFailureException("This project is not configured for JSF components generation");
+ }
+ } else {
+ throw new MojoFailureException("Goal 'create' must be run in existing project directory");
+ }
+
+ }
+
+ /**
+ * @param plugin
+ * @throws Exception
+ */
+ private void createComponent(Plugin plugin) throws Exception {
+ checkLibraryConfig();
+ String className = Character.toUpperCase(name.charAt(0))+name.substring(1);
+ VelocityContext context = new VelocityContext();
+ context.put("name", name);
+ context.put("className", className);
+ String basePackage = baseClass.substring(0, baseClass.lastIndexOf('.'));
+ String baseClassName = baseClass.substring(baseClass.lastIndexOf('.')+1);
+ context.put("baseClass", baseClass);
+ context.put("basePackage", basePackage);
+ context.put("baseClassName", baseClassName);
+ String prefix = library.getPrefix();
+ context.put("package", prefix);
+ context.put("prefix", prefix);
+ String path = prefix.replace('.', '/');
+ context.put("path", path);
+ if(null == markup){
+ markup = library.getRenderkits()[0].getMarkup();
+ }
+ context.put("markup", markup);
+ String markupName = Character.toUpperCase(markup.charAt(0))+markup.substring(1);
+ context.put("markupName", markupName);
+ // Create component configuration file.
+ File configFile = new File(componentConfigDirectory,name+".xml");
+ writeParsedTemplate(CONFIG_TEMPLATE, context, configFile);
+ File classFile = new File(project.getBuild().getSourceDirectory()+"/"+path+"/component/UI"+className+".java");
+ writeParsedTemplate(CLASS_TEMPLATE, context, classFile);
+ File templFile = new File(templatesDirectory,path+"/"+markup+className+".jspx");
+ writeParsedTemplate(RENDERER_TEMPLATE, context, templFile);
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CreateSkinMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,434 +0,0 @@
-package org.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.aja4jsf.builder.model.Resource;
-import org.aja4jsf.builder.model.ResourceConfig;
-import org.aja4jsf.builder.model.io.xpp3.ResourceConfigXpp3Reader;
-import org.aja4jsf.builder.model.io.xpp3.ResourceConfigXpp3Writer;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.versioning.VersionRange;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.velocity.VelocityContext;
-
-/**
- * This mojo is intended to create new skin add-on within existing project.
- * New resources are added to the project, and existing resource config is modified to include new files.
- * <p><b>Usage</b> <tt>mvn cdk:add-skin -Dname=<skinName> -Dpackage=<skinPackage>. </tt></p>
- * This adds new skin named <skinName> to project resources/META-INF/skins folder.<br/>
- * Skin resources - XCSS files are placed in <skinPackage>.<skinName> package within project resources directory.<br/>
- * If <em>package</em> is not specified, it is set same as groupId.<br/>
- *
- * Following parameters can be used
- * <li><strong>name</strong> - name of the skin. <strong>Required.</strong></li>
- * <li><strong>package</strong> - base package of the skin. If not specified, <em>groupId</em> is used</li>
- * <li><strong>createExt</strong> - if set to true, extended skin files are added</li>
- * <li><strong>baseSkin</strong> - name of base skin</li>
- *
- * @goal add-skin
- * @requiresProject true
- *
- *
-
- * @author Maksim Kaszynski
- *
- */
-public class CreateSkinMojo extends AbstractCDKMojo {
-
- private static final String SRC_MAIN_RESOURCES = "src/main/resources";
-
- private static final String PROPERTIES = ".skin.properties";
-
- private static final String XCSS = ".xcss";
-
- private static final String EXT_XCSS = "-ext.xcss";
-
- private static final String SRC_MAIN_CONFIG_RESOURCES = "src/main/config/resources";
-
- private static final String META_INF_SKINS = "META-INF/skins/";
-
- /**
- * Name of base package of skin.
- * If it is not set, GroupId is used.
- * @parameter expression="${package}" default-value="${project.groupId}"
- */
- private String packageName;
-
-
- /**
- * Name of skin. Required parameter.
- * @parameter expression="${name}"
- * @required
- */
- private String skinName;
-
-
- /**
- * Name of base skin.
- * @parameter expression="${baseSkin}"
- */
- private String baseSkin;
-
- /**
- * If set to true, a set of extended classes is generated
- * @parameter expression="${createExt}"
- */
- private boolean createExt;
-
-
- /**
- * @parameter expression="${plugin.artifactId}"
- * @readonly
- */
- private String pluginArtifactId;
-
- /**
- * @parameter expression="${plugin.groupId}"
- * @readonly
- */
- private String pluginGroupId;
-
- /**
- * @parameter expression="${plugin.version}"
- * @readonly
- */
- private String pluginVersion;
-
- /** @component */
- private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory;
-
- /** @component */
- private org.apache.maven.artifact.resolver.ArtifactResolver resolver;
-
- /**
- * @parameter expression="${localRepository}"
- * @readonly
- * */
- private org.apache.maven.artifact.repository.ArtifactRepository localRepository;
-
- /**
- *
- */
- private File pluginJarFile = null;
-
- /**
- *
- */
- private File resourceDir;
-
- public void execute() throws MojoExecutionException, MojoFailureException {
-
- getLog().info("Executing " + project);
- getLog().info("Generating Skin " + skinName);
- String fullSkinName = packageName.replace('/', '.') + "." + skinName;
- String shortName = skinName;
- getLog().debug("Skin name is supposed to be " + shortName);
- getLog().debug("Root package " + packageName);
- getLog().debug("Skin package is " + fullSkinName);
-
-
- SkinInfo skinInfoTemplate = new SkinInfo();
- skinInfoTemplate.setShortName(shortName);
- skinInfoTemplate.setPackageName(fullSkinName.toLowerCase());
- skinInfoTemplate.setBaseClassResources(getArchetypeSkinTemplatesFromJar("skin/baseclasses"));
- skinInfoTemplate.setExtClassResources(getArchetypeSkinTemplatesFromJar("skin/extclasses"));
- skinInfoTemplate.setBaseSkin(baseSkin);
- skinInfoTemplate.setPropertyFile(new Resource("skin/skin.properties"));
- skinInfoTemplate.setMasterXcss(new Resource("skin/skin.xcss"));
- skinInfoTemplate.setExtendedXcss(new Resource("skin/skin.xcss"));
- skinInfoTemplate.setUseExt(createExt);
- generateSkin(skinInfoTemplate);
-
-
- getLog().info("Generating Skin successful");
-
- }
-
- private void copyJarResource(Resource template, Resource skinResource, File baseDir) throws Exception{
- File newFile = new File(baseDir, skinResource.getPath());
- if (newFile.exists()) {
- getLog().debug("File " + newFile + " already exists. Skipping.");
- } else {
- try {
- File dir = newFile.getParentFile();
- if (!dir.exists()) {
- dir.mkdirs();
- }
-
- InputStream inputStream = getClass().getClassLoader().getResourceAsStream(template.getPath());
- FileOutputStream fileOutputStream = new FileOutputStream(newFile);
- byte [] buffer = new byte[1024];
- int read = -1;
- while((read = inputStream.read(buffer)) != -1) {
- fileOutputStream.write(buffer, 0, read);
- }
- inputStream.close();
- fileOutputStream.close();
-
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to write file " + newFile, e);
- }
- }
- }
-
- private void filterJarResource(Resource template, Resource skinResource, File baseDir, VelocityContext context) throws Exception{
- File newFile = new File(baseDir, skinResource.getPath());
- if (newFile.exists()) {
- getLog().debug("File " + newFile + " already exists. Skipping.");
- } else {
- try {
- writeParsedTemplate(template.getPath(), context, newFile);
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to write file " + newFile, e);
- }
- }
- }
-
- private List<Resource> filterComponentSkinTemplates(List<Resource> jarTemplates, SkinInfo skinInfo, File resourceDir) throws MojoExecutionException {
- List<Resource> newResources = new ArrayList<Resource>(jarTemplates.size());
- for (Resource jarTemplate : jarTemplates) {
- Resource newResource = new Resource();
- String jarTemplateName = jarTemplate.getName();
- int indexOfSlash = jarTemplateName.lastIndexOf('/');
- if (indexOfSlash > 0) {
- jarTemplateName = jarTemplateName.substring(indexOfSlash + 1);
- }
- String resourceName = skinInfo.getPackageName().replace('.', '/') + "/css/" + jarTemplateName;
- newResource.setName(resourceName);
- newResource.setPath(resourceName);
- newResources.add(newResource);
- try {
- filterJarResource(jarTemplate, newResource, resourceDir, new VelocityContext());
- } catch (Exception e) {
- throw new MojoExecutionException("An exception occured while filtering resource " + jarTemplate + " into " + newResource, e);
- }
- }
- return newResources;
- }
-
-
- private SkinInfo cloneSkinInfo(SkinInfo skinInfo) throws MojoExecutionException {
- try {
- return (SkinInfo) skinInfo.clone();
- } catch(CloneNotSupportedException exception) {
- throw new MojoExecutionException("Dunno why.", exception);
- }
- }
-
- private void generateSkin(SkinInfo skinInfoTemplate) throws MojoExecutionException, MojoFailureException{
- resourceDir = new File(project.getBasedir(), SRC_MAIN_RESOURCES);
- getLog().debug("Resources directory is supposed to be" + resourceDir);
- checkAndCreateDirectory(resourceDir);
-
- String fullName = skinInfoTemplate.getPackageName();
- String packageFolder = fullName.replace('.', '/');
- getLog().debug("Relative path to package is " + packageFolder);
-
- VelocityContext velocityMasterContext = new VelocityContext();
- velocityMasterContext.put("mojo", this);
- velocityMasterContext.put("packagePath", packageFolder);
- velocityMasterContext.put("name", skinInfoTemplate.getShortName());
-
- if (baseSkin != null) {
- velocityMasterContext.put("baseSkin", baseSkin);
- }
-
- SkinInfo effectiveSkinInfo = cloneSkinInfo(skinInfoTemplate);
- List<Resource> allResources = new ArrayList<Resource>();
- velocityMasterContext.put("skinInfo", effectiveSkinInfo);
-
- //Copy basic classes, and list them
-
- List<Resource> baseClassResources = filterComponentSkinTemplates(skinInfoTemplate.getBaseClassResources(), skinInfoTemplate, resourceDir);
-
- effectiveSkinInfo.setBaseClassResources(baseClassResources);
- allResources.addAll(baseClassResources);
- velocityMasterContext.put("baseClassResources", baseClassResources);
-
- //Generate Master XCSS file
- Resource masterXcss = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + XCSS);
- effectiveSkinInfo.setMasterXcss(masterXcss);
- allResources.add(masterXcss);
- try {
- generateMasterXCSSFile(skinInfoTemplate.getMasterXcss(), effectiveSkinInfo.getMasterXcss(), effectiveSkinInfo.getBaseClassResources());
- } catch(Exception e) {
- throw new MojoExecutionException("Unable to generate master.xcss file " + masterXcss, e);
- }
-
- if (createExt) {
- //Copy Ext classes, if needed
- List<Resource> extClassResources = filterComponentSkinTemplates(skinInfoTemplate.getExtClassResources(), skinInfoTemplate, resourceDir);
- effectiveSkinInfo.setExtClassResources(extClassResources);
- allResources.addAll(extClassResources);
- velocityMasterContext.put("extClassResources", extClassResources);
-
- //Generate Master EXT XCSS file
- Resource masterExtXcss = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + EXT_XCSS);
- effectiveSkinInfo.setExtendedXcss(masterExtXcss);
- allResources.add(masterExtXcss);
- try {
- generateMasterXCSSFile(skinInfoTemplate.getExtendedXcss(), effectiveSkinInfo.getExtendedXcss(), effectiveSkinInfo.getExtClassResources());
-
- } catch(Exception e) {
- throw new MojoExecutionException("Unable to generate master.xcss file " + masterExtXcss, e);
- }
- }
-
- Resource properties = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + PROPERTIES);
- effectiveSkinInfo.setPropertyFile(properties);
- try {
- filterJarResource(skinInfoTemplate.getPropertyFile(), properties, resourceDir, velocityMasterContext);
- } catch (Exception e) {
- throw new MojoExecutionException("An exception occured while filtering resource " + skinInfoTemplate.getPropertyFile() + " into " + properties, e);
- }
-
-
- File resourceConfigDir = new File(project.getBasedir(), SRC_MAIN_CONFIG_RESOURCES);
- checkAndCreateDirectory(resourceConfigDir);
- File resourceConfigFile = new File(resourceConfigDir, effectiveSkinInfo.getShortName() + "-resources.xml");;
- try {
- addToResourceConfig(allResources, resourceConfigFile);
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to register newly added resources in resource-config.xml", e);
- }
-
-
- packageArchetypeResourcesToBaseDir("src/main/java", effectiveSkinInfo, true);
- packageArchetypeResourcesToBaseDir("src/main/resources", effectiveSkinInfo, false);
- packageArchetypeResourcesToBaseDir("src/test/java", effectiveSkinInfo, true);
-
-
-
- }
-
- private List<Resource> packageArchetypeResourcesToBaseDir(String prefix, final SkinInfo skinInfo, boolean filter) throws MojoExecutionException{
- String archetypePrefix = "skin/archetype/" + prefix;
- List<Resource> archetypeResources = getArchetypeSkinTemplatesFromJar(archetypePrefix);
- List<Resource> filteredResources = new ArrayList<Resource>(archetypeResources.size());
- String newPrefix = prefix;
- String packageFolder = skinInfo.getPackageName().replace('.', '/');
- if (packageFolder != null) {
- newPrefix = prefix + "/" + packageFolder;
- }
-
-
- @SuppressWarnings("serial") VelocityContext velocityContext = new VelocityContext() {
- {
- put("skinInfo", skinInfo);
- }
- };
- for (Resource resource : archetypeResources) {
- String archetypePath = resource.getPath();
- String pathSuffix = archetypePath.substring(archetypePrefix.length());
- String newPath = newPrefix + pathSuffix;
-
- Resource newResource = new Resource(newPath);
-
- try {
- if (filter) {
- filterJarResource(resource, newResource, project.getBasedir(), velocityContext);
- } else {
- copyJarResource(resource, newResource, project.getBasedir());
- }
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to process archetype file " + resource.getPath(), e);
- }
-
- filteredResources.add(newResource);
- }
- return filteredResources;
- }
-
- private void generateMasterXCSSFile(Resource template, Resource target, List<Resource> includedResources) throws Exception {
- VelocityContext context = new VelocityContext();
- context.put("mojo", this);
- context.put("includedResources", includedResources);
- filterJarResource(template, target, resourceDir, context);
- }
-
- private Resource fromJarEntry(JarEntry entry) {
- Resource resource = new Resource();
- resource.setName(entry.getName());
- resource.setPath(entry.getName());
- return resource;
- }
-
- private List<Resource> getArchetypeSkinTemplatesFromJar(String prefix) throws MojoExecutionException{
- try {
- if (pluginJarFile == null) {
- pluginJarFile = getPluginArtifactJar();
- }
- List <Resource> fileNames = new ArrayList<Resource>();
- JarFile jar = new JarFile(pluginJarFile);
- Enumeration<JarEntry> entries = jar.entries();
- while(entries.hasMoreElements()) {
- JarEntry jarEntry = entries.nextElement();
- String jarEntryName = jarEntry.getName();
- if(jarEntryName.startsWith(prefix) && !jarEntry.isDirectory()) {
- fileNames.add(fromJarEntry(jarEntry));
- }
- }
- return fileNames;
- } catch (Exception e) {
- throw new MojoExecutionException("Unable to list templates within Plugin Jar file");
- }
- }
-
- private File getPluginArtifactJar() throws ArtifactResolutionException, ArtifactNotFoundException {
- Artifact pluginArtifact =
- artifactFactory.createPluginArtifact(pluginGroupId, pluginArtifactId, VersionRange.createFromVersion(pluginVersion));
-
- resolver.resolve(pluginArtifact, Collections.emptyList(), localRepository);
-
- return pluginArtifact.getFile();
- }
-
- private void checkAndCreateDirectory(File directory) throws MojoExecutionException {
- getLog().debug("Checking directory " + directory + " for existence");
- if (!directory.exists()) {
- directory.mkdirs();
- getLog().debug("Directory " + directory + " created");
- }
- if (!directory.isDirectory()) {
- throw new MojoExecutionException("Directory " + directory.getAbsolutePath() + " is not a Directory");
- }
- }
-
- private void addToResourceConfig(List<Resource> resources, File resourceConfigFile) throws Exception{
- ResourceConfig resourceConfig = null;
-
- if (resourceConfigFile.exists()) {
- resourceConfig = new ResourceConfigXpp3Reader().read(new FileInputStream(resourceConfigFile));
- }
-
- if (resourceConfig == null) {
- resourceConfig = new ResourceConfig();
- resourceConfig.setResources(resources);
- } else {
- for (Resource resource : resources) {
- if (!resourceConfig.containsResource(resource)) {
- resourceConfig.addResource(resource);
- }
- }
- }
-
-
-
- new ResourceConfigXpp3Writer().write(new FileWriter(resourceConfigFile), resourceConfig);
-
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CreateSkinMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateSkinMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,437 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.aja4jsf.builder.model.Resource;
+import org.aja4jsf.builder.model.ResourceConfig;
+import org.aja4jsf.builder.model.io.xpp3.ResourceConfigXpp3Reader;
+import org.aja4jsf.builder.model.io.xpp3.ResourceConfigXpp3Writer;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.versioning.VersionRange;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * This mojo is intended to create new skin add-on within existing project.
+ * New resources are added to the project, and existing resource config is modified to include new files.
+ * <p><b>Usage</b> <tt>mvn cdk:add-skin -Dname=<skinName> -Dpackage=<skinPackage>. </tt></p>
+ * This adds new skin named <skinName> to project resources/META-INF/skins folder.<br/>
+ * Skin resources - XCSS files are placed in <skinPackage>.<skinName> package within project resources directory.<br/>
+ * If <em>package</em> is not specified, it is set same as groupId.<br/>
+ *
+ * Following parameters can be used
+ * <li><strong>name</strong> - name of the skin. <strong>Required.</strong></li>
+ * <li><strong>package</strong> - base package of the skin. If not specified, <em>groupId</em> is used</li>
+ * <li><strong>createExt</strong> - if set to true, extended skin files are added</li>
+ * <li><strong>baseSkin</strong> - name of base skin</li>
+ *
+ * @goal add-skin
+ * @requiresProject true
+ *
+ *
+
+ * @author Maksim Kaszynski
+ *
+ */
+public class CreateSkinMojo extends AbstractCreateMojo {
+
+ private static final String PROPERTIES = ".skin.properties";
+
+ private static final String XCSS = ".xcss";
+
+ private static final String EXT_XCSS = "-ext.xcss";
+
+ private static final String SRC_MAIN_CONFIG_RESOURCES = "src/main/config/resources";
+
+ private static final String META_INF_SKINS = "META-INF/skins/";
+
+ /**
+ * Name of base package of skin.
+ * If it is not set, GroupId is used.
+ * @parameter expression="${package}" default-value="${project.groupId}"
+ */
+ private String packageName;
+
+
+ /**
+ * Name of skin. Required parameter.
+ * @parameter expression="${name}"
+ * @required
+ */
+ private String skinName;
+
+
+ /**
+ * Name of base skin.
+ * @parameter expression="${baseSkin}"
+ */
+ private String baseSkin;
+
+ /**
+ * If set to true, a set of extended classes is generated
+ * @parameter expression="${createExt}"
+ */
+ private boolean createExt;
+
+
+ /**
+ * @parameter expression="${plugin.artifactId}"
+ * @readonly
+ */
+ private String pluginArtifactId;
+
+ /**
+ * @parameter expression="${plugin.groupId}"
+ * @readonly
+ */
+ private String pluginGroupId;
+
+ /**
+ * @parameter expression="${plugin.version}"
+ * @readonly
+ */
+ private String pluginVersion;
+
+ /** @component */
+ private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory;
+
+ /** @component */
+ private org.apache.maven.artifact.resolver.ArtifactResolver resolver;
+
+ /**
+ * @parameter expression="${localRepository}"
+ * @readonly
+ * */
+ private org.apache.maven.artifact.repository.ArtifactRepository localRepository;
+
+ /**
+ *
+ */
+ private File pluginJarFile = null;
+
+ /**
+ *
+ */
+ private File resourceDir;
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+
+ getLog().info("Executing " + project);
+ getLog().info("Generating Skin " + skinName);
+ String fullSkinName = packageName.replace('/', '.') + "." + skinName;
+ String shortName = skinName;
+ getLog().debug("Skin name is supposed to be " + shortName);
+ getLog().debug("Root package " + packageName);
+ getLog().debug("Skin package is " + fullSkinName);
+
+ //RF-4023
+ if (!isValidJavaName(skinName)){
+ throw new MojoExecutionException("Invalid skin name '" + skinName + "'. Please type another name.");
+ }
+
+ if (!isValidPackageName(packageName)) {
+ throw new MojoExecutionException("Invalid skin package '" + packageName + "'. Please type another package.");
+ }
+
+ SkinInfo skinInfoTemplate = new SkinInfo();
+ skinInfoTemplate.setShortName(shortName);
+ skinInfoTemplate.setPackageName(fullSkinName.toLowerCase());
+ skinInfoTemplate.setBaseClassResources(getArchetypeSkinTemplatesFromJar("skin/baseclasses"));
+ skinInfoTemplate.setExtClassResources(getArchetypeSkinTemplatesFromJar("skin/extclasses"));
+ skinInfoTemplate.setBaseSkin(baseSkin);
+ skinInfoTemplate.setPropertyFile(new Resource("skin/skin.properties"));
+ skinInfoTemplate.setMasterXcss(new Resource("skin/skin.xcss"));
+ skinInfoTemplate.setExtendedXcss(new Resource("skin/skin.xcss"));
+ skinInfoTemplate.setUseExt(createExt);
+ generateSkin(skinInfoTemplate);
+
+
+ getLog().info("Generating Skin successful");
+
+ }
+
+ private void copyJarResource(Resource template, Resource skinResource, File baseDir) throws Exception{
+ File newFile = new File(baseDir, skinResource.getPath());
+ if (newFile.exists()) {
+ getLog().debug("File " + newFile + " already exists. Skipping.");
+ } else {
+ try {
+ File dir = newFile.getParentFile();
+ if (!dir.exists()) {
+ dir.mkdirs();
+ }
+
+ InputStream inputStream = getClass().getClassLoader().getResourceAsStream(template.getPath());
+ FileOutputStream fileOutputStream = new FileOutputStream(newFile);
+ byte [] buffer = new byte[1024];
+ int read = -1;
+ while((read = inputStream.read(buffer)) != -1) {
+ fileOutputStream.write(buffer, 0, read);
+ }
+ inputStream.close();
+ fileOutputStream.close();
+
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to write file " + newFile, e);
+ }
+ }
+ }
+
+ private List<Resource> filterComponentSkinTemplates(List<Resource> jarTemplates, SkinInfo skinInfo, File resourceDir) throws MojoExecutionException {
+ List<Resource> newResources = new ArrayList<Resource>(jarTemplates.size());
+ for (Resource jarTemplate : jarTemplates) {
+ Resource newResource = new Resource();
+ String jarTemplateName = jarTemplate.getName();
+ int indexOfSlash = jarTemplateName.lastIndexOf('/');
+ if (indexOfSlash > 0) {
+ jarTemplateName = jarTemplateName.substring(indexOfSlash + 1);
+ }
+ String resourceName = skinInfo.getPackageName().replace('.', '/') + "/css/" + jarTemplateName;
+ newResource.setName(resourceName);
+ newResource.setPath(resourceName);
+ newResources.add(newResource);
+ try {
+ filterJarResource(jarTemplate, newResource, resourceDir, new VelocityContext());
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + jarTemplate + " into " + newResource, e);
+ }
+ }
+ return newResources;
+ }
+
+
+ private SkinInfo cloneSkinInfo(SkinInfo skinInfo) throws MojoExecutionException {
+ try {
+ return (SkinInfo) skinInfo.clone();
+ } catch(CloneNotSupportedException exception) {
+ throw new MojoExecutionException("Dunno why.", exception);
+ }
+ }
+
+ private void generateSkin(SkinInfo skinInfoTemplate) throws MojoExecutionException, MojoFailureException{
+ resourceDir = new File(project.getBasedir(), SRC_MAIN_RESOURCES);
+ getLog().debug("Resources directory is supposed to be" + resourceDir);
+ checkAndCreateDirectory(resourceDir);
+
+ String fullName = skinInfoTemplate.getPackageName();
+ String packageFolder = fullName.replace('.', '/');
+ getLog().debug("Relative path to package is " + packageFolder);
+
+ VelocityContext velocityMasterContext = new VelocityContext();
+ velocityMasterContext.put("mojo", this);
+ velocityMasterContext.put("packagePath", packageFolder);
+ velocityMasterContext.put("name", skinInfoTemplate.getShortName());
+
+ if (baseSkin != null) {
+ velocityMasterContext.put("baseSkin", baseSkin);
+ }
+
+ SkinInfo effectiveSkinInfo = cloneSkinInfo(skinInfoTemplate);
+ List<Resource> allResources = new ArrayList<Resource>();
+ velocityMasterContext.put("skinInfo", effectiveSkinInfo);
+
+ //Copy basic classes, and list them
+
+ List<Resource> baseClassResources = filterComponentSkinTemplates(skinInfoTemplate.getBaseClassResources(), skinInfoTemplate, resourceDir);
+
+ effectiveSkinInfo.setBaseClassResources(baseClassResources);
+ allResources.addAll(baseClassResources);
+ velocityMasterContext.put("baseClassResources", baseClassResources);
+
+ //Generate Master XCSS file
+ Resource masterXcss = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + XCSS);
+ effectiveSkinInfo.setMasterXcss(masterXcss);
+ allResources.add(masterXcss);
+ try {
+ generateMasterXCSSFile(skinInfoTemplate.getMasterXcss(), effectiveSkinInfo.getMasterXcss(), effectiveSkinInfo.getBaseClassResources());
+ } catch(Exception e) {
+ throw new MojoExecutionException("Unable to generate master.xcss file " + masterXcss, e);
+ }
+
+ if (createExt) {
+ //Copy Ext classes, if needed
+ List<Resource> extClassResources = filterComponentSkinTemplates(skinInfoTemplate.getExtClassResources(), skinInfoTemplate, resourceDir);
+ effectiveSkinInfo.setExtClassResources(extClassResources);
+ allResources.addAll(extClassResources);
+ velocityMasterContext.put("extClassResources", extClassResources);
+
+ //Generate Master EXT XCSS file
+ Resource masterExtXcss = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + EXT_XCSS);
+ effectiveSkinInfo.setExtendedXcss(masterExtXcss);
+ allResources.add(masterExtXcss);
+ try {
+ generateMasterXCSSFile(skinInfoTemplate.getExtendedXcss(), effectiveSkinInfo.getExtendedXcss(), effectiveSkinInfo.getExtClassResources());
+
+ } catch(Exception e) {
+ throw new MojoExecutionException("Unable to generate master.xcss file " + masterExtXcss, e);
+ }
+ }
+
+ Resource properties = new Resource(META_INF_SKINS + effectiveSkinInfo.getShortName() + PROPERTIES);
+ effectiveSkinInfo.setPropertyFile(properties);
+ try {
+ filterJarResource(skinInfoTemplate.getPropertyFile(), properties, resourceDir, velocityMasterContext);
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + skinInfoTemplate.getPropertyFile() + " into " + properties, e);
+ }
+
+
+ File resourceConfigDir = new File(project.getBasedir(), SRC_MAIN_CONFIG_RESOURCES);
+ checkAndCreateDirectory(resourceConfigDir);
+ File resourceConfigFile = new File(resourceConfigDir, effectiveSkinInfo.getShortName() + "-resources.xml");;
+ try {
+ addToResourceConfig(allResources, resourceConfigFile);
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to register newly added resources in resource-config.xml", e);
+ }
+
+
+ packageArchetypeResourcesToBaseDir("src/main/java", effectiveSkinInfo, true);
+ packageArchetypeResourcesToBaseDir("src/main/resources", effectiveSkinInfo, false);
+ packageArchetypeResourcesToBaseDir("src/test/java", effectiveSkinInfo, true);
+
+
+
+ }
+
+ private List<Resource> packageArchetypeResourcesToBaseDir(String prefix, final SkinInfo skinInfo, boolean filter) throws MojoExecutionException{
+ String archetypePrefix = "skin/archetype/" + prefix;
+ List<Resource> archetypeResources = getArchetypeSkinTemplatesFromJar(archetypePrefix);
+ List<Resource> filteredResources = new ArrayList<Resource>(archetypeResources.size());
+ String newPrefix = prefix;
+ String packageFolder = skinInfo.getPackageName().replace('.', '/');
+ if (packageFolder != null) {
+ newPrefix = prefix + "/" + packageFolder;
+ }
+
+
+ @SuppressWarnings("serial") VelocityContext velocityContext = new VelocityContext() {
+ {
+ put("skinInfo", skinInfo);
+ }
+ };
+ for (Resource resource : archetypeResources) {
+ String archetypePath = resource.getPath();
+ String pathSuffix = archetypePath.substring(archetypePrefix.length());
+ String newPath = newPrefix + pathSuffix;
+
+ Resource newResource = new Resource(newPath);
+
+ try {
+ if (filter) {
+ filterJarResource(resource, newResource, project.getBasedir(), velocityContext);
+ } else {
+ copyJarResource(resource, newResource, project.getBasedir());
+ }
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to process archetype file " + resource.getPath(), e);
+ }
+
+ filteredResources.add(newResource);
+ }
+ return filteredResources;
+ }
+
+ private void generateMasterXCSSFile(Resource template, Resource target, List<Resource> includedResources) throws Exception {
+ VelocityContext context = new VelocityContext();
+ context.put("mojo", this);
+ context.put("includedResources", includedResources);
+ filterJarResource(template, target, resourceDir, context);
+ }
+
+ private Resource fromJarEntry(JarEntry entry) {
+ Resource resource = new Resource();
+ resource.setName(entry.getName());
+ resource.setPath(entry.getName());
+ return resource;
+ }
+
+ private List<Resource> getArchetypeSkinTemplatesFromJar(String prefix) throws MojoExecutionException{
+ try {
+ if (pluginJarFile == null) {
+ pluginJarFile = getPluginArtifactJar();
+ }
+ List <Resource> fileNames = new ArrayList<Resource>();
+ JarFile jar = new JarFile(pluginJarFile);
+ Enumeration<JarEntry> entries = jar.entries();
+ while(entries.hasMoreElements()) {
+ JarEntry jarEntry = entries.nextElement();
+ String jarEntryName = jarEntry.getName();
+ if(jarEntryName.startsWith(prefix) && !jarEntry.isDirectory()) {
+ fileNames.add(fromJarEntry(jarEntry));
+ }
+ }
+ return fileNames;
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to list templates within Plugin Jar file");
+ }
+ }
+
+ private File getPluginArtifactJar() throws ArtifactResolutionException, ArtifactNotFoundException {
+ Artifact pluginArtifact =
+ artifactFactory.createPluginArtifact(pluginGroupId, pluginArtifactId, VersionRange.createFromVersion(pluginVersion));
+
+ resolver.resolve(pluginArtifact, Collections.emptyList(), localRepository);
+
+ return pluginArtifact.getFile();
+ }
+
+ private void addToResourceConfig(List<Resource> resources, File resourceConfigFile) throws Exception{
+ ResourceConfig resourceConfig = null;
+
+ if (resourceConfigFile.exists()) {
+ resourceConfig = new ResourceConfigXpp3Reader().read(new FileInputStream(resourceConfigFile));
+ }
+
+ if (resourceConfig == null) {
+ resourceConfig = new ResourceConfig();
+ resourceConfig.setResources(resources);
+ } else {
+ for (Resource resource : resources) {
+ if (!resourceConfig.containsResource(resource)) {
+ resourceConfig.addResource(resource);
+ }
+ }
+ }
+
+
+
+ new ResourceConfigXpp3Writer().write(new FileWriter(resourceConfigFile), resourceConfig);
+
+ }
+
+}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateThemeMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/CreateThemeMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateThemeMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/CreateThemeMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,158 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.util.Locale;
+
+import org.aja4jsf.builder.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.velocity.VelocityContext;
+
+/**
+ * This mojo is intended to create new theme within existing project.
+ * <p><b>Usage</b> <tt>mvn cdk:add-theme -Dname=<themeName> [ -Dpackage=<themePackage> ]</tt></p>
+ * This adds new theme named <themeName> to project resources/META-INF/themes folder.<br/>
+ * If <em>package</em> is not specified, it is set same as groupId.<br/>
+ *
+ * Following parameters can be used
+ * <li><strong>name</strong> - name of the theme. <strong>Required.</strong></li>
+ * <li><strong>package</strong> - base package of the theme. If not specified, <em>groupId</em> is used</li>
+ *
+ * @goal add-theme
+ * @requiresProject true
+ *
+ * @author Nick Belaevski
+ */
+public class CreateThemeMojo extends AbstractCreateMojo {
+
+ private static final String XCSS = ".xcss";
+
+ private static final String META_INF_THEMES = "META-INF/themes/";
+
+ private static final String XCSS_THEMES_PACKAGE = "/renderkit/html/css";
+
+ private static final String THEME_PROPERTIES = ".theme.properties";
+
+ private static final String RENDERKIT_THEMES = "renderkit.html";
+
+ /**
+ * Name of base package of theme.
+ * If it is not set, GroupId is used.
+ * @parameter expression="${package}" default-value="${project.groupId}"
+ */
+ private String packageName;
+
+
+ /**
+ * Name of theme. Required parameter.
+ * @parameter expression="${name}"
+ * @required
+ */
+ private String themeName;
+
+ private String generateRendererName(String themeName) {
+ StringBuilder rendererTypeBuilder = new StringBuilder();
+ rendererTypeBuilder.append(Character.toUpperCase(themeName.charAt(0)));
+ rendererTypeBuilder.append(themeName.subSequence(1, themeName.length()));
+ rendererTypeBuilder.append("Renderer");
+ return rendererTypeBuilder.toString();
+ }
+
+ private void generateTheme(String packageName, String themeName) throws MojoExecutionException, MojoFailureException {
+ Resource themeProperties = new Resource("theme/themes/theme.properties");
+ Resource themeXCSS = new Resource("theme/css/theme.xcss");
+ Resource themeConfig = new Resource("theme/component/theme.xml");
+ Resource themeTemplate = new Resource("theme/template/theme.jspx");
+
+ File resourceDir = new File(project.getBasedir(), SRC_MAIN_RESOURCES);
+
+ String packagePath = packageName.replace('.', '/');
+ String xcssPackagePath = packagePath + XCSS_THEMES_PACKAGE;
+ String rendererName = generateRendererName(themeName);
+ String rendererType = packageName + '.' + rendererName;
+ String rendererClassName = packageName + '.' + RENDERKIT_THEMES + '.' + rendererName;
+
+ getLog().debug("Relative path to package is " + packagePath);
+
+ VelocityContext velocityMasterContext = new VelocityContext();
+ velocityMasterContext.put("packagePath", packagePath);
+ velocityMasterContext.put("xcssPackagePath", xcssPackagePath);
+ velocityMasterContext.put("name", themeName);
+ velocityMasterContext.put("rendererType", rendererType);
+ velocityMasterContext.put("rendererClassName", rendererClassName);
+
+ Resource properties = new Resource(META_INF_THEMES + themeName + THEME_PROPERTIES);
+ try {
+ filterJarResource(themeProperties, properties, resourceDir, velocityMasterContext);
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + themeProperties + " into " + properties, e);
+ }
+
+ Resource xcss = new Resource(xcssPackagePath + '/' + themeName + XCSS);
+ try {
+ filterJarResource(themeXCSS, xcss, resourceDir, velocityMasterContext);
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + themeXCSS + " into " + xcss, e);
+ }
+
+ File configDir = new File(project.getBasedir(), "src/main/config/component");
+ Resource config = new Resource(themeName + ".xml");
+ try {
+ filterJarResource(themeConfig, config, configDir, velocityMasterContext);
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + themeConfig + " into " + config, e);
+ }
+
+ File templateDir = new File(project.getBasedir(), "src/main/templates");
+ Resource template = new Resource(packagePath + '/' + themeName + ".jspx");
+ try {
+ filterJarResource(themeTemplate, template, templateDir, velocityMasterContext);
+ } catch (Exception e) {
+ throw new MojoExecutionException("An exception occured while filtering resource " + themeTemplate + " into " + template, e);
+ }
+ }
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().info("Executing " + project);
+ getLog().info("Generating Theme " + themeName);
+
+ String themePackageName = packageName.replace('/', '.').toLowerCase(Locale.US);
+ String shortName = themeName;
+ getLog().debug("Root package " + packageName);
+ getLog().debug("Theme package is " + themePackageName);
+
+ if (!isValidJavaName(themeName)){
+ throw new MojoExecutionException("Invalid theme name '" + themeName + "'. Please type another name.");
+ }
+
+ if (!isValidPackageName(packageName)) {
+ throw new MojoExecutionException("Invalid theme package '" + packageName + "'. Please type another package.");
+ }
+
+ generateTheme(themePackageName, shortName);
+
+ getLog().info("Generating Theme successful");
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,324 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.io.File;
-import java.io.FilenameFilter;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.generator.ComponentGenerator;
-import org.ajax4jsf.builder.generator.ComponentGenerator2;
-import org.ajax4jsf.builder.generator.ComponentTagGenerator;
-import org.ajax4jsf.builder.generator.ConverterGenerator;
-import org.ajax4jsf.builder.generator.ConverterTagGenerator;
-import org.ajax4jsf.builder.generator.FaceletsTaglibGenerator;
-import org.ajax4jsf.builder.generator.FacesConfigGenerator;
-import org.ajax4jsf.builder.generator.GeneratorException;
-import org.ajax4jsf.builder.generator.JSFGeneratorConfiguration;
-import org.ajax4jsf.builder.generator.ListenerGenerator;
-import org.ajax4jsf.builder.generator.ListenerTagGenerator;
-import org.ajax4jsf.builder.generator.RenderKitBean;
-import org.ajax4jsf.builder.generator.RendererGenerator;
-import org.ajax4jsf.builder.generator.ResourcesConfigGenerator;
-import org.ajax4jsf.builder.generator.TagHandlerGenerator;
-import org.ajax4jsf.builder.generator.TaglibGenerator;
-import org.ajax4jsf.builder.generator.ValidatorGenerator;
-import org.ajax4jsf.builder.generator.ValidatorTagGenerator;
-import org.ajax4jsf.builder.maven.MavenLogger;
-import org.ajax4jsf.builder.velocity.BuilderContext;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-import org.apache.velocity.exception.ParseErrorException;
-import org.apache.velocity.exception.ResourceNotFoundException;
-
-/**
- * This plugin geterate JSF components and renderers source code, as well as
- * configuration files.
- *
- * @author shura
- * @goal generate
- * @requiresDependencyResolution compile
- * @phase generate-sources
- * @execute phase="compile"
- */
-public class GenerateMojo extends AbstractCDKMojo implements
- JSFGeneratorConfiguration {
-
- /**
- * Project executed by first compile lifecycle.
- *
- * @parameter expression="${executedProject}"
- * @readonly
- */
- protected MavenProject executedProject;
-
- /*
- * (non-Javadoc)
- *
- * @see org.apache.maven.plugin.Mojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- getLog().debug("GenerateMojo components");
-
- //FIXME: configure plexus component instead of programmatic property set.
-
- // velocity.getEngine().setProperty("velocimacro.library", getTemplatesPath() + "/VM_global_library.vm");
-
- if (null != executedProject) {
- Taglib taglib = checkLibraryConfig();
- ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
- // compile goal executed
- try {
- // Parse config files.
- ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
- Thread.currentThread().setContextClassLoader(generatiorLoader);
- BuilderConfig config = createConfig(generatiorLoader);
- MavenLogger mavenLogger = new MavenLogger(getLog());
- // TODO - parse sources by qdox for JavaDoc comments ?
- // GenerateMojo components.
- ComponentGenerator2 compGenerator = new ComponentGenerator2(this,
- mavenLogger);
- compGenerator.createFiles(config);
- // GenerateMojo validators
- ValidatorGenerator validatorGenerator = new ValidatorGenerator(this, mavenLogger);
- validatorGenerator.createFiles(config);
- // GenerateMojo converters
- ConverterGenerator converterGenerator = new ConverterGenerator(this, mavenLogger);
- converterGenerator.createFiles(config);
- // GenerateMojo renderers
- RendererGenerator rendererGenerator = new RendererGenerator(
- this, mavenLogger);
- rendererGenerator.setSrcDir(templatesDirectory);
- rendererGenerator.createFiles(config);
- // GenerateMojo component test
-/*
- ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
- componentTestGenerator.setDestDir(outputTestsDirectory);
- componentTestGenerator.createFiles(config);
-*/
- // GenerateMojo tags
- ComponentTagGenerator componentTagGenerator = new ComponentTagGenerator(this, mavenLogger);
- componentTagGenerator.createFiles(config);
-
-// GenerateMojo tags for validators
- ValidatorTagGenerator validatorTagGenerator = new ValidatorTagGenerator(this, mavenLogger);
- validatorTagGenerator.createFiles(config);
-
-// GenerateMojo tags for converters
- ConverterTagGenerator converterTagGenerator = new ConverterTagGenerator(this, mavenLogger);
- converterTagGenerator.createFiles(config);
-
-
- ListenerTagGenerator listenerTagGenerator = new ListenerTagGenerator(this, mavenLogger);
- listenerTagGenerator.createFiles(config);
-
-
- // GenerateMojo tag test
-/*
- TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
- tagTestGenerator.setDestDir(outputTestsDirectory);
- tagTestGenerator.createFiles(config);
-*/
- // GenerateMojo tag handlers
- TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
- this, mavenLogger);
- tagHandlerGenerator.createFiles(config);
- //Generate listeners
- ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
- listenerGenerator.createFiles(config);
-
- JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
-
- public ClassLoader getClassLoader() {
- return createProjectClassLoader(executedProject);
- }
-
- public File getDestDir() {
- return outputResourcesDirectory;
- }
-
- public String getKey() {
- return key;
- }
-
- public Template getTemplate(String name) throws GeneratorException {
- return GenerateMojo.this.getTemplate(name);
- }
-
- public String getTemplatesPath() {
- return GenerateMojo.this.getTemplatesPath();
- }
-
- };
- // GenerateMojo faces-config
- FacesConfigGenerator configGenerator = new FacesConfigGenerator(
- resourcesConfiguration, mavenLogger);
- configGenerator.setInclude(facesConfigInclude);
- configGenerator.setFacesconfig(new File(
- outputResourcesDirectory, "META-INF/faces-config.xml"));
- RenderKitBean renderKitBean = configGenerator.createRenderKit();
- renderKitBean.setRenderkitid("HTML_BASIC");
- configGenerator.createFiles(config);
- // GenerateMojo JSP taglib
- if (null != taglib) {
- TaglibGenerator taglibGenerator = new TaglibGenerator(
- resourcesConfiguration, mavenLogger);
- taglibGenerator.setUri(taglib.getUri());
- taglibGenerator.setShortname(taglib.getShortName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setDisplayname(taglib.getDisplayName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setValidatorclass(taglib.getValidatorClass());
- taglibGenerator.setTlibversion(taglib.getTlibVersion());
- taglibGenerator.setJspversion(taglib.getJspVersion());
- taglibGenerator.setInclude(taglibInclude);
- taglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".tld"));
- taglibGenerator.createFiles(config);
- // GenerateMojo Facelets taglib
- FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
- resourcesConfiguration, mavenLogger);
- faceletsTaglibGenerator.setUri(taglib.getUri());
- faceletsTaglibGenerator.setShortname(taglib.getShortName());
- faceletsTaglibGenerator.setInclude(taglibInclude);
- faceletsTaglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".taglib.xml"));
- faceletsTaglibGenerator.createFiles(config);
- }
-
- // Generate resources configuration file resources-config.xml
- // for all images/scripts/css...
- ResourcesConfigGenerator resourcesConfigGenerator = new ResourcesConfigGenerator(resourcesConfiguration, mavenLogger);
- resourcesConfigGenerator.setInclude(resourcesInclude);
- resourcesConfigGenerator.setTemplates(templatesDirectory);
- resourcesConfigGenerator.setResourcesConfig(new File(
- outputResourcesDirectory, "META-INF/resources-config.xml"));
- resourcesConfigGenerator.createFiles(config);
-
- // Add generated sources and resources to project
- project.addCompileSourceRoot(outputJavaDirectory.getPath());
-// project.addCompileSourceRoot(outputTestsDirectory.getPath());
-
- Resource resource = new Resource();
- resource.setDirectory(outputResourcesDirectory.getPath());
-// resource.setTargetPath("META-INF");
- project.addResource(resource);
- } catch (Exception e) {
- getLog().error("Error on generate component", e);
- throw new MojoExecutionException(
- "Error in component generation", e);
- }
- Thread.currentThread().setContextClassLoader(contextCL);
- }
-
- }
-
- protected BuilderConfig createConfig(ClassLoader generatiorLoader)
- throws ParsingException {
- BuilderConfig builderConfig = new BuilderConfig(generatiorLoader,
- new MavenLogger(getLog()));
- // Get all *.xml config files
- FilenameFilter filter = new FilenameFilter() {
-
- public boolean accept(File dir, String name) {
-
- return name.toLowerCase().endsWith(".xml");
- }
-
- };
- boolean filesParsed = false;
- File [] directories = {
- componentConfigDirectory,
- validatorConfigDirectory,
- converterConfigDirectory
- };
-
- for (File directory : directories) {
- if (directory.exists()) {
- File[] files = directory.listFiles(filter);
- for (File file : files) {
- filesParsed = true;
- builderConfig.parseConfig(file);
- }
- }
- }
- if (!filesParsed) {
- getLog().warn("No component configuration files found -- probably a skin project");
- }
- /*
- if (!filesParsed) {
- throw new ParsingException("No config files found");
- }
- */
- builderConfig.checkComponentProperties();
- return builderConfig;
- }
-
- public File getDestDir() {
- // TODO Auto-generated method stub
- return outputJavaDirectory;
- }
-
- public String getKey() {
- // TODO Auto-generated method stub
- return key;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getClassLoader()
- */
- public ClassLoader getClassLoader() {
- return createProjectClassLoader(executedProject);
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplate(java.lang.String)
- */
- public Template getTemplate(String name) throws GeneratorException {
- // TODO Auto-generated method stub
- try {
- return this.velocity.getEngine().getTemplate(name);
- } catch (ResourceNotFoundException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (ParseErrorException e) {
- throw new GeneratorException(e.getLocalizedMessage());
- } catch (Exception e) {
- throw new GeneratorException(e.getLocalizedMessage());
- }
- }
-
- /* (non-Javadoc)
- * @see org.ajax4jsf.builder.generator.JSFGeneratorConfiguration#getTemplatesPath()
- */
- public String getTemplatesPath() {
- return Library.JSF12.equals(library.getJsfVersion())?BuilderContext.TEMPLATES12_PATH:BuilderContext.TEMPLATES_PATH;
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,339 @@
+/**
+ * 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.builder.mojo;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+import org.apache.velocity.Template;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.generator.ComponentGenerator2;
+import org.richfaces.builder.generator.ComponentTagGenerator;
+import org.richfaces.builder.generator.ConverterGenerator;
+import org.richfaces.builder.generator.ConverterTagGenerator;
+import org.richfaces.builder.generator.FaceletsTaglibGenerator;
+import org.richfaces.builder.generator.FacesConfigGenerator;
+import org.richfaces.builder.generator.GeneratorException;
+import org.richfaces.builder.generator.JSFGeneratorConfiguration;
+import org.richfaces.builder.generator.ListenerGenerator;
+import org.richfaces.builder.generator.ListenerTagGenerator;
+import org.richfaces.builder.generator.RenderKitBean;
+import org.richfaces.builder.generator.RendererGenerator;
+import org.richfaces.builder.generator.ResourcesConfigGenerator;
+import org.richfaces.builder.generator.ResourcesConfigParser;
+import org.richfaces.builder.generator.ResourcesDependenciesGenerator;
+import org.richfaces.builder.generator.TagHandlerGenerator;
+import org.richfaces.builder.generator.TaglibGenerator;
+import org.richfaces.builder.generator.ValidatorGenerator;
+import org.richfaces.builder.generator.ValidatorTagGenerator;
+import org.richfaces.builder.maven.MavenLogger;
+import org.richfaces.builder.velocity.BuilderContext;
+
+/**
+ * This plugin geterate JSF components and renderers source code, as well as
+ * configuration files.
+ *
+ * @author shura
+ * @goal generate
+ * @requiresDependencyResolution compile
+ * @phase generate-sources
+ * @execute phase="compile"
+ */
+public class GenerateMojo extends AbstractCDKMojo implements
+ JSFGeneratorConfiguration {
+
+ /**
+ * Project executed by first compile lifecycle.
+ *
+ * @parameter expression="${executedProject}"
+ * @readonly
+ */
+ protected MavenProject executedProject;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("GenerateMojo components");
+
+ //FIXME: configure plexus component instead of programmatic property set.
+
+ // velocity.getEngine().setProperty("velocimacro.library", getTemplatesPath() + "/VM_global_library.vm");
+
+ if (null != executedProject) {
+ Taglib taglib = checkLibraryConfig();
+ ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
+ // compile goal executed
+ try {
+ // Parse config files.
+ ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
+ Thread.currentThread().setContextClassLoader(generatiorLoader);
+ BuilderConfig config = createConfig(generatiorLoader);
+ MavenLogger mavenLogger = new MavenLogger(getLog());
+ // TODO - parse sources by qdox for JavaDoc comments ?
+ // GenerateMojo components.
+ ComponentGenerator2 compGenerator = new ComponentGenerator2(this,
+ mavenLogger);
+ compGenerator.createFiles(config);
+ // GenerateMojo validators
+ ValidatorGenerator validatorGenerator = new ValidatorGenerator(this, mavenLogger);
+ validatorGenerator.createFiles(config);
+ // GenerateMojo converters
+ ConverterGenerator converterGenerator = new ConverterGenerator(this, mavenLogger);
+ converterGenerator.createFiles(config);
+ // GenerateMojo renderers
+ RendererGenerator rendererGenerator = new RendererGenerator(
+ this, mavenLogger);
+ rendererGenerator.setSrcDir(templatesDirectory);
+ rendererGenerator.createFiles(config);
+ // GenerateMojo component test
+/*
+ ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
+ componentTestGenerator.setDestDir(outputTestsDirectory);
+ componentTestGenerator.createFiles(config);
+*/
+ // GenerateMojo tags
+ ComponentTagGenerator componentTagGenerator = new ComponentTagGenerator(this, mavenLogger);
+ componentTagGenerator.createFiles(config);
+
+// GenerateMojo tags for validators
+ ValidatorTagGenerator validatorTagGenerator = new ValidatorTagGenerator(this, mavenLogger);
+ validatorTagGenerator.createFiles(config);
+
+// GenerateMojo tags for converters
+ ConverterTagGenerator converterTagGenerator = new ConverterTagGenerator(this, mavenLogger);
+ converterTagGenerator.createFiles(config);
+
+
+ ListenerTagGenerator listenerTagGenerator = new ListenerTagGenerator(this, mavenLogger);
+ listenerTagGenerator.createFiles(config);
+
+
+ // GenerateMojo tag test
+/*
+ TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
+ tagTestGenerator.setDestDir(outputTestsDirectory);
+ tagTestGenerator.createFiles(config);
+*/
+ // GenerateMojo tag handlers
+ TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
+ this, mavenLogger);
+ tagHandlerGenerator.createFiles(config);
+ //Generate listeners
+ ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
+ listenerGenerator.createFiles(config);
+
+ JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
+
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ public File getDestDir() {
+ return outputResourcesDirectory;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Template getTemplate(String name) throws GeneratorException {
+ return GenerateMojo.this.getTemplate(name);
+ }
+
+ public String getTemplatesPath() {
+ return GenerateMojo.this.getTemplatesPath();
+ }
+
+ };
+ // GenerateMojo faces-config
+ FacesConfigGenerator configGenerator = new FacesConfigGenerator(
+ resourcesConfiguration, mavenLogger);
+ configGenerator.setInclude(facesConfigInclude);
+ configGenerator.setFacesconfig(new File(
+ outputResourcesDirectory, "META-INF/faces-config.xml"));
+ RenderKitBean renderKitBean = configGenerator.createRenderKit();
+ renderKitBean.setRenderkitid("HTML_BASIC");
+ configGenerator.createFiles(config);
+ // GenerateMojo JSP taglib
+ if (null != taglib) {
+ TaglibGenerator taglibGenerator = new TaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ taglibGenerator.setUri(taglib.getUri());
+ taglibGenerator.setShortname(taglib.getShortName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setDisplayname(taglib.getDisplayName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setValidatorclass(taglib.getValidatorClass());
+ taglibGenerator.setTlibversion(taglib.getTlibVersion());
+ taglibGenerator.setJspversion(taglib.getJspVersion());
+ taglibGenerator.setInclude(taglibInclude);
+ taglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".tld"));
+ taglibGenerator.createFiles(config);
+ // GenerateMojo Facelets taglib
+ FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ faceletsTaglibGenerator.setUri(taglib.getUri());
+ faceletsTaglibGenerator.setShortname(taglib.getShortName());
+ faceletsTaglibGenerator.setInclude(taglibInclude);
+ faceletsTaglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".taglib.xml"));
+ faceletsTaglibGenerator.createFiles(config);
+ }
+
+ ResourcesConfigParser resourcesConfigParser = new ResourcesConfigParser(resourcesConfiguration, mavenLogger);
+ resourcesConfigParser.setTemplates(templatesDirectory);
+ resourcesConfigParser.parse(config);
+
+ if (taglib != null) {
+ ResourcesDependenciesGenerator resourcesDependenciesGenerator = new ResourcesDependenciesGenerator(resourcesConfiguration, mavenLogger);
+ resourcesDependenciesGenerator.setUri(taglib.getUri());
+ resourcesDependenciesGenerator.setDependencyFile(new File(outputResourcesDirectory,
+ "META-INF/" + taglib.getShortName() + ".component-dependencies.xml"));
+ resourcesDependenciesGenerator.setComponentDependencies(resourcesConfigParser.getComponentResourcesMap());
+ resourcesDependenciesGenerator.createFiles(config);
+ }
+
+ // Generate resources configuration file resources-config.xml
+ // for all images/scripts/css...
+ ResourcesConfigGenerator resourcesConfigGenerator = new ResourcesConfigGenerator(resourcesConfiguration, mavenLogger);
+ resourcesConfigGenerator.setResourcesConfigGeneratorBean(resourcesConfigParser.getResourcesConfigGeneratorBean());
+ resourcesConfigGenerator.setInclude(resourcesInclude);
+ resourcesConfigGenerator.setTemplates(templatesDirectory);
+ resourcesConfigGenerator.setResourcesConfig(new File(
+ outputResourcesDirectory, "META-INF/resources-config.xml"));
+ resourcesConfigGenerator.createFiles(config);
+
+ // Add generated sources and resources to project
+ project.addCompileSourceRoot(outputJavaDirectory.getPath());
+// project.addCompileSourceRoot(outputTestsDirectory.getPath());
+
+ Resource resource = new Resource();
+ resource.setDirectory(outputResourcesDirectory.getPath());
+// resource.setTargetPath("META-INF");
+ project.addResource(resource);
+ } catch (Exception e) {
+ getLog().error("Error on generate component", e);
+ throw new MojoExecutionException(
+ "Error in component generation", e);
+ }
+ Thread.currentThread().setContextClassLoader(contextCL);
+ }
+
+ }
+
+ protected BuilderConfig createConfig(ClassLoader generatiorLoader)
+ throws ParsingException {
+ BuilderConfig builderConfig = new BuilderConfig(generatiorLoader,
+ new MavenLogger(getLog()));
+ // Get all *.xml config files
+ FilenameFilter filter = new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+
+ return name.toLowerCase().endsWith(".xml");
+ }
+
+ };
+ boolean filesParsed = false;
+ File [] directories = {
+ componentConfigDirectory,
+ validatorConfigDirectory,
+ converterConfigDirectory
+ };
+
+ for (File directory : directories) {
+ if (directory.exists()) {
+ File[] files = directory.listFiles(filter);
+ for (File file : files) {
+ filesParsed = true;
+ builderConfig.parseConfig(file);
+ }
+ }
+ }
+ if (!filesParsed) {
+ getLog().warn("No component configuration files found -- probably a skin project");
+ }
+ /*
+ if (!filesParsed) {
+ throw new ParsingException("No config files found");
+ }
+ */
+ builderConfig.checkComponentProperties();
+ return builderConfig;
+ }
+
+ public File getDestDir() {
+ // TODO Auto-generated method stub
+ return outputJavaDirectory;
+ }
+
+ public String getKey() {
+ // TODO Auto-generated method stub
+ return key;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.builder.generator.JSFGeneratorConfiguration#getClassLoader()
+ */
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.builder.generator.JSFGeneratorConfiguration#getTemplate(java.lang.String)
+ */
+ public Template getTemplate(String name) throws GeneratorException {
+ // TODO Auto-generated method stub
+ try {
+ return this.velocity.getEngine().getTemplate(name);
+ } catch (ResourceNotFoundException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (ParseErrorException e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ } catch (Exception e) {
+ throw new GeneratorException(e.getLocalizedMessage());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.richfaces.builder.generator.JSFGeneratorConfiguration#getTemplatesPath()
+ */
+ public String getTemplatesPath() {
+ return Library.JSF12.equals(library.getJsfVersion())?BuilderContext.TEMPLATES12_PATH:BuilderContext.TEMPLATES_PATH;
+ }
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,152 +0,0 @@
-package org.ajax4jsf.builder.mojo;
-
-import org.ajax4jsf.builder.config.BuilderConfig;
-import org.ajax4jsf.builder.generator.ComponentTestGenerator;
-import org.ajax4jsf.builder.generator.TagTestGenerator;
-import org.ajax4jsf.builder.maven.MavenLogger;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.apache.velocity.Template;
-
-/**
- *
- * @author dbiatenia
- * @goal generate-tests
- * @requiresDependencyResolution test
- * @phase generate-test-sources
- * @execute phase="test-compile"
- */
-public class GenerateTestMojo extends GenerateMojo{
-
- public void execute() throws MojoExecutionException, MojoFailureException {
- getLog().debug("GenerateTestMojo tests");
- if (null != executedProject) {
- Taglib taglib = checkLibraryConfig();
- // compile goal executed
- try {
- // Parse config files.
- ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
- BuilderConfig config = createConfig(generatiorLoader);
- MavenLogger mavenLogger = new MavenLogger(getLog());
- // TODO - parse sources by qdox for JavaDoc comments ?
- // GenerateMojo components.
-/*
- ComponentGenerator compGenerator = new ComponentGenerator(this,
- mavenLogger);
- compGenerator.createFiles(config);
-*/
- // GenerateMojo renderers
-/*
- RendererGenerator rendererGenerator = new RendererGenerator(
- this, mavenLogger);
- rendererGenerator.setSrcDir(templatesDirectory);
- rendererGenerator.createFiles(config);
-*/
- // GenerateMojo component test
- ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
- componentTestGenerator.setDestDir(outputTestsDirectory);
- componentTestGenerator.createFiles(config);
-
- // GenerateMojo tags
-/*
- TagGenerator tagGenerator = new TagGenerator(this, mavenLogger);
- tagGenerator.createFiles(config);
-*/
- // GenerateMojo tag test
- TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
- tagTestGenerator.setDestDir(outputTestsDirectory);
- tagTestGenerator.createFiles(config);
-
- // GenerateMojo tag handlers
-/*
- TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
- this, mavenLogger);
- tagHandlerGenerator.createFiles(config);
- //Generate listeners
- ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
- listenerGenerator.createFiles(config);
-*/
-/*
- JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
-
- public ClassLoader getClassLoader() {
- return createProjectClassLoader(executedProject);
- }
-
- public File getDestDir() {
- return outputResourcesDirectory;
- }
-
- public String getKey() {
- return key;
- }
-
- public Template getTemplate(String name) throws GeneratorException {
- return GenerateTestMojo.this.getTemplate(name);
- }
-
- public String getTemplatesPath() {
- return GenerateTestMojo.this.getTemplatesPath();
- }
-
- };
- // GenerateMojo faces-config
- FacesConfigGenerator configGenerator = new FacesConfigGenerator(
- resourcesConfiguration, mavenLogger);
- configGenerator.setInclude(facesConfigInclude);
- configGenerator.setFacesconfig(new File(
- outputResourcesDirectory, "META-INF/faces-config.xml"));
- RenderKitBean renderKitBean = configGenerator.createRenderKit();
- renderKitBean.setRenderkitid("HTML_BASIC");
- configGenerator.createFiles(config);
- // GenerateMojo JSP taglib
- if (null != taglib) {
- TaglibGenerator taglibGenerator = new TaglibGenerator(
- resourcesConfiguration, mavenLogger);
- taglibGenerator.setUri(taglib.getUri());
- taglibGenerator.setShortname(taglib.getShortName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setDisplayname(taglib.getDisplayName());
- taglibGenerator.setListenerclass(taglib.getListenerClass());
- taglibGenerator.setValidatorclass(taglib.getValidatorClass());
- taglibGenerator.setTlibversion(taglib.getTlibVersion());
- taglibGenerator.setJspversion(taglib.getJspVersion());
- taglibGenerator.setInclude(taglibInclude);
- taglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".tld"));
- taglibGenerator.createFiles(config);
- // GenerateMojo Facelets taglib
- FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
- resourcesConfiguration, mavenLogger);
- faceletsTaglibGenerator.setUri(taglib.getUri());
- faceletsTaglibGenerator.setShortname(taglib.getShortName());
- faceletsTaglibGenerator.setInclude(taglibInclude);
- faceletsTaglibGenerator.setTaglib(new File(
- outputResourcesDirectory, "META-INF/"+taglib.getShortName()
- + ".taglib.xml"));
- faceletsTaglibGenerator.createFiles(config);
- }
- // Generate resources configuration file resources-config.xml
- // for all images/scripts/css...
- // Add generated sources and resources to project
-*/
-// project.addCompileSourceRoot(outputJavaDirectory.getPath());
- project.addTestCompileSourceRoot(outputTestsDirectory.getPath());
-/*
- Resource resource = new Resource();
- resource.setDirectory(outputResourcesDirectory.getPath());
-// resource.setTargetPath("META-INF");
- project.addResource(resource);
-*/
- } catch (Exception e) {
- getLog().error("Error on generate component", e);
- throw new MojoExecutionException(
- "Error in component generation", e);
- }
- }
-
- }
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/GenerateTestMojo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateTestMojo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,171 @@
+/**
+ * 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.builder.mojo;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.richfaces.builder.config.BuilderConfig;
+import org.richfaces.builder.generator.ComponentTestGenerator;
+import org.richfaces.builder.generator.TagTestGenerator;
+import org.richfaces.builder.maven.MavenLogger;
+
+/**
+ *
+ * @author dbiatenia
+ * @goal generate-tests
+ * @requiresDependencyResolution test
+ * @phase generate-test-sources
+ * @execute phase="test-compile"
+ */
+public class GenerateTestMojo extends GenerateMojo{
+
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ getLog().debug("GenerateTestMojo tests");
+ if (null != executedProject) {
+ Taglib taglib = checkLibraryConfig();
+ // compile goal executed
+ try {
+ // Parse config files.
+ ClassLoader generatiorLoader = createProjectClassLoader(executedProject);
+ BuilderConfig config = createConfig(generatiorLoader);
+ MavenLogger mavenLogger = new MavenLogger(getLog());
+ // TODO - parse sources by qdox for JavaDoc comments ?
+ // GenerateMojo components.
+/*
+ ComponentGenerator compGenerator = new ComponentGenerator(this,
+ mavenLogger);
+ compGenerator.createFiles(config);
+*/
+ // GenerateMojo renderers
+/*
+ RendererGenerator rendererGenerator = new RendererGenerator(
+ this, mavenLogger);
+ rendererGenerator.setSrcDir(templatesDirectory);
+ rendererGenerator.createFiles(config);
+*/
+ // GenerateMojo component test
+ ComponentTestGenerator componentTestGenerator = new ComponentTestGenerator(this, mavenLogger);
+ componentTestGenerator.setDestDir(outputTestsDirectory);
+ componentTestGenerator.createFiles(config);
+
+ // GenerateMojo tags
+/*
+ TagGenerator tagGenerator = new TagGenerator(this, mavenLogger);
+ tagGenerator.createFiles(config);
+*/
+ // GenerateMojo tag test
+ TagTestGenerator tagTestGenerator = new TagTestGenerator(this, mavenLogger);
+ tagTestGenerator.setDestDir(outputTestsDirectory);
+ tagTestGenerator.createFiles(config);
+
+ // GenerateMojo tag handlers
+/*
+ TagHandlerGenerator tagHandlerGenerator = new TagHandlerGenerator(
+ this, mavenLogger);
+ tagHandlerGenerator.createFiles(config);
+ //Generate listeners
+ ListenerGenerator listenerGenerator = new ListenerGenerator(this, mavenLogger);
+ listenerGenerator.createFiles(config);
+*/
+/*
+ JSFGeneratorConfiguration resourcesConfiguration = new JSFGeneratorConfiguration() {
+
+ public ClassLoader getClassLoader() {
+ return createProjectClassLoader(executedProject);
+ }
+
+ public File getDestDir() {
+ return outputResourcesDirectory;
+ }
+
+ public String getKey() {
+ return key;
+ }
+
+ public Template getTemplate(String name) throws GeneratorException {
+ return GenerateTestMojo.this.getTemplate(name);
+ }
+
+ public String getTemplatesPath() {
+ return GenerateTestMojo.this.getTemplatesPath();
+ }
+
+ };
+ // GenerateMojo faces-config
+ FacesConfigGenerator configGenerator = new FacesConfigGenerator(
+ resourcesConfiguration, mavenLogger);
+ configGenerator.setInclude(facesConfigInclude);
+ configGenerator.setFacesconfig(new File(
+ outputResourcesDirectory, "META-INF/faces-config.xml"));
+ RenderKitBean renderKitBean = configGenerator.createRenderKit();
+ renderKitBean.setRenderkitid("HTML_BASIC");
+ configGenerator.createFiles(config);
+ // GenerateMojo JSP taglib
+ if (null != taglib) {
+ TaglibGenerator taglibGenerator = new TaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ taglibGenerator.setUri(taglib.getUri());
+ taglibGenerator.setShortname(taglib.getShortName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setDisplayname(taglib.getDisplayName());
+ taglibGenerator.setListenerclass(taglib.getListenerClass());
+ taglibGenerator.setValidatorclass(taglib.getValidatorClass());
+ taglibGenerator.setTlibversion(taglib.getTlibVersion());
+ taglibGenerator.setJspversion(taglib.getJspVersion());
+ taglibGenerator.setInclude(taglibInclude);
+ taglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".tld"));
+ taglibGenerator.createFiles(config);
+ // GenerateMojo Facelets taglib
+ FaceletsTaglibGenerator faceletsTaglibGenerator = new FaceletsTaglibGenerator(
+ resourcesConfiguration, mavenLogger);
+ faceletsTaglibGenerator.setUri(taglib.getUri());
+ faceletsTaglibGenerator.setShortname(taglib.getShortName());
+ faceletsTaglibGenerator.setInclude(taglibInclude);
+ faceletsTaglibGenerator.setTaglib(new File(
+ outputResourcesDirectory, "META-INF/"+taglib.getShortName()
+ + ".taglib.xml"));
+ faceletsTaglibGenerator.createFiles(config);
+ }
+ // Generate resources configuration file resources-config.xml
+ // for all images/scripts/css...
+ // Add generated sources and resources to project
+*/
+// project.addCompileSourceRoot(outputJavaDirectory.getPath());
+ project.addTestCompileSourceRoot(outputTestsDirectory.getPath());
+/*
+ Resource resource = new Resource();
+ resource.setDirectory(outputResourcesDirectory.getPath());
+// resource.setTargetPath("META-INF");
+ project.addResource(resource);
+*/
+ } catch (Exception e) {
+ getLog().error("Error on generate component", e);
+ throw new MojoExecutionException(
+ "Error in component generation", e);
+ }
+ }
+
+ }
+
+}
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Library.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Library.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.mojo;
+package org.richfaces.builder.mojo;
/**
* @author shura
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Renderkit.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Renderkit.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-package org.ajax4jsf.builder.mojo;
+package org.richfaces.builder.mojo;
/**
* @author shura
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/SkinInfo.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,87 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.mojo;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.aja4jsf.builder.model.Resource;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class SkinInfo implements Cloneable{
- private String shortName;
- private String packageName;
-
- private String baseSkin;
- private List<Resource> baseClassResources = new ArrayList<Resource>();
- private List<Resource> extClassResources = new ArrayList<Resource>();
- private Resource masterXcss;
- private Resource extendedXcss;
- private Resource propertyFile;
- private boolean useExt;
-
- public boolean isUseExt() {
- return useExt;
- }
- public void setUseExt(boolean useExt) {
- this.useExt = useExt;
- }
- public String getShortName() {
- return shortName;
- }
- public void setShortName(String shortName) {
- this.shortName = shortName;
- }
- public String getPackageName() {
- return packageName;
- }
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
- public List<Resource> getBaseClassResources() {
- return baseClassResources;
- }
- public void setBaseClassResources(List<Resource> baseClassResources) {
- this.baseClassResources = baseClassResources;
- }
- public List<Resource> getExtClassResources() {
- return extClassResources;
- }
- public void setExtClassResources(List<Resource> extClassResources) {
- this.extClassResources = extClassResources;
- }
- public Resource getMasterXcss() {
- return masterXcss;
- }
- public void setMasterXcss(Resource masterXcss) {
- this.masterXcss = masterXcss;
- }
- public Resource getExtendedXcss() {
- return extendedXcss;
- }
- public void setExtendedXcss(Resource extendedXcss) {
- this.extendedXcss = extendedXcss;
- }
- public Resource getPropertyFile() {
- return propertyFile;
- }
- public void setPropertyFile(Resource propertyFile) {
- this.propertyFile = propertyFile;
- }
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
- public String getBaseSkin() {
- return baseSkin;
- }
- public void setBaseSkin(String baseSkin) {
- this.baseSkin = baseSkin;
- }
-
-
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/SkinInfo.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/SkinInfo.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,105 @@
+/**
+ * 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.builder.mojo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.aja4jsf.builder.model.Resource;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class SkinInfo implements Cloneable{
+ private String shortName;
+ private String packageName;
+
+ private String baseSkin;
+ private List<Resource> baseClassResources = new ArrayList<Resource>();
+ private List<Resource> extClassResources = new ArrayList<Resource>();
+ private Resource masterXcss;
+ private Resource extendedXcss;
+ private Resource propertyFile;
+ private boolean useExt;
+
+ public boolean isUseExt() {
+ return useExt;
+ }
+ public void setUseExt(boolean useExt) {
+ this.useExt = useExt;
+ }
+ public String getShortName() {
+ return shortName;
+ }
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+ public String getPackageName() {
+ return packageName;
+ }
+ public void setPackageName(String packageName) {
+ this.packageName = packageName;
+ }
+ public List<Resource> getBaseClassResources() {
+ return baseClassResources;
+ }
+ public void setBaseClassResources(List<Resource> baseClassResources) {
+ this.baseClassResources = baseClassResources;
+ }
+ public List<Resource> getExtClassResources() {
+ return extClassResources;
+ }
+ public void setExtClassResources(List<Resource> extClassResources) {
+ this.extClassResources = extClassResources;
+ }
+ public Resource getMasterXcss() {
+ return masterXcss;
+ }
+ public void setMasterXcss(Resource masterXcss) {
+ this.masterXcss = masterXcss;
+ }
+ public Resource getExtendedXcss() {
+ return extendedXcss;
+ }
+ public void setExtendedXcss(Resource extendedXcss) {
+ this.extendedXcss = extendedXcss;
+ }
+ public Resource getPropertyFile() {
+ return propertyFile;
+ }
+ public void setPropertyFile(Resource propertyFile) {
+ this.propertyFile = propertyFile;
+ }
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+ public String getBaseSkin() {
+ return baseSkin;
+ }
+ public void setBaseSkin(String baseSkin) {
+ this.baseSkin = baseSkin;
+ }
+
+
+}
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,227 +0,0 @@
-/**
- * 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.ajax4jsf.builder.mojo;
-
-import java.io.File;
-
-/**
- * @author shura
- *
- */
-public class Taglib {
-
- private String _taglib;
-
- private String _uri;
-
- private String _shortName;
-
- private String _listenerClass;
-
- private String _displayName;
-
- private String _tlibVersion = "1.2";
-
- private String _jspVersion ;
-
- private String _validatorClass = null;
-
- private String _includeModules = null;
-
- private String _excludeModules = null;
-
- private String _includeTags = null;
-
- private String _excludeTags = null;
- /**
- * @return the displayName
- */
- public String getDisplayName() {
- return this._displayName;
- }
-
- /**
- * @param displayName the displayName to set
- */
- public void setDisplayName(String displayName) {
- this._displayName = displayName;
- }
-
- /**
- * @return the listenerClass
- */
- public String getListenerClass() {
- return this._listenerClass;
- }
-
- /**
- * @param listenerClass the listenerClass to set
- */
- public void setListenerClass(String listenerClass) {
- this._listenerClass = listenerClass;
- }
-
- /**
- * @return the shortName
- */
- public String getShortName() {
- return this._shortName;
- }
-
- /**
- * @param shortName the shortName to set
- */
- public void setShortName(String shortName) {
- this._shortName = shortName;
- }
-
- /**
- * @return the taglib
- */
- public String getTaglib() {
- return this._taglib;
- }
-
- /**
- * @param taglib the taglib to set
- */
- public void setTaglib(String taglib) {
- this._taglib = taglib;
- }
-
- /**
- * @return the uri
- */
- public String getUri() {
- return this._uri;
- }
-
- /**
- * @param uri the uri to set
- */
- public void setUri(String uri) {
- this._uri = uri;
- }
-
- /**
- * @return the jspVersion
- */
- public String getJspVersion() {
- return this._jspVersion;
- }
-
- /**
- * @param jspVersion the jspVersion to set
- */
- public void setJspVersion(String jspVersion) {
- this._jspVersion = jspVersion;
- }
-
- /**
- * @return the tlibVersion
- */
- public String getTlibVersion() {
- return this._tlibVersion;
- }
-
- /**
- * @param tlibVersion the tlibVersion to set
- */
- public void setTlibVersion(String tlibVersion) {
- this._tlibVersion = tlibVersion;
- }
-
- /**
- * @return the validatorClass
- */
- public String getValidatorClass() {
- return this._validatorClass;
- }
-
- /**
- * @param validatorClass the validatorClass to set
- */
- public void setValidatorClass(String validatorClass) {
- this._validatorClass = validatorClass;
- }
-
- /**
- * @return the includeModules
- */
- public String getIncludeModules() {
- return _includeModules;
- }
-
- /**
- * @param includeModules the includeModules to set
- */
- public void setIncludeModules(String includeModules) {
- _includeModules = includeModules;
- }
-
- /**
- * @return the excludeModules
- */
- public String getExcludeModules() {
- return _excludeModules;
- }
-
- /**
- * @param excludeModules the excludeModules to set
- */
- public void setExcludeModules(String excludeModules) {
- _excludeModules = excludeModules;
- }
-
- /**
- * @return the includeTags
- */
- public String getIncludeTags() {
- return _includeTags;
- }
-
- /**
- * @param includeTags the includeTags to set
- */
- public void setIncludeTags(String includeTags) {
- _includeTags = includeTags;
- }
-
- /**
- * @return the excludeTags
- */
- public String getExcludeTags() {
- return _excludeTags;
- }
-
- /**
- * @param excludeTags the excludeTags to set
- */
- public void setExcludeTags(String excludeTags) {
- _excludeTags = excludeTags;
- }
-
- @Override
- public String toString() {
- return "Lib: "+getShortName()+", URL: "+getUri();
- }
-}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/mojo/Taglib.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/Taglib.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,226 @@
+/**
+ * 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.builder.mojo;
+
+
+/**
+ * @author shura
+ *
+ */
+public class Taglib {
+
+ private String _taglib;
+
+ private String _uri;
+
+ private String _shortName;
+
+ private String _listenerClass;
+
+ private String _displayName;
+
+ private String _tlibVersion = null;
+
+ private String _jspVersion ;
+
+ private String _validatorClass = null;
+
+ private String _includeModules = null;
+
+ private String _excludeModules = null;
+
+ private String _includeTags = null;
+
+ private String _excludeTags = null;
+ /**
+ * @return the displayName
+ */
+ public String getDisplayName() {
+ return this._displayName;
+ }
+
+ /**
+ * @param displayName the displayName to set
+ */
+ public void setDisplayName(String displayName) {
+ this._displayName = displayName;
+ }
+
+ /**
+ * @return the listenerClass
+ */
+ public String getListenerClass() {
+ return this._listenerClass;
+ }
+
+ /**
+ * @param listenerClass the listenerClass to set
+ */
+ public void setListenerClass(String listenerClass) {
+ this._listenerClass = listenerClass;
+ }
+
+ /**
+ * @return the shortName
+ */
+ public String getShortName() {
+ return this._shortName;
+ }
+
+ /**
+ * @param shortName the shortName to set
+ */
+ public void setShortName(String shortName) {
+ this._shortName = shortName;
+ }
+
+ /**
+ * @return the taglib
+ */
+ public String getTaglib() {
+ return this._taglib;
+ }
+
+ /**
+ * @param taglib the taglib to set
+ */
+ public void setTaglib(String taglib) {
+ this._taglib = taglib;
+ }
+
+ /**
+ * @return the uri
+ */
+ public String getUri() {
+ return this._uri;
+ }
+
+ /**
+ * @param uri the uri to set
+ */
+ public void setUri(String uri) {
+ this._uri = uri;
+ }
+
+ /**
+ * @return the jspVersion
+ */
+ public String getJspVersion() {
+ return this._jspVersion;
+ }
+
+ /**
+ * @param jspVersion the jspVersion to set
+ */
+ public void setJspVersion(String jspVersion) {
+ this._jspVersion = jspVersion;
+ }
+
+ /**
+ * @return the tlibVersion
+ */
+ public String getTlibVersion() {
+ return this._tlibVersion;
+ }
+
+ /**
+ * @param tlibVersion the tlibVersion to set
+ */
+ public void setTlibVersion(String tlibVersion) {
+ this._tlibVersion = tlibVersion;
+ }
+
+ /**
+ * @return the validatorClass
+ */
+ public String getValidatorClass() {
+ return this._validatorClass;
+ }
+
+ /**
+ * @param validatorClass the validatorClass to set
+ */
+ public void setValidatorClass(String validatorClass) {
+ this._validatorClass = validatorClass;
+ }
+
+ /**
+ * @return the includeModules
+ */
+ public String getIncludeModules() {
+ return _includeModules;
+ }
+
+ /**
+ * @param includeModules the includeModules to set
+ */
+ public void setIncludeModules(String includeModules) {
+ _includeModules = includeModules;
+ }
+
+ /**
+ * @return the excludeModules
+ */
+ public String getExcludeModules() {
+ return _excludeModules;
+ }
+
+ /**
+ * @param excludeModules the excludeModules to set
+ */
+ public void setExcludeModules(String excludeModules) {
+ _excludeModules = excludeModules;
+ }
+
+ /**
+ * @return the includeTags
+ */
+ public String getIncludeTags() {
+ return _includeTags;
+ }
+
+ /**
+ * @param includeTags the includeTags to set
+ */
+ public void setIncludeTags(String includeTags) {
+ _includeTags = includeTags;
+ }
+
+ /**
+ * @return the excludeTags
+ */
+ public String getExcludeTags() {
+ return _excludeTags;
+ }
+
+ /**
+ * @param excludeTags the excludeTags to set
+ */
+ public void setExcludeTags(String excludeTags) {
+ _excludeTags = excludeTags;
+ }
+
+ @Override
+ public String toString() {
+ return "Lib: "+getShortName()+", URL: "+getUri();
+ }
+}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity (from rev 14075, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/velocity)
Deleted: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/velocity/ResourceLoader.java 2009-05-07 17:35:57 UTC (rev 14075)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -1,58 +0,0 @@
-/**
- *
- */
-package org.ajax4jsf.builder.velocity;
-
-import java.io.InputStream;
-
-import org.apache.commons.collections.ExtendedProperties;
-import org.apache.velocity.exception.ResourceNotFoundException;
-import org.apache.velocity.runtime.resource.Resource;
-
-/**
- * @author Maksim Kaszynski
- *
- */
-public class ResourceLoader extends
- org.apache.velocity.runtime.resource.loader.ResourceLoader {
-
- public void init( ExtendedProperties configuration)
- {
- rsvc.info("ClasspathResourceLoader : initialization starting.");
-
- rsvc.info("ClasspathResourceLoader : initialization complete.");
- }
-
- public synchronized InputStream getResourceStream( String name )
- throws ResourceNotFoundException
- {
- InputStream result = null;
-
- if (name == null || name.length() == 0)
- {
- throw new ResourceNotFoundException ("No template name provided");
- }
-
- try
- {
- ClassLoader classLoader = getClass().getClassLoader();
-
- result= classLoader.getResourceAsStream( name );
- }
- catch( Exception fnfe )
- {
- throw new ResourceNotFoundException( fnfe.getMessage() );
- }
-
- return result;
- }
-
- public boolean isSourceModified(Resource resource)
- {
- return false;
- }
-
- public long getLastModified(Resource resource)
- {
- return 0;
- }}
Copied: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java (from rev 14245, branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/ajax4jsf/builder/velocity/ResourceLoader.java)
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java (rev 0)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/ResourceLoader.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -0,0 +1,76 @@
+/**
+ * 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.builder.velocity;
+
+import java.io.InputStream;
+
+import org.apache.commons.collections.ExtendedProperties;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.apache.velocity.runtime.resource.Resource;
+
+/**
+ * @author Maksim Kaszynski
+ *
+ */
+public class ResourceLoader extends
+ org.apache.velocity.runtime.resource.loader.ResourceLoader {
+
+ public void init( ExtendedProperties configuration)
+ {
+ rsvc.info("ClasspathResourceLoader : initialization starting.");
+
+ rsvc.info("ClasspathResourceLoader : initialization complete.");
+ }
+
+ public synchronized InputStream getResourceStream( String name )
+ throws ResourceNotFoundException
+ {
+ InputStream result = null;
+
+ if (name == null || name.length() == 0)
+ {
+ throw new ResourceNotFoundException ("No template name provided");
+ }
+
+ try
+ {
+ ClassLoader classLoader = getClass().getClassLoader();
+
+ result= classLoader.getResourceAsStream( name );
+ }
+ catch( Exception fnfe )
+ {
+ throw new ResourceNotFoundException( fnfe.getMessage() );
+ }
+
+ return result;
+ }
+
+ public boolean isSourceModified(Resource resource)
+ {
+ return false;
+ }
+
+ public long getLastModified(Resource resource)
+ {
+ return 0;
+ }}
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/META-INF/plexus/components.xml
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/META-INF/plexus/components.xml 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/META-INF/plexus/components.xml 2009-06-09 22:53:29 UTC (rev 14575)
@@ -15,7 +15,7 @@
</property>
<property>
<name>cdk.resource.loader.class</name>
- <value>org.ajax4jsf.builder.velocity.ResourceLoader</value>
+ <value>org.richfaces.builder.velocity.ResourceLoader</value>
</property>
<property>
<name>velocimacro.messages.on</name>
Modified: branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/component/config.xml
===================================================================
--- branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/component/config.xml 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/maven-cdk-plugin/src/main/resources/component/config.xml 2009-06-09 22:53:29 UTC (rev 14575)
@@ -19,12 +19,12 @@
<name>${name}</name>
<classname>${package}.taglib.${className}Tag</classname>
<superclass>
- org.ajax4jsf.webapp.taglib.HtmlComponentTagBase
+ org.richfaces.webapp.taglib.HtmlComponentTagBase
</superclass>
</tag>
<!--
<taghandler>
- <classname>org.ajax4jsf.tag.TestHandler</classname>
+ <classname>org.richfaces.tag.TestHandler</classname>
</taghandler>
-->
&ui_component_attributes;
Modified: branches/jsf2.0/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java
===================================================================
--- branches/jsf2.0/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-06-09 17:01:35 UTC (rev 14574)
+++ branches/jsf2.0/cdk/maven-resource-dependency-plugin/src/main/java/org/richfaces/cdk/rd/generator/StyleAssembler.java 2009-06-09 22:53:29 UTC (rev 14575)
@@ -26,8 +26,6 @@
import java.io.InputStream;
import java.net.URL;
-import org.ajax4jsf.builder.config.ParsingException;
-import org.ajax4jsf.builder.xml.XMLBody;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.plugin.logging.SystemStreamLog;
import org.apache.velocity.Template;
@@ -35,6 +33,8 @@
import org.apache.velocity.app.VelocityEngine;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.velocity.VelocityComponent;
+import org.richfaces.builder.config.ParsingException;
+import org.richfaces.builder.xml.XMLBody;
/**
More information about the richfaces-svn-commits
mailing list