[seam-commits] Seam SVN: r13538 - in modules/xml/trunk: examples/princess-rescue and 4 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sun Aug 1 05:50:28 EDT 2010
Author: swd847
Date: 2010-08-01 05:50:28 -0400 (Sun, 01 Aug 2010)
New Revision: 13538
Removed:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldTypeSetter.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueSetter.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java
Modified:
modules/xml/trunk/examples/princess-rescue/pom.xml
modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/beans.xml
modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/web.xml
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanFieldValue.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.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/PropertyXmlItem.java
modules/xml/trunk/pom.xml
Log:
change to using weld-extensions protperties
Modified: modules/xml/trunk/examples/princess-rescue/pom.xml
===================================================================
--- modules/xml/trunk/examples/princess-rescue/pom.xml 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/examples/princess-rescue/pom.xml 2010-08-01 09:50:28 UTC (rev 13538)
@@ -27,7 +27,6 @@
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
- <scope>provided</scope>
</dependency>
<dependency>
@@ -57,14 +56,21 @@
<artifactId>jsf-impl</artifactId>
<scope>runtime</scope>
</dependency>
- <!--
+
<dependency>
<groupId>org.jboss.weld.servlet</groupId>
<artifactId>weld-servlet</artifactId>
<scope>runtime</scope>
</dependency>
- -->
+
<dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <scope>runtime</scope>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>el-impl</artifactId>
<scope>runtime</scope>
Modified: modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/beans.xml 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/examples/princess-rescue/src/main/resources/META-INF/beans.xml 2010-08-01 09:50:28 UTC (rev 13538)
@@ -1,194 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:s="urn:java:ee"
- xmlns:p="org.jboss.seam.xml.examples.princess"
- xsi:schemaLocation="
- http://java.sun.com/xml/ns/javaee
- http://docs.jboss.org/cdi/beans_1_0.xsd">
-
- <!-- Makes the Room annotation a qualifier -->
- <p:Room>
- <s:Qualifier/>
- </p:Room>
-
- <p:GameManager>
- <s:extends/>
- <p:allRooms>
- <s:Any/>
- <s:Inject/>
- </p:allRooms>
- <p:emptyRoomShootMessage>Your arrow does not appear to hit anything.</p:emptyRoomShootMessage>
- <p:startMessage>You enter the dungeon, with you bow in your hand and your heart in your mouth.</p:startMessage>
- <p:startRoom>
- <!-- Inject the starting room -->
- <s:Inject/>
- <p:Room>startRoom</p:Room>
- </p:startRoom>
- </p:GameManager>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room value="startRoom"/>
- <p:north><s:Inject/><p:Room>emptyRoom1</p:Room></p:north>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom1</p:Room>
- <p:north><s:Inject/><p:Room>emptyRoom3</p:Room></p:north>
- <p:west><s:Inject/><p:Room>dwarfRoom</p:Room></p:west>
- <p:east><s:Inject/><p:Room>pitRoom1</p:Room></p:east>
- <p:south><s:Inject/><p:Room>startRoom</p:Room></p:south>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>dwarfRoom</p:Room>
- <p:roomType>MONSTER</p:roomType>
- <p:shootEffect>KILL</p:shootEffect>
- <p:adjacentMessage>You hear drunken singing.</p:adjacentMessage>
- <p:message>You find a drunken dwarven miner. He belches in your direction, falls over, then seems to forget you are there.</p:message>
- <p:shootMessage>You hear a 'Thud', followed by a surprised yell.</p:shootMessage>
- <p:killedRoomMessage>You find a dead dwarven miner with something that looks suspiciously like one of your arrows sticking out of his chest. Probably best you don't mention this to anyone...</p:killedRoomMessage>
- <p:east><s:Inject/><p:Room>emptyRoom1</p:Room></p:east>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>pitRoom1</p:Room>
- <p:roomType>GAMEOVER</p:roomType>
- <p:adjacentMessage>You feel a breeze.</p:adjacentMessage>
- <p:message>You fall into a bottomless pit. Game Over. </p:message>
- <p:west><s:Inject/><p:Room>emptyRoom1</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom2</p:Room>
- <p:north><s:Inject/><p:Room>emptyRoom4</p:Room></p:north>
- <p:west><s:Inject/><p:Room>pitRoom1</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom3</p:Room>
- <p:north><s:Inject/><p:Room>pitRoom2</p:Room></p:north>
- <p:east><s:Inject/><p:Room>batRoom</p:Room></p:east>
- <p:south><s:Inject/><p:Room>emptyRoom1</p:Room></p:south>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>batRoom</p:Room>
- <p:adjacentMessage>You hear a screeching noise.</p:adjacentMessage>
- <p:message>A swarm of bats lands on you and tries to pick you up. They fail miserably. You swat them away with your bow.</p:message>
- <p:shootMessage>You seem to have disturbed some bats, they fly past your head in the dark.</p:shootMessage>
- <p:north><s:Inject/><p:Room>emptyRoom6</p:Room></p:north>
- <p:east><s:Inject/><p:Room>emptyRoom4</p:Room></p:east>
- <p:south><s:Inject/><p:Room>pitRoom1</p:Room></p:south>
- <p:west><s:Inject/><p:Room>emptyRoom3</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom4</p:Room>
- <p:east><s:Inject/><p:Room>emptyRoom5</p:Room></p:east>
- <p:south><s:Inject/><p:Room>emptyRoom2</p:Room></p:south>
- <p:west><s:Inject/><p:Room>batRoom</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom5</p:Room>
- <p:north><s:Inject/><p:Room>emptyRoom7</p:Room></p:north>
- <p:east><s:Inject/><p:Room>dragonRoom</p:Room></p:east>
- <p:west><s:Inject/><p:Room>emptyRoom4</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <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. 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><s:Inject/><p:Room>princessRoom</p:Room></p:north>
- <p:west><s:Inject/><p:Room>emptyRoom5</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>pitRoom2</p:Room>
- <p:roomType>GAMEOVER</p:roomType>
- <p:adjacentMessage>You feel a breeze.</p:adjacentMessage>
- <p:message>You fall into a bottomless pit. Game Over. </p:message>
- <p:south><s:Inject/><p:Room>emptyRoom3</p:Room></p:south>
- <p:east><s:Inject/><p:Room>emptyRoom6</p:Room></p:east>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom6</p:Room>
- <p:north><s:Inject/><p:Room>emptyRoom8</p:Room></p:north>
- <p:west><s:Inject/><p:Room>pitRoom2</p:Room></p:west>
- <p:south><s:Inject/><p:Room>batRoom</p:Room></p:south>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom7</p:Room>
- <p:north><s:Inject/><p:Room>emptyRoom10</p:Room></p:north>
- <p:east><s:Inject/><p:Room>princessRoom</p:Room></p:east>
- <p:south><s:Inject/><p:Room>emptyRoom5</p:Room></p:south>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>princessRoom</p:Room>
- <p:adjacentMessage>You hear a sobbing noise.</p:adjacentMessage>
- <p:roomType>GAMEOVER</p:roomType>
- <p:message>You find the princess and quickly free her, and then escape from the dungeon. You both live happily ever after.</p:message>
- <p:shootEffect>ANNOY</p:shootEffect>
- <p:shootMessage>Your arrow clatters against the wall. You hear a cry 'Help i'm being shot at'. The cry wakes the dragon in the room next door, which promptly eats you.</p:shootMessage>
- <p:south><s:Inject/><p:Room>dragonRoom</p:Room></p:south>
- <p:west><s:Inject/><p:Room>emptyRoom7</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom8</p:Room>
- <p:east><s:Inject/><p:Room>emptyRoom9</p:Room></p:east>
- <p:south><s:Inject/><p:Room>emptyRoom6</p:Room></p:south>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom9</p:Room>
- <p:north><s:Inject/><p:Room>wumpusRoom</p:Room></p:north>
- <p:east><s:Inject/><p:Room>emptyRoom10</p:Room></p:east>
- <p:west><s:Inject/><p:Room>emptyRoom8</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:Room>emptyRoom10</p:Room>
- <p:south><s:Inject/><p:Room>emptyRoom7</p:Room></p:south>
- <p:west><s:Inject/><p:Room>emptyRoom9</p:Room></p:west>
- </p:GameRoom>
-
- <p:GameRoom>
- <s:SessionScoped/>
- <p:roomType>MONSTER</p:roomType>
- <p:adjacentMessage>You smell a Wumpus</p:adjacentMessage>
- <p:shootMessage>You hear a 'Thud', followed by a roar of pain.</p:shootMessage>
- <p:killedRoomMessage>You stumbe accross a dead Wumpus. Well that wasn't so hard...</p:killedRoomMessage>
- <p:message>You find a Wumpus. It eats you.</p:message>
- <p:shootEffect>KILL</p:shootEffect>
- <p:Room>wumpusRoom</p:Room>
- <p:south><s:Inject/><p:Room>emptyRoom9</p:Room></p:south>
- </p:GameRoom>
-
-
-</beans>
Modified: modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/web.xml 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/examples/princess-rescue/src/main/webapp/WEB-INF/web.xml 2010-08-01 09:50:28 UTC (rev 13538)
@@ -26,12 +26,18 @@
<param-value>true</param-value>
</context-param>
+ <listener>
+ <listener-class>org.jboss.weld.extensions.resourceLoader.servlet.ResourceListener</listener-class>
+ </listener>
+
<!-- Weld Jetty/Tomcat specific configuration parameters -->
<!-- *** The <listener> and <resource-env-ref> elements can be deleted when running in a Java EE 6 container *** -->
<listener>
<listener-class>org.jboss.weld.environment.servlet.Listener</listener-class>
</listener>
+
+
<resource-env-ref>
<description>Object factory for the CDI Bean Manager</description>
<resource-env-ref-name>BeanManager</resource-env-ref-name>
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -30,6 +30,7 @@
import org.jboss.seam.xml.model.ValueXmlItem;
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.util.XmlObjectConverter;
+import org.jboss.weld.extensions.util.properties.Property;
/**
* class responsible for setting the value of array properties.
@@ -39,109 +40,28 @@
*/
public class ArrayFieldSet implements FieldValueObject
{
- final private FieldValueSetter field;
+ final private Property field;
final private List<AFS> values;
- final private Class arrayType;
+ final private Class<?> arrayType;
- public ArrayFieldSet(FieldValueSetter field, List<ValueXmlItem> items)
+ public ArrayFieldSet(Property<?> field, List<ValueXmlItem> items)
{
this.field = field;
this.values = new ArrayList<AFS>();
- arrayType = field.getType().getComponentType();
+ arrayType = field.getJavaClass().getComponentType();
AFS setter;
for (XmlItem i : items)
{
final Object fv = XmlObjectConverter.convert(arrayType, i.getInnerText());
- if (field.getType() == char.class)
+ final Object val = fv;
+ setter = new AFS()
{
-
- final char val = (Character) fv;
- setter = new AFS()
+ public void set(Object o, int i) throws IllegalAccessException
{
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setChar(o, i, val);
- }
- };
- }
- else if (field.getType() == int.class)
- {
- final int val = (Integer) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setInt(o, i, val);
- }
- };
- }
- else if (field.getType() == short.class)
- {
- final short val = (Short) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setShort(o, i, val);
- }
- };
- }
- else if (field.getType() == long.class)
- {
- final long val = (Long) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setLong(o, i, val);
- }
- };
- }
- else if (field.getType() == byte.class)
- {
- final byte val = (Byte) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setByte(o, i, val);
- }
- };
- }
- else if (field.getType() == double.class)
- {
- final double val = (Double) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setDouble(o, i, val);
- }
- };
- }
- else if (field.getType() == float.class)
- {
- final float val = (Float) fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.setFloat(o, i, val);
- }
- };
- }
- else
- {
- final Object val = fv;
- setter = new AFS()
- {
- public void set(Object o, int i) throws IllegalAccessException
- {
- Array.set(o, i, val);
- }
- };
- }
+ Array.set(o, i, val);
+ }
+ };
values.add(setter);
}
@@ -152,7 +72,7 @@
try
{
Object array = Array.newInstance(arrayType, values.size());
- field.set(instance, array);
+ field.setValue(instance, array);
for (int i = 0; i < values.size(); ++i)
{
values.get(i).set(array, i);
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -39,6 +39,7 @@
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.util.TypeReader;
import org.jboss.seam.xml.util.XmlObjectConverter;
+import org.jboss.weld.extensions.util.properties.Property;
/**
* class responsible for setting the value of collection properties.
@@ -51,17 +52,17 @@
*/
public class CollectionFieldSet implements FieldValueObject
{
- private final FieldValueSetter field;
+ private final Property field;
private final List<CFS> values;
private final Class<?> elementType;
private final Class<? extends Collection> collectionType;
- public CollectionFieldSet(FieldValueSetter field, List<ValueXmlItem> items)
+ public CollectionFieldSet(Property field, List<ValueXmlItem> items)
{
this.field = field;
this.values = new ArrayList<CFS>();
- Type type = field.getGenericType();
+ Type type = field.getBaseType();
if (type instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) type;
@@ -136,7 +137,7 @@
try
{
Collection<Object> res = collectionType.newInstance();
- field.set(instance, res);
+ field.setValue(instance, res);
for (int i = 0; i < values.size(); ++i)
{
values.get(i).add(res);
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/DirectFieldSetter.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -1,110 +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.fieldset;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Type;
-
-/**
- * class that can set a field value directly
- *
- * @author Stuart Douglas <stuart at baileyroberts.com.au>
- *
- */
-public class DirectFieldSetter implements FieldValueSetter
-{
-
- private final Field field;
-
- public DirectFieldSetter(Field field)
- {
- this.field = field;
- field.setAccessible(true);
- }
-
- public void set(Object instance, Object value) throws IllegalAccessException
- {
- field.set(instance, value);
- }
-
- public Type getGenericType()
- {
- return field.getGenericType();
- }
-
- public Class<?> getType()
- {
- return field.getType();
- }
-
- public String getName()
- {
- return field.getName();
- }
-
- public Class<?> getDeclaringClass()
- {
- return field.getDeclaringClass();
- }
-
- public void setBoolean(Object instance, boolean value) throws IllegalAccessException, InvocationTargetException
- {
- field.setBoolean(instance, value);
- }
-
- public void setByte(Object instance, byte value) throws IllegalAccessException, InvocationTargetException
- {
- field.setByte(instance, value);
- }
-
- public void setChar(Object instance, char value) throws IllegalAccessException, InvocationTargetException
- {
- field.setChar(instance, value);
- }
-
- public void setDouble(Object instance, double value) throws IllegalAccessException, InvocationTargetException
- {
- field.setDouble(instance, value);
- }
-
- public void setFloat(Object instance, float value) throws IllegalAccessException, InvocationTargetException
- {
- field.setFloat(instance, value);
- }
-
- public void setInt(Object instance, int value) throws IllegalAccessException, InvocationTargetException
- {
- field.setInt(instance, value);
- }
-
- public void setLong(Object instance, long value) throws IllegalAccessException, InvocationTargetException
- {
- field.setLong(instance, value);
- }
-
- public void setShort(Object instance, short value) throws IllegalAccessException, InvocationTargetException
- {
- field.setShort(instance, value);
- }
-
-}
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldTypeSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldTypeSetter.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldTypeSetter.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -1,37 +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.fieldset;
-
-import java.lang.reflect.Field;
-
-/**
- * Interface the can set primitive types
- *
- * @author Stuart Douglas <stuart at baileyroberts.com.au>
- *
- */
-public interface FieldTypeSetter
-{
-
- public void setField(String value, Field field);
-
-}
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueSetter.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueSetter.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -1,63 +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.fieldset;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Type;
-
-/**
- * Class that knows how to set a field value, either directly or by calling a
- * getter
- *
- * @author Stuart Douglas <stuart at baileyroberts.com.au>
- *
- */
-public interface FieldValueSetter
-{
-
- public void set(Object instance, Object value) throws IllegalAccessException, InvocationTargetException;
-
- public Class<?> getType();
-
- public Type getGenericType();
-
- public Class<?> getDeclaringClass();
-
- public String getName();
-
- public void setInt(Object instance, int value) throws IllegalAccessException, InvocationTargetException;
-
- public void setShort(Object instance, short value) throws IllegalAccessException, InvocationTargetException;
-
- public void setLong(Object instance, long value) throws IllegalAccessException, InvocationTargetException;
-
- public void setByte(Object instance, byte value) throws IllegalAccessException, InvocationTargetException;
-
- public void setChar(Object instance, char value) throws IllegalAccessException, InvocationTargetException;
-
- public void setDouble(Object instance, double value) throws IllegalAccessException, InvocationTargetException;
-
- public void setFloat(Object instance, float value) throws IllegalAccessException, InvocationTargetException;
-
- public void setBoolean(Object instance, boolean value) throws IllegalAccessException, InvocationTargetException;
-
-}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanFieldValue.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanFieldValue.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanFieldValue.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -25,6 +25,8 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
+import org.jboss.weld.extensions.util.properties.Property;
+
/**
* Field value object for an inline bean definition
*
@@ -34,7 +36,7 @@
public class InlineBeanFieldValue implements FieldValueObject
{
- private final FieldValueSetter field;
+ private final Property field;
private final int beanId;
@@ -46,7 +48,7 @@
private Bean<?> bean;
- public InlineBeanFieldValue(Class<?> type, int syntheticBeanQualifierNo, FieldValueSetter setter, BeanManager manager)
+ public InlineBeanFieldValue(Class<?> type, int syntheticBeanQualifierNo, Property setter, BeanManager manager)
{
this.beanId = syntheticBeanQualifierNo;
this.field = setter;
@@ -64,7 +66,7 @@
Object obj = manager.getReference(bean, type, ctx);
try
{
- field.set(instance, obj);
+ field.setValue(instance, obj);
}
catch (Exception e)
{
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -36,6 +36,7 @@
import org.jboss.seam.xml.model.EntryXmlItem;
import org.jboss.seam.xml.util.TypeReader;
import org.jboss.seam.xml.util.XmlObjectConverter;
+import org.jboss.weld.extensions.util.properties.Property;
/**
* class responsible for setting the value of map properties.
@@ -46,18 +47,18 @@
*/
public class MapFieldSet implements FieldValueObject
{
- private final FieldValueSetter field;
+ private final Property field;
private final List<MFS> values;
private final Class<?> keyType;
private final Class<?> valueType;
private final Class<? extends Map> collectionType;
- public MapFieldSet(FieldValueSetter field, List<EntryXmlItem> items)
+ public MapFieldSet(Property field, List<EntryXmlItem> items)
{
this.field = field;
this.values = new ArrayList<MFS>();
// figure out the collection type
- Type type = field.getGenericType();
+ Type type = field.getBaseType();
if (type instanceof ParameterizedType)
{
ParameterizedType parameterizedType = (ParameterizedType) type;
@@ -124,7 +125,7 @@
try
{
Map res = collectionType.newInstance();
- field.set(instance, res);
+ field.setValue(instance, res);
for (int i = 0; i < values.size(); ++i)
{
values.get(i).add(res);
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MethodFieldSetter.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -1,108 +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.fieldset;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-
-/**
- * class that sets a field value by calling a setter method
- *
- * @author Stuart Douglas <stuart at baileyroberts.com.au>
- *
- */
-public class MethodFieldSetter implements FieldValueSetter
-{
- private final Method method;
-
- public MethodFieldSetter(Method method)
- {
- this.method = method;
- }
-
- public void set(Object instance, Object value) throws IllegalAccessException, InvocationTargetException
- {
- method.invoke(instance, value);
- }
-
- public Type getGenericType()
- {
- return method.getGenericParameterTypes()[0];
- }
-
- public String getName()
- {
- return method.getName();
- }
-
- public Class<?> getDeclaringClass()
- {
- return method.getDeclaringClass();
- }
-
- public Class<?> getType()
- {
- return method.getParameterTypes()[0];
- }
-
- public void setBoolean(Object instance, boolean value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setByte(Object instance, byte value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setChar(Object instance, char value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setDouble(Object instance, double value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setFloat(Object instance, float value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setInt(Object instance, int value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setLong(Object instance, long value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
- public void setShort(Object instance, short value) throws IllegalAccessException, InvocationTargetException
- {
- set(instance, value);
- }
-
-}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -28,119 +28,30 @@
import org.jboss.seam.xml.model.ModelBuilder;
import org.jboss.seam.xml.util.XmlObjectConverter;
+import org.jboss.weld.extensions.util.properties.Property;
public class SimpleFieldValue implements FieldValueObject
{
- private final FieldValueSetter field;
+ private final Property field;
private final FS setter;
- public SimpleFieldValue(Class<?> javaObject, final FieldValueSetter f, final String value)
+ public SimpleFieldValue(Class<?> javaObject, final Property f, final String value)
{
this.field = f;
- Object fv = XmlObjectConverter.convert(f.getType(), value);
- if (field.getType() == char.class)
- {
+ Object fv = XmlObjectConverter.convert(f.getJavaClass(), value);
- final char val = (Character) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setChar(o, val);
- }
- };
- }
- else if (field.getType() == int.class)
+ final Object val = fv;
+ setter = new FS()
{
- final int val = (Integer) fv;
- setter = new FS()
+ public void set(Object o) throws IllegalAccessException, InvocationTargetException
{
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setInt(o, val);
- }
- };
- }
- else if (field.getType() == short.class)
- {
- final short val = (Short) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setShort(o, val);
- }
- };
- }
- else if (field.getType() == long.class)
- {
- final long val = (Long) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setLong(o, val);
- }
- };
- }
- else if (field.getType() == byte.class)
- {
- final byte val = (Byte) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setByte(o, val);
- }
- };
- }
- else if (field.getType() == double.class)
- {
- final double val = (Double) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setDouble(o, val);
- }
- };
- }
- else if (field.getType() == float.class)
- {
- final float val = (Float) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setFloat(o, val);
- }
- };
- }
- else if (field.getType() == boolean.class)
- {
- final boolean val = (Boolean) fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.setBoolean(o, val);
- }
- };
- }
- else
- {
- final Object val = fv;
- setter = new FS()
- {
- public void set(Object o) throws IllegalAccessException, InvocationTargetException
- {
- field.set(o, val);
- }
- };
- }
+ field.setValue(o, val);
+ }
+ };
+
}
interface FS
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -34,12 +34,12 @@
import org.jboss.seam.xml.fieldset.ArrayFieldSet;
import org.jboss.seam.xml.fieldset.CollectionFieldSet;
import org.jboss.seam.xml.fieldset.FieldValueObject;
-import org.jboss.seam.xml.fieldset.FieldValueSetter;
import org.jboss.seam.xml.fieldset.InlineBeanFieldValue;
import org.jboss.seam.xml.fieldset.MapFieldSet;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
+import org.jboss.weld.extensions.util.properties.Property;
/**
* represents either a field or a property of a bean
@@ -50,7 +50,7 @@
public abstract class AbstractFieldXmlItem extends AbstractXmlItem
{
- protected FieldValueSetter fieldSetter;
+ protected Property property;
protected FieldValueObject fieldValue;
protected HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
@@ -95,7 +95,7 @@
}
if (!mapEntries.isEmpty())
{
- fieldValue = new MapFieldSet(fieldSetter, mapEntries);
+ fieldValue = new MapFieldSet(property, mapEntries);
}
}
else if (Collection.class.isAssignableFrom(getFieldType()) || getFieldType().isArray())
@@ -108,11 +108,11 @@
{
if (getFieldType().isArray())
{
- fieldValue = new ArrayFieldSet(fieldSetter, valueEntries);
+ fieldValue = new ArrayFieldSet(property, valueEntries);
}
else
{
- fieldValue = new CollectionFieldSet(fieldSetter, valueEntries);
+ fieldValue = new CollectionFieldSet(property, valueEntries);
}
}
}
@@ -130,12 +130,12 @@
BeanResult<?> result = value.getBeanResult(manager);
if (result == null)
{
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
+ fieldValue = new SimpleFieldValue(parent.getJavaClass(), property, valueEntries.get(0).getInnerText());
}
else
{
inlineBeans.add(result);
- fieldValue = new InlineBeanFieldValue(getFieldType(), value.getSyntheticQualifierId(), fieldSetter, manager);
+ fieldValue = new InlineBeanFieldValue(getFieldType(), value.getSyntheticQualifierId(), property, manager);
}
}
}
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-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -24,11 +24,10 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import org.jboss.seam.xml.fieldset.DirectFieldSetter;
-import org.jboss.seam.xml.fieldset.FieldValueSetter;
-import org.jboss.seam.xml.fieldset.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
import org.jboss.seam.xml.util.TypeOccuranceInformation;
+import org.jboss.weld.extensions.util.properties.Properties;
+import org.jboss.weld.extensions.util.properties.Property;
public class FieldXmlItem extends AbstractFieldXmlItem
{
@@ -39,10 +38,10 @@
{
super(XmlItemType.FIELD, parent, parent.getJavaClass(), innerText, null, document, lineno);
this.field = c;
- this.fieldSetter = getFieldValueSetter(c);
+ this.property = getFieldValueSetter(c);
if (innerText != null && innerText.length() > 0)
{
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, innerText);
+ fieldValue = new SimpleFieldValue(parent.getJavaClass(), property, innerText);
}
allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
allowed.add(TypeOccuranceInformation.of(XmlItemType.VALUE, null, null));
@@ -54,7 +53,7 @@
return field;
}
- private FieldValueSetter getFieldValueSetter(Field field)
+ private Property getFieldValueSetter(Field field)
{
String fieldName = field.getName();
String methodName = "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
@@ -73,9 +72,9 @@
}
if (setter != null)
{
- return new MethodFieldSetter(setter);
+ return Properties.createProperty(setter);
}
- return new DirectFieldSetter(field);
+ return Properties.createProperty(field);
}
@Override
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-08-01 09:50:28 UTC (rev 13538)
@@ -24,8 +24,8 @@
import java.lang.reflect.Method;
import org.jboss.seam.xml.fieldset.FieldValueObject;
-import org.jboss.seam.xml.fieldset.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
+import org.jboss.weld.extensions.util.properties.Properties;
public class PropertyXmlItem extends AbstractFieldXmlItem
{
@@ -40,10 +40,10 @@
this.name = name;
this.type = setter.getParameterTypes()[0];
this.declaringClass = setter.getDeclaringClass();
- this.fieldSetter = new MethodFieldSetter(setter);
+ this.property = Properties.createProperty(setter);
if (innerText != null && innerText.length() > 0)
{
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, innerText);
+ fieldValue = new SimpleFieldValue(parent.getJavaClass(), property, innerText);
}
}
Modified: modules/xml/trunk/pom.xml
===================================================================
--- modules/xml/trunk/pom.xml 2010-07-31 01:13:09 UTC (rev 13537)
+++ modules/xml/trunk/pom.xml 2010-08-01 09:50:28 UTC (rev 13538)
@@ -16,6 +16,7 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
+ <weld-extensions.version>1.0.0-SNAPSHOT</weld-extensions.version>
</properties>
<prerequisites>
@@ -44,6 +45,12 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>${weld-extensions.version}</version>
+ </dependency>
+
</dependencies>
</dependencyManagement>
More information about the seam-commits
mailing list