[jboss-cvs] JBossAS SVN: r97254 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers and 8 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Dec 1 12:55:21 EST 2009
Author: jesper.pedersen
Date: 2009-12-01 12:55:21 -0500 (Tue, 01 Dec 2009)
New Revision: 97254
Added:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Failure.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/FailureHelper.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Rule.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Severity.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Validator.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/package.html
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFEquals.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFHashCode.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/package.html
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/package.html
projects/jboss-jca/trunk/deployers/src/main/resources/validator.properties
Modified:
projects/jboss-jca/trunk/deployers/build.xml
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java
projects/jboss-jca/trunk/doc/userguide/en/modules/configuration.xml
Log:
[JBJCA-201] Add verifier - 1st draft
Modified: projects/jboss-jca/trunk/deployers/build.xml
===================================================================
--- projects/jboss-jca/trunk/deployers/build.xml 2009-12-01 17:37:42 UTC (rev 97253)
+++ projects/jboss-jca/trunk/deployers/build.xml 2009-12-01 17:55:21 UTC (rev 97254)
@@ -69,12 +69,17 @@
<copy todir="${build.deployers.dir}/jars/rar">
<fileset dir="${build.deployers.dir}/impl"
- includes="**/mc/rar/**"/>
+ includes="**/common/**,**/mc/rar/**"/>
</copy>
<copy file="src/main/resources/jca-deployers-jboss-beans.xml"
tofile="${build.deployers.dir}/jars/rar/META-INF/jboss-beans.xml"/>
+ <copy todir="${build.deployers.dir}/jars/rar">
+ <fileset dir="src/main/resources/"
+ includes="**/*.properties"/>
+ </copy>
+
<jar destfile="${target.dir}/jboss-jca-deployers-rar.jar"
manifest="src/main/resources/rar-manifest.mf"
basedir="${build.deployers.dir}/jars/rar"/>
@@ -84,9 +89,14 @@
<copy todir="${build.deployers.dir}/jars/fungal">
<fileset dir="${build.deployers.dir}/impl"
- includes="**/fungal/**"/>
+ includes="**/common/**,**/fungal/**"/>
</copy>
+ <copy todir="${build.deployers.dir}/jars/fungal">
+ <fileset dir="src/main/resources/"
+ includes="**/*.properties"/>
+ </copy>
+
<jar destfile="${target.dir}/jboss-jca-deployers-fungal.jar"
manifest="src/main/resources/fungal-ra-manifest.mf"
basedir="${build.deployers.dir}/jars/fungal"/>
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Failure.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Failure.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Failure.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,165 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator;
+
+import java.util.ResourceBundle;
+
+/**
+ * Failure
+ */
+public class Failure
+{
+ /** New line character */
+ private static final String NEW_LINE = System.getProperty("line.separator");
+
+ /** Severity */
+ private int severity;
+
+ /** Section */
+ private String section;
+
+ /** Description */
+ private String description;
+
+ /** Code */
+ private String code;
+
+ /**
+ * Constructor
+ * @param severity The severity
+ * @param section The section
+ * @param description The description
+ */
+ public Failure(int severity,
+ String section,
+ String description)
+ {
+ this(severity, section, description, null);
+ }
+
+ /**
+ * Constructor
+ * @param severity The severity
+ * @param section The section
+ * @param description The description
+ * @param code The code
+ */
+ public Failure(int severity,
+ String section,
+ String description,
+ String code)
+ {
+ this.severity = severity;
+ this.section = section;
+ this.description = description;
+ this.code = code;
+ }
+
+ /**
+ * Get the severity
+ * @return The severity
+ */
+ public int getSeverity()
+ {
+ return severity;
+ }
+
+ /**
+ * Get the section
+ * @return The section
+ */
+ public String getSection()
+ {
+ return section;
+ }
+
+ /**
+ * Get the description
+ * @return The description
+ */
+ public String getDescription()
+ {
+ return description;
+ }
+
+ /**
+ * Get the code
+ * @return The code
+ */
+ public String getCode()
+ {
+ return code;
+ }
+
+ /**
+ * As text
+ * @param rb The resource bundle
+ * @return The text representation
+ */
+ public String asText(ResourceBundle rb)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb = sb.append(rb.getString("severity"));
+ sb = sb.append(": ");
+ if (severity == Severity.WARNING)
+ {
+ sb = sb.append(rb.getString("severity.warn"));
+ }
+ else
+ {
+ sb = sb.append(rb.getString("severity.error"));
+ }
+ sb = sb.append(NEW_LINE);
+
+ sb = sb.append(rb.getString("section"));
+ sb = sb.append(": ");
+ sb = sb.append(section);
+ sb = sb.append(NEW_LINE);
+
+ sb = sb.append(rb.getString("description"));
+ sb = sb.append(": ");
+ sb = sb.append(description);
+ sb = sb.append(NEW_LINE);
+
+ if (code != null)
+ {
+ sb = sb.append(rb.getString("code"));
+ sb = sb.append(": ");
+ sb = sb.append(code);
+ sb = sb.append(NEW_LINE);
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * As XML
+ * @param rb The resource bundle
+ * @return The XML representation
+ */
+ public String asXML(ResourceBundle rb)
+ {
+ return "";
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/FailureHelper.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/FailureHelper.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/FailureHelper.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator;
+
+import java.util.List;
+import java.util.ResourceBundle;
+
+/**
+ * Failure helper
+ */
+public class FailureHelper
+{
+ /** New line character */
+ private static final String NEW_LINE = System.getProperty("line.separator");
+
+ /** List of failures */
+ private List<Failure> failures;
+
+ /**
+ * Constructor
+ * @param failures The list of failures
+ */
+ public FailureHelper(List<Failure> failures)
+ {
+ this.failures = failures;
+ }
+
+ /**
+ * As text
+ * @param rb The resource bundle
+ * @return The text representation
+ */
+ public String asText(ResourceBundle rb)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (failures != null)
+ {
+ // PRE-TEXT
+
+ for (int i = 0; i < failures.size(); i++)
+ {
+ Failure f = failures.get(i);
+
+ sb = sb.append(f.asText(rb));
+
+ if (i < failures.size() - 1)
+ sb = sb.append(NEW_LINE);
+ }
+
+ // POST-TEXT
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * As XML
+ * @param rb The resource bundle
+ * @return The XML representation
+ */
+ public String asXML(ResourceBundle rb)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (failures != null)
+ {
+ // PRE-XML
+
+ for (int i = 0; i < failures.size(); i++)
+ {
+ Failure f = failures.get(i);
+
+ sb = sb.append(f.asXML(rb));
+
+ if (i < failures.size() - 1)
+ sb = sb.append(NEW_LINE);
+ }
+
+ // POST-XML
+ }
+
+ return sb.toString();
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Rule.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Rule.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Rule.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator;
+
+import java.util.List;
+import java.util.ResourceBundle;
+
+/**
+ * Rule
+ */
+public interface Rule
+{
+ /**
+ * Validate
+ * @param obj The object
+ * @param rb The resource bundle
+ * @return The list of failures found; <code>null</code> if none
+ */
+ public List<Failure> validate(Object obj, ResourceBundle rb);
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Severity.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Severity.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Severity.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator;
+
+/**
+ * Severity
+ */
+public class Severity
+{
+ /** WARNING */
+ public static final int WARNING = 0;
+
+ /** ERROR */
+ public static final int ERROR = 1;
+
+ /**
+ * Constructor
+ */
+ private Severity()
+ {
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Validator.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Validator.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/Validator.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * Validator
+ */
+public class Validator
+{
+ /**
+ * The fully qualified class name of the rules
+ * as we may want to externalize them into a
+ * properties file
+ */
+ private static final String[] RULES = {
+ "org.jboss.jca.deployers.common.validator.rules.mcf.MCFHashCode",
+ "org.jboss.jca.deployers.common.validator.rules.mcf.MCFEquals"
+ };
+
+ /**
+ * Constructor
+ */
+ public Validator()
+ {
+ }
+
+ /**
+ * Get the resource bundle
+ * @return The resource bundle
+ */
+ public ResourceBundle getResourceBundle()
+ {
+ return ResourceBundle.getBundle("validator", Locale.US, Validator.class.getClassLoader());
+ }
+
+ /**
+ * Validate
+ * @param url The URL of the resource adapter archive
+ * @return The list of failures; <code>null</code> if no errors
+ */
+ public List<Failure> validate(URL url)
+ {
+ Object[] objects = null;
+
+ // TODO
+
+ return validate(objects);
+ }
+
+ /**
+ * Validate
+ * @param objects Objects that should be validated
+ * @return The list of failures; <code>null</code> if no errors
+ */
+ public List<Failure> validate(Object[] objects)
+ {
+ if (objects == null || objects.length == 0)
+ return null;
+
+ List<Rule> rules = new ArrayList<Rule>(RULES.length);
+
+ for (int i = 0; i < RULES.length; i++)
+ {
+ try
+ {
+ Class clz = Class.forName(RULES[i], true, Validator.class.getClassLoader());
+ Rule rule = (Rule)clz.newInstance();
+
+ rules.add(rule);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ ResourceBundle resourceBundle = getResourceBundle();
+
+ List<Failure> result = null;
+
+ for (Rule rule : rules)
+ {
+ for (Object obj : objects)
+ {
+ List<Failure> failures = rule.validate(obj, resourceBundle);
+
+ if (failures != null)
+ {
+ if (result == null)
+ result = new ArrayList<Failure>();
+
+ result.addAll(failures);
+ }
+ }
+ }
+
+ return result;
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/package.html
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/package.html (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/package.html 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,3 @@
+<body>
+This package contains the specification validator module
+</body>
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFEquals.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFEquals.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFEquals.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator.rules.mcf;
+
+import org.jboss.jca.deployers.common.validator.Failure;
+import org.jboss.jca.deployers.common.validator.Rule;
+import org.jboss.jca.deployers.common.validator.Severity;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * ManagedConnectionFactory must have an equals implementation
+ */
+public class MCFEquals implements Rule
+{
+ /** Section */
+ private static final String SECTION = "6.5.3.2";
+
+ /**
+ * Constructor
+ */
+ public MCFEquals()
+ {
+ }
+
+ /**
+ * Validate
+ * @param obj The object
+ * @param rb The resource bundle
+ * @return The list of failures found; <code>null</code> if none
+ */
+ @SuppressWarnings("unchecked")
+ public List<Failure> validate(Object obj, ResourceBundle rb)
+ {
+ if (obj != null && obj instanceof ManagedConnectionFactory)
+ {
+ boolean error = true;
+ Class clz = obj.getClass();
+
+ while (error && !clz.equals(Object.class))
+ {
+ try
+ {
+ Method equals = clz.getDeclaredMethod("equals", new Class[] {Object.class});
+ if (equals != null)
+ error = false;
+ }
+ catch (Exception e)
+ {
+ clz = clz.getSuperclass();
+ }
+ }
+
+ if (error)
+ {
+ List<Failure> failures = new ArrayList<Failure>(1);
+
+ Failure failure = new Failure(Severity.ERROR,
+ SECTION,
+ rb.getString("mcf.MCFEquals"),
+ obj.getClass().getName());
+ failures.add(failure);
+
+ return failures;
+ }
+ }
+
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFHashCode.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFHashCode.java (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/MCFHashCode.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.jca.deployers.common.validator.rules.mcf;
+
+import org.jboss.jca.deployers.common.validator.Failure;
+import org.jboss.jca.deployers.common.validator.Rule;
+import org.jboss.jca.deployers.common.validator.Severity;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+
+import javax.resource.spi.ManagedConnectionFactory;
+
+/**
+ * ManagedConnectionFactory must have a hashCode implementation
+ */
+public class MCFHashCode implements Rule
+{
+ /** Section */
+ private static final String SECTION = "6.5.3.2";
+
+ /**
+ * Constructor
+ */
+ public MCFHashCode()
+ {
+ }
+
+ /**
+ * Validate
+ * @param obj The object
+ * @param rb The resource bundle
+ * @return The list of failures found; <code>null</code> if none
+ */
+ @SuppressWarnings("unchecked")
+ public List<Failure> validate(Object obj, ResourceBundle rb)
+ {
+ if (obj != null && obj instanceof ManagedConnectionFactory)
+ {
+ boolean error = true;
+ Class clz = obj.getClass();
+
+ while (error && !clz.equals(Object.class))
+ {
+ try
+ {
+ Method hashCode = clz.getDeclaredMethod("hashCode", (Class[])null);
+ if (hashCode != null)
+ error = false;
+ }
+ catch (Exception e)
+ {
+ clz = clz.getSuperclass();
+ }
+ }
+
+ if (error)
+ {
+ List<Failure> failures = new ArrayList<Failure>(1);
+
+ Failure failure = new Failure(Severity.ERROR,
+ SECTION,
+ rb.getString("mcf.MCFHashCode"),
+ obj.getClass().getName());
+ failures.add(failure);
+
+ return failures;
+ }
+ }
+
+ return null;
+ }
+}
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/package.html
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/package.html (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/mcf/package.html 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,3 @@
+<body>
+Validation rules for ManagedConnectionFactory.
+</body>
Added: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/package.html
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/package.html (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/validator/rules/package.html 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,3 @@
+<body>
+This package contains the rules for the specification validator
+</body>
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2009-12-01 17:37:42 UTC (rev 97253)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -22,6 +22,10 @@
package org.jboss.jca.deployers.fungal;
+import org.jboss.jca.deployers.common.validator.Failure;
+import org.jboss.jca.deployers.common.validator.FailureHelper;
+import org.jboss.jca.deployers.common.validator.Severity;
+import org.jboss.jca.deployers.common.validator.Validator;
import org.jboss.jca.fungal.deployers.CloneableDeployer;
import org.jboss.jca.fungal.deployers.DeployException;
import org.jboss.jca.fungal.deployers.Deployer;
@@ -30,7 +34,9 @@
import org.jboss.jca.fungal.util.Injection;
import org.jboss.jca.fungal.util.JarFilter;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
@@ -70,6 +76,15 @@
/** Preform bean validation */
private static AtomicBoolean beanValidation = new AtomicBoolean(true);
+ /** Preform archive validation */
+ private static AtomicBoolean archiveValidation = new AtomicBoolean(true);
+
+ /** Archive validation: Fail on Warn */
+ private static AtomicBoolean archiveValidationFailOnWarn = new AtomicBoolean(false);
+
+ /** Archive validation: Fail on Error */
+ private static AtomicBoolean archiveValidationFailOnError = new AtomicBoolean(true);
+
/**
* Constructor
*/
@@ -96,6 +111,60 @@
}
/**
+ * Set if archive validation should be performed
+ * @param value The value
+ */
+ public void setArchiveValidation(boolean value)
+ {
+ archiveValidation.set(value);
+ }
+
+ /**
+ * Should archive validation be performed
+ * @return True if validation; otherwise false
+ */
+ public boolean getArchiveValidation()
+ {
+ return archiveValidation.get();
+ }
+
+ /**
+ * Set if a failed warning archive validation report should fail the deployment
+ * @param value The value
+ */
+ public void setArchiveValidationFailOnWarn(boolean value)
+ {
+ archiveValidationFailOnWarn.set(value);
+ }
+
+ /**
+ * Does a failed archive validation warning report fail the deployment
+ * @return True if failing; otherwise false
+ */
+ public boolean getArchiveValidationFailOnWarn()
+ {
+ return archiveValidationFailOnWarn.get();
+ }
+
+ /**
+ * Set if a failed error archive validation report should fail the deployment
+ * @param value The value
+ */
+ public void setArchiveValidationFailOnError(boolean value)
+ {
+ archiveValidationFailOnError.set(value);
+ }
+
+ /**
+ * Does a failed archive validation error report fail the deployment
+ * @return True if failing; otherwise false
+ */
+ public boolean getArchiveValidationFailOnError()
+ {
+ return archiveValidationFailOnError.get();
+ }
+
+ /**
* Deploy
* @param url The url
* @param parent The parent classloader
@@ -283,6 +352,82 @@
}
}
+ // Archive validation
+ if (getArchiveValidation())
+ {
+ Validator validator = new Validator();
+ List<Failure> failures = validator.validate(objects.toArray(new Object[objects.size()]));
+
+ if (failures != null && failures.size() > 0)
+ {
+ FailureHelper fh = new FailureHelper(failures);
+ File reportDirectory = new File(SecurityActions.getSystemProperty("jboss.jca.home"), "/log/");
+
+ boolean failureWarn = false;
+ boolean failureError = false;
+
+ for (Failure failure : failures)
+ {
+ if (failure.getSeverity() == Severity.WARNING)
+ {
+ failureWarn = true;
+ }
+ else
+ {
+ failureError = true;
+ }
+ }
+
+ String errorText = "";
+ if (reportDirectory.exists())
+ {
+ String reportName = url.getFile();
+ int lastIndex = reportName.lastIndexOf(File.separator);
+ if (lastIndex != -1)
+ reportName = reportName.substring(lastIndex + 1);
+ reportName += ".log";
+
+ File report = new File(reportDirectory, reportName);
+ FileWriter fw = null;
+ try
+ {
+ fw = new FileWriter(report);
+ BufferedWriter bw = new BufferedWriter(fw, 8192);
+ bw.write(fh.asText(validator.getResourceBundle()));
+ bw.flush();
+
+ errorText = "Validation failures - see: " + report.getAbsolutePath();
+ }
+ catch (IOException ioe)
+ {
+ log.warn(ioe.getMessage(), ioe);
+ }
+ finally
+ {
+ if (fw != null)
+ {
+ try
+ {
+ fw.close();
+ }
+ catch (IOException ignore)
+ {
+ // Ignore
+ }
+ }
+ }
+ }
+ else
+ {
+ errorText = fh.asText(validator.getResourceBundle());
+ }
+
+ if ((getArchiveValidationFailOnWarn() && failureWarn) ||
+ (getArchiveValidationFailOnError() && failureError))
+ throw new DeployException(errorText);
+ }
+ }
+
// Activate deployment
log.info("Deployed: " + url.toExternalForm());
Added: projects/jboss-jca/trunk/deployers/src/main/resources/validator.properties
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/resources/validator.properties (rev 0)
+++ projects/jboss-jca/trunk/deployers/src/main/resources/validator.properties 2009-12-01 17:55:21 UTC (rev 97254)
@@ -0,0 +1,8 @@
+severity=Severity
+severity.warn=WARNING
+severity.error=ERROR
+section=Section
+description=Description
+code=Code
+mcf.MCFHashCode=A ManagedConnectionFactory must implement a "public int hashCode()" method.
+mcf.MCFEquals=A ManagedConnectionFactory must implement a "public boolean equals(Object)" method.
Modified: projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java 2009-12-01 17:37:42 UTC (rev 97253)
+++ projects/jboss-jca/trunk/deployers/src/test/java/org/jboss/jca/test/deployers/spec/rars/BaseManagedConnectionFactory.java 2009-12-01 17:55:21 UTC (rev 97254)
@@ -125,4 +125,26 @@
}
+ /**
+ * Hash code
+ * @return The hash
+ */
+ @Override
+ public int hashCode()
+ {
+ return 42;
+ }
+
+ /**
+ * Equals
+ * @param other The other object
+ * @return True if equal; otherwise false
+ */
+ public boolean equals(Object other)
+ {
+ if (other == null)
+ return false;
+
+ return getClass().equals(other.getClass());
+ }
}
Modified: projects/jboss-jca/trunk/doc/userguide/en/modules/configuration.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en/modules/configuration.xml 2009-12-01 17:37:42 UTC (rev 97253)
+++ projects/jboss-jca/trunk/doc/userguide/en/modules/configuration.xml 2009-12-01 17:55:21 UTC (rev 97254)
@@ -39,6 +39,84 @@
</section>
+ <section id="jca">
+ <title>JCA</title>
+
+ <section id="jca_deployer">
+ <title>Deployer</title>
+
+ <para>The JBoss JCA deployer is configured in the</para>
+
+ <programlisting>
+config/bootstrap/jca.xml
+ </programlisting>
+
+ <para>file, as the</para>
+
+ <programlisting>
+<bean name="RADeployer"
+ interface="org.jboss.jca.fungal.deployers.Deployer"
+ class="org.jboss.jca.deployers.fungal.RADeployer">
+ <depends>BeanValidation</depends>
+ <depends>WorkManager</depends>
+</bean>
+ </programlisting>
+
+ <para>bean.</para>
+
+ <table frame="all">
+ <title>JCA Deployer</title>
+ <tgroup cols="3" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1" colwidth="2*"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3" colwidth="3*"/>
+ <thead>
+ <row>
+ <entry align="left">Property</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><code>BeanValidation</code></entry>
+ <entry><code>boolean</code></entry>
+ <entry>
+ Toggle bean validation (JSR-303) for the deployment units.
+ <para>Default: <code>true</code></para>
+ </entry>
+ </row>
+ <row>
+ <entry><code>ArchiveValidation</code></entry>
+ <entry><code>boolean</code></entry>
+ <entry>
+ Toggle archive validation for the deployment units.
+ <para>Default: <code>true</code></para>
+ </entry>
+ </row>
+ <row>
+ <entry><code>ArchiveValidationFailOnWarn</code></entry>
+ <entry><code>boolean</code></entry>
+ <entry>
+ Should an archive validation warning report fail the deployment.
+ <para>Default: <code>false</code></para>
+ </entry>
+ </row>
+ <row>
+ <entry><code>ArchiveValidationFailOnError</code></entry>
+ <entry><code>boolean</code></entry>
+ <entry>
+ Should an archive validation error report fail the deployment.
+ <para>Default: <code>true</code></para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
+ </section>
+
+ </section>
+
<section id="webserver">
<title>Web server</title>
@@ -52,8 +130,31 @@
<para>file.</para>
- <para>The <code>port</code> property specifies which port the web server will be running on. Default port
- is 8080.</para>
+ <table frame="all">
+ <title>Web server</title>
+ <tgroup cols="3" align="left" colsep="1" rowsep="1">
+ <colspec colname="c1" colwidth="2*"/>
+ <colspec colname="c2"/>
+ <colspec colname="c3" colwidth="3*"/>
+ <thead>
+ <row>
+ <entry align="left">Property</entry>
+ <entry align="left">Type</entry>
+ <entry align="left">Description</entry>
+ </row>
+ </thead>
+ <tbody>
+ <row>
+ <entry><code>Port</code></entry>
+ <entry><code>int</code></entry>
+ <entry>
+ Set the port for the web server
+ <para>Default: <code>8080</code></para>
+ </entry>
+ </row>
+ </tbody>
+ </tgroup>
+ </table>
<para>The web server can be removed from the environment by removing the reference to <code>web.xml</code>
in</para>
More information about the jboss-cvs-commits
mailing list