[seam-commits] Seam SVN: r13360 - in modules/xml/trunk: impl/src/main/java/org/jboss/seam/xml/bootstrap and 3 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Jul 10 21:16:28 EDT 2010


Author: swd847
Date: 2010-07-10 21:16:28 -0400 (Sat, 10 Jul 2010)
New Revision: 13360

Removed:
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java
Modified:
   modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
   modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
   modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
   modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml
Log:
change <type> to <Exact> as per SEAMXML-8



Modified: modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
===================================================================
--- modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml	2010-07-11 01:16:28 UTC (rev 13360)
@@ -141,7 +141,7 @@
         
         <itemizedlist>
             <listitem><para><literal>Beans</literal></para></listitem>
-            <listitem><para><literal>extends</literal></para></listitem>
+            <listitem><para><literal>modifies</literal></para></listitem>
             <listitem><para><literal>overrides</literal></para></listitem>
             <listitem><para><literal>parameters</literal></para></listitem>
             <listitem><para><literal>value</literal></para></listitem>
@@ -173,6 +173,7 @@
             <listitem><para><literal>javax.enterprise.event</literal></para></listitem>
             <listitem><para><literal>javax.decorator</literal></para></listitem>
             <listitem><para><literal>javax.interceptor</literal></para></listitem>
+            <listitem><para><literal>org.jboss.weld.extensions.core</literal></para></listitem>
         </itemizedlist>
         
         <para>Other namspaces are specified using the following syntax:</para>
@@ -193,16 +194,16 @@
         <para>By configuring a bean via XML creates a new bean, however there 
           may be cases where you want to modify an existing bean rather than
           adding a new one. The <literal>&lt;s:overrides&gt;</literal> and 
-          <literal>&lt;s:extends&gt;</literal> tags allow you to do this.</para>
+          <literal>&lt;s:modifies&gt;</literal> tags allow you to do this.</para>
           <para>The <literal>&lt;s:overrides&gt;</literal> tag prevents the existing bean from being 
           installed, and registers a new one with the given configuration. The 
-          <literal>&lt;s:extends&gt;</literal> tag does the same, except that it merges
+          <literal>&lt;s:modifies&gt;</literal> tag does the same, except that it merges
           the annotations on the bean with the annotations defined in XML. This has the
           same effect as modifiying an existing bean.</para>
         
         <programlisting role="XML"><![CDATA[
 <test:Report>
-	<s:extends>
+	<s:modifies>
 	<test:NewQualifier/>
 </test:Report>
 
@@ -406,9 +407,7 @@
 <test:SomeBean>
         <test:someField>
          	<s:Inject/>
-         	<s:type>
-         		<test:InjectedBean/>
-         	</s:type>
+         	<s:Exact>com.mydomain.InjectedBean</s:Exact>
         </test:someField>
 </test:SomeBean>
 ]]>
@@ -491,7 +490,7 @@
 <s:genericBean class="org.jboss.seam.xml.test.generic.GenericMain" >
 	<test:GenericDependant>
 		<s:ApplyQualifiers/>
-		<s:extends/>
+		<s:modifies/>
 		<test:instance>
 			<s:ApplyQualifiers/>
 		</test:instance>

Modified: modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml
===================================================================
--- modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/docs/src/main/docbook/en-US/xml-introduction.xml	2010-07-11 01:16:28 UTC (rev 13360)
@@ -100,9 +100,7 @@
  		<s:overrides/>
  		<r:datasource>
  			<s:Inject/>
- 			<s:type>
- 				<r:BillingDatasource/>
- 			</s:type>
+ 			<s:Exact>org.example.reports.BillingDatasource</s:Exact>
  		</r:datasource>
   	</r:Report>  	
 </beans>
@@ -142,8 +140,8 @@
                                 from the class definition.</para>
                             </callout>
                             <callout arearefs="datasource-type">
-                                <para>The <literal>&lt;s:type&gt;</literal> restricts the type of bean that is availible for injection without using qualifiers. In this case 
-                                <literal>BillingDatasource</literal> will be injected.</para>
+                                <para>The <literal>&lt;s:Eact&gt;</literal> annotation restricts the type of bean that is availible for injection without using qualifiers. In this case 
+                                <literal>BillingDatasource</literal> will be injected. This is provided as part of weld-extensions.</para>
                             </callout>
                             
     </calloutlist>

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -64,6 +64,7 @@
 import org.jboss.seam.xml.parser.SaxNode;
 import org.jboss.seam.xml.util.FileDataReader;
 import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.core.Exact;
 import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -429,6 +430,53 @@
       return false;
    }
 
+   /**
+    * temprary hack to support @Exact in seam-xml, remove once WELD-485 is
+    * resolved
+    */
+   <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager beanManager)
+   {
+
+      AnnotatedTypeBuilder<X> builder = AnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).mergeAnnotations(pat.getAnnotatedType(), true);
+
+      // support for @Exact
+      // fields
+      for (AnnotatedField<? super X> f : pat.getAnnotatedType().getFields())
+      {
+         if (f.isAnnotationPresent(Exact.class))
+         {
+            Class<?> type = f.getAnnotation(Exact.class).value();
+            builder.overrideFieldType(f.getJavaMember(), type);
+         }
+      }
+      // method parameters
+      for (AnnotatedMethod<? super X> m : pat.getAnnotatedType().getMethods())
+      {
+         for (AnnotatedParameter<? super X> p : m.getParameters())
+         {
+            if (p.isAnnotationPresent(Exact.class))
+            {
+               Class<?> type = p.getAnnotation(Exact.class).value();
+               builder.overrideMethodParameterType(m.getJavaMember(), type, p.getPosition());
+            }
+         }
+      }
+      // constructor parameters
+      for (AnnotatedConstructor<X> c : pat.getAnnotatedType().getConstructors())
+      {
+         for (AnnotatedParameter<? super X> p : c.getParameters())
+         {
+            if (p.isAnnotationPresent(Exact.class))
+            {
+               Class<?> type = p.getAnnotation(Exact.class).value();
+               builder.overrideConstructorParameterType(c.getJavaMember(), type, p.getPosition());
+            }
+         }
+      }
+      pat.setAnnotatedType(builder.create());
+
+   }
+
    public static class DefaultLiteral extends AnnotationLiteral<Default> implements Default
    {
    };

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -43,7 +43,6 @@
       allowed.add(XmlItemType.FIELD);
       allowed.add(XmlItemType.METHOD);
       allowed.add(XmlItemType.PARAMETERS);
-      allowed.add(XmlItemType.TYPE);
    }
 
    public Set<XmlItemType> getAllowedItem()

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -59,7 +59,6 @@
       }
       allowed.add(XmlItemType.ANNOTATION);
       allowed.add(XmlItemType.VALUE);
-      allowed.add(XmlItemType.TYPE);
    }
 
    public Field getField()

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -341,22 +341,6 @@
             Annotation a = createAnnotation(fi);
             type.addToField(item.getField(), a);
          }
-         List<TypeXmlItem> types = item.getChildrenOfType(TypeXmlItem.class);
-         if (types.size() > 1)
-         {
-            throw new XmlConfigurationException("Only one <type> element may be present on a field", rb.getDocument(), rb.getLineno());
-         }
-         if (!types.isEmpty())
-         {
-            List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
-            if (overridenTypes.size() != 1)
-            {
-               throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
-            }
-
-            type.overrideFieldType(item.getField(), overridenTypes.get(0).getJavaClass());
-         }
-
       }
       for (MethodXmlItem item : rb.getChildrenOfType(MethodXmlItem.class))
       {
@@ -382,20 +366,6 @@
                   Annotation a = createAnnotation(pan);
                   type.addToMethodParameter(item.getMethod(), param, a);
                }
-               List<TypeXmlItem> types = fi.getChildrenOfType(TypeXmlItem.class);
-               if (types.size() > 1)
-               {
-                  throw new XmlConfigurationException("Only one <type> element may be present on a parameter", rb.getDocument(), rb.getLineno());
-               }
-               if (!types.isEmpty())
-               {
-                  List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
-                  if (overridenTypes.size() != 1)
-                  {
-                     throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
-                  }
-                  type.overrideMethodParameterType(item.getMethod(), overridenTypes.get(0).getJavaClass(), param);
-               }
             }
          }
 
@@ -417,21 +387,6 @@
                Annotation a = createAnnotation(pan);
                type.addToConstructorParameter((Constructor) c, param, a);
             }
-            List<TypeXmlItem> types = fi.getChildrenOfType(TypeXmlItem.class);
-            if (types.size() > 1)
-            {
-               throw new XmlConfigurationException("Only one <type> element may be present on a parameter", rb.getDocument(), rb.getLineno());
-            }
-            if (!types.isEmpty())
-            {
-               List<ClassXmlItem> overridenTypes = types.get(0).getChildrenOfType(ClassXmlItem.class);
-               if (overridenTypes.size() != 1)
-               {
-                  throw new XmlConfigurationException("<type> must have a single child element", rb.getDocument(), rb.getLineno());
-               }
-
-               type.overrideConstructorParameterType(c, overridenTypes.get(0).getJavaClass(), param);
-            }
          }
       }
       return result;

Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/TypeXmlItem.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -1,47 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.seam.xml.model;
-
-import java.util.HashSet;
-import java.util.Set;
-
-public class TypeXmlItem extends AbstractXmlItem
-{
-
-   static final Set<XmlItemType> allowed = new HashSet<XmlItemType>();
-
-   static
-   {
-      allowed.add(XmlItemType.CLASS);
-      allowed.add(XmlItemType.ANNOTATION);
-   }
-
-   public TypeXmlItem(XmlItem parent, String document, int lineno)
-   {
-      super(XmlItemType.TYPE, parent, null, null, null, document, lineno);
-   }
-
-   public Set<XmlItemType> getAllowedItem()
-   {
-      return allowed;
-   }
-}

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItemType.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -23,5 +23,5 @@
 
 public enum XmlItemType
 {
-   CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, MODIFIES, TYPE, GENERIC_BEAN;
+   CLASS, METHOD, FIELD, ANNOTATION, VALUE, ENTRY, KEY, DEPENDENCY, PARAMETERS, PARAMETER, ARRAY, OVERRIDE, MODIFIES, GENERIC_BEAN;
 }

Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/RootNamespaceElementResolver.java	2010-07-11 01:16:28 UTC (rev 13360)
@@ -30,7 +30,6 @@
 import org.jboss.seam.xml.model.OverrideXmlItem;
 import org.jboss.seam.xml.model.ParameterXmlItem;
 import org.jboss.seam.xml.model.ParametersXmlItem;
-import org.jboss.seam.xml.model.TypeXmlItem;
 import org.jboss.seam.xml.model.ValueXmlItem;
 import org.jboss.seam.xml.model.XmlItem;
 import org.jboss.seam.xml.model.XmlItemType;
@@ -40,7 +39,7 @@
 {
 
    private final CompositeNamespaceElementResolver delegate;
-   static final String[] namspaces = { "java.lang", "java.util", "javax.annotation", "javax.inject", "javax.enterprise.inject", "javax.enterprise.context", "javax.enterprise.event", "javax.decorator", "javax.interceptor", "org.jboss.seam.xml.annotations.internal" };
+   static final String[] namspaces = { "java.lang", "java.util", "javax.annotation", "javax.inject", "javax.enterprise.inject", "javax.enterprise.context", "javax.enterprise.event", "javax.decorator", "javax.interceptor", "org.jboss.seam.xml.annotations.internal", "org.jboss.weld.extensions.core" };
 
    public RootNamespaceElementResolver()
    {
@@ -87,10 +86,6 @@
       {
          return new ParametersXmlItem(parent, node.getDocument(), node.getLineNo());
       }
-      else if (item.equals("type"))
-      {
-         return new TypeXmlItem(parent, node.getDocument(), node.getLineNo());
-      }
       else if (item.equals("genericBean"))
       {
          return new GenericBeanXmlItem(parent, node.getAttributes(), node.getDocument(), node.getLineNo());

Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml	2010-07-11 00:54:59 UTC (rev 13359)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/types/types-test-beans.xml	2010-07-11 01:16:28 UTC (rev 13360)
@@ -7,17 +7,13 @@
        <overrides/>
        <test:value>
        	<Inject/>
-       	<type>
-       		<test:AllowedType/>
-       	</type>
+       	<Exact>org.jboss.seam.xml.test.types.AllowedType</Exact>
        </test:value>
        <test:create>
        	 <Inject/>
        	 <parameters>
        	 	<test:SomeInterface>
-       	 		<type>
-       	 			<test:RestrictedType/>
-       	 		</type>
+       	 		<Exact>org.jboss.seam.xml.test.types.RestrictedType</Exact>
        	 	</test:SomeInterface>
        	 </parameters>
        </test:create>



More information about the seam-commits mailing list