[richfaces-svn-commits] JBoss Rich Faces SVN: r15830 - in root/cdk/trunk/plugins/generator/src: main/java/org/richfaces/cdk/templatecompiler/model and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Wed Nov 4 20:25:24 EST 2009


Author: alexsmirnov
Date: 2009-11-04 20:25:23 -0500 (Wed, 04 Nov 2009)
New Revision: 15830

Added:
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
   root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
   root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/
   root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/
   root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
Log:
JAXB-based template parser.

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,91 @@
+/*
+ * $Id: RendererTemplateParser.java 15789 2009-11-01 16:17:29Z Alex.Kolonitsky $
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+
+
+package org.richfaces.cdk.templatecompiler;
+
+import org.richfaces.cdk.CdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.ModelBuilder;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.*;
+import org.richfaces.cdk.templatecompiler.model.Template;
+import org.richfaces.cdk.xmlconfig.JAXBBinding;
+
+import javax.xml.stream.XMLStreamException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+public class RendererTemplateParser implements ModelBuilder {
+    private CdkContext context;
+    private JAXBBinding jaxbBinding;
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.cdk.ModelBuilder#build()
+     */
+    @Override
+    public ComponentLibrary build() throws CdkException {
+        ComponentLibrary library = new ComponentLibrary();
+
+        for (File file : getContext().getSources(StandardSources.RENDERER_TEMPLATES)) {
+            try {
+                Template template = parseTemplate(file);
+//            } catch (FileNotFoundException e) {
+//                throw new CdkException(e);
+//            } catch (XMLStreamException e) {
+//                throw new CdkException(e);
+            } finally {
+                
+            }
+        }
+
+        return library;
+    }
+
+    protected Template parseTemplate(File file) throws CdkException {
+        return jaxbBinding.unmarshal(file, null, Template.class);
+    }
+
+    /*
+     *  (non-Javadoc)
+     * @see org.richfaces.cdk.ModelBuilder#init(org.richfaces.cdk.CdkContext)
+     */
+    @Override
+    public void init(CdkContext context) throws CdkException {
+        this.context = context;
+        jaxbBinding = context.getWorkerInstance(JAXBBinding.class);
+    }
+
+    public CdkContext getContext() {
+        return context;
+    }
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/RendererTemplateParser.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,83 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.namespace.QName;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+public class AnyElement extends ModelFragment {
+    
+    private QName name;
+    
+    private Map<QName,Object> attributes;
+    
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the name
+     */
+    public QName getName() {
+        return this.name;
+    }
+
+
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param name the name to set
+     */
+    public void setName(QName name) {
+        this.name = name;
+    }
+
+
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the attributes
+     */
+    @XmlAnyAttribute
+    public Map<QName, Object> getAttributes() {
+        return this.attributes;
+    }
+
+
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param attributes the attributes to set
+     */
+    public void setAttributes(Map<QName, Object> attributes) {
+        this.attributes = attributes;
+    }
+
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/AnyElement.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,208 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlType(name="uicomponent-attributeType",namespace=Template.COMPOSITE_NAMESPACE)
+public class Attribute {
+    
+    @XmlAttribute(required=true)
+    private String name;
+    
+    @XmlAttribute
+    private String displayName;
+    
+    @XmlAttribute
+    private String shortDescription;
+    
+    @XmlAttribute(name="default")
+    private String defaultValue;
+    
+    @XmlAttribute(name="method-signature")
+    private String methodSignature;
+    
+    @XmlAttribute
+    private String applyTo;
+    
+    @XmlAttribute
+    private boolean required;
+    
+    @XmlAttribute
+    private boolean preffered;
+    
+    @XmlAttribute
+    private boolean expert;
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the name
+     */
+    public String getName() {
+        return this.name;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param name the name to set
+     */
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the displayName
+     */
+    public String getDisplayName() {
+        return this.displayName;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param displayName the displayName to set
+     */
+    public void setDisplayName(String displayName) {
+        this.displayName = displayName;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the shortDescription
+     */
+    public String getShortDescription() {
+        return this.shortDescription;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param shortDescription the shortDescription to set
+     */
+    public void setShortDescription(String shortDescription) {
+        this.shortDescription = shortDescription;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the defaultValue
+     */
+    public String getDefaultValue() {
+        return this.defaultValue;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param defaultValue the defaultValue to set
+     */
+    public void setDefaultValue(String defaultValue) {
+        this.defaultValue = defaultValue;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the methodSignature
+     */
+    public String getMethodSignature() {
+        return this.methodSignature;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param methodSignature the methodSignature to set
+     */
+    public void setMethodSignature(String methodSignature) {
+        this.methodSignature = methodSignature;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the applyTo
+     */
+    public String getApplyTo() {
+        return this.applyTo;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param applyTo the applyTo to set
+     */
+    public void setApplyTo(String applyTo) {
+        this.applyTo = applyTo;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the required
+     */
+    public boolean isRequired() {
+        return this.required;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param required the required to set
+     */
+    public void setRequired(boolean required) {
+        this.required = required;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the preffered
+     */
+    public boolean isPreffered() {
+        return this.preffered;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param preffered the preffered to set
+     */
+    public void setPreffered(boolean preffered) {
+        this.preffered = preffered;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the expert
+     */
+    public boolean isExpert() {
+        return this.expert;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param expert the expert to set
+     */
+    public void setExpert(boolean expert) {
+        this.expert = expert;
+    }
+    
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Attribute.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,33 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+public class CdkBodyElement extends ModelFragment {
+
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkBodyElement.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,60 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlRootElement(name="call",namespace=Template.CDK_NAMESPACE)
+public class CdkCallElement {
+
+    private String expression;
+    
+    public CdkCallElement() {
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the expression
+     */
+    @XmlAttribute
+    public String getExpression() {
+        return this.expression;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param expression the expression to set
+     */
+    public void setExpression(String expression) {
+        this.expression = expression;
+    }
+    
+  
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CdkCallElement.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,38 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlType(name="ImplementationType",namespace=Template.COMPOSITE_NAMESPACE)
+public class CompositeImplementation extends ModelFragment {
+    
+
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeImplementation.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,172 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.faces.render.RenderKitFactory;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlType(name="InterfaceType",namespace=Template.COMPOSITE_NAMESPACE)
+public class CompositeInterface {
+    
+    private String componentType;
+    
+    private String family;
+    
+    private List<Attribute> attributes;
+
+    private String renderKitId = RenderKitFactory.HTML_BASIC_RENDER_KIT;
+
+    private String javaClass;
+
+    private String baseClass;
+
+    private String rendererType;
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the componentType
+     */
+    @XmlElement(name="component-type",namespace=Template.CDK_NAMESPACE)
+    public String getComponentType() {
+        return this.componentType;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param componentType the componentType to set
+     */
+    public void setComponentType(String componentType) {
+        this.componentType = componentType;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the family
+     */
+    @XmlElement(name="family",namespace=Template.CDK_NAMESPACE)
+    public String getFamily() {
+        return this.family;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param family the family to set
+     */
+    public void setFamily(String family) {
+        this.family = family;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the attributes
+     */
+    @XmlElement(name="attribute",namespace=Template.COMPOSITE_NAMESPACE)
+    public List<Attribute> getAttributes() {
+        return this.attributes;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param attributes the attributes to set
+     */
+    public void setAttributes(List<Attribute> attributes) {
+        this.attributes = attributes;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the renderKitId
+     */
+    @XmlElement(name="render-kit",namespace=Template.CDK_NAMESPACE)
+    public String getRenderKitId() {
+        return this.renderKitId;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param renderKitId the renderKitId to set
+     */
+    public void setRenderKitId(String renderKitId) {
+        this.renderKitId = renderKitId;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the javaClass
+     */
+    @XmlElement(name="class",namespace=Template.CDK_NAMESPACE)
+    public String getJavaClass() {
+        return this.javaClass;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param javaClass the javaClass to set
+     */
+    public void setJavaClass(String javaClass) {
+        this.javaClass = javaClass;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the rendererType
+     */
+    @XmlElement(name="renderer-type",namespace=Template.CDK_NAMESPACE)
+    public String getRendererType() {
+        return this.rendererType;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param rendererType the rendererType to set
+     */
+    public void setRendererType(String rendererType) {
+        this.rendererType = rendererType;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the baseClass
+     */
+    @XmlElement(name="superclass",namespace=Template.CDK_NAMESPACE)
+    public String getBaseClass() {
+        return this.baseClass;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param baseClass the baseClass to set
+     */
+    public void setBaseClass(String baseClass) {
+        this.baseClass = baseClass;
+    }
+    
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/CompositeInterface.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,134 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.JAXB;
+import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.DomHandler;
+import javax.xml.bind.annotation.W3CDomHandler;
+import javax.xml.namespace.QName;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMResult;
+import javax.xml.transform.dom.DOMSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.DocumentFragment;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+public class ElementsHandler  implements DomHandler<ModelElement, DOMResult> {
+
+    private DocumentBuilder builder;
+
+    /**
+     * Default constructor.
+     *
+     * It is up to a JAXB provider to decide which DOM implementation
+     * to use or how that is configured.
+     */
+    public ElementsHandler() {
+        DocumentBuilderFactory docFactory = DocumentBuilderFactory
+        .newInstance();
+// Create Document Builder
+        try {
+            this.builder = docFactory.newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            throw new IllegalArgumentException("No documentBuilderFactory");
+        };
+    }
+
+    /**
+     * Constructor that allows applications to specify which DOM implementation
+     * to be used.
+     *
+     * @param builder
+     *      must not be null. JAXB uses this {@link DocumentBuilder} to create
+     *      a new element.
+     */
+    public ElementsHandler(DocumentBuilder builder) {
+        if(builder==null)
+            throw new IllegalArgumentException();
+        this.builder = builder;
+    }
+
+    public DocumentBuilder getBuilder() {
+        return builder;
+    }
+
+    public void setBuilder(DocumentBuilder builder) {
+        if(builder==null)
+            throw new IllegalArgumentException();
+        this.builder = builder;
+    }
+
+    public DOMResult createUnmarshaller(ValidationEventHandler errorHandler) {
+        if(builder==null)
+            return new DOMResult();
+        else
+            return new DOMResult(builder.newDocument());
+    }
+
+    @Override
+    public ModelElement getElement(DOMResult rt) {
+        Element domElement = getDomElement(rt);
+        AnyElement element = JAXB.unmarshal(new DOMSource(domElement), AnyElement.class);
+
+        QName name = new QName(domElement.getNamespaceURI(),domElement.getLocalName());
+        element.setName(name);
+        return element;
+    }
+
+    public Element getDomElement(DOMResult r) {
+        // JAXP spec is ambiguous about what really happens in this case,
+        // so work defensively
+        Node n = r.getNode();
+        if( n instanceof Document ) {
+            return ((Document)n).getDocumentElement();
+        }
+        if( n instanceof Element )
+            return (Element)n;
+        if( n instanceof DocumentFragment )
+            return (Element)n.getChildNodes().item(0);
+
+        // if the result object contains something strange,
+        // it is not a user problem, but it is a JAXB provider's problem.
+        // That's why we throw a runtime exception.
+        throw new IllegalStateException(n.toString());
+    }
+
+    @Override
+    public Source marshal(ModelElement n, ValidationEventHandler errorHandler) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ElementsHandler.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,17 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+
+public interface LeafModelElement extends ModelElement {
+
+    /* (non-Javadoc)
+     * @see org.richfaces.cdk.templatecompiler.model.ModelElement#getChildren()
+     */
+    @XmlAnyElement(lax=true,value=ElementsHandler.class)
+    @XmlMixed
+    public List<Object> getChildren();
+
+}
\ No newline at end of file


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/LeafModelElement.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,54 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import com.google.common.collect.Lists;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+public class ModelBase {
+
+    private List<ModelBase> children = Lists.newArrayList();
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the children
+     */
+    public List<ModelBase> getChildren() {
+        return this.children;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param children the children to set
+     */
+    public void setChildren(List<ModelBase> children) {
+        this.children = children;
+    }
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelBase.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,14 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+
+import org.w3c.dom.Element;
+
+public interface ModelElement {
+
+
+
+}
\ No newline at end of file


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelElement.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,35 @@
+package org.richfaces.cdk.templatecompiler.model;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlMixed;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * <p class="changed_added_4_0">All classes that are used in template bodey should be presented
+ * in the {@link XmlSeeAlso} annotation </p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlSeeAlso({CdkCallElement.class,CdkBodyElement.class})
+public class ModelFragment implements LeafModelElement {
+
+    private List<Object> children;
+
+
+    @XmlAnyElement(lax=true,value=ElementsHandler.class)
+    @XmlMixed
+    public List<Object> getChildren() {
+        return this.children;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param body the body to set
+     */
+    public void setChildren(List<Object> body) {
+        this.children = body;
+    }
+
+}
\ No newline at end of file


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/ModelFragment.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,80 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlSeeAlso;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov at exadel.com
+ *
+ */
+ at XmlRootElement(name="root",namespace=Template.CDK_NAMESPACE)
+public class Template {
+    
+
+    public static final String CDK_NAMESPACE="http://richfaces.org/cdk";
+    
+    public static final String COMPOSITE_NAMESPACE="http://java.sun.com/jsf/composite";
+
+    private CompositeInterface _interface;
+    
+    private CompositeImplementation _implementation;
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the interface
+     */
+    @XmlElement(name="interface",namespace=COMPOSITE_NAMESPACE)
+    public CompositeInterface getInterface() {
+        return this._interface;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param interface1 the interface to set
+     */
+    public void setInterface(CompositeInterface interface1) {
+        this._interface = interface1;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @return the implementation
+     */
+    @XmlElement(name="implementation",namespace=COMPOSITE_NAMESPACE)
+    public CompositeImplementation getImplementation() {
+        return this._implementation;
+    }
+
+    /**
+     * <p class="changed_added_4_0"></p>
+     * @param implementation the implementation to set
+     */
+    public void setImplementation(CompositeImplementation implementation) {
+        this._implementation = implementation;
+    }
+
+}


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/Template.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,22 @@
+/**
+ * <h2>JAXB classes that wraps real model classes.</h2>
+ * <p>Some model requirements do not match JAXB plain bean model. The most important case is requirements for unique 
+ * Id's like component and renderer type. the other important difference is model properties which do not map to
+ * faces-config schema but moved into &lt;<....-extension&gt; elements.</p>
+ *
+ */
+ at XmlAccessorType(XmlAccessType.NONE)
+ at javax.xml.bind.annotation.XmlSchema(namespace = Template.CDK_NAMESPACE,
+        xmlns = {@javax.xml.bind.annotation.XmlNs(prefix = "cdk",
+                namespaceURI = Template.CDK_NAMESPACE),
+                @javax.xml.bind.annotation.XmlNs(prefix = "cc",
+                        namespaceURI = Template.COMPOSITE_NAMESPACE)})
+                        
+package org.richfaces.cdk.templatecompiler.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlSchemaTypes;
+import javax.xml.bind.annotation.XmlSchemaType;
+
+


Property changes on: root/cdk/trunk/plugins/generator/src/main/java/org/richfaces/cdk/templatecompiler/model/package-info.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
===================================================================
--- root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java	                        (rev 0)
+++ root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java	2009-11-05 01:25:23 UTC (rev 15830)
@@ -0,0 +1,67 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
+ */
+
+package org.richfaces.cdk.templatecompiler.model;
+
+import static org.junit.Assert.*;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.richfaces.cdk.xmlconfig.JaxbTestBase;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ * 
+ * @author asmirnov at exadel.com
+ * 
+ */
+public class TemplateTest extends JaxbTestBase {
+
+    private static final String TEMPLATE_EPILOG = "</cc:implementation></cdk:root>";
+    private static final String TEMPLATE_MIDDLE = "</cc:interface><cc:implementation>";
+    public static final String TEMPLATE_PROLOG = "<cdk:root xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:cdk=\"http://richfaces.org/cdk\" xmlns:cc=\"http://java.sun.com/jsf/composite\"><cc:interface>";
+
+    @Test
+    public void testTemplate() throws Exception {
+        Template template = unmarshal(Template.class, TEMPLATE_PROLOG
+                + TEMPLATE_MIDDLE + TEMPLATE_EPILOG);
+        assertNotNull(template.getInterface());
+        assertNotNull(template.getImplementation());
+    }
+    @Test
+    public void testImpl() throws Exception {
+        Template template = unmarshal(Template.class, TEMPLATE_PROLOG
+                + TEMPLATE_MIDDLE +"<cdk:call expression=\"#{cc.clientId}\"/><table width=\"200\"><tbody><cdk:call expression=\"#{cc.fooMethod(clientId)}\"/></tbody></table>Header<div class='bar'>foo</div>"+ TEMPLATE_EPILOG);
+        
+        CompositeImplementation implementation = template.getImplementation();
+        assertNotNull(implementation);
+        List<Object> children = implementation.getChildren();
+        assertNotNull(children);
+        assertEquals(4, children.size());
+        assertEquals(CdkCallElement.class, children.get(0).getClass());
+        assertEquals(AnyElement.class, children.get(1).getClass());
+        assertEquals(String.class, children.get(2).getClass());
+    }
+}


Property changes on: root/cdk/trunk/plugins/generator/src/test/java/org/richfaces/cdk/templatecompiler/model/TemplateTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the richfaces-svn-commits mailing list