Seam SVN: r13507 - in branches/enterprise/JBPAPP_5_0: ui/src/main/java/org/jboss/seam/ui/component and 1 other directory.
by seam-commits@lists.jboss.org
Author: manaRH
Date: 2010-07-26 05:23:20 -0400 (Mon, 26 Jul 2010)
New Revision: 13507
Modified:
branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/Feedback.java
branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/component/UIFragment.java
Log:
removed some useless things. semicolon and unused suppresswarning
Modified: branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/Feedback.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/Feedback.java 2010-07-26 07:46:16 UTC (rev 13506)
+++ branches/enterprise/JBPAPP_5_0/examples/restbay/src/org/jboss/seam/example/restbay/Feedback.java 2010-07-26 09:23:20 UTC (rev 13507)
@@ -15,7 +15,7 @@
{
private static final long serialVersionUID = -5814392910187956828L;
- public enum Rating {positive, neutral, negative};
+ public enum Rating {positive, neutral, negative}
private Integer feedbackId;
private Account forAccount;
Modified: branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/component/UIFragment.java
===================================================================
--- branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/component/UIFragment.java 2010-07-26 07:46:16 UTC (rev 13506)
+++ branches/enterprise/JBPAPP_5_0/ui/src/main/java/org/jboss/seam/ui/component/UIFragment.java 2010-07-26 09:23:20 UTC (rev 13507)
@@ -30,7 +30,6 @@
*/
public abstract class UIFragment extends UIComponentBase {
- @SuppressWarnings("unused")
private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Fragment";
@SuppressWarnings("unused")
14 years, 5 months
Seam SVN: r13506 - in sandbox/modules/spreadsheet/src: main/java/org/jboss/seam/spreadsheet/css and 6 other directories.
by seam-commits@lists.jboss.org
Author: nickarls
Date: 2010-07-26 03:46:16 -0400 (Mon, 26 Jul 2010)
New Revision: 13506
Added:
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/Parser.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilder.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleStringParser.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java
Modified:
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jxl/writer/JXLSpreadsheetWriter.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Background.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Border.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/CellFormat.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Colour.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Font.java
sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/util/ReflectionUtil.java
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorkbookTest.java
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorksheetTest.java
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/formatting/SpreadsheetTest.java
Log:
dump of the (untested) css port/strip from Seam 2
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/CSSNames.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,53 @@
+package org.jboss.seam.spreadsheet.css;
+
+public class CSSNames
+{
+ public static final String FONT_FAMILY = "xls-font-family";
+ public static final String FONT_SIZE = "xls-font-size";
+ public static final String FONT_COLOR = "xls-font-color";
+ public static final String FONT_ITALIC = "xls-font-italic";
+ public static final String FONT_SCRIPT_STYLE = "xls-font-script-style";
+ public static final String FONT_STRUCK_OUT = "xls-font-struck-out";
+ public static final String FONT_UNDERLINE_STYLE = "xls-font-underline-style";
+ public static final String FONT_BOLD = "xls-font-bold";
+ public static final String FONT = "xls-font";
+
+ public static final String BACKGROUND_PATTERN = "xls-background-pattern";
+ public static final String BACKGROUND_COLOR = "xls-background-color";
+ public static final String BACKGROUND = "xls-background";
+
+ public static final String BORDER_LEFT_COLOR = "xls-border-left-color";
+ public static final String BORDER_LEFT_LINE_STYLE = "xls-border-left-line-style";
+ public static final String BORDER_LEFT = "xls-border-left";
+
+ public static final String BORDER_TOP_COLOR = "xls-border-top-color";
+ public static final String BORDER_TOP_LINE_STYLE = "xls-border-top-line-style";
+ public static final String BORDER_TOP = "xls-border-top";
+
+ public static final String BORDER_RIGHT_COLOR = "xls-border-right-color";
+ public static final String BORDER_RIGHT_LINE_STYLE = "xls-border-right-line-style";
+ public static final String BORDER_RIGHT = "xls-border-right";
+
+ public static final String BORDER_BOTTOM_COLOR = "xls-border-bottom-color";
+ public static final String BORDER_BOTTOM_LINE_STYLE = "xls-border-bottom-line-style";
+ public static final String BORDER_BOTTOM = "xls-border-bottom";
+
+ public static final String BORDER = "xls-border";
+
+ public static final String ALIGNMENT = "xls-alignment";
+ public static final String FORMAT_MASK = "xls-format-mask";
+ public static final String INDENTATION = "xls-indentation";
+ public static final String LOCKED = "xls-locked";
+ public static final String ORIENTATION = "xls-orientation";
+ public static final String SHRINK_TO_FIT = "xls-shrink-to-fit";
+ public static final String VERICAL_ALIGNMENT = "xls-vertical-alignment";
+ public static final String WRAP = "xls-wrap";
+ public static final String FORCE_TYPE = "xls-force-type";
+
+ public static final String COLUMN_WIDTH = "xls-column-width";
+ public static final String COLUMN_WIDTHS = "xls-column-widths";
+ public static final String COLUMN_AUTO_SIZE = "xls-column-autosize";
+ public static final String COLUMN_HIDDEN = "xls-column-hidden";
+ public static final String COLUMN_EXPORT = "xls-column-export";
+
+}
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/Parser.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/Parser.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/Parser.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,115 @@
+package org.jboss.seam.spreadsheet.css;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.seam.spreadsheet.SpreadsheetException;
+
+public class Parser
+{
+ private static final String STYLE_SHORTHAND_SEPARATOR = " ";
+ private static final String LEFT_BRACE = "{";
+ private static final String RIGHT_BRACE = "}";
+
+ private Map<String, PropertyBuilder> propertyBuilders = PropertyBuilders.getPropertyBuilders();
+
+ private Map<String, StyleMap> definedStyleClasses = new HashMap<String, StyleMap>();
+
+ public void loadStylesheet(URL stylesheet)
+ {
+ try
+ {
+ definedStyleClasses.putAll(parseStylesheet(stylesheet));
+ }
+ catch (MalformedURLException e)
+ {
+ throw new SpreadsheetException(String.format("Malformed URL for stylesheet %s", stylesheet), e);
+ }
+ catch (IOException e)
+ {
+ throw new SpreadsheetException(String.format("Could not read CSS from stylesheet %s", stylesheet), e);
+ }
+ }
+
+ private Map<String, StyleMap> parseStylesheet(URL url) throws MalformedURLException, IOException
+ {
+ Map<String, StyleMap> styleClasses = new HashMap<String, StyleMap>();
+ String css = readCSS(url.openStream()).toLowerCase();
+ int firstBrace = -1;
+ int secondBrace = -1;
+ while (!"".equals(css))
+ {
+ firstBrace = css.indexOf(LEFT_BRACE);
+ if (firstBrace >= 0)
+ {
+ secondBrace = css.indexOf(RIGHT_BRACE, firstBrace + 1);
+ }
+ if (firstBrace >= 0 && secondBrace >= 0 && firstBrace != secondBrace)
+ {
+ String styleName = css.substring(0, firstBrace).trim();
+ if (styleName.startsWith("."))
+ {
+ styleName = styleName.substring(1);
+ }
+ String styleString = css.substring(firstBrace + 1, secondBrace).trim();
+ StyleMap styleMap = StyleStringParser.of(styleString, propertyBuilders).parse();
+ styleClasses.put(styleName, styleMap);
+ css = css.substring(secondBrace + 1);
+ }
+ else
+ {
+ css = "";
+ }
+ }
+ return styleClasses;
+ }
+
+ private static String readCSS(InputStream in) throws IOException
+ {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+ StringBuilder builder = new StringBuilder();
+ String line;
+ while ((line = reader.readLine()) != null)
+ {
+ builder.append(line);
+ }
+ reader.close();
+ return builder.toString();
+ }
+
+ public StyleMap parseStyle(String style)
+ {
+ if (style == null)
+ {
+ return new StyleMap();
+ }
+ return StyleStringParser.of(style, propertyBuilders).parse();
+ }
+
+ public StyleMap parseStyleClasses(String styleClasses)
+ {
+ if (styleClasses == null)
+ {
+ return new StyleMap();
+ }
+ StyleMap styleMap = new StyleMap();
+ String[] trimmedClasses = StyleStringParser.trimArray(styleClasses.split(STYLE_SHORTHAND_SEPARATOR));
+ for (String styleClass : trimmedClasses)
+ {
+ if (!definedStyleClasses.containsKey(styleClass))
+ {
+ System.out.println(String.format("Unknown style class #0", styleClass));
+ continue;
+ }
+ styleMap.putAll(definedStyleClasses.get(styleClass));
+ }
+ return null;
+ }
+
+}
\ No newline at end of file
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilder.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilder.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilder.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,6 @@
+package org.jboss.seam.spreadsheet.css;
+
+public interface PropertyBuilder
+{
+ public StyleMap parseProperty(String key, String[] values);
+}
\ No newline at end of file
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/PropertyBuilders.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,509 @@
+package org.jboss.seam.spreadsheet.css;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.seam.spreadsheet.SpreadsheetException;
+import org.jboss.seam.spreadsheet.model.formatting.Background.Pattern;
+import org.jboss.seam.spreadsheet.model.formatting.Border.BorderLineStyle;
+import org.jboss.seam.spreadsheet.model.formatting.Colour;
+import org.jboss.seam.spreadsheet.model.formatting.Font.ScriptStyle;
+import org.jboss.seam.spreadsheet.model.formatting.Font.UnderlineStyle;
+
+public class PropertyBuilders
+{
+ private static final String COLUMN_WIDTH_WILDCARD = "*";
+
+ public static Map<String, PropertyBuilder> getPropertyBuilders()
+ {
+ Map<String, PropertyBuilder> propertyBuilders = new HashMap<String, PropertyBuilder>();
+ propertyBuilders.put(CSSNames.FONT_FAMILY, new PropertyBuilders.FontFamily());
+ propertyBuilders.put(CSSNames.FONT_SIZE, new PropertyBuilders.FontSize());
+ propertyBuilders.put(CSSNames.FONT_COLOR, new PropertyBuilders.FontColor());
+ propertyBuilders.put(CSSNames.FONT_ITALIC, new PropertyBuilders.FontItalic());
+ propertyBuilders.put(CSSNames.FONT_SCRIPT_STYLE, new PropertyBuilders.FontScriptStyle());
+ propertyBuilders.put(CSSNames.FONT_STRUCK_OUT, new PropertyBuilders.FontStruckOut());
+ propertyBuilders.put(CSSNames.FONT_UNDERLINE_STYLE, new PropertyBuilders.FontUnderlineStyle());
+ propertyBuilders.put(CSSNames.FONT_BOLD, new PropertyBuilders.FontBold());
+ propertyBuilders.put(CSSNames.FONT, new PropertyBuilders.FontShorthand());
+ propertyBuilders.put(CSSNames.BACKGROUND_PATTERN, new PropertyBuilders.BackgroundPattern());
+ propertyBuilders.put(CSSNames.BACKGROUND_COLOR, new PropertyBuilders.BackgroundColor());
+ propertyBuilders.put(CSSNames.BACKGROUND, new PropertyBuilders.BackgroundShorthand());
+ propertyBuilders.put(CSSNames.BORDER_LEFT_COLOR, new PropertyBuilders.BorderLeftColor());
+ propertyBuilders.put(CSSNames.BORDER_LEFT_LINE_STYLE, new PropertyBuilders.BorderLeftLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_LEFT, new PropertyBuilders.BorderLeftShorthand());
+ propertyBuilders.put(CSSNames.BORDER_TOP_COLOR, new PropertyBuilders.BorderTopColor());
+ propertyBuilders.put(CSSNames.BORDER_TOP_LINE_STYLE, new PropertyBuilders.BorderTopLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_TOP, new PropertyBuilders.BorderTopShorthand());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT_COLOR, new PropertyBuilders.BorderRightColor());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT_LINE_STYLE, new PropertyBuilders.BorderRightLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_RIGHT, new PropertyBuilders.BorderRightShorthand());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM_COLOR, new PropertyBuilders.BorderBottomColor());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, new PropertyBuilders.BorderBottomLineStyle());
+ propertyBuilders.put(CSSNames.BORDER_BOTTOM, new PropertyBuilders.BorderBottomShorthand());
+ propertyBuilders.put(CSSNames.BORDER, new PropertyBuilders.BorderShorthand());
+ propertyBuilders.put(CSSNames.FORMAT_MASK, new PropertyBuilders.FormatMask());
+ propertyBuilders.put(CSSNames.ALIGNMENT, new PropertyBuilders.Alignment());
+ propertyBuilders.put(CSSNames.INDENTATION, new PropertyBuilders.Indentation());
+ propertyBuilders.put(CSSNames.ORIENTATION, new PropertyBuilders.Orientation());
+ propertyBuilders.put(CSSNames.LOCKED, new PropertyBuilders.Locked());
+ propertyBuilders.put(CSSNames.SHRINK_TO_FIT, new PropertyBuilders.ShrinkToFit());
+ propertyBuilders.put(CSSNames.WRAP, new PropertyBuilders.Wrap());
+ propertyBuilders.put(CSSNames.VERICAL_ALIGNMENT, new PropertyBuilders.VericalAlignment());
+ propertyBuilders.put(CSSNames.COLUMN_WIDTH, new PropertyBuilders.ColumnWidth());
+ propertyBuilders.put(CSSNames.COLUMN_AUTO_SIZE, new PropertyBuilders.ColumnAutoSize());
+ propertyBuilders.put(CSSNames.COLUMN_HIDDEN, new PropertyBuilders.ColumnHidden());
+ propertyBuilders.put(CSSNames.COLUMN_EXPORT, new PropertyBuilders.ColumnExport());
+ propertyBuilders.put(CSSNames.COLUMN_WIDTHS, new PropertyBuilders.ColumnWidths());
+ propertyBuilders.put(CSSNames.FORCE_TYPE, new PropertyBuilders.ForceType());
+ return propertyBuilders;
+ }
+
+ public static class ForceType extends StringPropertyBuilder
+ {
+ }
+
+ public static class ColumnWidths implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ String indexedKey = CSSNames.COLUMN_WIDTHS + i;
+ if (COLUMN_WIDTH_WILDCARD.equals(value))
+ {
+ // Skip it, just moving along
+ }
+ else if (isNumeric(value))
+ {
+ styleMap.put(indexedKey, Integer.parseInt(value));
+ }
+ else
+ {
+ throw new SpreadsheetException(String.format("Column widths must be numerical or *, not #0", value));
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class ColumnWidth extends IntegerPropertyBuilder
+ {
+ }
+
+ public static class ColumnAutoSize extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class ColumnHidden extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class ColumnExport extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderBottomShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Colour.isColour(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, value);
+ }
+ else if (BorderLineStyle.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new SpreadsheetException("Border bottom shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderRightLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderRightColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderRightShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Colour.isColour(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_RIGHT_COLOR, value);
+ }
+ else if (BorderLineStyle.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new SpreadsheetException("Border right shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderTopLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderTopColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderTopShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Colour.isColour(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_TOP_COLOR, value);
+ }
+ else if (BorderLineStyle.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new SpreadsheetException("Border top shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderLeftLineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderLeftColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BorderLeftShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Colour.isColour(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_COLOR, value);
+ }
+ else if (BorderLineStyle.isBorderLineStyle(values[i]))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, value);
+ }
+ else
+ {
+ throw new SpreadsheetException("Border left shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BorderShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Colour.isColour(value))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_RIGHT_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_TOP_COLOR, values[1]);
+ styleMap.put(CSSNames.BORDER_BOTTOM_COLOR, values[1]);
+ }
+ else if (BorderLineStyle.isBorderLineStyle(value))
+ {
+ styleMap.put(CSSNames.BORDER_LEFT_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_RIGHT_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_TOP_LINE_STYLE, values[0]);
+ styleMap.put(CSSNames.BORDER_BOTTOM_LINE_STYLE, values[0]);
+ }
+ else
+ {
+ throw new SpreadsheetException("Border shorthand can only handle line style and color");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class BackgroundColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class BackgroundPattern extends StringPropertyBuilder
+ {
+ }
+
+ public static class BackgroundShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (Pattern.isPattern(values[i]))
+ {
+ styleMap.put(CSSNames.BACKGROUND_PATTERN, value);
+ }
+ else if (Colour.isColour(values[i]))
+ {
+ styleMap.put(CSSNames.BACKGROUND_COLOR, value);
+ }
+ else
+ {
+ throw new SpreadsheetException("Background shorthand can only handle color and pattern");
+ }
+ }
+ return styleMap;
+ }
+ }
+
+ public static class FontFamily extends MergingStringPropertyBuilder
+ {
+ }
+
+ private static String collectString(String[] values, String delimiter)
+ {
+ StringBuffer buffer = new StringBuffer();
+ for (int i = 0; i < values.length; i++)
+ {
+ if (i > 0)
+ {
+ buffer.append(delimiter);
+ }
+ buffer.append(values[i]);
+ }
+ return buffer.toString();
+ }
+
+ private static class MergingStringPropertyBuilder extends StringPropertyBuilder
+ {
+ @Override
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ String concatValues = collectString(values, " ");
+ return super.parseProperty(key, new String[] { concatValues });
+ }
+ }
+
+ public static class FontSize extends IntegerPropertyBuilder
+ {
+ }
+
+ public static class FontColor extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontItalic extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class FontScriptStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontUnderlineStyle extends StringPropertyBuilder
+ {
+ }
+
+ public static class FontBold extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class FontStruckOut extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class FontShorthand implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+
+ String valueString = collectString(values, " ");
+ int firstQuote = valueString.indexOf("'");
+ int lastQuote = valueString.lastIndexOf("'");
+ if (firstQuote > 0 && lastQuote > 0 && firstQuote != lastQuote)
+ {
+ String fontName = valueString.substring(firstQuote, lastQuote);
+ styleMap.put(CSSNames.FONT_FAMILY, fontName);
+ String pre = valueString.substring(0, firstQuote - 1).trim();
+ String post = valueString.substring(lastQuote + 1).trim();
+ valueString = pre + post;
+ values = valueString.split(" ");
+ }
+
+ for (int i = 0; i < values.length; i++)
+ {
+ String value = values[i];
+ if (ScriptStyle.isScriptStyle(value))
+ {
+ styleMap.put(CSSNames.FONT_SCRIPT_STYLE, value);
+ }
+ else if (Colour.isColour(value))
+ {
+ styleMap.put(CSSNames.FONT_COLOR, value);
+ }
+ else if (UnderlineStyle.isUnderlineStyle(value))
+ {
+ styleMap.put(CSSNames.FONT_UNDERLINE_STYLE, value);
+ }
+ else if ("italic".equals(value.toLowerCase()))
+ {
+ styleMap.put(CSSNames.FONT_ITALIC, Boolean.TRUE);
+ }
+ else if ("bold".equals(value.toLowerCase()))
+ {
+ styleMap.put(CSSNames.FONT_BOLD, Boolean.TRUE);
+ }
+ else if ("struck_out".equals(value.toLowerCase()))
+ {
+ styleMap.put(CSSNames.FONT_STRUCK_OUT, Boolean.TRUE);
+ }
+ else if (isNumeric(value))
+ {
+ styleMap.put(CSSNames.FONT_SIZE, Integer.parseInt(value));
+ }
+ else
+ {
+ styleMap.put(CSSNames.FONT_FAMILY, value);
+ }
+ }
+
+ return styleMap;
+ }
+ }
+
+ private static boolean isNumeric(String value)
+ {
+ try
+ {
+ Integer.parseInt(value);
+ }
+ catch (NumberFormatException e)
+ {
+ return false;
+ }
+ return true;
+ }
+
+ private static boolean isBoolean(String value)
+ {
+ return "true".equalsIgnoreCase(value) || "false".equalsIgnoreCase(value);
+ }
+
+ public static class VericalAlignment extends StringPropertyBuilder
+ {
+ }
+
+ public static class Wrap extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class ShrinkToFit extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class Locked extends BooleanPropertyBuilder
+ {
+ }
+
+ public static class Orientation extends StringPropertyBuilder
+ {
+ }
+
+ public static class Indentation extends IntegerPropertyBuilder
+ {
+ }
+
+ public static class Alignment extends StringPropertyBuilder
+ {
+ }
+
+ public static class FormatMask extends MergingStringPropertyBuilder
+ {
+ }
+
+ private static class StringPropertyBuilder implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ StyleMap styleMap = new StyleMap();
+ styleMap.put(key, values[0]);
+ return styleMap;
+ }
+ }
+
+ private static class IntegerPropertyBuilder implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ String value = values[0];
+ if (!isNumeric(value))
+ {
+ throw new SpreadsheetException(String.format("%s is not a number in #s", value, key));
+ }
+ StyleMap styleMap = new StyleMap();
+ styleMap.put(key, Integer.parseInt(value));
+ return styleMap;
+ }
+ }
+
+ private static class BooleanPropertyBuilder implements PropertyBuilder
+ {
+ public StyleMap parseProperty(String key, String[] values)
+ {
+ String value = values[0];
+ if (!isBoolean(value))
+ {
+ throw new SpreadsheetException(String.format("%s is not a boolean in #s", value, key));
+ }
+ StyleMap styleMap = new StyleMap();
+ styleMap.put(key, Boolean.parseBoolean(value));
+ return styleMap;
+ }
+ }
+}
\ No newline at end of file
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleMap.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,8 @@
+package org.jboss.seam.spreadsheet.css;
+
+import java.util.HashMap;
+
+public class StyleMap extends HashMap<String, Object>
+{
+ private static final long serialVersionUID = 1L;
+}
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleStringParser.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleStringParser.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/css/StyleStringParser.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,98 @@
+package org.jboss.seam.spreadsheet.css;
+
+import java.text.CharacterIterator;
+import java.text.StringCharacterIterator;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class StyleStringParser
+{
+ private static final char STYLE_SEPARATOR = ';';
+ private static final String KEY_VALUE_SEPARATOR = ":";
+ private static final String STYLE_SHORTHAND_SEPARATOR = " ";
+ private static final char ESCAPE_CHAR = '\'';
+
+ private String styleString;
+ private Map<String, PropertyBuilder> propertyBuilderMap;
+ private StyleMap styleMap = new StyleMap();
+ private boolean escaping = false;
+
+ public static StyleStringParser of(String styleString, Map<String, PropertyBuilder> propertyBuilderMap)
+ {
+ return new StyleStringParser(styleString, propertyBuilderMap);
+ }
+
+ protected StyleStringParser(String styleString, Map<String, PropertyBuilder> propertyBuilderMap)
+ {
+ this.styleString = styleString;
+ this.propertyBuilderMap = propertyBuilderMap;
+ }
+
+ private void addStyle(StringBuilder styleBuilder)
+ {
+ String styleString = styleBuilder.toString();
+ int keyValueBreakpointIndex = styleString.indexOf(KEY_VALUE_SEPARATOR);
+ if (keyValueBreakpointIndex < 0)
+ {
+ System.out.println(String.format("Key-value separator character #0 not found in style #1, dropping", KEY_VALUE_SEPARATOR + styleBuilder.toString()));
+ return;
+ }
+ String styleName = styleString.substring(0, keyValueBreakpointIndex).toLowerCase().trim();
+ if (!propertyBuilderMap.containsKey(styleName))
+ {
+ System.out.println(String.format("No property builder (unknown style) for property #0", styleName));
+ return;
+ }
+ PropertyBuilder propertyBuilder = propertyBuilderMap.get(styleName);
+ String styleValue = styleString.substring(keyValueBreakpointIndex + 1);
+ System.out.println(String.format("Parsed style #0 to #1 => #2", styleString, styleName, styleValue));
+ String[] styleValues = trimArray(styleValue.trim().split(STYLE_SHORTHAND_SEPARATOR));
+ styleMap.putAll(propertyBuilder.parseProperty(styleName, styleValues));
+ }
+
+ public static String[] trimArray(String[] array)
+ {
+ List<String> validValues = new ArrayList<String>();
+ for (int i = 0; i < array.length; i++)
+ {
+ if (!"".equals(array[i]) && !" ".equals(array[i]))
+ {
+ validValues.add(array[i].toLowerCase().trim());
+ }
+ }
+ return validValues.toArray(new String[validValues.size()]);
+ }
+
+ public StyleMap parse()
+ {
+ CharacterIterator iterator = new StringCharacterIterator(styleString);
+ StringBuilder styleBuilder = new StringBuilder();
+ for (char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next())
+ {
+ if (ESCAPE_CHAR == c)
+ {
+ escaping = !escaping;
+ }
+ else if (STYLE_SEPARATOR == c && !escaping)
+ {
+ addStyle(styleBuilder);
+ styleBuilder = new StringBuilder();
+ }
+ else
+ {
+ styleBuilder.append(c);
+ }
+ }
+ if (styleBuilder.length() > 0)
+ {
+ addStyle(styleBuilder);
+ }
+
+ if (escaping)
+ {
+ System.out.println(String.format("Unbalanced escape characters #0 in style #1", ESCAPE_CHAR, styleBuilder.toString()));
+ }
+ return styleMap;
+ }
+}
\ No newline at end of file
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/CellFormatFactory.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,15 @@
+package org.jboss.seam.spreadsheet.jsf;
+
+import org.jboss.seam.spreadsheet.css.StyleMap;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat;
+
+public class CellFormatFactory
+{
+
+ public static CellFormat getCellFormat(StyleMap styleMap)
+ {
+ CellFormat cellFormat = new CellFormat();
+ return cellFormat;
+ }
+
+}
Added: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java (rev 0)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jsf/ComponentStyle.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -0,0 +1,80 @@
+package org.jboss.seam.spreadsheet.jsf;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.faces.component.UIComponent;
+
+import org.jboss.seam.spreadsheet.css.Parser;
+import org.jboss.seam.spreadsheet.css.StyleMap;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat;
+import org.jboss.seam.spreadsheet.util.ReflectionUtil;
+
+public class ComponentStyle
+{
+ private static final String STYLE_CLASS_ATTRIBUTE = "styleClass";
+ private static final String STYLE_ATTRIBUTE = "style";
+
+ private Parser parser = new Parser();
+
+ public void load(URL stylesheet)
+ {
+ parser.loadStylesheet(stylesheet);
+ }
+
+ public CellFormat getCellFormat(UIComponent component)
+ {
+ List<StyleMap> styleMaps = getStyleMapHierarchy(component);
+ List<CellFormat> cellFormats = getCellFormats(styleMaps);
+ return CellFormat.merge(cellFormats);
+ }
+
+ private List<StyleMap> getStyleMapHierarchy(UIComponent component)
+ {
+ List<StyleMap> styleMaps = new ArrayList<StyleMap>();
+ UIComponent currentComponent = component;
+ while (currentComponent != null)
+ {
+ styleMaps.add(getStyleMap(currentComponent));
+ if (currentComponent.getParent() != null)
+ {
+ currentComponent = currentComponent.getParent();
+ }
+ else
+ {
+ currentComponent = null;
+ }
+ }
+ return styleMaps;
+ }
+
+ private List<CellFormat> getCellFormats(List<StyleMap> styleMaps)
+ {
+ List<CellFormat> cellFormats = new ArrayList<CellFormat>();
+ for (StyleMap styleMap : styleMaps)
+ {
+ cellFormats.add(CellFormatFactory.getCellFormat(styleMap));
+ }
+ return cellFormats;
+ }
+
+ private StyleMap getStyleMap(UIComponent component)
+ {
+ StyleMap styleMap = new StyleMap();
+ styleMap.putAll(parser.parseStyleClasses(getStyleClassProperty(component)));
+ styleMap.putAll(parser.parseStyle(getStyleProperty(component)));
+ return styleMap;
+ }
+
+ private String getStyleProperty(UIComponent component)
+ {
+ return (String) ReflectionUtil.readRawField(component, STYLE_ATTRIBUTE);
+ }
+
+ private String getStyleClassProperty(UIComponent component)
+ {
+ return (String) ReflectionUtil.readRawField(component, STYLE_CLASS_ATTRIBUTE);
+ }
+
+}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jxl/writer/JXLSpreadsheetWriter.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jxl/writer/JXLSpreadsheetWriter.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/jxl/writer/JXLSpreadsheetWriter.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -34,7 +34,7 @@
private SettingsHelper settingsHelper = new SettingsHelper();
@Inject
- private Events events;
+// private Events events;
@Override
public SpreadsheetWriter processWorkbook(Workbook workbook) throws SpreadsheetException
@@ -81,7 +81,7 @@
private void processWorksheet(Worksheet worksheet, List<Command> workbookCommands)
{
cellFormatResolver.setWorksheetRules(worksheet.getCellFormatRules());
- events.worksheetCreated(worksheet);
+// events.worksheetCreated(worksheet);
WritableSheet jxlWorksheet = jxlWorkbook.createSheet(worksheet.getName(), jxlWorkbook.getNumberOfSheets());
if (worksheet.getSettings() != null)
{
@@ -100,7 +100,7 @@
for (Command command : commands)
{
JxlCommand jxlCommand = CommandFactory.getJxlCommand(command, jxlWorksheet);
- events.commandExecuted(command);
+// events.commandExecuted(command);
jxlCommand.execute();
}
}
@@ -109,7 +109,7 @@
{
try
{
- events.cellAdded(cell);
+// events.cellAdded(cell);
jxlWorksheet.addCell(cellFactory.createCell(cell, cellFormatResolver));
if (cell.getCellSpan() != null)
{
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Background.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Background.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Background.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -6,7 +6,20 @@
{
public enum Pattern
{
- GRAY_25, GRAY_50, GRAY_75, NONE, PATTERN1, PATTERN10, PATTERN11, PATTERN12, PATTERN13, PATTERN14, PATTERN2, PATTERN3, PATTERN4, PATTERN5, PATTERN6, PATTERN7, PATTERN8, PATTERN9, SOLID
+ GRAY_25, GRAY_50, GRAY_75, NONE, PATTERN1, PATTERN10, PATTERN11, PATTERN12, PATTERN13, PATTERN14, PATTERN2, PATTERN3, PATTERN4, PATTERN5, PATTERN6, PATTERN7, PATTERN8, PATTERN9, SOLID;
+
+ public static boolean isPattern(String pattern)
+ {
+ try
+ {
+ valueOf(pattern);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ return true;
+ }
}
private Colour colour;
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Border.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Border.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Border.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -2,8 +2,6 @@
import static org.jboss.seam.spreadsheet.util.HashUtil.same;
-import org.jboss.seam.spreadsheet.model.formatting.Border.BorderType;
-
public class Border
{
public enum BorderType
@@ -13,7 +11,20 @@
public enum BorderLineStyle
{
- DASH_DOT, DASH_DOT_DOT, DASHED, DOTTED, DOUBLE, HAIR, MEDIUM, MEDIUM_DASH_DOT, MEDIUM_DASH_DOT_DOT, MEDIUM_DASHED, NONE, SLANTED_DASH_DOT, THICK, THIN
+ DASH_DOT, DASH_DOT_DOT, DASHED, DOTTED, DOUBLE, HAIR, MEDIUM, MEDIUM_DASH_DOT, MEDIUM_DASH_DOT_DOT, MEDIUM_DASHED, NONE, SLANTED_DASH_DOT, THICK, THIN;
+
+ public static boolean isBorderLineStyle(String borderLineStyle)
+ {
+ try
+ {
+ valueOf(borderLineStyle);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ return true;
+ }
}
private BorderType borderType;
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/CellFormat.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/CellFormat.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/CellFormat.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -267,4 +267,14 @@
return same(font, otherCellFormat.getFont()) && same(alignment, otherCellFormat.getAlignment()) && same(background, otherCellFormat.getBackground()) && same(borders, otherCellFormat.getBorders()) && same(indentation, otherCellFormat.getIndentation()) && same(locked, otherCellFormat.getLocked()) && same(orientation, otherCellFormat.getOrientation()) && same(shrinkToFit, otherCellFormat.getShrinkToFit()) && same(verticalAlignment, otherCellFormat.getVerticalAlignment()) && same(wrap, otherCellFormat.getWrap()) && same(mask, otherCellFormat.getMask());
}
+ public static CellFormat merge(List<CellFormat> cellFormats)
+ {
+ CellFormat newCellFormat = new CellFormat();
+ for (CellFormat cellFormat : cellFormats)
+ {
+ newCellFormat.merge(cellFormat);
+ }
+ return newCellFormat;
+ }
+
}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Colour.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Colour.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Colour.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -2,5 +2,18 @@
public enum Colour
{
- AQUA, AUTOMATIC, BLACK, BLUE, BLUE_GREY, BLUE2, BRIGHT_GREEN, BROWN, CORAL, DARK_BLUE, DARK_BLUE2, DARK_GREEN, DARK_PURPLE, DARK_RED, DARK_RED2, DARK_TEAL, DARK_YELLOW, DEFAULT_BACKGROUND, DEFAULT_BACKGROUND1, GOLD, GRAY_25, GRAY_50, GRAY_80, GREEN, GREY_25_PERCENT, GREY_40_PERCENT, GREY_50_PERCENT, GREY_80_PERCENT, ICE_BLUE, INDIGO, IVORY, LAVENDER, LIGHT_BLUE, LIGHT_GREEN, LIGHT_ORANGE, LIGHT_TURQUOISE, LIGHT_TURQUOISE2, LIME, OCEAN_BLUE, OLIVE_GREEN, ORANGE, PALE_BLUE, PALETTE_BLACK, PERIWINKLE, PINK, PINK2, PLUM, PLUM2, RED, ROSE, SEA_GREEN, SKY_BLUE, TAN, TEAL, TEAL2, TURQOISE2, TURQUOISE, UNKNOWN, VERY_LIGHT_YELLOW, VIOLET, VIOLET2, WHITE, YELLOW, YELLOW2
+ AQUA, AUTOMATIC, BLACK, BLUE, BLUE_GREY, BLUE2, BRIGHT_GREEN, BROWN, CORAL, DARK_BLUE, DARK_BLUE2, DARK_GREEN, DARK_PURPLE, DARK_RED, DARK_RED2, DARK_TEAL, DARK_YELLOW, DEFAULT_BACKGROUND, DEFAULT_BACKGROUND1, GOLD, GRAY_25, GRAY_50, GRAY_80, GREEN, GREY_25_PERCENT, GREY_40_PERCENT, GREY_50_PERCENT, GREY_80_PERCENT, ICE_BLUE, INDIGO, IVORY, LAVENDER, LIGHT_BLUE, LIGHT_GREEN, LIGHT_ORANGE, LIGHT_TURQUOISE, LIGHT_TURQUOISE2, LIME, OCEAN_BLUE, OLIVE_GREEN, ORANGE, PALE_BLUE, PALETTE_BLACK, PERIWINKLE, PINK, PINK2, PLUM, PLUM2, RED, ROSE, SEA_GREEN, SKY_BLUE, TAN, TEAL, TEAL2, TURQOISE2, TURQUOISE, UNKNOWN, VERY_LIGHT_YELLOW, VIOLET, VIOLET2, WHITE, YELLOW, YELLOW2;
+
+ public static boolean isColour(String colour)
+ {
+ try
+ {
+ valueOf(colour);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ return true;
+ }
}
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Font.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Font.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/model/formatting/Font.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -6,12 +6,38 @@
{
public enum ScriptStyle
{
- NORMAL_SCRIPT, SUBSCRIPT, SUPERSCRIPT
+ NORMAL_SCRIPT, SUBSCRIPT, SUPERSCRIPT;
+
+ public static boolean isScriptStyle(String scriptStyle)
+ {
+ try
+ {
+ valueOf(scriptStyle);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ return true;
+ }
};
public enum UnderlineStyle
{
- NO_UNDERLINE, SINGLE, SINGLE_ACCOUNTING, DOUBLE, DOUBLE_ACCOUNTING
+ NO_UNDERLINE, SINGLE, SINGLE_ACCOUNTING, DOUBLE, DOUBLE_ACCOUNTING;
+
+ public static boolean isUnderlineStyle(String underlineStyle)
+ {
+ try
+ {
+ valueOf(underlineStyle);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return false;
+ }
+ return true;
+ }
};
private String fontName;
Modified: sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/util/ReflectionUtil.java
===================================================================
--- sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/util/ReflectionUtil.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/main/java/org/jboss/seam/spreadsheet/util/ReflectionUtil.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -72,6 +72,32 @@
return null;
}
+ public static Object readRawField(Object instance, String fieldName)
+ {
+ Field field;
+ try
+ {
+ field = instance.getClass().getField(fieldName);
+ }
+ catch (Exception e)
+ {
+ throw new SpreadsheetException(String.format("Could not access field %s from %s", fieldName, instance), e);
+ }
+ if (field != null)
+ {
+ field.setAccessible(true);
+ try
+ {
+ return field.get(instance);
+ }
+ catch (Exception e)
+ {
+ throw new SpreadsheetException(String.format("Could not read field %s from %s", fieldName, instance), e);
+ }
+ }
+ return null;
+ }
+
private Object getByField(Object instance, String fieldName)
{
try
Modified: sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorkbookTest.java
===================================================================
--- sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorkbookTest.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorkbookTest.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -7,6 +7,9 @@
import org.jboss.seam.spreadsheet.SpreadsheetException;
import org.jboss.seam.spreadsheet.jxl.writer.JXLSpreadsheetWriter;
import org.jboss.seam.spreadsheet.jxl.writer.event.Events;
+import org.jboss.seam.spreadsheet.model.formatting.CellFormat;
+import org.jboss.seam.spreadsheet.model.formatting.Colour;
+import org.jboss.seam.spreadsheet.model.formatting.Font;
import org.jboss.seam.spreadsheet.model.formatting.SpreadsheetTest;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -23,7 +26,7 @@
{
return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(JXLSpreadsheetWriter.class, Events.class).addManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
}
-
+
@Test
public void freshWorkbookStateTest()
{
@@ -31,7 +34,7 @@
Assert.assertTrue(workbook.getWorksheets().isEmpty());
Assert.assertTrue(workbook.getCellFormatRules().isEmpty());
}
-
+
@Test(expected = SpreadsheetException.class)
public void noWorksheetsFailTest()
{
@@ -39,9 +42,10 @@
@SuppressWarnings("unused")
jxl.Workbook jxlWorkbook = getWorkbook(workbook);
}
-
+
@Test
- public void workbookSettingsTest() {
+ public void workbookSettingsTest()
+ {
Workbook workbook = new Workbook();
workbook.getWorksheets().add(Worksheet.named("foo"));
WorkbookSettings settings = new WorkbookSettings();
@@ -50,4 +54,35 @@
workbook.setSettings(settings);
workbookToFile(workbook, "c:/temp/foo.xls");
}
+
+ @Test
+ public void performanceTest()
+ {
+ long time1 = System.currentTimeMillis();
+ Workbook workbook = new Workbook();
+ CellFormat cellFormat = new CellFormat();
+ Font font = new Font();
+ font.setFontName("Times New Roman");
+ font.setBold(true);
+ font.setColour(Colour.RED);
+ font.setPointSize(20);
+ cellFormat.setFont(font);
+ for (int i = 0; i < 1; i++)
+ {
+ Worksheet worksheet = Worksheet.named("Sheet " + i);
+ workbook.getWorksheets().add(worksheet);
+ for (int c = 0; c < 256; c++)
+ {
+ for (int r = 0; r < 65536; r++)
+ {
+ Cell cell = Cell.of("foo", Coordinate.of(c, r));
+ cell.setCellFormat(cellFormat);
+ worksheet.getCells().add(cell);
+ }
+ }
+ }
+ long time2 = System.currentTimeMillis();
+ workbookToFile(workbook, "c:/temp/performance.xls");
+ System.out.println(time2 - time1);
+ }
}
Modified: sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorksheetTest.java
===================================================================
--- sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorksheetTest.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/WorksheetTest.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -2,11 +2,27 @@
import junit.framework.Assert;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.spreadsheet.jxl.writer.JXLSpreadsheetWriter;
+import org.jboss.seam.spreadsheet.jxl.writer.event.Events;
import org.jboss.seam.spreadsheet.model.formatting.SpreadsheetTest;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.impl.base.asset.ByteArrayAsset;
import org.junit.Test;
+import org.junit.runner.RunWith;
+(a)RunWith(Arquillian.class)
public class WorksheetTest extends SpreadsheetTest
{
+
+ @Deployment
+ public static JavaArchive getArchive()
+ {
+ return ShrinkWrap.create("test.jar", JavaArchive.class).addClasses(JXLSpreadsheetWriter.class, Events.class).addManifestResource(new ByteArrayAsset("<beans/>".getBytes()), ArchivePaths.create("beans.xml"));
+ }
@Test
public void freshWorksheetStateTest()
@@ -17,20 +33,34 @@
Assert.assertTrue(worksheet.getCommands().isEmpty());
Assert.assertNull(worksheet.getSettings());
}
-
+
@Test
- public void usedRangeTest() {
+ public void worksheetSettingsTest()
+ {
Worksheet worksheet = Worksheet.named("foo");
+ worksheet.getCells().add(Cell.of("foo", Coordinate.ORIGO));
+ WorksheetSettings settings = new WorksheetSettings();
+ settings.setHorizontalFreeze(5);
+ worksheet.setSettings(settings);
+ Workbook wb = new Workbook();
+ wb.getWorksheets().add(worksheet);
+ Assert.assertEquals(5, getWorkbook(wb).getSheet(0).getSettings().getHorizontalFreeze());
+ }
+
+ @Test
+ public void usedRangeTest()
+ {
+ Worksheet worksheet = Worksheet.named("foo");
Assert.assertEquals(Range.of(0, 0, 0, 0), worksheet.getUsedRange());
}
-
+
@Test
- public void usedRangeTest2() {
+ public void usedRangeTest2()
+ {
Worksheet worksheet = Worksheet.named("foo");
worksheet.getCells().add(Cell.of("foo", Coordinate.of(10, 10)));
worksheet.getCells().add(Cell.of("bar", Coordinate.of(20, 20)));
Assert.assertEquals(Range.of(10, 10, 20, 20), worksheet.getUsedRange());
}
-
-
+
}
Modified: sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/formatting/SpreadsheetTest.java
===================================================================
--- sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/formatting/SpreadsheetTest.java 2010-07-25 12:39:28 UTC (rev 13505)
+++ sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/model/formatting/SpreadsheetTest.java 2010-07-26 07:46:16 UTC (rev 13506)
@@ -135,7 +135,7 @@
try
{
FileOutputStream out = new FileOutputStream(fileName);
- out.write(sw.processWorkbook(workbook).writeWorkbook());
+ out.write(getSpreadsheetWriter().processWorkbook(workbook).writeWorkbook());
out.flush();
out.close();
}
14 years, 5 months
Seam SVN: r13505 - modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 08:39:28 -0400 (Sun, 25 Jul 2010)
New Revision: 13505
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
Log:
oops
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 11:45:23 UTC (rev 13504)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 12:39:28 UTC (rev 13505)
@@ -35,7 +35,6 @@
import java.util.Map.Entry;
import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Default;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.Annotated;
import javax.enterprise.inject.spi.AnnotatedConstructor;
@@ -67,6 +66,7 @@
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.core.Exact;
import org.jboss.weld.extensions.core.Veto;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -200,7 +200,6 @@
AnnotatedType<?> tp = fixExactSupport(bb.getBuilder()).create();
log.info("Adding XML Defined Bean: " + tp.getJavaClass().getName());
event.addAnnotatedType(tp);
-
}
veto.addAll(r.getVeto());
@@ -318,7 +317,7 @@
// if the original type was qualified @Default we add that as well
if (!isQualifierPresent(type, beanManager))
{
- gb.addToClass(new DefaultLiteral());
+ gb.addToClass(DefaultLiteral.INSTANCE);
}
// we always apply qualifiers to the actual type
for (Annotation q : qualifiers)
@@ -336,7 +335,7 @@
// bother, as it should not be qualified @Default
if (!isQualifierPresent(f, beanManager) && f.getJavaMember().getType() != rootType.getJavaClass())
{
- gb.addToField(f.getJavaMember(), new DefaultLiteral());
+ gb.addToField(f.getJavaMember(), DefaultLiteral.INSTANCE);
}
for (Annotation q : qualifiers)
{
@@ -351,7 +350,7 @@
{
if (!isQualifierPresent(m, beanManager))
{
- gb.addToMethod(m.getJavaMember(), new DefaultLiteral());
+ gb.addToMethod(m.getJavaMember(), DefaultLiteral.INSTANCE);
}
for (Annotation q : qualifiers)
{
@@ -366,7 +365,7 @@
{
if (!isQualifierPresent(p, beanManager) && p.getBaseType() != rootType.getJavaClass())
{
- gb.addToMethodParameter(m.getJavaMember(), p.getPosition(), new DefaultLiteral());
+ gb.addToMethodParameter(m.getJavaMember(), p.getPosition(), DefaultLiteral.INSTANCE);
}
for (Annotation q : qualifiers)
{
@@ -382,7 +381,7 @@
{
if (!isQualifierPresent(con, beanManager))
{
- gb.addToConstructor((Constructor) con.getJavaMember(), new DefaultLiteral());
+ gb.addToConstructor((Constructor) con.getJavaMember(), DefaultLiteral.INSTANCE);
}
for (Annotation q : qualifiers)
{
@@ -396,7 +395,7 @@
{
if (!isQualifierPresent(p, beanManager))
{
- gb.addToConstructorParameter((Constructor) con.getJavaMember(), p.getPosition(), new DefaultLiteral());
+ gb.addToConstructorParameter((Constructor) con.getJavaMember(), p.getPosition(), DefaultLiteral.INSTANCE);
}
for (Annotation q : qualifiers)
{
@@ -471,8 +470,4 @@
}
return builder;
}
-
- public static class DefaultLiteral extends AnnotationLiteral<Default> implements Default
- {
- };
}
14 years, 5 months
Seam SVN: r13504 - modules/xml/trunk/docs/src/main/docbook/en-US.
by seam-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-07-25 07:45:23 -0400 (Sun, 25 Jul 2010)
New Revision: 13504
Modified:
modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
Log:
typo
Modified: modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml
===================================================================
--- modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml 2010-07-25 11:22:06 UTC (rev 13503)
+++ modules/xml/trunk/docs/src/main/docbook/en-US/xml-general.xml 2010-07-25 11:45:23 UTC (rev 13504)
@@ -500,7 +500,7 @@
</programlisting>
<para>The declaration above means that for every <literal>GenericMain</literal> that a user configures via xml
a corresponding <literal>GenericDependant</literal> is created as well. The
- <literal><s:ApplyQualifiers\></literal> is replaced with the qualifiers that are present on the user
+ <literal><s:ApplyQualifiers /></literal> is replaced with the qualifiers that are present on the user
configured bean.</para>
</section>
14 years, 5 months
Seam SVN: r13503 - in modules/persistence/trunk: api and 1 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 07:22:06 -0400 (Sun, 25 Jul 2010)
New Revision: 13503
Modified:
modules/persistence/trunk/api/pom.xml
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/pom.xml
Log:
update poms to put back ee dependency
Modified: modules/persistence/trunk/api/pom.xml
===================================================================
--- modules/persistence/trunk/api/pom.xml 2010-07-25 11:16:20 UTC (rev 13502)
+++ modules/persistence/trunk/api/pom.xml 2010-07-25 11:22:06 UTC (rev 13503)
@@ -24,6 +24,13 @@
<artifactId>cdi-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
</dependencies>
<scm>
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-07-25 11:16:20 UTC (rev 13502)
+++ modules/persistence/trunk/impl/pom.xml 2010-07-25 11:22:06 UTC (rev 13503)
@@ -89,6 +89,13 @@
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-07-25 11:16:20 UTC (rev 13502)
+++ modules/persistence/trunk/pom.xml 2010-07-25 11:22:06 UTC (rev 13503)
@@ -31,6 +31,7 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
+ <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
</properties>
<dependencyManagement>
@@ -51,6 +52,14 @@
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>${jboss-javaee6-spec.version}</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
14 years, 5 months
Seam SVN: r13502 - modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 07:16:20 -0400 (Sun, 25 Jul 2010)
New Revision: 13502
Modified:
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
Log:
fix build
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java 2010-07-25 10:56:31 UTC (rev 13501)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionBeanLifecycle.java 2010-07-25 11:16:20 UTC (rev 13502)
@@ -8,9 +8,9 @@
import java.lang.reflect.Proxy;
import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
-import org.jboss.weld.extensions.bean.BeanImpl;
import org.jboss.weld.extensions.bean.BeanLifecycle;
/**
@@ -47,7 +47,7 @@
this.manager = manager;
}
- public SeamTransaction create(BeanImpl<SeamTransaction> bean, CreationalContext<SeamTransaction> ctx)
+ public SeamTransaction create(Bean<SeamTransaction> bean, CreationalContext<SeamTransaction> ctx)
{
try
{
@@ -59,7 +59,7 @@
}
}
- public void destroy(BeanImpl<SeamTransaction> bean, SeamTransaction arg0, CreationalContext<SeamTransaction> arg1)
+ public void destroy(Bean<SeamTransaction> bean, SeamTransaction arg0, CreationalContext<SeamTransaction> arg1)
{
arg1.release();
}
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-25 10:56:31 UTC (rev 13501)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/transaction/TransactionExtension.java 2010-07-25 11:16:20 UTC (rev 13502)
@@ -55,13 +55,12 @@
public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager manager)
{
- AnnotatedTypeBuilder<SeamTransaction> utbuilder = AnnotatedTypeBuilder.newInstance(SeamTransaction.class);
- BeanBuilder<SeamTransaction> builder = new BeanBuilder<SeamTransaction>(utbuilder.create(), manager);
- builder.defineBeanFromAnnotatedType();
+ AnnotatedTypeBuilder<SeamTransaction> utbuilder = new AnnotatedTypeBuilder().setJavaClass(SeamTransaction.class);
+ BeanBuilder<SeamTransaction> builder = new BeanBuilder<SeamTransaction>(manager);
+ builder.defineBeanFromAnnotatedType(utbuilder.create());
builder.setBeanLifecycle(new TransactionBeanLifecycle(manager));
builder.getQualifiers().clear();
builder.getQualifiers().add(DefaultTransactionLiteral.INSTANCE);
DefaultBeanExtension.addDefaultBean(SeamTransaction.class, builder.create());
}
-
}
14 years, 5 months
Seam SVN: r13501 - in modules/persistence/trunk: api and 4 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 06:56:31 -0400 (Sun, 25 Jul 2010)
New Revision: 13501
Modified:
modules/persistence/trunk/api/pom.xml
modules/persistence/trunk/impl/pom.xml
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml
modules/persistence/trunk/pom.xml
Log:
removed dep on ee api
Modified: modules/persistence/trunk/api/pom.xml
===================================================================
--- modules/persistence/trunk/api/pom.xml 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/api/pom.xml 2010-07-25 10:56:31 UTC (rev 13501)
@@ -24,13 +24,6 @@
<artifactId>cdi-api</artifactId>
</dependency>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
</dependencies>
<scm>
Modified: modules/persistence/trunk/impl/pom.xml
===================================================================
--- modules/persistence/trunk/impl/pom.xml 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/pom.xml 2010-07-25 10:56:31 UTC (rev 13501)
@@ -89,13 +89,6 @@
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/ManagedPersistenceContextExtension.java 2010-07-25 10:56:31 UTC (rev 13501)
@@ -66,7 +66,8 @@
AnnotatedTypeBuilder<T> modifiedType = null;
for (AnnotatedField<? super T> f : event.getAnnotatedType().getFields())
{
- // look for a seam managed persistence unit declaration
+ // look for a seam managed persistence unit declaration on EE resource
+ // producer fields
if (f.isAnnotationPresent(SeamManaged.class) && f.isAnnotationPresent(PersistenceUnit.class) && f.isAnnotationPresent(Produces.class))
{
if (modifiedType == null)
@@ -97,14 +98,11 @@
{
modifiedType.removeFromField(f.getJavaMember(), scope);
}
- // create the new bean to be registerd later
- AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
- BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
- builder.setQualifiers(qualifiers);
- builder.setScope(scope);
- builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
- beans.add(builder.create());
+ registerManagedPersistenceContext(qualifiers, scope, manager);
}
+ // now look for producer methods that produce an EntityManagerFactory.
+ // This allows the user to manually configure an EntityManagerFactory
+ // and return it from a producer method
}
if (modifiedType != null)
{
@@ -112,6 +110,24 @@
}
}
+ /**
+ */
+ public void processProducer()
+ {
+
+ }
+
+ public void registerManagedPersistenceContext(Set<Annotation> qualifiers, Class<? extends Annotation> scope, BeanManager manager)
+ {
+ // create the new bean to be registerd later
+ AnnotatedTypeBuilder<EntityManager> typeBuilder = new AnnotatedTypeBuilder().setJavaClass(EntityManager.class);
+ BeanBuilder<EntityManager> builder = new BeanBuilder<EntityManager>(manager).defineBeanFromAnnotatedType(typeBuilder.create());
+ builder.setQualifiers(qualifiers);
+ builder.setScope(scope);
+ builder.setBeanLifecycle(new ManagedPersistenceContextBeanLifecycle(qualifiers, manager));
+ beans.add(builder.create());
+ }
+
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event)
{
for (Bean<?> i : beans)
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/PersistenceContextExtension.java 2010-07-25 10:56:31 UTC (rev 13501)
@@ -33,8 +33,6 @@
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Alternative;
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.Default;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.Bean;
@@ -43,24 +41,29 @@
import javax.enterprise.inject.spi.InjectionPoint;
import javax.enterprise.inject.spi.ProcessProducer;
import javax.enterprise.inject.spi.Producer;
-import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Qualifier;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;
+import org.jboss.weld.extensions.literal.AnyLiteral;
+import org.jboss.weld.extensions.literal.DefaultLiteral;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Support for managed persistence contexts in a Java SE environment or Servlet container.
- *
- * <p>Unlike with standard Java EE, the unitName attribute on {@link PersistenceContext} must
- * be provided if the persistence unit is assigned a name in persistence.xml. This
- * class supports multiple persistence units, but it does not permit multiple
- * producers for the same persistence unit (naturally).</p>
+ * Support for managed persistence contexts in a Java SE environment or Servlet
+ * container.
*
+ * <p>
+ * Unlike with standard Java EE, the unitName attribute on
+ * {@link PersistenceContext} must be provided if the persistence unit is
+ * assigned a name in persistence.xml. This class supports multiple persistence
+ * units, but it does not permit multiple producers for the same persistence
+ * unit (naturally).
+ * </p>
+ *
* @author Gavin King
* @author Dan Allen
*/
@@ -117,17 +120,9 @@
}
if (qualifiers.isEmpty())
{
- qualifiers.add(new AnnotationLiteral<Default>()
- {
- /** default value. Added only to suppress compiler warnings. */
- private static final long serialVersionUID = 1L;
- });
+ qualifiers.add(DefaultLiteral.INSTANCE);
}
- qualifiers.add(new AnnotationLiteral<Any>()
- {
- /** default value. Added only to suppress compiler warnings. */
- private static final long serialVersionUID = 1L;
- });
+ qualifiers.add(AnyLiteral.INSTANCE);
final boolean alternative = field.isAnnotationPresent(Alternative.class);
final Set<Type> types = new HashSet<Type>()
{
@@ -248,10 +243,11 @@
/**
* Check whether persistence is container managed. For now, this simply
- * checks for the presence of the EJB API. If it's present, we assume
- * this is an EE environment and that persistence is container managed.
+ * checks for the presence of the EJB API. If it's present, we assume this is
+ * an EE environment and that persistence is container managed.
*/
- boolean isPersistenceContainerManaged() {
+ boolean isPersistenceContainerManaged()
+ {
boolean eeEnv = true;
try
{
Modified: modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java
===================================================================
--- modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/java/org/jboss/seam/persistence/util/EjbApi.java 2010-07-25 10:56:31 UTC (rev 13501)
@@ -39,22 +39,22 @@
{
}
- public static final Class<Annotation> STATELESS;
- public static final Class<Annotation> STATEFUL;
- public static final Class<Annotation> MESSAGE_DRIVEN;
- public static final Class<Annotation> PRE_PASSIVATE;
- public static final Class<Annotation> POST_ACTIVATE;
- public static final Class<Annotation> PRE_DESTROY;
- public static final Class<Annotation> POST_CONSTRUCT;
- public static final Class<Annotation> REMOTE;
- public static final Class<Annotation> REMOVE;
- public static final Class<Annotation> LOCAL;
- public static final Class<Annotation> APPLICATION_EXCEPTION;
- public static final Class<Annotation> PERSISTENCE_CONTEXT;
- public static final Class<Annotation> PERSISTENCE_UNIT;
- public static final Class<Annotation> INTERCEPTORS;
- public static final Class<Annotation> AROUND_INVOKE;
- public static final Class<Annotation> EJB_EXCEPTION;
+ public static final Class<? extends Annotation> TRANSACTION_ATTRIBUTE;
+ public static final Class<? extends Enum> TRANSACTION_ATTRIBUTE_TYPE;
+ public static final Class<? extends Annotation> APPLICATION_EXCEPTION;
+
+ private static final Object MANDATORY;
+
+ private static final Object REQUIRED;
+
+ private static final Object REQUIRES_NEW;
+
+ private static final Object SUPPORTS;
+
+ private static final Object NOT_SUPPORTED;
+
+ private static final Object NEVER;
+
public static final boolean INVOCATION_CONTEXT_AVAILABLE;
private static Class classForName(String name)
@@ -71,22 +71,27 @@
static
{
- STATELESS = classForName("javax.ejb.Stateless");
- STATEFUL = classForName("javax.ejb.Stateful");
- MESSAGE_DRIVEN = classForName("javax.ejb.MessageDriven");
APPLICATION_EXCEPTION = classForName("javax.ejb.ApplicationException");
- PERSISTENCE_CONTEXT = classForName("javax.persistence.PersistenceContext");
- PERSISTENCE_UNIT = classForName("javax.persistence.PersistenceUnit");
- REMOVE = classForName("javax.ejb.Remove");
- REMOTE = classForName("javax.ejb.Remote");
- LOCAL = classForName("javax.ejb.Local");
- PRE_PASSIVATE = classForName("javax.ejb.PrePassivate");
- POST_ACTIVATE = classForName("javax.ejb.PostActivate");
- PRE_DESTROY = classForName("javax.annotation.PreDestroy");
- POST_CONSTRUCT = classForName("javax.annotation.PostConstruct");
- INTERCEPTORS = classForName("javax.interceptor.Interceptors");
- AROUND_INVOKE = classForName("javax.interceptor.AroundInvoke");
- EJB_EXCEPTION = classForName("javax.ejb.EJBException");
+ TRANSACTION_ATTRIBUTE = classForName("javax.ejb.TransactionAttribute");
+ TRANSACTION_ATTRIBUTE_TYPE = classForName("javax.ejb.TransactionAttributeType");
+ if (TRANSACTION_ATTRIBUTE_TYPE.getName().equals("javax.ejb.TransactionAttributeType"))
+ {
+ MANDATORY = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "MANDATORY");
+ REQUIRED = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "REQUIRED");
+ NOT_SUPPORTED = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "NOT_SUPPORTED");
+ REQUIRES_NEW = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "REQUIRES_NEW");
+ NEVER = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "NEVER");
+ SUPPORTS = Enum.valueOf(TRANSACTION_ATTRIBUTE_TYPE, "SUPPORTS");
+ }
+ else
+ {
+ MANDATORY = Dummy.class;
+ REQUIRED = Dummy.class;
+ NOT_SUPPORTED = Dummy.class;
+ REQUIRES_NEW = Dummy.class;
+ NEVER = Dummy.class;
+ SUPPORTS = Dummy.class;
+ }
INVOCATION_CONTEXT_AVAILABLE = !classForName("javax.interceptor.InvocationContext").equals(Dummy.class);
}
Modified: modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/impl/src/main/resources/META-INF/beans.xml 2010-07-25 10:56:31 UTC (rev 13501)
@@ -5,10 +5,27 @@
-->
<beans xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:persistence="urn:java:org.jboss.seam.persistence"
+ xmlns:s="urn:java:ee"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
<interceptors>
<class>org.jboss.seam.persistence.transaction.TransactionInterceptor</class>
</interceptors>
+ <genericBean class="org.jboss.seam.persistence.ManagedPersistenceContext" >
+ <persistence:EntityManagerFactoryProvider>
+ <s:ApplyQualifiers/>
+
+ <persistence:managedPersistenceContext>
+ <s:Inject/>
+ <s:ApplyQualifiers/>
+ </persistence:managedPersistenceContext>
+
+ <persistence:produceEntityManagerFactory>
+ <ApplyQualifiers/>
+ <s:Produces/>
+ </persistence:produceEntityManagerFactory>
+ </persistence:EntityManagerFactoryProvider>
+ </genericBean>
</beans>
Modified: modules/persistence/trunk/pom.xml
===================================================================
--- modules/persistence/trunk/pom.xml 2010-07-25 09:12:55 UTC (rev 13500)
+++ modules/persistence/trunk/pom.xml 2010-07-25 10:56:31 UTC (rev 13501)
@@ -31,7 +31,6 @@
<properties>
<seam.version>3.0.0.b01</seam.version>
- <jboss-javaee6-spec.version>1.0.0.Beta4</jboss-javaee6-spec.version>
</properties>
<dependencyManagement>
@@ -52,14 +51,6 @@
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>${jboss-javaee6-spec.version}</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
-
<dependency>
<groupId>org.jboss.seam.persistence</groupId>
<artifactId>seam-persistence</artifactId>
14 years, 5 months
Seam SVN: r13500 - in modules/xml/trunk/impl: src/main/java/org/jboss/seam/xml/bootstrap and 3 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 05:12:55 -0400 (Sun, 25 Jul 2010)
New Revision: 13500
Modified:
modules/xml/trunk/impl/pom.xml
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
Log:
update to latest weld-extensions
Modified: modules/xml/trunk/impl/pom.xml
===================================================================
--- modules/xml/trunk/impl/pom.xml 2010-07-25 08:15:58 UTC (rev 13499)
+++ modules/xml/trunk/impl/pom.xml 2010-07-25 09:12:55 UTC (rev 13500)
@@ -48,6 +48,7 @@
<dependency>
<groupId>org.jboss.weld</groupId>
<artifactId>weld-extensions</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
</dependency>
<dependency>
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 08:15:58 UTC (rev 13499)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 09:12:55 UTC (rev 13500)
@@ -197,7 +197,7 @@
bb.getBuilder().addToClass(new AnnotationLiteral<XmlConfiguredBean>()
{
});
- AnnotatedType<?> tp = bb.getBuilder().create();
+ AnnotatedType<?> tp = fixExactSupport(bb.getBuilder()).create();
log.info("Adding XML Defined Bean: " + tp.getJavaClass().getName());
event.addAnnotatedType(tp);
@@ -308,10 +308,10 @@
{
AnnotatedType<?> type = c.getBuilder().create();
- AnnotatedTypeBuilder<?> gb = AnnotatedTypeBuilder.newInstance(type);
+ AnnotatedTypeBuilder<?> gb = new AnnotatedTypeBuilder().setJavaClass(type.getJavaClass());
if (c.getBeanType() == BeanResultType.MODIFIES)
{
- gb.readAnnotationsFromUnderlyingType();
+ gb.readFromType((Class) type.getJavaClass());
// we don't want to keep the veto annotation on the class
gb.removeFromClass(Veto.class);
}
@@ -406,7 +406,7 @@
}
}
- ret.add(gb.create());
+ ret.add(fixExactSupport(gb).create());
}
return ret;
}
@@ -431,14 +431,13 @@
* temprary hack to support @Exact in seam-xml, remove once WELD-485 is
* resolved
*/
- <X> void processAnnotatedType(@Observes final ProcessAnnotatedType<X> pat, BeanManager beanManager)
+ public <X> AnnotatedTypeBuilder<X> fixExactSupport(AnnotatedTypeBuilder<X> old)
{
-
- AnnotatedTypeBuilder<X> builder = AnnotatedTypeBuilder.newInstance(pat.getAnnotatedType()).mergeAnnotations(pat.getAnnotatedType(), true);
-
+ AnnotatedType<X> pat = old.create();
+ AnnotatedTypeBuilder<X> builder = new AnnotatedTypeBuilder<X>().readFromType(pat);
// support for @Exact
// fields
- for (AnnotatedField<? super X> f : pat.getAnnotatedType().getFields())
+ for (AnnotatedField<? super X> f : pat.getFields())
{
if (f.isAnnotationPresent(Exact.class))
{
@@ -447,31 +446,30 @@
}
}
// method parameters
- for (AnnotatedMethod<? super X> m : pat.getAnnotatedType().getMethods())
+ for (AnnotatedMethod<? super X> m : pat.getMethods())
{
for (AnnotatedParameter<? super X> p : m.getParameters())
{
if (p.isAnnotationPresent(Exact.class))
{
Class<?> type = p.getAnnotation(Exact.class).value();
- builder.overrideMethodParameterType(m.getJavaMember(), type, p.getPosition());
+ builder.overrideMethodParameterType(m.getJavaMember(), p.getPosition(), type);
}
}
}
// constructor parameters
- for (AnnotatedConstructor<X> c : pat.getAnnotatedType().getConstructors())
+ for (AnnotatedConstructor<X> c : pat.getConstructors())
{
for (AnnotatedParameter<? super X> p : c.getParameters())
{
if (p.isAnnotationPresent(Exact.class))
{
Class<?> type = p.getAnnotation(Exact.class).value();
- builder.overrideConstructorParameterType(c.getJavaMember(), type, p.getPosition());
+ builder.overrideConstructorParameterType(c.getJavaMember(), p.getPosition(), type);
}
}
}
- pat.setAnnotatedType(builder.create());
-
+ return builder;
}
public static class DefaultLiteral extends AnnotationLiteral<Default> implements Default
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java 2010-07-25 08:15:58 UTC (rev 13499)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java 2010-07-25 09:12:55 UTC (rev 13500)
@@ -40,10 +40,10 @@
public BeanResult(Class<X> type, boolean readAnnotations, BeanResultType beanType, List<FieldValueObject> fieldValues, List<BeanResult<?>> inlineBeans)
{
this.type = type;
- builder = AnnotatedTypeBuilder.newInstance(type);
+ builder = new AnnotatedTypeBuilder().setJavaClass(type);
if (readAnnotations)
{
- builder.readAnnotationsFromUnderlyingType();
+ builder.readFromType(type);
// we don't want to keep the veto annotation on the class
builder.removeFromClass(Veto.class);
}
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-25 08:15:58 UTC (rev 13499)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-25 09:12:55 UTC (rev 13500)
@@ -81,7 +81,7 @@
String methodName = "set" + Character.toUpperCase(e.getKey().charAt(0)) + e.getKey().substring(1);
if (Reflections.methodExists(getJavaClass(), methodName))
{
- Set<Method> methods = Reflections.getMethods(getJavaClass());
+ Set<Method> methods = Reflections.getAllMethods(getJavaClass());
for (Method m : methods)
{
if (m.getName().equals(methodName) && m.getParameterTypes().length == 1)
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-07-25 08:15:58 UTC (rev 13499)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-07-25 09:12:55 UTC (rev 13500)
@@ -141,7 +141,7 @@
String methodName = "set" + Character.toUpperCase(name.charAt(0)) + name.substring(1);
if (Reflections.methodExists(p, methodName))
{
- Set<Method> methods = Reflections.getMethods(p);
+ Set<Method> methods = Reflections.getAllMethods(p);
for (Method m : methods)
{
if (m.getName().equals(methodName) && m.getParameterTypes().length == 1)
14 years, 5 months
Seam SVN: r13499 - in modules/xml/trunk/impl/src: main/java/org/jboss/seam/xml/core and 6 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 04:15:58 -0400 (Sun, 25 Jul 2010)
New Revision: 13499
Added:
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/InlineBeanIdCreator.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanQualifier.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Horse.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/HorseShoe.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/InlineBeanFieldValueBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Knight.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Sword.java
modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/inline-bean-field-value-beans.xml
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResultType.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
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/FieldValueObject.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.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/AbstractXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationUtils.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java
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/FieldXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java
Log:
inital attempt an inline beans, needs cleanup
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/bootstrap/XmlExtension.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -66,6 +66,7 @@
import org.jboss.seam.xml.util.FileDataReader;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.core.Exact;
+import org.jboss.weld.extensions.core.Veto;
import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -112,9 +113,9 @@
{
log.info("Reading XML file: " + d.getFileUrl());
ParserMain parser = new ParserMain();
- ModelBuilder builder = new ModelBuilder();
+ ModelBuilder builder = new ModelBuilder(d.getFileUrl());
SaxNode parentNode = parser.parse(d.getInputSource(), d.getFileUrl(), errors);
- results.add(builder.build(parentNode, d.getFileUrl()));
+ results.add(builder.build(parentNode, beanManager));
}
}
catch (Exception e)
@@ -150,14 +151,17 @@
errors.add(new RuntimeException(i));
}
}
- for (BeanResult<?> b : r.getFieldValues().keySet())
+ for (BeanResult<?> b : r.getFlattenedBeans())
{
- int val = count++;
- fieldValues.put(val, r.getFieldValues().get(b));
- Map<String, Object> am = new HashMap<String, Object>();
- am.put("value", val);
- Annotation a = ac.get(XmlId.class, am);
- b.getBuilder().addToClass(a);
+ if (!b.getFieldValues().isEmpty())
+ {
+ int val = count++;
+ fieldValues.put(val, b.getFieldValues());
+ Map<String, Object> am = new HashMap<String, Object>();
+ am.put("value", val);
+ Annotation a = ac.get(XmlId.class, am);
+ b.getBuilder().addToClass(a);
+ }
}
for (Class<? extends Annotation> b : r.getInterceptorBindings())
@@ -170,7 +174,7 @@
log.info("Adding XML Defined Stereotype: " + b.getKey().getName());
event.addStereotype(b.getKey(), b.getValue());
}
- for (BeanResult<?> bb : r.getBeans())
+ for (BeanResult<?> bb : r.getFlattenedBeans())
{
GenericBeanResult found = null;
for (Class<?> g : genericBeans.keySet())
@@ -230,18 +234,6 @@
List<FieldValueObject> fvs = fieldValues.get(xid.value());
event.setInjectionTarget(new InjectionTargetWrapper<T>(event.getInjectionTarget(), fvs));
}
- for (XmlResult r : results)
- {
- for (Entry<Class<?>, List<FieldValueObject>> e : r.getInterfaceFieldValues().entrySet())
- {
- if (e.getKey().isAssignableFrom(event.getAnnotatedType().getJavaClass()))
- {
- log.info("Wrapping InjectionTarget to set field values based on interface " + e.getKey().getName() + ": " + event.getAnnotatedType().getJavaClass().getName());
- List<FieldValueObject> fvs = e.getValue();
- event.setInjectionTarget(new InjectionTargetWrapper<T>(event.getInjectionTarget(), fvs));
- }
- }
- }
}
public void processAfterBeanDeployment(@Observes AfterBeanDiscovery event)
@@ -317,9 +309,11 @@
AnnotatedType<?> type = c.getBuilder().create();
AnnotatedTypeBuilder<?> gb = AnnotatedTypeBuilder.newInstance(type);
- if (c.getBeanType() == BeanResultType.SPECIALISE)
+ if (c.getBeanType() == BeanResultType.MODIFIES)
{
gb.readAnnotationsFromUnderlyingType();
+ // we don't want to keep the veto annotation on the class
+ gb.removeFromClass(Veto.class);
}
// if the original type was qualified @Default we add that as well
if (!isQualifierPresent(type, beanManager))
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResult.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -21,25 +21,42 @@
*/
package org.jboss.seam.xml.core;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.jboss.seam.xml.fieldset.FieldValueObject;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
+import org.jboss.weld.extensions.core.Veto;
public class BeanResult<X>
{
- final AnnotatedTypeBuilder<X> builder;
- final Class<X> type;
- final BeanResultType beanType;
+ private final AnnotatedTypeBuilder<X> builder;
+ private final Class<X> type;
+ private final BeanResultType beanType;
+ private final List<FieldValueObject> fieldValues;
+ private final List<BeanResult<?>> inlineBeans;
- public BeanResult(Class<X> type, boolean readAnnotations, BeanResultType beanType)
+ public BeanResult(Class<X> type, boolean readAnnotations, BeanResultType beanType, List<FieldValueObject> fieldValues, List<BeanResult<?>> inlineBeans)
{
this.type = type;
builder = AnnotatedTypeBuilder.newInstance(type);
if (readAnnotations)
{
builder.readAnnotationsFromUnderlyingType();
+ // we don't want to keep the veto annotation on the class
+ builder.removeFromClass(Veto.class);
}
this.beanType = beanType;
+ this.fieldValues = new ArrayList<FieldValueObject>(fieldValues);
+ this.inlineBeans = new ArrayList<BeanResult<?>>(inlineBeans);
}
+ public List<BeanResult<?>> getInlineBeans()
+ {
+ return inlineBeans;
+ }
+
public AnnotatedTypeBuilder<X> getBuilder()
{
return builder;
@@ -55,4 +72,9 @@
return beanType;
}
+ public List<FieldValueObject> getFieldValues()
+ {
+ return Collections.unmodifiableList(fieldValues);
+ }
+
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResultType.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResultType.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/BeanResultType.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -23,5 +23,5 @@
public enum BeanResultType
{
- ADD, OVERRIDE, SPECIALISE;
+ ADD, REPLACES, MODIFIES;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/core/XmlResult.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -27,8 +27,6 @@
import java.util.List;
import java.util.Map;
-import org.jboss.seam.xml.fieldset.FieldValueObject;
-
/**
* Stores the result of parsing an XML document
*
@@ -52,10 +50,6 @@
private final List<GenericBeanResult> genericBeans = new ArrayList<GenericBeanResult>();
- private final Map<BeanResult<?>, List<FieldValueObject>> fieldValues = new HashMap<BeanResult<?>, List<FieldValueObject>>();
-
- private final Map<Class<?>, List<FieldValueObject>> interfaceFieldValues = new HashMap<Class<?>, List<FieldValueObject>>();
-
private final String sortKey;
public XmlResult(String fileUrl)
@@ -108,24 +102,38 @@
return beans;
}
- public List<String> getProblems()
+ /**
+ * Gets all beans from the result, including inline beans
+ *
+ * @return
+ */
+ public List<BeanResult<?>> getFlattenedBeans()
{
- return problems;
+ List<BeanResult<?>> results = new ArrayList<BeanResult<?>>();
+ for (BeanResult<?> a : beans)
+ {
+ getFlattenedBeans(a, results);
+ }
+ return results;
}
- public void addProblem(String p)
+ private void getFlattenedBeans(BeanResult<?> r, List<BeanResult<?>> results)
{
- problems.add(p);
+ results.add(r);
+ for (BeanResult<?> a : r.getInlineBeans())
+ {
+ getFlattenedBeans(a, results);
+ }
}
- public void addFieldValue(BeanResult<?> res, List<FieldValueObject> list)
+ public List<String> getProblems()
{
- fieldValues.put(res, list);
+ return problems;
}
- public Map<BeanResult<?>, List<FieldValueObject>> getFieldValues()
+ public void addProblem(String p)
{
- return fieldValues;
+ problems.add(p);
}
public void addVeto(Class<?> clazz)
@@ -138,16 +146,6 @@
return veto;
}
- public void addInterfaceFieldValues(Class<?> clazz, List<FieldValueObject> values)
- {
- interfaceFieldValues.put(clazz, values);
- }
-
- public Map<Class<?>, List<FieldValueObject>> getInterfaceFieldValues()
- {
- return interfaceFieldValues;
- }
-
public void addGenericBean(GenericBeanResult result)
{
genericBeans.add(result);
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/ArrayFieldSet.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -25,6 +25,9 @@
import java.util.ArrayList;
import java.util.List;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.seam.xml.model.ValueXmlItem;
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.util.XmlObjectConverter;
@@ -40,7 +43,7 @@
final private List<AFS> values;
final private Class arrayType;
- public ArrayFieldSet(FieldValueSetter field, List<XmlItem> items)
+ public ArrayFieldSet(FieldValueSetter field, List<ValueXmlItem> items)
{
this.field = field;
this.values = new ArrayList<AFS>();
@@ -144,7 +147,7 @@
}
- public void setValue(Object instance)
+ public void setValue(Object instance, CreationalContext<?> ctx)
{
try
{
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/CollectionFieldSet.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -33,6 +33,9 @@
import java.util.SortedSet;
import java.util.TreeSet;
+import javax.enterprise.context.spi.CreationalContext;
+
+import org.jboss.seam.xml.model.ValueXmlItem;
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.util.TypeReader;
import org.jboss.seam.xml.util.XmlObjectConverter;
@@ -53,7 +56,7 @@
private final Class<?> elementType;
private final Class<? extends Collection> collectionType;
- public CollectionFieldSet(FieldValueSetter field, List<XmlItem> items)
+ public CollectionFieldSet(FieldValueSetter field, List<ValueXmlItem> items)
{
this.field = field;
this.values = new ArrayList<CFS>();
@@ -128,7 +131,7 @@
}
- public void setValue(Object instance)
+ public void setValue(Object instance, CreationalContext<?> ctx)
{
try
{
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueObject.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueObject.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/FieldValueObject.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.fieldset;
+import javax.enterprise.context.spi.CreationalContext;
+
/**
* FieldValueObjects set field values for a given instance
*
@@ -29,7 +31,6 @@
*/
public interface FieldValueObject
{
+ public void setValue(Object instance, CreationalContext<?> ctx);
- public void setValue(Object instance);
-
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InjectionTargetWrapper.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -43,7 +43,7 @@
{
for (FieldValueObject f : fieldValues)
{
- f.setValue(instance);
+ f.setValue(instance, ctx);
}
target.inject(instance, ctx);
}
Added: 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 (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanFieldValue.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,75 @@
+/*
+ * 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 javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+/**
+ * Field value object for an inline bean definition
+ *
+ * @author Stuart Douglas
+ *
+ */
+public class InlineBeanFieldValue implements FieldValueObject
+{
+
+ private final FieldValueSetter field;
+
+ private final int beanId;
+
+ private final Class<?> type;
+
+ private final InlineBeanQualifier.InlineBeanQualifierLiteral literal;
+
+ private final BeanManager manager;
+
+ private Bean<?> bean;
+
+ public InlineBeanFieldValue(Class<?> type, int syntheticBeanQualifierNo, FieldValueSetter setter, BeanManager manager)
+ {
+ this.beanId = syntheticBeanQualifierNo;
+ this.field = setter;
+ this.type = type;
+ this.literal = new InlineBeanQualifier.InlineBeanQualifierLiteral(beanId);
+ this.manager = manager;
+ }
+
+ public void setValue(Object instance, CreationalContext<?> ctx)
+ {
+ if (bean == null)
+ {
+ bean = manager.resolve(manager.getBeans(type, literal));
+ }
+ Object obj = manager.getReference(bean, type, ctx);
+ try
+ {
+ field.set(instance, obj);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanIdCreator.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanIdCreator.java (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanIdCreator.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,11 @@
+package org.jboss.seam.xml.fieldset;
+
+public class InlineBeanIdCreator
+{
+ static int count = 0;
+
+ public static int getId()
+ {
+ return count++;
+ }
+}
Added: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanQualifier.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanQualifier.java (rev 0)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/InlineBeanQualifier.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,61 @@
+/*
+ * 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.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.enterprise.util.AnnotationLiteral;
+import javax.inject.Qualifier;
+
+/**
+ * Internal qualifier used for inline beans
+ *
+ * @author Stuart Douglas
+ *
+ */
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.TYPE, ElementType.FIELD, ElementType.METHOD })
+public @interface InlineBeanQualifier
+{
+ int value();
+
+ static class InlineBeanQualifierLiteral extends AnnotationLiteral<InlineBeanQualifier> implements InlineBeanQualifier
+ {
+ private final int value;
+
+ public InlineBeanQualifierLiteral(int value)
+ {
+ this.value = value;
+ }
+
+ public int value()
+ {
+ return value;
+ }
+
+ }
+
+}
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/MapFieldSet.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -31,6 +31,8 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import javax.enterprise.context.spi.CreationalContext;
+
import org.jboss.seam.xml.model.EntryXmlItem;
import org.jboss.seam.xml.util.TypeReader;
import org.jboss.seam.xml.util.XmlObjectConverter;
@@ -117,7 +119,7 @@
}
- public void setValue(Object instance)
+ public void setValue(Object instance, CreationalContext<?> ctx)
{
try
{
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/fieldset/SimpleFieldValue.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -23,6 +23,10 @@
import java.lang.reflect.InvocationTargetException;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.seam.xml.model.ModelBuilder;
import org.jboss.seam.xml.util.XmlObjectConverter;
public class SimpleFieldValue implements FieldValueObject
@@ -144,7 +148,7 @@
void set(Object o) throws IllegalAccessException, InvocationTargetException;
}
- public void setValue(Object instance)
+ public void setValue(Object instance, CreationalContext<?> ctx)
{
try
{
@@ -156,4 +160,10 @@
}
}
+ public void initalize(ModelBuilder modelBuilder, BeanManager manager)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AbstractXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.Map;
+import javax.enterprise.inject.spi.BeanManager;
+
public abstract class AbstractXmlItem implements XmlItem
{
protected final XmlItemType type;
@@ -57,7 +59,7 @@
}
else
{
- this.attributes = attributes;
+ this.attributes = new HashMap<String, String>(attributes);
}
this.lineno = lineno;
this.document = document;
@@ -100,7 +102,7 @@
return javaClass;
}
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
return true;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationUtils.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationUtils.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationUtils.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -1,3 +1,26 @@
+/*
+ * JBoss, Home of Professional Opimport java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.jboss.seam.xml.util.XmlConfigurationException;
+import org.jboss.seam.xml.util.XmlObjectConverter;
+import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
+ublished 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.lang.annotation.Annotation;
@@ -10,6 +33,11 @@
import org.jboss.seam.xml.util.XmlObjectConverter;
import org.jboss.weld.extensions.util.AnnotationInstanceProvider;
+/**
+ *
+ * @author Stuart Douglas
+ *
+ */
class AnnotationUtils
{
final private static AnnotationInstanceProvider annotationInstanceProvider = new AnnotationInstanceProvider();
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -38,7 +38,7 @@
{
if (!innerText.trim().equals(""))
{
- attributes.put("value", innerText);
+ this.attributes.put("value", innerText);
}
}
allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ArrayXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -25,6 +25,8 @@
import java.util.List;
import java.util.Map;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.seam.xml.util.XmlConfigurationException;
public class ArrayXmlItem extends ParameterXmlItem
@@ -50,7 +52,7 @@
}
}
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
List<ClassXmlItem> classXmlItems = getChildrenOfType(ClassXmlItem.class);
if (classXmlItems.isEmpty())
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -32,11 +32,13 @@
import java.util.Set;
import java.util.Map.Entry;
+import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.jboss.seam.xml.core.BeanResult;
import org.jboss.seam.xml.core.BeanResultType;
+import org.jboss.seam.xml.fieldset.FieldValueObject;
import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
@@ -99,7 +101,7 @@
return values;
}
- public BeanResult<?> createBeanResult()
+ public BeanResult<?> createBeanResult(BeanManager manager)
{
boolean override = !getChildrenOfType(ReplacesXmlItem.class).isEmpty();
boolean extend = !getChildrenOfType(ModifiesXmlItem.class).isEmpty();
@@ -110,16 +112,39 @@
}
if (override)
{
- beanType = BeanResultType.OVERRIDE;
+ beanType = BeanResultType.REPLACES;
}
else if (extend)
{
- beanType = BeanResultType.SPECIALISE;
+ beanType = BeanResultType.MODIFIES;
}
+ List<BeanResult> inlineBeans = new ArrayList<BeanResult>();
+ // 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))
+ {
+ inlineBeans.addAll(xi.getInlineBeans());
+ FieldValueObject f = xi.getFieldValue();
+ if (f != null)
+ {
+ fields.add(f);
+ configuredFields.add(xi.getFieldName());
+ }
+ }
+ for (FieldValueXmlItem f : getShorthandFieldValues())
+ {
+ if (configuredFields.contains(f.getFieldName()))
+ {
+ throw new XmlConfigurationException("Field configured in two places: " + getJavaClass().getName() + "." + f.getFieldName(), getDocument(), getLineno());
+ }
+ fields.add(f.getFieldValue());
+ }
+
// if it is an extend we want to read the annotations from the underlying
// class
- BeanResult<?> result = new BeanResult(getJavaClass(), extend, beanType);
+ BeanResult<?> result = new BeanResult(getJavaClass(), extend, beanType, fields, inlineBeans);
AnnotatedTypeBuilder<?> type = result.getBuilder();
// list of constructor arguments
List<ParameterXmlItem> constList = new ArrayList<ParameterXmlItem>();
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -24,6 +24,8 @@
import java.util.HashSet;
import java.util.Set;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
@@ -48,7 +50,7 @@
}
@Override
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
if (children.size() != 2)
{
Modified: 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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldValueXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -21,6 +21,9 @@
*/
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
@@ -28,4 +31,6 @@
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -30,11 +30,15 @@
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;
@@ -48,6 +52,7 @@
FieldValueObject fieldValue;
Field field;
HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
+ List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
public FieldXmlItem(XmlItem parent, Field c, String innerText, String document, int lineno)
{
@@ -74,17 +79,17 @@
}
@Override
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
List<EntryXmlItem> mapEntries = new ArrayList<EntryXmlItem>();
- List<XmlItem> valueEntries = new ArrayList<XmlItem>();
+ List<ValueXmlItem> valueEntries = new ArrayList<ValueXmlItem>();
if (fieldValue == null)
{
for (XmlItem i : children)
{
if (i.getType() == XmlItemType.VALUE)
{
- valueEntries.add(i);
+ valueEntries.add((ValueXmlItem) i);
}
else if (i.getType() == XmlItemType.ENTRY)
{
@@ -134,7 +139,17 @@
{
throw new XmlConfigurationException("Non collection fields can only have a single <value> element Field:" + field.getDeclaringClass().getName() + '.' + field.getName(), getDocument(), getLineno());
}
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
+ 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;
@@ -173,4 +188,9 @@
{
return field.getName();
}
+
+ public Collection<? extends BeanResult> getInlineBeans()
+ {
+ return inlineBeans;
+ }
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -27,6 +27,8 @@
import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
@@ -74,7 +76,7 @@
* @param childeren
* @return
*/
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
// return true if this is not a method or there was only
// only method to choose from
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -22,7 +22,6 @@
package org.jboss.seam.xml.model;
import java.lang.annotation.Annotation;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -30,6 +29,7 @@
import java.util.Set;
import javax.enterprise.inject.Stereotype;
+import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Qualifier;
import javax.interceptor.InterceptorBinding;
@@ -37,7 +37,6 @@
import org.jboss.seam.xml.core.BeanResultType;
import org.jboss.seam.xml.core.GenericBeanResult;
import org.jboss.seam.xml.core.XmlResult;
-import org.jboss.seam.xml.fieldset.FieldValueObject;
import org.jboss.seam.xml.parser.SaxNode;
import org.jboss.seam.xml.parser.namespace.CompositeNamespaceElementResolver;
import org.jboss.seam.xml.parser.namespace.NamespaceElementResolver;
@@ -58,16 +57,20 @@
static final String BEANS_ROOT_NAMESPACE = "http://java.sun.com/xml/ns/javaee";
+ private final XmlResult ret;
+
+ public ModelBuilder(String fileUrl)
+ {
+ ret = new XmlResult(fileUrl);
+ }
+
/**
* builds an XML result from a parsed xml document
*/
- public XmlResult build(SaxNode root, String fileUrl)
+ public XmlResult build(SaxNode root, BeanManager manager)
{
-
Map<String, NamespaceElementResolver> resolvers = new HashMap<String, NamespaceElementResolver>();
- XmlResult ret = new XmlResult(fileUrl);
-
if (!root.getName().equals("beans"))
{
throw new XmlConfigurationException("Wrong root element for XML config file, expected:<beans> found:" + root.getName(), root.getDocument(), root.getLineNo());
@@ -92,9 +95,12 @@
{
continue;
}
- XmlItem rb = resolveNode(node, null, resolvers);
+ XmlItem rb = resolveNode(node, null, resolvers, manager);
// validateXmlItem(rb);
- addNodeToResult(ret, rb);
+ if (rb != null)
+ {
+ addNodeToResult(rb, manager);
+ }
}
}
catch (Exception e)
@@ -108,7 +114,7 @@
}
@SuppressWarnings("unchecked")
- private void addNodeToResult(XmlResult ret, XmlItem xmlItem)
+ public void addNodeToResult(XmlItem xmlItem, BeanManager manager)
{
validateXmlItem(xmlItem);
if (xmlItem.getType() == XmlItemType.CLASS || xmlItem.getType() == XmlItemType.ANNOTATION)
@@ -119,46 +125,14 @@
{
ClassXmlItem cxml = (ClassXmlItem) xmlItem;
// get the AnnotatedType information
- BeanResult<?> beanResult = cxml.createBeanResult();
+ BeanResult<?> beanResult = cxml.createBeanResult(manager);
ret.addBean(beanResult);
// <override> or <speciailizes> need to veto the bean
if (beanResult.getBeanType() != BeanResultType.ADD)
{
ret.addVeto(beanResult.getType());
}
- // get all the field values from the bean
- Set<String> configuredFields = new HashSet<String>();
- List<FieldValueObject> fields = new ArrayList<FieldValueObject>();
- for (FieldValueXmlItem xi : cxml.getChildrenOfType(FieldValueXmlItem.class))
- {
- FieldValueObject f = xi.getFieldValue();
- if (f != null)
- {
- fields.add(f);
- configuredFields.add(xi.getFieldName());
- }
- }
- for (FieldValueXmlItem f : cxml.getShorthandFieldValues())
- {
- if (configuredFields.contains(f.getFieldName()))
- {
- throw new XmlConfigurationException("Field configured in two places: " + cxml.getJavaClass().getName() + "." + f.getFieldName(), cxml.getDocument(), cxml.getLineno());
- }
- fields.add(f.getFieldValue());
- }
-
- if (!fields.isEmpty())
- {
- if (xmlItem.getJavaClass().isInterface())
- {
- ret.addInterfaceFieldValues(beanResult.getType(), fields);
- }
- else
- {
- ret.addFieldValue(beanResult, fields);
- }
- }
}
else if (resultType == ResultType.QUALIFIER)
{
@@ -180,7 +154,7 @@
Set<BeanResult<?>> classes = new HashSet<BeanResult<?>>();
for (ClassXmlItem c : xmlItem.getChildrenOfType(ClassXmlItem.class))
{
- BeanResult<?> br = c.createBeanResult();
+ BeanResult<?> br = c.createBeanResult(manager);
if (br.getBeanType() != BeanResultType.ADD)
{
ret.addVeto(br.getType());
@@ -194,10 +168,13 @@
/**
* resolves the appropriate java elements from the xml
*/
- protected XmlItem resolveNode(SaxNode node, XmlItem parent, Map<String, NamespaceElementResolver> resolvers)
+ protected XmlItem resolveNode(SaxNode node, XmlItem parent, Map<String, NamespaceElementResolver> resolvers, BeanManager manager)
{
NamespaceElementResolver resolver = resolveNamepsace(node.getNamespaceUri(), resolvers);
-
+ if (resolver == null)
+ {
+ return null;
+ }
XmlItem ret = resolver.getItemForNamespace(node, parent);
if (ret == null)
@@ -209,11 +186,11 @@
{
if (n.getNamespaceUri() != null)
{
- XmlItem rb = resolveNode(n, ret, resolvers);
+ XmlItem rb = resolveNode(n, ret, resolvers, manager);
ret.addChild(rb);
}
}
- ret.resolveChildren();
+ ret.resolveChildren(manager);
return ret;
}
@@ -224,6 +201,10 @@
{
return resolvers.get(namespaceURI);
}
+ if (!namespaceURI.startsWith("urn:java:"))
+ {
+ return null;
+ }
String ns = namespaceURI.replaceFirst("urn:java:", "");
CompositeNamespaceElementResolver res = new CompositeNamespaceElementResolver(ns.split(":"));
resolvers.put(namespaceURI, res);
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -29,10 +29,14 @@
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;
@@ -47,6 +51,7 @@
String name;
Class<?> type;
HashSet<TypeOccuranceInformation> allowed = new HashSet<TypeOccuranceInformation>();
+ List<BeanResult<?>> inlineBeans = new ArrayList<BeanResult<?>>();
public PropertyXmlItem(XmlItem parent, String name, Method setter, String innerText, String document, int lineno)
{
@@ -68,17 +73,17 @@
}
@Override
- public boolean resolveChildren()
+ public boolean resolveChildren(BeanManager manager)
{
List<EntryXmlItem> mapEntries = new ArrayList<EntryXmlItem>();
- List<XmlItem> valueEntries = new ArrayList<XmlItem>();
+ List<ValueXmlItem> valueEntries = new ArrayList<ValueXmlItem>();
if (fieldValue == null)
{
for (XmlItem i : children)
{
if (i.getType() == XmlItemType.VALUE)
{
- valueEntries.add(i);
+ valueEntries.add((ValueXmlItem) i);
}
else if (i.getType() == XmlItemType.ENTRY)
{
@@ -128,7 +133,17 @@
{
throw new XmlConfigurationException("Non collection fields can only have a single <value> element Field:" + parent.getJavaClass().getName() + '.' + name, getDocument(), getLineno());
}
- fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter, valueEntries.get(0).getInnerText());
+ 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;
@@ -144,4 +159,8 @@
return name;
}
+ public Collection<? extends BeanResult> getInlineBeans()
+ {
+ return inlineBeans;
+ }
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -22,12 +22,20 @@
package org.jboss.seam.xml.model;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.seam.xml.core.BeanResult;
+import org.jboss.seam.xml.fieldset.InlineBeanIdCreator;
+import org.jboss.seam.xml.fieldset.InlineBeanQualifier;
import org.jboss.seam.xml.util.TypeOccuranceInformation;
+import org.jboss.seam.xml.util.XmlConfigurationException;
public class ValueXmlItem extends AbstractXmlItem
{
+ int syntheticQualifierId;
public ValueXmlItem(XmlItem parent, String innerText, String document, int lineno)
{
@@ -39,4 +47,29 @@
return Collections.singleton(TypeOccuranceInformation.of(XmlItemType.CLASS, null, 1));
}
+ public BeanResult<?> getBeanResult(BeanManager manager)
+ {
+ List<ClassXmlItem> inlineBeans = getChildrenOfType(ClassXmlItem.class);
+ if (!inlineBeans.isEmpty())
+ {
+ ClassXmlItem inline = inlineBeans.get(0);
+ for (AnnotationXmlItem i : inline.getChildrenOfType(AnnotationXmlItem.class))
+ {
+ if (manager.isQualifier((Class) i.getJavaClass()))
+ {
+ throw new XmlConfigurationException("Cannot define qualifiers on inline beans", i.getDocument(), i.getLineno());
+ }
+ }
+ syntheticQualifierId = InlineBeanIdCreator.getId();
+ AnnotationXmlItem syntheticQualifier = new AnnotationXmlItem(this, InlineBeanQualifier.class, "" + syntheticQualifierId, Collections.EMPTY_MAP, getDocument(), getLineno());
+ inline.addChild(syntheticQualifier);
+ return inline.createBeanResult(manager);
+ }
+ return null;
+ }
+
+ public int getSyntheticQualifierId()
+ {
+ return syntheticQualifierId;
+ }
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -24,6 +24,8 @@
import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.spi.BeanManager;
+
import org.jboss.seam.xml.util.TypeOccuranceInformation;
public interface XmlItem
@@ -47,7 +49,7 @@
* @param childeren
* @return
*/
- public boolean resolveChildren();
+ public boolean resolveChildren(BeanManager manager);
public Set<TypeOccuranceInformation> getAllowedItem();
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java 2010-07-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -1,3 +1,24 @@
+/*
+ * 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.util;
import java.util.Set;
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-25 04:43:53 UTC (rev 13498)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -67,7 +67,7 @@
XmlItem method = resolver.getItemForNamespace(new SaxNode("method1", null, null, null, null, 0), item);
Assert.assertTrue("Item returned wrong type", method.getType() == XmlItemType.METHOD);
- method.resolveChildren();
+ method.resolveChildren(null);
Assert.assertTrue("Could not resolve method", ((MethodXmlItem) method).getMethod() != null);
Assert.assertTrue("Wrong method was resolved", ((MethodXmlItem) method).getMethod().getParameterTypes().length == 0);
Added: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Horse.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Horse.java (rev 0)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Horse.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,48 @@
+/*
+ * 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.test.fieldset;
+
+public class Horse
+{
+ private HorseShoe shoe;
+ private String name;
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public HorseShoe getShoe()
+ {
+ return shoe;
+ }
+
+ public void setShoe(HorseShoe shoe)
+ {
+ this.shoe = shoe;
+ }
+}
Added: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/HorseShoe.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/HorseShoe.java (rev 0)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/HorseShoe.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,27 @@
+/*
+ * 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.test.fieldset;
+
+public class HorseShoe
+{
+
+}
Added: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/InlineBeanFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/InlineBeanFieldValueBeanTest.java (rev 0)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/InlineBeanFieldValueBeanTest.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,47 @@
+/*
+ * 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.test.fieldset;
+
+import junit.framework.Assert;
+
+import org.jboss.seam.xml.test.AbstractXMLTest;
+import org.junit.Test;
+
+public class InlineBeanFieldValueBeanTest extends AbstractXMLTest
+{
+
+ @Override
+ protected String getXmlFileName()
+ {
+ return "inline-bean-field-value-beans.xml";
+ }
+
+ @Test
+ public void simpleInlineBeanTest()
+ {
+ Knight knight = getReference(Knight.class, org.jboss.weld.literal.DefaultLiteral.INSTANCE);
+ Assert.assertTrue(knight.getSword().getType().equals("sharp"));
+ Assert.assertTrue(knight.getHorse().getShoe() != null);
+ Assert.assertTrue(knight.getHorse().getName().equals("billy"));
+ }
+
+}
Added: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Knight.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Knight.java (rev 0)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Knight.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,52 @@
+/*
+ * 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.test.fieldset;
+
+import org.jboss.weld.extensions.core.Veto;
+
+@Veto
+public class Knight
+{
+ Sword sword;
+
+ Horse horse;
+
+ public Sword getSword()
+ {
+ return sword;
+ }
+
+ public void setSword(Sword sword)
+ {
+ this.sword = sword;
+ }
+
+ public Horse getHorse()
+ {
+ return horse;
+ }
+
+ public void setHorse(Horse horse)
+ {
+ this.horse = horse;
+ }
+}
Added: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Sword.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Sword.java (rev 0)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/Sword.java 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,38 @@
+/*
+ * 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.test.fieldset;
+
+public class Sword
+{
+ String type;
+
+ public String getType()
+ {
+ return type;
+ }
+
+ public void setType(String type)
+ {
+ this.type = type;
+ }
+
+}
Added: modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/inline-bean-field-value-beans.xml
===================================================================
--- modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/inline-bean-field-value-beans.xml (rev 0)
+++ modules/xml/trunk/impl/src/test/resources/org/jboss/seam/xml/test/fieldset/inline-bean-field-value-beans.xml 2010-07-25 08:15:58 UTC (rev 13499)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="urn:java:ee"
+ xmlns:test="urn:java:org.jboss.seam.xml.test.fieldset">
+
+ <test:Knight>
+
+ <test:sword>
+ <value>
+ <test:Sword type="sharp"/>
+ </value>
+ </test:sword>
+
+ <test:horse>
+ <value>
+ <test:Horse>
+ <test:name>
+ <value>billy</value>
+ </test:name>
+ <test:shoe>
+ <Inject/>
+ </test:shoe>
+ </test:Horse>
+ </value>
+ </test:horse>
+
+ </test:Knight>
+
+</beans>
\ No newline at end of file
14 years, 5 months
Seam SVN: r13498 - in modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test: constructor and 9 other directories.
by seam-commits@lists.jboss.org
Author: swd847
Date: 2010-07-25 00:43:53 -0400 (Sun, 25 Jul 2010)
New Revision: 13498
Modified:
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/BootstrapTest.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/constructor/ConstructorTest.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/SetFieldValueBeanTest.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/generic/GenericBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/ProducerFieldValueBeanTest.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/interceptor/InterceptorTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/method/PrimitiveMethodTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/producer/MultipleProducerBeanTest.java
modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/simple/SimpleBeanTest.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
Log:
replace assert with Assert.assertTrue
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/BootstrapTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/BootstrapTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/BootstrapTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -23,6 +23,8 @@
import java.util.List;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.bootstrap.XmlDocumentProvider;
import org.jboss.seam.xml.bootstrap.XmlExtension;
import org.junit.Test;
@@ -35,7 +37,7 @@
{
XmlExtension extension = getReference(XmlExtension.class);
List<Class<? extends XmlDocumentProvider>> providers = extension.getDocumentProviders();
- assert providers.size() == 2;
+ Assert.assertTrue(providers.size() == 2);
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/NamespaceResolverTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -24,6 +24,8 @@
import java.util.ArrayList;
import java.util.List;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.model.FieldXmlItem;
import org.jboss.seam.xml.model.MethodXmlItem;
import org.jboss.seam.xml.model.XmlItem;
@@ -60,19 +62,19 @@
{
XmlItem item = resolver.getItemForNamespace(new SaxNode("Bean1", null, null, null, null, 0), null);
- assert item.getJavaClass() == Bean1.class : "Namespace resolver returned wrong class type";
- assert item.getType() == XmlItemType.CLASS : "Namespace resolver did not return class";
+ Assert.assertTrue("Namespace resolver returned wrong class type", item.getJavaClass() == Bean1.class);
+ Assert.assertTrue("Namespace resolver did not return class", item.getType() == XmlItemType.CLASS);
XmlItem method = resolver.getItemForNamespace(new SaxNode("method1", null, null, null, null, 0), item);
- assert method.getType() == XmlItemType.METHOD : "Item returned wrong type";
+ Assert.assertTrue("Item returned wrong type", method.getType() == XmlItemType.METHOD);
method.resolveChildren();
- assert ((MethodXmlItem) method).getMethod() != null : "Could not resolve method";
- assert ((MethodXmlItem) method).getMethod().getParameterTypes().length == 0 : "Wrong method was resolved";
+ Assert.assertTrue("Could not resolve method", ((MethodXmlItem) method).getMethod() != null);
+ 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 ((FieldXmlItem) field).getType() == XmlItemType.FIELD : "Element of wrong type returned";
- assert ((FieldXmlItem) field).getField() != null : "field was not set";
+ Assert.assertTrue("Element of wrong type returned", ((FieldXmlItem) 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/constructor/ConstructorTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/constructor/ConstructorTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/constructor/ConstructorTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.constructor;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -36,7 +38,7 @@
public void testBeanConstructorAnnotations()
{
ConstructedBean bean = getReference(ConstructedBean.class);
- assert bean.getValue() == 10;
+ Assert.assertTrue(bean.getValue() == 10);
}
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetArrayFieldValueBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.fieldset;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
@@ -38,15 +40,15 @@
public void arrayFieldSetterTest()
{
ArrayFieldValue x = WeldManagerUtils.getInstanceByType(manager, ArrayFieldValue.class);
- assert x.carray.length == 2;
- assert x.iarray.length == 2;
- assert x.sarray.length == 2;
- assert x.sarray[0].equals("hello");
- assert x.sarray[1].equals("world");
- assert x.iarray[0] == 1;
- assert x.iarray[1] == 2;
- assert x.carray[0] == Integer.class;
- assert x.carray[1] == Long.class;
+ Assert.assertTrue(x.carray.length == 2);
+ Assert.assertTrue(x.iarray.length == 2);
+ Assert.assertTrue(x.sarray.length == 2);
+ Assert.assertTrue(x.sarray[0].equals("hello"));
+ Assert.assertTrue(x.sarray[1].equals("world"));
+ Assert.assertTrue(x.iarray[0] == 1);
+ Assert.assertTrue(x.iarray[1] == 2);
+ Assert.assertTrue(x.carray[0] == Integer.class);
+ Assert.assertTrue(x.carray[1] == Long.class);
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetCollectionFieldValueBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.fieldset;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
@@ -38,20 +40,20 @@
public void collectionSetFieldValue()
{
CollectionFieldValue x = WeldManagerUtils.getInstanceByType(manager, CollectionFieldValue.class);
- assert x.iset.size() == 2;
- assert x.clist.size() == 2;
- assert x.sset.size() == 2;
+ Assert.assertTrue(x.iset.size() == 2);
+ Assert.assertTrue(x.clist.size() == 2);
+ Assert.assertTrue(x.sset.size() == 2);
boolean first = true;
for (String i : x.sset)
{
if (first)
{
- assert i.equals("1");
+ Assert.assertTrue(i.equals("1"));
first = false;
}
else
{
- assert i.equals("2");
+ Assert.assertTrue(i.equals("2"));
}
}
@@ -60,17 +62,17 @@
{
if (first)
{
- assert i.equals(new Integer(1));
+ Assert.assertTrue(i.equals(new Integer(1)));
first = false;
}
else
{
- assert i.equals(new Integer(2));
+ Assert.assertTrue(i.equals(new Integer(2)));
}
}
- assert x.clist.get(0) == Integer.class;
- assert x.clist.get(1) == Long.class;
+ Assert.assertTrue(x.clist.get(0) == Integer.class);
+ Assert.assertTrue(x.clist.get(1) == Long.class);
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetFieldValueBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -25,6 +25,8 @@
import javax.enterprise.util.AnnotationLiteral;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.seam.xml.test.method.QualifierEnum;
import org.junit.Test;
@@ -42,15 +44,15 @@
public void simpleFieldSetterTest()
{
FieldValueBean x = getReference(FieldValueBean.class);
- assert x.bigDecimalValue.compareTo(BigDecimal.TEN) == 0;
- assert x.bvalue == true;
- assert x.dvalue == 0;
- assert x.enumValue == QualifierEnum.A;
- assert x.fvalue == 0;
- assert x.getIvalue() == 11;
- assert x.lvalue == 23;
- assert x.svalue == 4;
- assert x.noFieldValue == 7;
+ Assert.assertTrue(x.bigDecimalValue.compareTo(BigDecimal.TEN) == 0);
+ Assert.assertTrue(x.bvalue == true);
+ Assert.assertTrue(x.dvalue == 0);
+ Assert.assertTrue(x.enumValue == QualifierEnum.A);
+ Assert.assertTrue(x.fvalue == 0);
+ Assert.assertTrue(x.getIvalue() == 11);
+ Assert.assertTrue(x.lvalue == 23);
+ Assert.assertTrue(x.svalue == 4);
+ Assert.assertTrue(x.noFieldValue == 7);
}
@@ -60,15 +62,15 @@
FieldValueBean x = getReference(FieldValueBean.class, new AnnotationLiteral<FieldsetQualifier>()
{
});
- assert x.bigDecimalValue.compareTo(BigDecimal.TEN) == 0;
- assert x.bvalue == true;
- assert x.dvalue == 0;
- assert x.enumValue == QualifierEnum.A;
- assert x.fvalue == 0;
- assert x.getIvalue() == 11;
- assert x.lvalue == 23;
- assert x.svalue == 4;
- assert x.noFieldValue == 7;
+ Assert.assertTrue(x.bigDecimalValue.compareTo(BigDecimal.TEN) == 0);
+ Assert.assertTrue(x.bvalue == true);
+ Assert.assertTrue(x.dvalue == 0);
+ Assert.assertTrue(x.enumValue == QualifierEnum.A);
+ Assert.assertTrue(x.fvalue == 0);
+ Assert.assertTrue(x.getIvalue() == 11);
+ Assert.assertTrue(x.lvalue == 23);
+ Assert.assertTrue(x.svalue == 4);
+ Assert.assertTrue(x.noFieldValue == 7);
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/fieldset/SetMapFieldValueBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.fieldset;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
@@ -38,13 +40,13 @@
public void mapSetFieldValue()
{
MapFieldValue x = WeldManagerUtils.getInstanceByType(manager, MapFieldValue.class);
- assert x.map1.size() == 2;
- assert x.map2.size() == 2;
+ Assert.assertTrue(x.map1.size() == 2);
+ Assert.assertTrue(x.map2.size() == 2);
- assert x.map1.get(1).equals("hello");
- assert x.map1.get(2).equals("world");
- assert x.map2.get("1") == Integer.class;
- assert x.map2.get("2") == Long.class;
+ Assert.assertTrue(x.map1.get(1).equals("hello"));
+ Assert.assertTrue(x.map1.get(2).equals("world"));
+ Assert.assertTrue(x.map2.get("1") == Integer.class);
+ Assert.assertTrue(x.map2.get("2") == Long.class);
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/generic/GenericBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -23,6 +23,8 @@
import javax.enterprise.util.AnnotationLiteral;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -45,7 +47,7 @@
dep = getReference(GenericDependant.class, new AnnotationLiteral<LowGenericQualifier>()
{
});
- assert dep.getValue() == 11 : " actual " + dep.getValue();
+ Assert.assertTrue(" actual " + dep.getValue(), dep.getValue() == 11);
}
@Test
@@ -54,15 +56,15 @@
GenericDependant dep = getReference(GenericDependant.class, new AnnotationLiteral<HighGenericQualifier>()
{
});
- assert dep.initCalled;
+ Assert.assertTrue(dep.initCalled);
dep = getReference(GenericDependant.class, new AnnotationLiteral<LowGenericQualifier>()
{
});
- assert dep.initCalled;
+ Assert.assertTrue(dep.initCalled);
GenericMain main = getReference(GenericMain.class, new AnnotationLiteral<LowGenericQualifier>()
{
});
- assert main.init;
+ Assert.assertTrue(main.init);
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/ProducerFieldValueBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/ProducerFieldValueBeanTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/ProducerFieldValueBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.injection;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -38,7 +40,7 @@
{
RecieverBean s = getReference(RecieverBean.class);
- assert s.value.equals("hello world");
+ Assert.assertTrue(s.value.equals("hello world"));
}
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/injection/QualifierAttributesTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.injection;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
@@ -41,8 +43,8 @@
public void tstQualifiersWithAttributes()
{
QualifierTestBean x = WeldManagerUtils.getInstanceByType(manager, QualifierTestBean.class);
- assert x.bean1.getBeanNumber() == 1;
- assert x.bean2.getBeanNumber() == 2;
+ 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/interceptor/InterceptorTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/interceptor/InterceptorTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.interceptor;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -39,7 +41,7 @@
InterceptedBean x = getReference(InterceptedBean.class);
String res = x.method();
- assert res.equals("hello world");
+ Assert.assertTrue(res.equals("hello world"));
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/method/PrimitiveMethodTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/method/PrimitiveMethodTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/method/PrimitiveMethodTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -23,6 +23,8 @@
import javax.enterprise.util.AnnotationLiteral;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -39,11 +41,11 @@
public void methodTest()
{
int x = getReference(int.class, new Qual1Lit());
- assert x == 1;
+ Assert.assertTrue(x == 1);
int[] y = getReference(int[].class, new Qual2Lit());
for (int i = 0; i < y.length; ++i)
{
- assert y[i] == i + 2;
+ Assert.assertTrue(y[i] == i + 2);
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/producer/MultipleProducerBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/producer/MultipleProducerBeanTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/producer/MultipleProducerBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.producer;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -38,8 +40,8 @@
{
Reciever s = getReference(Reciever.class);
- assert s.val1 == 1;
- assert s.val2 == 2;
+ Assert.assertTrue(s.val1 == 1);
+ Assert.assertTrue(s.val2 == 2);
}
@Test
@@ -47,7 +49,7 @@
{
Reciever s = getReference(Reciever.class);
- assert s.meth1 == 1;
- assert s.meth2 == 2;
+ Assert.assertTrue(s.meth1 == 1);
+ Assert.assertTrue(s.meth2 == 2);
}
}
Modified: modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/simple/SimpleBeanTest.java
===================================================================
--- modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/simple/SimpleBeanTest.java 2010-07-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/simple/SimpleBeanTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -26,6 +26,8 @@
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.util.AnnotationLiteral;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.junit.Test;
@@ -45,20 +47,20 @@
public void simpleBeanTest()
{
Bean1 x = getReference(Bean1.class);
- assert x != null;
- assert x.bean2 != null;
+ Assert.assertTrue(x != null);
+ Assert.assertTrue(x.bean2 != null);
Bean3 y = getReference(Bean3.class);
- assert y != null;
- assert x.value == 1 : "Post construct method not called";
+ Assert.assertTrue(y != null);
+ Assert.assertTrue("Post construct method not called", x.value == 1);
}
@Test
public void testOverride()
{
Set<Bean<?>> beans = manager.getBeans(OverriddenBean.class);
- assert beans.size() == 1;
- assert beans.iterator().next().getName().equals("someBean");
+ Assert.assertTrue(beans.size() == 1);
+ Assert.assertTrue(beans.iterator().next().getName().equals("someBean"));
}
@@ -73,7 +75,7 @@
};
ExtendedBean ext = getReference(ExtendedBean.class, e1, e2);
- assert ext != null;
+ Assert.assertTrue(ext != null);
}
}
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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/stereotype/StereotypeTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.stereotype;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.seam.xml.test.interceptor.InterceptedBean;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
@@ -45,7 +47,7 @@
InterceptedBean x = WeldManagerUtils.getInstanceByType(manager, InterceptedBean.class);
String res = x.method();
- assert res.equals("hello world");
+ 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-25 03:50:38 UTC (rev 13497)
+++ modules/xml/trunk/impl/src/test/java/org/jboss/seam/xml/test/types/TypesTest.java 2010-07-25 04:43:53 UTC (rev 13498)
@@ -21,6 +21,8 @@
*/
package org.jboss.seam.xml.test.types;
+import junit.framework.Assert;
+
import org.jboss.seam.xml.test.AbstractXMLTest;
import org.jboss.weld.environment.se.util.WeldManagerUtils;
import org.junit.Test;
@@ -42,8 +44,8 @@
{
TypeInjectedClass x = WeldManagerUtils.getInstanceByType(manager, TypeInjectedClass.class);
- assert x.value instanceof AllowedType;
- assert x.createValue instanceof RestrictedType;
+ Assert.assertTrue(x.value instanceof AllowedType);
+ Assert.assertTrue(x.createValue instanceof RestrictedType);
}
}
14 years, 5 months