[seam-commits] Seam SVN: r12111 - in modules/xml/trunk: docs and 8 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Mar 6 17:15:32 EST 2010


Author: swd847
Date: 2010-03-06 17:15:32 -0500 (Sat, 06 Mar 2010)
New Revision: 12111

Added:
   modules/xml/trunk/examples/princess-rescue/readme.txt
Removed:
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/util/ReflectionUtils.java
Modified:
   modules/xml/trunk/
   modules/xml/trunk/docs/
   modules/xml/trunk/examples/princess-rescue/
   modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/seam-beans.xml
   modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/templates/default.xhtml
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/BeanResult.java
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/XmlResult.java
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
   modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
Log:
changed the behaviour of the <extends> tag




Property changes on: modules/xml/trunk
___________________________________________________________________
Name: svn:ignore
   + .classpath
.settings
.project
target
test-output




Property changes on: modules/xml/trunk/docs
___________________________________________________________________
Name: svn:ignore
   + target



Property changes on: modules/xml/trunk/examples/princess-rescue
___________________________________________________________________
Name: svn:ignore
   - .classpath
.project
.settings

   + .classpath
.project
.settings
target


Added: modules/xml/trunk/examples/princess-rescue/readme.txt
===================================================================
--- modules/xml/trunk/examples/princess-rescue/readme.txt	                        (rev 0)
+++ modules/xml/trunk/examples/princess-rescue/readme.txt	2010-03-06 22:15:32 UTC (rev 12111)
@@ -0,0 +1,7 @@
+To run the example:
+
+mvn jetty:run
+
+Then navigate to:
+
+http://localhost:9090/princess-rescue/home.jsf
\ No newline at end of file

Modified: modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/seam-beans.xml
===================================================================
--- modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/seam-beans.xml	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/seam-beans.xml	2010-03-06 22:15:32 UTC (rev 12111)
@@ -105,7 +105,7 @@
    	<p:Room>dragonRoom</p:Room>
    	<p:adjacentMessage>You hear a snoring noise. With every snore you see a flickering light, as if something were breathing flames from its nostrils.</p:adjacentMessage>
    	<p:roomType>GAMEOVER</p:roomType>
-   	<p:message>The dragon wakes up as you enter. 'Well this is fortunate, I was feeling a bit peckish' are the last words you ever hear.</p:message>
+   	<p:message>The dragon wakes up as you enter. Then it eats you.</p:message>
    	<p:shootEffect>ANNOY</p:shootEffect>
    	<p:shootMessage>Your arrow wakes up the dragon, without appearing to do any real damage. The last moments of your life are spent running from an angry dragon.</p:shootMessage>
    	<p:north><Inject/><p:Room>princessRoom</p:Room></p:north> 

Modified: modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/templates/default.xhtml
===================================================================
--- modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/templates/default.xhtml	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/templates/default.xhtml	2010-03-06 22:15:32 UTC (rev 12111)
@@ -4,38 +4,14 @@
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <h:head>
-      <title>CDI and JSF 2 Starter Application</title>
+      <title>Princess Rescue</title>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <h:outputStylesheet name="css/screen.css"/>
    </h:head>
    <h:body>
       <div id="container">
          <div id="content">
-            <div id="sidebar">
-               <h3>Find out more</h3>
-               <p>
-                  Explore JavaServer Faces.
-               </p>
-               <ul>
-                  <li><a href="http://www.javaserverfaces.org">JSF community site</a></li>
-               </ul>
-               <p>
-                  Learn more about Java EE 6 and the extensions provided by Weld and Seam.
-               </p>
-               <ul>
-                  <li><a href="http://seamframework.org/Weld/JSR299AndWeldOverview">Overview</a></li>
-                  <li><a href="http://seamframework.org">Project site</a></li>
-                  <li><a href="http://seamframework.org/Documentation/SeamDocumentation#H-WeldReferenceDocumentation">Documentation</a></li>
-                  <li><a href="http://seamframework.org/Community/Forums">User forums</a></li>
-                  <li><a href="http://seamframework.org/Community/MailingLists">Mailing lists</a></li>
-                  <li><a href="https://jira.jboss.org/jira/browse/WELD">Issue tracker</a></li>
-               </ul>
-               <p>
-                  If you have an add-on, please <a href="http://seamframework.org/Community/Forums">let us know</a> and
-                  consider <a href="http://seamframework.org/Community/Contribute">contributing</a> it back to the
-                  community!
-               </p>
-            </div>
+            
             <ui:insert name="content">
                [Template content will be inserted here]
             </ui:insert>

Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -33,7 +33,6 @@
 import org.jboss.seam.xml.parser.SaxNode;
 import org.jboss.seam.xml.util.FileDataReader;
 import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
-import org.jboss.weld.extensions.util.annotated.NewAnnotatedTypeBuilder;
 
 public class XmlExtension implements Extension
 {
@@ -48,8 +47,6 @@
 
    Map<Class<?>, AnnotatedType<?>> types = new HashMap<Class<?>, AnnotatedType<?>>();
 
-   Map<Class<?>, BeanResult<?>> beanExtensions = new HashMap<Class<?>, BeanResult<?>>();
-
    int count = 0;
 
    /**
@@ -124,10 +121,7 @@
             event.addAnnotatedType(tp);
             types.put(tp.getJavaClass(), tp);
          }
-         for (BeanResult<?> bb : r.getExtendBeans())
-         {
-            beanExtensions.put(bb.getType(), bb);
-         }
+
          veto.addAll(r.getVeto());
 
       }
@@ -140,13 +134,7 @@
       {
          event.veto();
       }
-      Class javaClass = event.getAnnotatedType().getJavaClass();
-      if (beanExtensions.containsKey(javaClass))
-      {
-         NewAnnotatedTypeBuilder typeBuilder = beanExtensions.get(javaClass).getBuilder();
-         typeBuilder.mergeAnnotations(event.getAnnotatedType(), false);
-         event.setAnnotatedType(typeBuilder.create());
-      }
+
    }
 
    public <T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> event)

Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/BeanResult.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/BeanResult.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/BeanResult.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -12,10 +12,10 @@
    Class<X> type;
    boolean override, extend;
 
-   public BeanResult(Class<X> type)
+   public BeanResult(Class<X> type, boolean readAnnotations)
    {
       this.type = type;
-      builder = new NewAnnotatedTypeBuilder<X>(type);
+      builder = new NewAnnotatedTypeBuilder<X>(type, readAnnotations);
    }
 
    public NewAnnotatedTypeBuilder<X> getBuilder()

Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/XmlResult.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/XmlResult.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/core/XmlResult.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -33,8 +33,6 @@
 
    List<BeanResult<?>> beans = new ArrayList<BeanResult<?>>();
 
-   List<BeanResult<?>> extendBeans = new ArrayList<BeanResult<?>>();
-
    Map<BeanResult<?>, List<FieldValueObject>> fieldValues = new HashMap<BeanResult<?>, List<FieldValueObject>>();
 
    public Map<Class<? extends Annotation>, Annotation[]> getStereotypes()
@@ -82,9 +80,4 @@
       return veto;
    }
 
-   public List<BeanResult<?>> getExtendBeans()
-   {
-      return extendBeans;
-   }
-
 }

Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -27,10 +27,10 @@
 import org.jboss.seam.xml.parser.namespace.CompositeNamespaceElementResolver;
 import org.jboss.seam.xml.parser.namespace.NamespaceElementResolver;
 import org.jboss.seam.xml.parser.namespace.RootNamespaceElementResolver;
-import org.jboss.seam.xml.util.ReflectionUtils;
 import org.jboss.seam.xml.util.XmlConfigurationException;
 import org.jboss.seam.xml.util.XmlObjectConverter;
 import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
+import org.jboss.weld.extensions.util.ReflectionUtils;
 import org.jboss.weld.extensions.util.annotated.NewAnnotatedTypeBuilder;
 
 /**
@@ -99,16 +99,9 @@
          if (type == ResultType.BEAN)
          {
             BeanResult<?> tp = buildAnnotatedType((ClassXmlItem) rb);
-            if (tp.isExtend())
+            ret.getBeans().add(tp);
+            if (tp.isOverride() || tp.isExtend())
             {
-               ret.getExtendBeans().add(tp);
-            }
-            else
-            {
-               ret.getBeans().add(tp);
-            }
-            if (tp.isOverride())
-            {
                ret.addVeto(tp.getType());
             }
             List<FieldValueObject> fields = new ArrayList<FieldValueObject>();
@@ -237,13 +230,16 @@
    @SuppressWarnings("unchecked")
    BeanResult<?> buildAnnotatedType(ClassXmlItem rb)
    {
-      BeanResult<?> result = new BeanResult(rb.getJavaClass());
+      boolean override = !rb.getChildrenOfType(OverrideXmlItem.class).isEmpty();
+      boolean extend = !rb.getChildrenOfType(ExtendsXmlItem.class).isEmpty();
+
+      // if it is an extend we want to read the annotations from the underlying
+      // class
+      BeanResult<?> result = new BeanResult(rb.getJavaClass(), extend);
       NewAnnotatedTypeBuilder<?> type = result.getBuilder();
       // list of constructor arguments
       List<ParameterXmlItem> constList = new ArrayList<ParameterXmlItem>();
 
-      boolean override = !rb.getChildrenOfType(OverrideXmlItem.class).isEmpty();
-      boolean extend = !rb.getChildrenOfType(ExtendsXmlItem.class).isEmpty();
       if (override && extend)
       {
          throw new XmlConfigurationException("A bean may not both <override> and <extend> an existing bean", rb.getDocument(), rb.getLineno());

Modified: modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -4,6 +4,7 @@
  */
 package org.jboss.seam.xml.parser.namespace;
 
+import java.lang.reflect.Field;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -11,11 +12,14 @@
 
 import org.jboss.seam.xml.model.AnnotationXmlItem;
 import org.jboss.seam.xml.model.ClassXmlItem;
+import org.jboss.seam.xml.model.FieldXmlItem;
+import org.jboss.seam.xml.model.MethodXmlItem;
 import org.jboss.seam.xml.model.ParameterXmlItem;
 import org.jboss.seam.xml.model.XmlItem;
 import org.jboss.seam.xml.model.XmlItemType;
 import org.jboss.seam.xml.parser.SaxNode;
-import org.jboss.seam.xml.util.ReflectionUtils;
+import org.jboss.seam.xml.util.XmlConfigurationException;
+import org.jboss.weld.extensions.util.ReflectionUtils;
 
 public class PackageNamespaceElementResolver implements NamespaceElementResolver
 {
@@ -80,7 +84,7 @@
          // if the item can be a method of a FIELD
          if (parent.getAllowedItem().contains(XmlItemType.METHOD) || parent.getAllowedItem().contains(XmlItemType.FIELD))
          {
-            return ReflectionUtils.resolveMethodOrField(name, parent, node.getInnerText(), node.getDocument(), node.getLineNo());
+            return resolveMethodOrField(name, parent, node.getInnerText(), node.getDocument(), node.getLineNo());
          }
          else
          {
@@ -94,4 +98,25 @@
       return null;
    }
 
+   public static XmlItem resolveMethodOrField(String name, XmlItem parent, String innerText, String document, int lineno)
+   {
+      Class<?> p = parent.getJavaClass();
+      Field f = null;
+      boolean methodFound = ReflectionUtils.methodExists(p, name);
+      f = ReflectionUtils.getField(p, name);
+
+      if (methodFound && f != null)
+      {
+         throw new XmlConfigurationException(parent.getJavaClass().getName() + " has both a method and a field named " + name + " and so cannot be configured via XML", document, lineno);
+      }
+      if (methodFound)
+      {
+         return new MethodXmlItem(parent, name, document, lineno);
+      }
+      else if (f != null)
+      {
+         return new FieldXmlItem(parent, f, innerText, document, lineno);
+      }
+      return null;
+   }
 }

Deleted: modules/xml/trunk/src/main/java/org/jboss/seam/xml/util/ReflectionUtils.java
===================================================================
--- modules/xml/trunk/src/main/java/org/jboss/seam/xml/util/ReflectionUtils.java	2010-03-06 21:42:25 UTC (rev 12110)
+++ modules/xml/trunk/src/main/java/org/jboss/seam/xml/util/ReflectionUtils.java	2010-03-06 22:15:32 UTC (rev 12111)
@@ -1,112 +0,0 @@
-/*
- * Distributed under the LGPL License
- * 
- */
-package org.jboss.seam.xml.util;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import org.jboss.seam.xml.model.FieldXmlItem;
-import org.jboss.seam.xml.model.MethodXmlItem;
-import org.jboss.seam.xml.model.XmlItem;
-
-public class ReflectionUtils
-{
-   public static XmlItem resolveMethodOrField(String name, XmlItem parent, String innerText, String document, int lineno)
-   {
-      Class<?> p = parent.getJavaClass();
-      Field f = null;
-      boolean methodFound = methodExists(p, name);
-      f = getField(p, name);
-
-      if (methodFound && f != null)
-      {
-         throw new XmlConfigurationException(parent.getJavaClass().getName() + " has both a method and a field named " + name + " and so cannot be configured via XML", document, lineno);
-      }
-      if (methodFound)
-      {
-         return new MethodXmlItem(parent, name, document, lineno);
-      }
-      else if (f != null)
-      {
-         return new FieldXmlItem(parent, f, innerText, document, lineno);
-      }
-      return null;
-   }
-
-   /**
-    * we need access to private fields so we cannot just use getField
-    */
-   public static Field getField(Class<?> parent, String name)
-   {
-      Class<?> p = parent;
-      while (p != Object.class)
-      {
-         try
-         {
-            return p.getDeclaredField(name);
-         }
-         catch (Exception e1)
-         {
-
-         }
-         p = p.getSuperclass();
-      }
-      return null;
-   }
-
-   public static boolean methodExists(Class<?> parent, String name)
-   {
-      Class<?> p = parent;
-      while (p != Object.class)
-      {
-         for (Method m : p.getDeclaredMethods())
-         {
-            if (m.getName().equals(name))
-            {
-               return true;
-            }
-         }
-         p = p.getSuperclass();
-      }
-      return false;
-   }
-
-   public static Method getMethod(Class<?> parent, String name, Class<?>... args)
-   {
-      Class<?> p = parent;
-      while (p != Object.class)
-      {
-         try
-         {
-            return p.getDeclaredMethod(name, args);
-         }
-         catch (Exception e1)
-         {
-
-         }
-         p = p.getSuperclass();
-      }
-      return null;
-   }
-
-   public static Constructor<?> getConstructor(Class<?> parent, Class<?>... args)
-   {
-      Class<?> p = parent;
-      while (p != Object.class)
-      {
-         try
-         {
-            return p.getDeclaredConstructor(args);
-         }
-         catch (Exception e1)
-         {
-
-         }
-         p = p.getSuperclass();
-      }
-      return null;
-   }
-}



More information about the seam-commits mailing list