Seam SVN: r13537 - in modules/xml/trunk/impl: src/main/java/org/jboss/seam/xml/model and 6 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-30 21:13:09 -0400 (Fri, 30 Jul 2010)
New Revision: 13537
Added:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.java
Removed:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java
Modified:
modules/xml/trunk/impl/pom.xml
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/PropertyXmlItem.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetArrayFieldValueBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetCollectionFieldValueBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetMapFieldValueBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/QualifierAttributesTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/stereotype/StereotypeTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/types/TypesTest.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/stereotype/stereotype-beans.xml
Log:
refactor field value settting, update to latest weld-se SNAPSHOT for testing
Modified: modules/xml/trunk/impl/pom.xml
===================================================================
--- modules/xml/trunk/impl/pom.xml 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/pom.xml 2010-07-31 01:13:09 UTC (rev 13537)
@@ -36,6 +36,7 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-se</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>
@@ -48,7 +49,6 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
- <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Added: 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 (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractFieldXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -0,0 +1,161 @@
+/*
+ * 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.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.seam.xml.core.BeanResult;
+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;
+
+/**
+ * represents either a field or a property of a bean
+ *
+ * @author stuart
+ *
+ */
+public abstract class AbstractFieldXmlItem extends AbstractXmlItem
+{
+
+ protected FieldValueSetter fieldSetter;
+ protected FieldValueObject fieldValue;
+ protected HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
+ List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
+
+ public AbstractFieldXmlItem(XmlItemType type, XmlItem parent, Class<?> javaClass, String innerText, Map<String, String> attributes, String document, int lineno)
+ {
+ super(type, parent, javaClass, innerText, attributes, document, lineno);
+ }
+
+ public FieldValueObject getFieldValue()
+ {
+ return fieldValue;
+ }
+
+ @Override
+ public boolean resolveChildren(BeanManager manager)
+ {
+ List<EntryXmlItem> mapEntries = new ArrayList<EntryXmlItem>();
+ List<ValueXmlItem> valueEntries = new ArrayList<ValueXmlItem>();
+ if (fieldValue == null)
+ {
+ for (XmlItem i : children)
+ {
+ if (i.getType() == XmlItemType.VALUE)
+ {
+ valueEntries.add((ValueXmlItem) i);
+ }
+ else if (i.getType() == XmlItemType.ENTRY)
+ {
+ mapEntries.add((EntryXmlItem) i);
+ }
+
+ }
+ }
+ if (!mapEntries.isEmpty() || !valueEntries.isEmpty())
+ {
+ if (Map.class.isAssignableFrom(getFieldType()))
+ {
+ if (!valueEntries.isEmpty())
+ {
+ throw new XmlConfigurationException("Map fields cannot have <value> elements as children,only <entry> elements Field:" + getDeclaringClass().getName() + '.' + getFieldName(), getDocument(), getLineno());
+ }
+ if (!mapEntries.isEmpty())
+ {
+ fieldValue = new MapFieldSet(fieldSetter, mapEntries);
+ }
+ }
+ else if (Collection.class.isAssignableFrom(getFieldType()) || getFieldType().isArray())
+ {
+ if (!mapEntries.isEmpty())
+ {
+ throw new XmlConfigurationException("Collection fields must be set using <value> not <entry> Field:" + getDeclaringClass().getName() + '.' + getFieldName(), getDocument(), getLineno());
+ }
+ if (!valueEntries.isEmpty())
+ {
+ if (getFieldType().isArray())
+ {
+ fieldValue = new ArrayFieldSet(fieldSetter, valueEntries);
+ }
+ else
+ {
+ fieldValue = new CollectionFieldSet(fieldSetter, valueEntries);
+ }
+ }
+ }
+ else
+ {
+ if (!mapEntries.isEmpty())
+ {
+ throw new XmlConfigurationException("Only Map fields can be set using <entry> Field:" + getDeclaringClass().getName() + '.' + getFieldName(), getDocument(), getLineno());
+ }
+ if (valueEntries.size() != 1)
+ {
+ throw new XmlConfigurationException("Non collection fields can only have a single <value> element Field:" + getDeclaringClass().getName() + '.' + getFieldName(), getDocument(), getLineno());
+ }
+ ValueXmlItem value = valueEntries.get(0);
+ BeanResult<?> result = value.getBeanResult(manager);
+ if (result == null)
+ {
+ fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
+ }
+ else
+ {
+ inlineBeans.add(result);
+ fieldValue = new InlineBeanFieldValue(getFieldType(), value.getSyntheticQualifierId(), fieldSetter, manager);
+ }
+ }
+ }
+ return true;
+ }
+
+ public Set<TypeOccuranceInformation> getAllowedItem()
+ {
+ return allowed;
+ }
+
+ public abstract Class<?> getFieldType();
+
+ public abstract String getFieldName();
+
+ public abstract Class<?> getDeclaringClass();
+
+ public Collection<? extends BeanResult> getInlineBeans()
+ {
+ return inlineBeans;
+ }
+
+}
\ No newline at end of file
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-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -65,9 +65,9 @@
return allowed;
}
- public Set<FieldValueXmlItem> getShorthandFieldValues()
+ public Set<AbstractFieldXmlItem> getShorthandFieldValues()
{
- Set<FieldValueXmlItem> values = new HashSet<FieldValueXmlItem>();
+ Set<AbstractFieldXmlItem> values = new HashSet<AbstractFieldXmlItem>();
for (Entry<String, String> e : attributes.entrySet())
{
@@ -122,7 +122,7 @@
// get all the field values from the bean
Set<String> configuredFields = new HashSet<String>();
List<FieldValueObject> fields = new ArrayList<FieldValueObject>();
- for (FieldValueXmlItem xi : getChildrenOfType(FieldValueXmlItem.class))
+ for (AbstractFieldXmlItem xi : getChildrenOfType(AbstractFieldXmlItem.class))
{
inlineBeans.addAll(xi.getInlineBeans());
FieldValueObject f = xi.getFieldValue();
@@ -133,7 +133,7 @@
}
}
- for (FieldValueXmlItem f : getShorthandFieldValues())
+ for (AbstractFieldXmlItem f : getShorthandFieldValues())
{
if (configuredFields.contains(f.getFieldName()))
{
Deleted: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -1,36 +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.Collection;
-
-import org.jboss.seam.xml.core.BeanResult;
-import org.jboss.seam.xml.fieldset.FieldValueObject;
-
-public interface FieldValueXmlItem
-{
- public FieldValueObject getFieldValue();
-
- public String getFieldName();
-
- public Collection<? extends BeanResult> getInlineBeans();
-}
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-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -23,36 +23,17 @@
import java.lang.reflect.Field;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.jboss.seam.xml.core.BeanResult;
-import org.jboss.seam.xml.fieldset.ArrayFieldSet;
-import org.jboss.seam.xml.fieldset.CollectionFieldSet;
import org.jboss.seam.xml.fieldset.DirectFieldSetter;
-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.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
import org.jboss.seam.xml.util.TypeOccuranceInformation;
-import org.jboss.seam.xml.util.XmlConfigurationException;
-public class FieldXmlItem extends AbstractXmlItem implements FieldValueXmlItem
+public class FieldXmlItem extends AbstractFieldXmlItem
{
- FieldValueSetter fieldSetter;
- FieldValueObject fieldValue;
- Field field;
- HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
- List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
+ private final Field field;
public FieldXmlItem(XmlItem parent, Field c, String innerText, String document, int lineno)
{
@@ -73,95 +54,8 @@
return field;
}
- public FieldValueObject getFieldValue()
+ private FieldValueSetter getFieldValueSetter(Field field)
{
- return fieldValue;
- }
-
- @Override
- public boolean resolveChildren(BeanManager manager)
- {
- List<EntryXmlItem> mapEntries = new ArrayList<EntryXmlItem>();
- List<ValueXmlItem> valueEntries = new ArrayList<ValueXmlItem>();
- if (fieldValue == null)
- {
- for (XmlItem i : children)
- {
- if (i.getType() == XmlItemType.VALUE)
- {
- valueEntries.add((ValueXmlItem) i);
- }
- else if (i.getType() == XmlItemType.ENTRY)
- {
- mapEntries.add((EntryXmlItem) i);
- }
-
- }
- }
- if (!mapEntries.isEmpty() || !valueEntries.isEmpty())
- {
- if (Map.class.isAssignableFrom(field.getType()))
- {
- if (!valueEntries.isEmpty())
- {
- throw new XmlConfigurationException("Map fields cannot have <value> elements as children,only <entry> elements Field:" + field.getDeclaringClass().getName() + '.' + field.getName(), getDocument(), getLineno());
- }
- if (!mapEntries.isEmpty())
- {
- fieldValue = new MapFieldSet(fieldSetter, mapEntries);
- }
- }
- else if (Collection.class.isAssignableFrom(field.getType()) || field.getType().isArray())
- {
- if (!mapEntries.isEmpty())
- {
- throw new XmlConfigurationException("Collection fields must be set using <value> not <entry> Field:" + field.getDeclaringClass().getName() + '.' + field.getName(), getDocument(), getLineno());
- }
- if (!valueEntries.isEmpty())
- {
- if (field.getType().isArray())
- {
- fieldValue = new ArrayFieldSet(fieldSetter, valueEntries);
- }
- else
- {
- fieldValue = new CollectionFieldSet(fieldSetter, valueEntries);
- }
- }
- }
- else
- {
- if (!mapEntries.isEmpty())
- {
- throw new XmlConfigurationException("Only Map fields can be set using <entry> Field:" + field.getDeclaringClass().getName() + '.' + field.getName(), getDocument(), getLineno());
- }
- if (valueEntries.size() != 1)
- {
- throw new XmlConfigurationException("Non collection fields can only have a single <value> element Field:" + field.getDeclaringClass().getName() + '.' + field.getName(), getDocument(), getLineno());
- }
- ValueXmlItem value = valueEntries.get(0);
- BeanResult<?> result = value.getBeanResult(manager);
- if (result == null)
- {
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
- }
- else
- {
- inlineBeans.add(result);
- fieldValue = new InlineBeanFieldValue(field.getType(), value.getSyntheticQualifierId(), fieldSetter, manager);
- }
- }
- }
- return true;
- }
-
- public Set<TypeOccuranceInformation> getAllowedItem()
- {
- return allowed;
- }
-
- FieldValueSetter getFieldValueSetter(Field field)
- {
String fieldName = field.getName();
String methodName = "set" + Character.toUpperCase(fieldName.charAt(0)) + fieldName.substring(1);
Method setter = null;
@@ -184,13 +78,21 @@
return new DirectFieldSetter(field);
}
+ @Override
+ public Class<?> getDeclaringClass()
+ {
+ return field.getDeclaringClass();
+ }
+
+ @Override
public String getFieldName()
{
return field.getName();
}
- public Collection<? extends BeanResult> getInlineBeans()
+ @Override
+ public Class<?> getFieldType()
{
- return inlineBeans;
+ return field.getType();
}
}
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-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -22,49 +22,29 @@
package org.jboss.seam.xml.model;
import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.enterprise.inject.spi.BeanManager;
-
-import org.jboss.seam.xml.core.BeanResult;
-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.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
-import org.jboss.seam.xml.util.TypeOccuranceInformation;
-import org.jboss.seam.xml.util.XmlConfigurationException;
-public class PropertyXmlItem extends AbstractXmlItem implements FieldValueXmlItem
+public class PropertyXmlItem extends AbstractFieldXmlItem
{
- FieldValueSetter fieldSetter;
- FieldValueObject fieldValue;
- String name;
- Class<?> type;
- HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
- List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
+ private final String name;
+ private final Class<?> type;
+ private final Class<?> declaringClass;
public PropertyXmlItem(XmlItem parent, String name, Method setter, String innerText, String document, int lineno)
{
super(XmlItemType.FIELD, parent, parent.getJavaClass(), innerText, null, document, lineno);
this.name = name;
this.type = setter.getParameterTypes()[0];
+ this.declaringClass = setter.getDeclaringClass();
this.fieldSetter = new MethodFieldSetter(setter);
if (innerText != null && innerText.length() > 0)
{
fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, innerText);
}
- allowed.add(TypeOccuranceInformation.of(XmlItemType.VALUE, null, null));
- allowed.add(TypeOccuranceInformation.of(XmlItemType.ENTRY, null, null));
}
public FieldValueObject getFieldValue()
@@ -73,94 +53,21 @@
}
@Override
- public boolean resolveChildren(BeanManager manager)
+ public Class<?> getDeclaringClass()
{
- List<EntryXmlItem> mapEntries = new ArrayList<EntryXmlItem>();
- List<ValueXmlItem> valueEntries = new ArrayList<ValueXmlItem>();
- if (fieldValue == null)
- {
- for (XmlItem i : children)
- {
- if (i.getType() == XmlItemType.VALUE)
- {
- valueEntries.add((ValueXmlItem) i);
- }
- else if (i.getType() == XmlItemType.ENTRY)
- {
- mapEntries.add((EntryXmlItem) i);
- }
-
- }
- }
- if (!mapEntries.isEmpty() || !valueEntries.isEmpty())
- {
- if (Map.class.isAssignableFrom(type))
- {
- if (!valueEntries.isEmpty())
- {
- throw new XmlConfigurationException("Map fields cannot have <value> elements as children,only <entry> elements Field:" + parent.getJavaClass().getName() + '.' + name, getDocument(), getLineno());
- }
- if (!mapEntries.isEmpty())
- {
- fieldValue = new MapFieldSet(fieldSetter, mapEntries);
- }
- }
- else if (Collection.class.isAssignableFrom(type) || type.isArray())
- {
- if (!mapEntries.isEmpty())
- {
- throw new XmlConfigurationException("Collection fields must be set using <value> not <entry> Field:" + parent.getJavaClass().getName() + '.' + name, getDocument(), getLineno());
- }
- if (!valueEntries.isEmpty())
- {
- if (type.isArray())
- {
- fieldValue = new ArrayFieldSet(fieldSetter, valueEntries);
- }
- else
- {
- fieldValue = new CollectionFieldSet(fieldSetter, valueEntries);
- }
- }
- }
- else
- {
- if (!mapEntries.isEmpty())
- {
- throw new XmlConfigurationException("Only Map fields can be set using <entry> Field:" + parent.getJavaClass().getName() + '.' + name, getDocument(), getLineno());
- }
- if (valueEntries.size() != 1)
- {
- throw new XmlConfigurationException("Non collection fields can only have a single <value> element Field:" + parent.getJavaClass().getName() + '.' + name, getDocument(), getLineno());
- }
- ValueXmlItem value = valueEntries.get(0);
- BeanResult<?> result = value.getBeanResult(manager);
- if (result == null)
- {
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
- }
- else
- {
- inlineBeans.add(result);
- fieldValue = new InlineBeanFieldValue(type, value.getSyntheticQualifierId(), fieldSetter, manager);
- }
- }
- }
- return true;
+ return declaringClass;
}
- public Set<TypeOccuranceInformation> getAllowedItem()
- {
- return allowed;
- }
-
+ @Override
public String getFieldName()
{
return name;
}
- public Collection<? extends BeanResult> getInlineBeans()
+ @Override
+ public Class<?> getFieldType()
{
- return inlineBeans;
+ return type;
}
+
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -26,6 +26,7 @@
import junit.framework.Assert;
+import org.jboss.seam.xml.model.AbstractFieldXmlItem;
import org.jboss.seam.xml.model.FieldXmlItem;
import org.jboss.seam.xml.model.MethodXmlItem;
import org.jboss.seam.xml.model.XmlItem;
@@ -73,7 +74,7 @@
Assert.assertTrue("Wrong method was resolved", ((MethodXmlItem) method).getMethod().getParameterTypes().length == 0);
XmlItem field = resolver.getItemForNamespace(new SaxNode("field1", null, null, null, null, 0), item);
- Assert.assertTrue("Element of wrong type returned", ((FieldXmlItem) field).getType() == XmlItemType.FIELD);
+ Assert.assertTrue("Element of wrong type returned", ((AbstractFieldXmlItem) field).getType() == XmlItemType.FIELD);
Assert.assertTrue("field was not set", ((FieldXmlItem) field).getField() != null);
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetArrayFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetArrayFieldValueBeanTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetArrayFieldValueBeanTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -24,7 +24,6 @@
import junit.framework.Assert;
import org.jboss.seam.xml.test.AbstractXMLTest;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
public class SetArrayFieldValueBeanTest extends AbstractXMLTest
@@ -39,7 +38,7 @@
@Test
public void arrayFieldSetterTest()
{
- ArrayFieldValue x = WeldManagerUtils.getInstanceByType(manager, ArrayFieldValue.class);
+ ArrayFieldValue x = getReference(ArrayFieldValue.class);
Assert.assertTrue(x.carray.length == 2);
Assert.assertTrue(x.iarray.length == 2);
Assert.assertTrue(x.sarray.length == 2);
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetCollectionFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetCollectionFieldValueBeanTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetCollectionFieldValueBeanTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -24,7 +24,6 @@
import junit.framework.Assert;
import org.jboss.seam.xml.test.AbstractXMLTest;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
public class SetCollectionFieldValueBeanTest extends AbstractXMLTest
@@ -39,7 +38,7 @@
@Test
public void collectionSetFieldValue()
{
- CollectionFieldValue x = WeldManagerUtils.getInstanceByType(manager, CollectionFieldValue.class);
+ CollectionFieldValue x = getReference(CollectionFieldValue.class);
Assert.assertTrue(x.iset.size() == 2);
Assert.assertTrue(x.clist.size() == 2);
Assert.assertTrue(x.sset.size() == 2);
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetMapFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetMapFieldValueBeanTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetMapFieldValueBeanTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -24,7 +24,6 @@
import junit.framework.Assert;
import org.jboss.seam.xml.test.AbstractXMLTest;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
public class SetMapFieldValueBeanTest extends AbstractXMLTest
@@ -39,7 +38,7 @@
@Test
public void mapSetFieldValue()
{
- MapFieldValue x = WeldManagerUtils.getInstanceByType(manager, MapFieldValue.class);
+ MapFieldValue x = getReference(MapFieldValue.class);
Assert.assertTrue(x.map1.size() == 2);
Assert.assertTrue(x.map2.size() == 2);
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/QualifierAttributesTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/QualifierAttributesTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/QualifierAttributesTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -24,7 +24,6 @@
import junit.framework.Assert;
import org.jboss.seam.xml.test.AbstractXMLTest;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
/**
@@ -42,7 +41,7 @@
@Test()
public void tstQualifiersWithAttributes()
{
- QualifierTestBean x = WeldManagerUtils.getInstanceByType(manager, QualifierTestBean.class);
+ QualifierTestBean x = getReference(QualifierTestBean.class);
Assert.assertTrue(x.bean1.getBeanNumber() == 1);
Assert.assertTrue(x.bean2.getBeanNumber() == 2);
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/stereotype/StereotypeTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/stereotype/StereotypeTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/stereotype/StereotypeTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -25,7 +25,6 @@
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.seam.xml.test.interceptor.InterceptedBean;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
/**
@@ -45,7 +44,7 @@
public void testStereotypes()
{
- InterceptedBean x = WeldManagerUtils.getInstanceByType(manager, InterceptedBean.class);
+ InterceptedBean x = getReference(InterceptedBean.class);
String res = x.method();
Assert.assertTrue(res.equals("hello world"));
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/types/TypesTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/types/TypesTest.java 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/types/TypesTest.java 2010-07-31 01:13:09 UTC (rev 13537)
@@ -24,7 +24,6 @@
import junit.framework.Assert;
import org.jboss.seam.xml.test.AbstractXMLTest;
-import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
/**
@@ -43,7 +42,7 @@
public void testTypeRestriction()
{
- TypeInjectedClass x = WeldManagerUtils.getInstanceByType(manager, TypeInjectedClass.class);
+ TypeInjectedClass x = getReference(TypeInjectedClass.class);
Assert.assertTrue(x.value instanceof AllowedType);
Assert.assertTrue(x.createValue instanceof RestrictedType);
Modified: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/stereotype/stereotype-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/stereotype/stereotype-beans.xml 2010-07-30 21:38:46 UTC (rev 13536)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/stereotype/stereotype-beans.xml 2010-07-31 01:13:09 UTC (rev 13537)
@@ -9,6 +9,7 @@
</test:Stereotype1>
<int:InterceptedBean>
+ <modifies/>
<test:Stereotype1/>
</int:InterceptedBean>
14 years, 3 months
Seam SVN: r13536 - in sandbox/encore/core/src: main/java/org/jboss/encore/grammar/java/ast and 3 other directories.
by seam-commits@lists.jboss.org
Author: lincolnthree
Date: 2010-07-30 17:38:46 -0400 (Fri, 30 Jul 2010)
New Revision: 13536
Added:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Annotation.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/ClassAnnotationTest.java
Modified:
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java
sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java
sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
sandbox/encore/core/src/test/resources/org/jboss/encore/grammar/java/MockClassFile.java
Log:
Added class annotation support (still needs value settings)... going to need to figure out a way to handle / respect / automatically manage imports.
Added: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Annotation.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Annotation.java (rev 0)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Annotation.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -0,0 +1,13 @@
+package org.jboss.encore.grammar.java;
+
+import org.jboss.encore.grammar.Internal;
+import org.jboss.encore.grammar.Mutable;
+
+public interface Annotation extends Internal, Mutable
+{
+
+ String getName();
+
+ Annotation setName(String className);
+
+}
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-30 15:13:34 UTC (rev 13535)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/JavaClass.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -45,8 +45,11 @@
import org.jboss.encore.grammar.java.ast.MethodFinderVisitor;
import org.jboss.encore.grammar.java.ast.ModifierAccessor;
import org.jboss.encore.grammar.java.ast.TypeDeclarationFinderVisitor;
+import org.jboss.encore.grammar.java.impl.AnnotationImpl;
/**
+ * Represents a Java Source File
+ *
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
*/
public class JavaClass implements Internal, Mutable
@@ -102,6 +105,44 @@
}
/*
+ * Annotation modifiers
+ */
+ @SuppressWarnings("unchecked")
+ public Annotation addAnnotation()
+ {
+ Annotation annotation = new AnnotationImpl(this);
+ getTypeDeclaration().modifiers().add(annotation.getInternal());
+ return annotation;
+ }
+
+ public Annotation addAnnotation(Class<?> clazz)
+ {
+ return addAnnotation(clazz.getName());
+ }
+
+ public Annotation addAnnotation(final String className)
+ {
+ return addAnnotation().setName(className);
+ }
+
+ public List<Annotation> getAnnotations()
+ {
+ List<Annotation> result = new ArrayList<Annotation>();
+
+ List<?> modifiers = getTypeDeclaration().modifiers();
+ for (Object object : modifiers)
+ {
+ if (object instanceof org.eclipse.jdt.core.dom.Annotation)
+ {
+ Annotation annotation = new AnnotationImpl(this, object);
+ result.add(annotation);
+ }
+ }
+
+ return result;
+ }
+
+ /*
* Import modifiers
*/
@@ -250,9 +291,22 @@
public JavaClass setName(String name)
{
getTypeDeclaration().setName(unit.getAST().newSimpleName(name));
+ updateConstructorNames();
return this;
}
+ private void updateConstructorNames()
+ {
+ for (Method m : getMethods())
+ {
+ if (m.isConstructor())
+ {
+ m.setConstructor(false);
+ m.setConstructor(true);
+ }
+ }
+ }
+
/*
* Package modifiers
*/
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java 2010-07-30 15:13:34 UTC (rev 13535)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/Method.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -105,9 +105,14 @@
return this;
}
- public Method setConstructor(final boolean isConstructor)
+ /**
+ * Toggle this method as a constructor. If true, and the name of the
+ * {@link Method} is not the same as the name of its parent {@link JavaClass}
+ * , update the name of the to match.
+ */
+ public Method setConstructor(final boolean constructor)
{
- method.setConstructor(isConstructor);
+ method.setConstructor(constructor);
if (isConstructor())
{
method.setName(ast.newSimpleName(parent.getName()));
Modified: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java 2010-07-30 15:13:34 UTC (rev 13535)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/ast/ModifierAccessor.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -9,11 +9,10 @@
public class ModifierAccessor
{
- @SuppressWarnings("unchecked")
public boolean hasModifier(BodyDeclaration body, final ModifierKeyword modifier)
{
boolean result = false;
- List<Modifier> modifiers = body.modifiers();
+ List<Modifier> modifiers = getModifiers(body);
for (Modifier m : modifiers)
{
if (m.getKeyword() == modifier)
@@ -24,10 +23,25 @@
return result;
}
+ private List<Modifier> getModifiers(BodyDeclaration body)
+ {
+ List<Modifier> result = new ArrayList<Modifier>();
+ List<?> modifiers = body.modifiers();
+ for (Object m : modifiers)
+ {
+ if (m instanceof Modifier)
+ {
+ Modifier mod = (Modifier) m;
+ result.add(mod);
+ }
+ }
+ return result;
+ }
+
@SuppressWarnings("unchecked")
public List<Modifier> clearVisibility(BodyDeclaration body)
{
- List<Modifier> modifiers = body.modifiers();
+ List<Modifier> modifiers = getModifiers(body);
List<Modifier> toBeRemoved = new ArrayList<Modifier>();
for (Modifier modifier : modifiers)
@@ -38,7 +52,7 @@
}
}
- modifiers.removeAll(toBeRemoved);
+ body.modifiers().removeAll(toBeRemoved);
return modifiers;
}
@@ -48,10 +62,9 @@
body.modifiers().add(body.getAST().newModifier(keyword));
}
- @SuppressWarnings("unchecked")
public void removeModifier(BodyDeclaration body, ModifierKeyword keyword)
{
- List<Modifier> modifiers = body.modifiers();
+ List<Modifier> modifiers = getModifiers(body);
List<Modifier> toBeRemoved = new ArrayList<Modifier>();
for (Modifier modifier : modifiers)
@@ -62,6 +75,6 @@
}
}
- modifiers.removeAll(toBeRemoved);
+ body.modifiers().removeAll(toBeRemoved);
}
}
Added: sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java
===================================================================
--- sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java (rev 0)
+++ sandbox/encore/core/src/main/java/org/jboss/encore/grammar/java/impl/AnnotationImpl.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -0,0 +1,59 @@
+package org.jboss.encore.grammar.java.impl;
+
+import org.eclipse.jdt.core.dom.AST;
+import org.eclipse.jdt.core.dom.CompilationUnit;
+import org.jboss.encore.grammar.java.Annotation;
+import org.jboss.encore.grammar.java.JavaClass;
+
+public class AnnotationImpl implements Annotation
+{
+ private JavaClass parent = null;
+ private CompilationUnit cu = null;
+ private AST ast = null;
+ private final org.eclipse.jdt.core.dom.Annotation annotation;
+
+ private void init(final JavaClass parent)
+ {
+ this.parent = parent;
+ cu = (CompilationUnit) parent.getInternal();
+ ast = cu.getAST();
+ }
+
+ public AnnotationImpl(JavaClass parent)
+ {
+ init(parent);
+ this.annotation = ast.newNormalAnnotation();
+ }
+
+ public AnnotationImpl(JavaClass parent, Object internal)
+ {
+ init(parent);
+ this.annotation = (org.eclipse.jdt.core.dom.Annotation) internal;
+ }
+
+ @Override
+ public String getName()
+ {
+ return annotation.getTypeName().getFullyQualifiedName();
+ }
+
+ @Override
+ public Annotation setName(String className)
+ {
+ annotation.setTypeName(ast.newName(className));
+ return this;
+ }
+
+ @Override
+ public Object getInternal()
+ {
+ return annotation;
+ }
+
+ @Override
+ public void applyChanges()
+ {
+ parent.applyChanges();
+ }
+
+}
Added: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/ClassAnnotationTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/ClassAnnotationTest.java (rev 0)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/ClassAnnotationTest.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -0,0 +1,105 @@
+/*
+ * 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.encore.grammar.java;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
+ */
+public class ClassAnnotationTest
+{
+ private InputStream stream;
+ private JavaClass javaClass;
+
+ @Before
+ public void reset()
+ {
+ stream = ClassAnnotationTest.class.getResourceAsStream("/org/jboss/encore/grammar/java/MockClassFile.java");
+ javaClass = new JavaClass(stream);
+ }
+
+ @Test
+ public void testParseAnnotation() throws Exception
+ {
+ List<Annotation> annotations = javaClass.getAnnotations();
+ assertEquals(1, annotations.size());
+ }
+
+ @Test
+ public void testAddAnnotation() throws Exception
+ {
+ javaClass.addAnnotation().setName("RequestScoped");
+ List<Annotation> annotations = javaClass.getAnnotations();
+ assertEquals(2, annotations.size());
+ assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
+ }
+
+ @Test
+ public void testAddAnnotationByClass() throws Exception
+ {
+ javaClass.addAnnotation(Test.class);
+ List<Annotation> annotations = javaClass.getAnnotations();
+ assertEquals(2, annotations.size());
+ assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
+ javaClass.applyChanges();
+ assertTrue(javaClass.toString().contains("@" + Test.class.getName()));
+ }
+
+ @Test
+ public void testAddAnnotationByName() throws Exception
+ {
+ javaClass.addAnnotation("RequestScoped");
+ List<Annotation> annotations = javaClass.getAnnotations();
+ assertEquals(2, annotations.size());
+ assertEquals("RequestScoped", annotations.get(annotations.size() - 1).getName());
+ javaClass.applyChanges();
+ assertTrue(javaClass.toString().contains("@RequestScoped"));
+ }
+
+ @Test
+ public void testCanAddAnnotationDuplicate() throws Exception
+ {
+ javaClass.addAnnotation(Test.class);
+ javaClass.addAnnotation(Test.class);
+ List<Annotation> annotations = javaClass.getAnnotations();
+ assertEquals(3, annotations.size());
+ assertEquals(Test.class.getName(), annotations.get(annotations.size() - 1).getName());
+ assertEquals(Test.class.getName(), annotations.get(annotations.size() - 2).getName());
+ javaClass.applyChanges();
+ String pattern = "@" + Test.class.getName() + "() " + "@" + Test.class.getName() + "()";
+ assertTrue(javaClass.toString().contains(pattern));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCannotAddAnnotationWithIllegalName() throws Exception
+ {
+ javaClass.addAnnotation("sdf*(&#$%");
+ }
+}
Modified: sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java
===================================================================
--- sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-30 15:13:34 UTC (rev 13535)
+++ sandbox/encore/core/src/test/java/org/jboss/encore/grammar/java/JavaClassTest.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -50,6 +50,20 @@
}
@Test
+ public void testApplyChangesRequiredForModification() throws Exception
+ {
+ assertEquals("MockClassFile", javaClass.getName());
+ javaClass.setName("Telephone");
+ assertEquals("Telephone", javaClass.getName());
+ assertFalse(javaClass.toString().contains("Telephone"));
+ assertTrue(javaClass.toString().contains("MockClassFile"));
+
+ javaClass.applyChanges();
+ assertTrue(javaClass.toString().contains("Telephone"));
+ assertFalse(javaClass.toString().contains("MockClassFile"));
+ }
+
+ @Test
public void testParse() throws Exception
{
assertEquals(URL.class.getName(), javaClass.getImports().get(0).getName());
@@ -68,6 +82,16 @@
}
@Test
+ public void testSetNameUpdatesConstructorNames() throws Exception
+ {
+ assertEquals("MockClassFile", javaClass.getName());
+ assertEquals("MockClassFile", javaClass.getMethods().get(0).getName());
+ javaClass.setName("Telephone");
+ assertEquals("Telephone", javaClass.getName());
+ assertEquals("Telephone", javaClass.getMethods().get(0).getName());
+ }
+
+ @Test
public void testSetPackage() throws Exception
{
javaClass.setPackage("org.lincoln");
Modified: sandbox/encore/core/src/test/resources/org/jboss/encore/grammar/java/MockClassFile.java
===================================================================
--- sandbox/encore/core/src/test/resources/org/jboss/encore/grammar/java/MockClassFile.java 2010-07-30 15:13:34 UTC (rev 13535)
+++ sandbox/encore/core/src/test/resources/org/jboss/encore/grammar/java/MockClassFile.java 2010-07-30 21:38:46 UTC (rev 13536)
@@ -2,6 +2,7 @@
import java.net.URL;
+@Deprecated
public class MockClassFile
{
private String field;
14 years, 3 months
Seam SVN: r13535 - branches/community/Seam_2_2/seam-gen/ide-project-files/eclipse.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 11:13:34 -0400 (Fri, 30 Jul 2010)
New Revision: 13535
Modified:
branches/community/Seam_2_2/seam-gen/ide-project-files/eclipse/.classpath
Log:
JBSEAM-4687
Modified: branches/community/Seam_2_2/seam-gen/ide-project-files/eclipse/.classpath
===================================================================
--- branches/community/Seam_2_2/seam-gen/ide-project-files/eclipse/.classpath 2010-07-30 15:09:08 UTC (rev 13534)
+++ branches/community/Seam_2_2/seam-gen/ide-project-files/eclipse/.classpath 2010-07-30 15:13:34 UTC (rev 13535)
@@ -20,7 +20,7 @@
<classpathentry kind="lib" path="lib/jsf-facelets.jar"/>
<classpathentry kind="lib" path="lib/jsf-api.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
- <classpathentry kind="lib" path="lib/testng.jar"/>
+ <classpathentry kind="lib" path="lib/testng-jdk15.jar"/>
<classpathentry kind="lib" path="lib/jboss-el.jar"/>
<classpathentry kind="lib" path="lib/el-api.jar"/>
<classpathentry kind="lib" path="lib/mvel2.jar"/>
14 years, 3 months
Seam SVN: r13534 - tags/JBoss_Seam_2_2_1_CR2/seam-gen/ide-project-files/eclipse.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 11:09:08 -0400 (Fri, 30 Jul 2010)
New Revision: 13534
Modified:
tags/JBoss_Seam_2_2_1_CR2/seam-gen/ide-project-files/eclipse/.classpath
Log:
JBSEAM-4687
Modified: tags/JBoss_Seam_2_2_1_CR2/seam-gen/ide-project-files/eclipse/.classpath
===================================================================
--- tags/JBoss_Seam_2_2_1_CR2/seam-gen/ide-project-files/eclipse/.classpath 2010-07-30 14:54:55 UTC (rev 13533)
+++ tags/JBoss_Seam_2_2_1_CR2/seam-gen/ide-project-files/eclipse/.classpath 2010-07-30 15:09:08 UTC (rev 13534)
@@ -20,7 +20,7 @@
<classpathentry kind="lib" path="lib/jsf-facelets.jar"/>
<classpathentry kind="lib" path="lib/jsf-api.jar"/>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
- <classpathentry kind="lib" path="lib/testng.jar"/>
+ <classpathentry kind="lib" path="lib/testng-jdk15.jar"/>
<classpathentry kind="lib" path="lib/jboss-el.jar"/>
<classpathentry kind="lib" path="lib/el-api.jar"/>
<classpathentry kind="lib" path="lib/mvel2.jar"/>
14 years, 3 months
Seam SVN: r13533 - tags/JBoss_Seam_2_2_1_CR2/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 10:54:55 -0400 (Fri, 30 Jul 2010)
New Revision: 13533
Modified:
tags/JBoss_Seam_2_2_1_CR2/build/root.pom.xml
Log:
JBSEAM-4688, JBSEAM-4687 - downgraded testng to 5.9
Modified: tags/JBoss_Seam_2_2_1_CR2/build/root.pom.xml
===================================================================
--- tags/JBoss_Seam_2_2_1_CR2/build/root.pom.xml 2010-07-30 14:47:40 UTC (rev 13532)
+++ tags/JBoss_Seam_2_2_1_CR2/build/root.pom.xml 2010-07-30 14:54:55 UTC (rev 13533)
@@ -41,7 +41,7 @@
<version.richfaces>3.3.3.CR1</version.richfaces>
<version.wicket>1.3.5.jboss1</version.wicket>
<version.drools>5.0.1</version.drools>
- <version.testng>5.10</version.testng>
+ <version.testng>5.9</version.testng>
<version.resteasy>2.0-beta-2</version.resteasy>
<version.spring>2.5.6.SEC02</version.spring>
</properties>
14 years, 3 months
Seam SVN: r13532 - branches/community/Seam_2_2/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 10:47:40 -0400 (Fri, 30 Jul 2010)
New Revision: 13532
Modified:
branches/community/Seam_2_2/build/root.pom.xml
Log:
JBSEAM-4688, JBSEAM-4687 - downgraded testng to 5.9
Modified: branches/community/Seam_2_2/build/root.pom.xml
===================================================================
--- branches/community/Seam_2_2/build/root.pom.xml 2010-07-30 11:11:00 UTC (rev 13531)
+++ branches/community/Seam_2_2/build/root.pom.xml 2010-07-30 14:47:40 UTC (rev 13532)
@@ -41,7 +41,7 @@
<version.richfaces>3.3.3.CR1</version.richfaces>
<version.wicket>1.3.5.jboss1</version.wicket>
<version.drools>5.0.1</version.drools>
- <version.testng>5.10</version.testng>
+ <version.testng>5.9</version.testng>
<version.resteasy>2.0-beta-2</version.resteasy>
<version.spring>2.5.6.SEC02</version.spring>
</properties>
14 years, 3 months
Seam SVN: r13531 - branches/community/Seam_2_2.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 07:11:00 -0400 (Fri, 30 Jul 2010)
New Revision: 13531
Modified:
branches/community/Seam_2_2/changelog.txt
Log:
added additional comment to issue JBSEAM-4676
Modified: branches/community/Seam_2_2/changelog.txt
===================================================================
--- branches/community/Seam_2_2/changelog.txt 2010-07-30 11:08:28 UTC (rev 13530)
+++ branches/community/Seam_2_2/changelog.txt 2010-07-30 11:11:00 UTC (rev 13531)
@@ -31,7 +31,7 @@
* [JBSEAM-4666] - QueueConnection.stop() can not be called from an EJB containrer as stated in JEE5 spec section EE 6.6
* [JBSEAM-4669] - Major java deadlock between BijectionInterceptor and Component since the getInstanceFromFactory method is synchronized
* [JBSEAM-4671] - XML texts in the chapter for WebSphere do not render correctly in HTML + light refresh of the chapter
- * [JBSEAM-4676] - Seam param - disabling EL expression evaluation
+ * [JBSEAM-4676] - Seam param - disabling EL expression evaluation - this fixes CVE-2010-1871 and JBoss would like to thank Meder Kydyraliev of the Google Security Team for responsibly reporting this issue
* [JBSEAM-4677] - Transaction Interceptor leaks transactions
** Patch
14 years, 3 months
Seam SVN: r13530 - tags/JBoss_Seam_2_2_1_CR2.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-30 07:08:28 -0400 (Fri, 30 Jul 2010)
New Revision: 13530
Modified:
tags/JBoss_Seam_2_2_1_CR2/changelog.txt
Log:
added additional comment to issue JBSEAM-4676
Modified: tags/JBoss_Seam_2_2_1_CR2/changelog.txt
===================================================================
--- tags/JBoss_Seam_2_2_1_CR2/changelog.txt 2010-07-30 08:30:04 UTC (rev 13529)
+++ tags/JBoss_Seam_2_2_1_CR2/changelog.txt 2010-07-30 11:08:28 UTC (rev 13530)
@@ -31,7 +31,7 @@
* [JBSEAM-4666] - QueueConnection.stop() can not be called from an EJB containrer as stated in JEE5 spec section EE 6.6
* [JBSEAM-4669] - Major java deadlock between BijectionInterceptor and Component since the getInstanceFromFactory method is synchronized
* [JBSEAM-4671] - XML texts in the chapter for WebSphere do not render correctly in HTML + light refresh of the chapter
- * [JBSEAM-4676] - Seam param - disabling EL expression evaluation
+ * [JBSEAM-4676] - Seam param - disabling EL expression evaluation - this fixes CVE-2010-1871 and JBoss would like to thank Meder Kydyraliev of the Google Security Team for responsibly reporting this issue
* [JBSEAM-4677] - Transaction Interceptor leaks transactions
** Patch
14 years, 3 months
Seam SVN: r13529 - in modules/persistence/trunk/impl/src: test/java/org/jboss/seam/persistence/test and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-30 04:30:04 -0400 (Fri, 30 Jul 2010)
New Revision: 13529
Added:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/InjectionEventListener.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/HelloService.java
modules/persistence/trunk/impl/src/test/resources/META-INF/orm.xml
modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-orm.xml
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java
Log:
add injection into JPA entities
Added: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/InjectionEventListener.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/InjectionEventListener.java (rev 0)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/InjectionEventListener.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -0,0 +1,178 @@
+/*
+ * 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.persistence;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.inject.Inject;
+
+import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.beanManager.BeanManagerAccessor;
+import org.jboss.weld.extensions.util.Reflections;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Event listener that enables injection and initalizer methods for JPA entities
+ *
+ * Other CDI featues such as interceptors, observer methods and decorators are
+ * not supported
+ *
+ * TODO: should we check for the presence of invalid annotations such as @Observes
+ * and log a warning?
+ *
+ * This listener must be enabled in orm.xml
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class InjectionEventListener
+{
+
+ private final static Logger log = LoggerFactory.getLogger(InjectionEventListener.class);
+
+ private final Map<Class<?>, InjectionTarget<?>> injectionTargets = new ConcurrentHashMap<Class<?>, InjectionTarget<?>>();
+
+ BeanManager manager;
+
+ public void load(Object entity)
+ {
+ if (manager == null)
+ {
+ this.manager = BeanManagerAccessor.getManager();
+ }
+ if (!injectionTargets.containsKey(entity.getClass()))
+ {
+ if (!injectionRequired(entity.getClass()))
+ {
+ injectionTargets.put(entity.getClass(), NULL_INJECTION_TARGET);
+ log.debug("Entity {} has no injection points so injection will not be enabled", entity.getClass());
+ }
+ else
+ {
+ // it is ok for this code to run twice, so we don't really need to
+ // lock
+ AnnotatedTypeBuilder<?> builder = new AnnotatedTypeBuilder().readFromType(entity.getClass());
+ InjectionTarget<?> injectionTarget = manager.createInjectionTarget(builder.create());
+ injectionTargets.put(entity.getClass(), injectionTarget);
+ log.info("Enabling injection into entity {}", entity.getClass());
+ }
+ }
+ InjectionTarget it = injectionTargets.get(entity.getClass());
+ if (it != NULL_INJECTION_TARGET)
+ {
+ log.debug("Running CDI injection for {}", entity.getClass());
+ it.inject(entity, new CreationalContextImpl());
+ }
+
+ }
+
+ /**
+ *
+ * returns true if the class has injection points or initalizer methods
+ */
+ private boolean injectionRequired(Class<?> entityClass)
+ {
+ for (Field f : Reflections.getAllFields(entityClass))
+ {
+ if (f.isAnnotationPresent(Inject.class))
+ {
+ return true;
+ }
+ }
+
+ for (Method m : Reflections.getAllMethods(entityClass))
+ {
+ if (m.isAnnotationPresent(Inject.class))
+ {
+ return true;
+ }
+ }
+
+ for (Constructor<?> c : Reflections.getAllConstructors(entityClass))
+ {
+ if (c.isAnnotationPresent(Inject.class))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * marker used for the null value, as a ConcurrentHashMap does not support
+ * null values
+ */
+ private static final InjectionTarget NULL_INJECTION_TARGET = new InjectionTarget()
+ {
+
+ public void inject(Object instance, CreationalContext ctx)
+ {
+ }
+
+ public void postConstruct(Object instance)
+ {
+ }
+
+ public void preDestroy(Object instance)
+ {
+ }
+
+ public void dispose(Object instance)
+ {
+ }
+
+ public Set getInjectionPoints()
+ {
+ return null;
+ }
+
+ public Object produce(CreationalContext ctx)
+ {
+ return null;
+ }
+ };
+
+ // no-op creational context
+ private static class CreationalContextImpl implements CreationalContext
+ {
+
+ public void push(Object incompleteInstance)
+ {
+
+ }
+
+ public void release()
+ {
+
+ }
+
+ }
+}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/SeamManaged.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -48,9 +48,10 @@
* conversation scoped with the qualifier @SomeQualifier.
*
* This field still produces the EntityManagerFactory with qualifier
+ *
* @SomeQualifier, however the scope for the producer field is changed to
- * {@link Dependent}, as the specification does not allow resource producer
- * fields to have a scope other than Depedent
+ * {@link Dependent}, as the specification does not allow
+ * resource producer fields to have a scope other than Depedent
*
* @author Stuart Douglas
*
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/EntityInjectionTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -0,0 +1,116 @@
+/*
+ * 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.persistence.test;
+
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.persistence.InjectionEventListener;
+import org.jboss.seam.persistence.transaction.DefaultTransaction;
+import org.jboss.seam.persistence.transaction.SeamTransaction;
+import org.jboss.seam.persistence.transaction.TransactionExtension;
+import org.jboss.seam.persistence.util.NamingUtils;
+import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
+import org.jboss.seam.transactions.test.util.Hotel;
+import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
+import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
+import org.jboss.shrinkwrap.api.Archive;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Tests that injection is working for JPA entities
+ *
+ * @author Stuart Douglas
+ *
+ */
+(a)RunWith(Arquillian.class)
+public class EntityInjectionTest
+{
+ @Deployment
+ public static Archive<?> createTestArchive()
+ {
+ WebArchive war = ShrinkWrap.createDomain().getArchiveFactory().create(WebArchive.class, "test.war");
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
+ war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
+ war.addPackage(TransactionExtension.class.getPackage());
+ war.addPackage(InjectionEventListener.class.getPackage());
+ war.addPackage(NamingUtils.class.getPackage());
+ war.addClasses(EntityInjectionTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
+ war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
+ war.addWebResource("META-INF/persistence-orm.xml", "classes/META-INF/persistence.xml");
+ war.addWebResource("META-INF/orm.xml", "classes/META-INF/orm.xml");
+ war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
+ return war;
+ }
+
+ @Inject
+ @DefaultTransaction
+ SeamTransaction transaction;
+
+ @Inject
+ EntityManagerFactory emf;
+
+ @Test
+ public void testInjectionIntoEntity() throws NotSupportedException, SystemException, SecurityException, IllegalStateException, RollbackException, HeuristicMixedException, HeuristicRollbackException
+ {
+ EntityManager em = null;
+ try
+ {
+ em = emf.createEntityManager();
+ transaction.begin();
+ em.joinTransaction();
+ Hotel h = new Hotel("Hilton", "Fake St", "Wollongong", "NSW", "2518", "Australia");
+ em.persist(h);
+ em.flush();
+ transaction.commit();
+ em.close();
+ transaction.begin();
+ em = emf.createEntityManager();
+ em.joinTransaction();
+
+ h = (Hotel) em.createQuery("select h from Hotel h where h.name='Hilton'").getSingleResult();
+ Assert.assertTrue(h.isInitalizerCalled());
+ Assert.assertEquals(h.sayHello(), "Hello");
+ }
+ finally
+ {
+ em.close();
+ transaction.rollback();
+ }
+
+ }
+
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextELTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -37,6 +37,7 @@
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
@@ -60,7 +61,7 @@
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(PersistenceContextExtension.class.getPackage());
war.addPackage(NamingUtils.class.getPackage());
- war.addClasses(ManagedPersistenceContextELTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class);
+ war.addClasses(ManagedPersistenceContextELTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HotelNameProducer.class, HelloService.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/test/ManagedPersistenceContextTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -41,6 +41,7 @@
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.ManagedPersistenceContextProvider;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
@@ -63,7 +64,7 @@
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(PersistenceContextExtension.class.getPackage());
war.addPackage(NamingUtils.class.getPackage());
- war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, ManagedPersistenceContextProvider.class);
+ war.addClasses(ManagedPersistenceContextTest.class, Hotel.class, ManagedPersistenceContextProvider.class, HelloService.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionAttributeInterceptorTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -45,6 +45,7 @@
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
@@ -74,7 +75,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(NamingUtils.class.getPackage());
- war.addClasses(TransactionAttributeInterceptorTest.class, TransactionAttributeManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
+ war.addClasses(TransactionAttributeInterceptorTest.class, TransactionAttributeManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionInterceptorTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -45,6 +45,7 @@
import org.jboss.seam.transactions.test.util.ArtifactNames;
import org.jboss.seam.transactions.test.util.DontRollBackException;
import org.jboss.seam.transactions.test.util.EntityManagerProvider;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
@@ -74,7 +75,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(NamingUtils.class.getPackage());
- war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
+ war.addClasses(TransactionInterceptorTest.class, TransactionManagedBean.class, HelloService.class, Hotel.class, EntityManagerProvider.class, DontRollBackException.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(("<beans><interceptors><class>" + TransactionInterceptor.class.getName() + "</class></interceptors></beans>").getBytes()), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/TransactionScopedTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -19,6 +19,7 @@
import org.jboss.seam.persistence.transaction.scope.TransactionScopeExtension;
import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
@@ -40,7 +41,7 @@
war.addPackage(TransactionExtension.class.getPackage());
war.addPackage(TransactionScopeExtension.class.getPackage());
war.addPackage(NamingUtils.class.getPackage());
- war.addClasses(TransactionScopedTest.class, Hotel.class, TransactionScopedObject.class);
+ war.addClasses(TransactionScopedTest.class, Hotel.class, HelloService.class, TransactionScopedObject.class);
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
war.addWebResource("META-INF/services/javax.enterprise.inject.spi.Extension", "classes/META-INF/services/javax.enterprise.inject.spi.Extension");
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/persistence/transactions/test/UserTransactionTest.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -20,6 +20,7 @@
import org.jboss.seam.persistence.transaction.TransactionExtension;
import org.jboss.seam.persistence.util.NamingUtils;
import org.jboss.seam.transactions.test.util.ArtifactNames;
+import org.jboss.seam.transactions.test.util.HelloService;
import org.jboss.seam.transactions.test.util.Hotel;
import org.jboss.seam.transactions.test.util.MavenArtifactResolver;
import org.jboss.shrinkwrap.api.Archive;
@@ -39,7 +40,7 @@
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.WELD_EXTENSIONS));
war.addLibraries(MavenArtifactResolver.resolve(ArtifactNames.SEAM_PERSISTENCE_API));
war.addPackage(TransactionExtension.class.getPackage());
- war.addClasses(UserTransactionTest.class, Hotel.class);
+ war.addClasses(UserTransactionTest.class, Hotel.class, HelloService.class);
war.addPackage(NamingUtils.class.getPackage());
war.addWebResource("META-INF/persistence.xml", "classes/META-INF/persistence.xml");
war.addWebResource(new ByteArrayAsset(new byte[0]), "beans.xml");
Added: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/HelloService.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/HelloService.java (rev 0)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/HelloService.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -0,0 +1,30 @@
+/*
+ * 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.transactions.test.util;
+
+public class HelloService
+{
+ public String sayHello()
+ {
+ return "Hello";
+ }
+}
Modified: modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java
===================================================================
--- modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java 2010-07-28 20:40:18 UTC (rev 13528)
+++ modules/persistence/trunk/impl/src/test/java/org/jboss/seam/transactions/test/util/Hotel.java 2010-07-30 08:30:04 UTC (rev 13529)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.math.BigDecimal;
+import javax.inject.Inject;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
@@ -34,6 +35,7 @@
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
+
import org.jboss.weld.extensions.core.Veto;
/**
@@ -59,10 +61,26 @@
private Integer stars;
private BigDecimal price;
+ @Inject
+ private HelloService helloService;
+
+ private boolean initalizerCalled = false;
+
public Hotel()
{
}
+ @Inject
+ public void create()
+ {
+ initalizerCalled = true;
+ }
+
+ public String sayHello()
+ {
+ return helloService.sayHello();
+ }
+
public Hotel(final String name, final String address, final String city, final String state, final String zip, final String country)
{
this.name = name;
@@ -202,4 +220,11 @@
{
return "Hotel(" + name + "," + address + "," + city + "," + zip + ")";
}
+
+ @Transient
+ public boolean isInitalizerCalled()
+ {
+ return initalizerCalled;
+ }
+
}
Added: modules/persistence/trunk/impl/src/test/resources/META-INF/orm.xml
===================================================================
--- modules/persistence/trunk/impl/src/test/resources/META-INF/orm.xml (rev 0)
+++ modules/persistence/trunk/impl/src/test/resources/META-INF/orm.xml 2010-07-30 08:30:04 UTC (rev 13529)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence/orm orm_1_0.xsd"
+ version="1.0"
+ >
+ <persistence-unit-metadata >
+ <persistence-unit-defaults >
+ <entity-listeners>
+ <entity-listener class="org.jboss.seam.persistence.InjectionEventListener" >
+ <post-load method-name="load" />
+
+ </entity-listener>
+ </entity-listeners>
+ </persistence-unit-defaults>
+ </persistence-unit-metadata>
+
+</entity-mappings>
\ No newline at end of file
Added: modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-orm.xml
===================================================================
--- modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-orm.xml (rev 0)
+++ modules/persistence/trunk/impl/src/test/resources/META-INF/persistence-orm.xml 2010-07-30 08:30:04 UTC (rev 13529)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+ version="2.0">
+ <persistence-unit name="transactionPu">
+ <!--
+ <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
+ -->
+ <provider>org.hibernate.ejb.HibernatePersistence</provider>
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <mapping-file>META-INF/orm.xml</mapping-file>
+ <class>org.jboss.seam.transactions.test.util.Hotel</class>
+ <exclude-unlisted-classes/>
+ <properties>
+ <!-- Properties for Hibernate (default provider for JBoss AS) -->
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ <property name="hibernate.show_sql" value="true"/>
+ <!-- Only format when you need to debug, because it slows things down -->
+ <property name="hibernate.format_sql" value="false"/>
+
+ <!-- Properties for EclipseLink (default provider for GlassFish) -->
+ <property name="eclipselink.ddl-generation" value="drop-and-create-tables"/>
+ <property name="eclipselink.logging.level" value="FINE"/>
+ </properties>
+ </persistence-unit>
+</persistence>
14 years, 3 months
Seam SVN: r13528 - branches/community/Seam_2_2/build.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-28 16:40:18 -0400 (Wed, 28 Jul 2010)
New Revision: 13528
Modified:
branches/community/Seam_2_2/build/default.build.properties
Log:
reverted back to SNAPSHOT in version
Modified: branches/community/Seam_2_2/build/default.build.properties
===================================================================
--- branches/community/Seam_2_2/build/default.build.properties 2010-07-28 20:31:40 UTC (rev 13527)
+++ branches/community/Seam_2_2/build/default.build.properties 2010-07-28 20:40:18 UTC (rev 13528)
@@ -8,7 +8,7 @@
major.version 2
minor.version .2
patchlevel .1
-qualifier .CR2
+qualifier -SNAPSHOT
#
# Other program locations
# -----------------------
14 years, 4 months