[jboss-cvs] JBossAS SVN: r79433 - in projects/metadata/trunk/src/main/java/org/jboss/metadata: annotation/creator/ejb/jboss and 5 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 13 22:01:46 EDT 2008
Author: ALRubinger
Date: 2008-10-13 22:01:45 -0400 (Mon, 13 Oct 2008)
New Revision: 79433
Added:
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/ValidationException.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ValidatorChain.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBoss50MetaDataValidatorChain.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBossMetaDataValidatorChain.java
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/
projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/Validator.java
Modified:
projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java
Log:
[JBMETA-118] Added a ValidatorChain, called from JBoss50Creator. Currently holds no validators.
Modified: projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java 2008-10-14 01:52:05 UTC (rev 79432)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/annotation/creator/ejb/jboss/JBoss50Creator.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -39,6 +39,7 @@
import org.jboss.metadata.ejb.spec.EnterpriseBeanMetaData;
import org.jboss.metadata.ejb.spec.SessionBeanMetaData;
import org.jboss.metadata.ejb.spec.SessionType;
+import org.jboss.metadata.validation.chain.ejb.jboss.JBoss50MetaDataValidatorChain;
/**
* A JBoss50Creator.
@@ -105,6 +106,9 @@
// Process annotations
processMetaData(classes, metaData);
+
+ // Validate
+ new JBoss50MetaDataValidatorChain(metaData).validate();
return metaData;
}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/ValidationException.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/ValidationException.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/ValidationException.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.validation;
+
+/**
+ * ValidationException
+ *
+ * Represents a problem with Validation upon
+ * Metadata
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class ValidationException extends RuntimeException
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final long serialVersionUID = 1L;
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ *
+ */
+ public ValidationException()
+ {
+ super();
+ }
+
+ /**
+ * @param message
+ */
+ public ValidationException(String message)
+ {
+ super(message);
+ }
+
+ /**
+ * @param cause
+ */
+ public ValidationException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ValidationException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ValidatorChain.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ValidatorChain.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ValidatorChain.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.validation.chain;
+
+import java.util.Set;
+
+import org.jboss.metadata.validation.ValidationException;
+import org.jboss.metadata.validation.validator.Validator;
+
+/**
+ * ValidatorChain
+ *
+ * Defines the contract for a chain of Validators upon
+ * metadata
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ValidatorChain
+{
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Validates the specified metadata against the configured
+ * validators
+ */
+ void validate() throws ValidationException;
+
+ /**
+ * Obtains all validators in the chain. Will return
+ * an immutable view of the configured validators as to not allow
+ * published mutation of the set except as provided
+ *
+ * @return
+ */
+ Set<Validator> getValidators();
+
+ /**
+ * Adds the specified validator to the chain
+ *
+ * @param validator
+ */
+ void addValidator(Validator validator);
+
+}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBoss50MetaDataValidatorChain.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBoss50MetaDataValidatorChain.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBoss50MetaDataValidatorChain.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.validation.chain.ejb.jboss;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBoss50MetaData;
+import org.jboss.metadata.validation.chain.ValidatorChain;
+
+/**
+ * JBoss50MetaDataValidatorChain
+ *
+ * A Validator Chain for JBoss50MetaData
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBoss50MetaDataValidatorChain extends JBossMetaDataValidatorChain implements ValidatorChain
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBoss50MetaDataValidatorChain.class);
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ public JBoss50MetaDataValidatorChain(JBoss50MetaData metadata)
+ {
+ super(metadata);
+ }
+
+}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBossMetaDataValidatorChain.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBossMetaDataValidatorChain.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/chain/ejb/jboss/JBossMetaDataValidatorChain.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.validation.chain.ejb.jboss;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.validation.ValidationException;
+import org.jboss.metadata.validation.chain.ValidatorChain;
+import org.jboss.metadata.validation.validator.Validator;
+
+/**
+ * JBossMetaDataValidatorChain
+ *
+ * A Validator Chain for JBossMetaData
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class JBossMetaDataValidatorChain implements ValidatorChain
+{
+
+ // --------------------------------------------------------------------------------||
+ // Class Members ------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ private static final Logger log = Logger.getLogger(JBossMetaDataValidatorChain.class);
+
+ // --------------------------------------------------------------------------------||
+ // Instance Members ---------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * The metadata upon which this chain will validate
+ */
+ private JBossMetaData metadata;
+
+ /**
+ * The validators to apply to the metadata
+ */
+ private Set<Validator> validators = new HashSet<Validator>();
+
+ // --------------------------------------------------------------------------------||
+ // Constructors -------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Constructs a new ValidatorChain upon the specified metadata,
+ * using the default Validators
+ */
+ public JBossMetaDataValidatorChain(JBossMetaData metadata)
+ {
+ this(metadata, getDefaultValidators());
+ }
+
+ /**
+ * Creates a new ValidatorChain upon the specified metadata, using
+ * the specified Validators
+ *
+ * @param metadata
+ * @param validators
+ */
+ public JBossMetaDataValidatorChain(JBossMetaData metadata, Set<Validator> validators)
+ {
+ // Set the Metadata
+ assert metadata != null : "Specified metadata was null";
+ this.setMetadata(metadata);
+
+ // For each specified validator
+ assert validators != null : "Specified validators for chain was null";
+ for (Validator validator : validators)
+ {
+ // Add to the chain
+ log.trace("Added Validator to " + this + ": " + validator.getClass().getSimpleName());
+ this.addValidator(validator);
+ }
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Required Implementations -------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /* (non-Javadoc)
+ * @see org.jboss.metadata.validation.chain.ValidatorChain#validate(org.jboss.metadata.spi.MetaData)
+ */
+ public void validate() throws ValidationException
+ {
+ // Get the metadata
+ JBossMetaData md = this.getMetadata();
+
+ // Obtain all configured validators
+ Set<Validator> validators = this.getValidators();
+
+ // For each validator
+ for (Validator validator : validators)
+ {
+ // Run validation
+ validator.validate(md);
+ }
+
+ log.debug("Passed Validation on all configured validators for " + metadata);
+ }
+
+ /**
+ * Obtains all validators in the chain. Will return
+ * an immutable view of the configured validators as to not allow
+ * published mutation of the set except as provided
+ *
+ * @return
+ */
+ public Set<Validator> getValidators()
+ {
+ Set<Validator> validators = Collections.unmodifiableSet(this._getValidators());
+ return validators;
+ }
+
+ /**
+ * Adds the specified validator to the chain
+ *
+ * @param validator
+ */
+ public void addValidator(Validator validator)
+ {
+ assert validator != null : "Specified validator was null";
+ this._getValidators().add(validator);
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Functional Methods -------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Returns a Set of validators to use as the default for this chain
+ */
+ protected static Set<Validator> getDefaultValidators()
+ {
+ // Initialize
+ Set<Validator> defaultValidators = new HashSet<Validator>();
+
+ // Add all default validators
+ //TODO Add Validators here
+
+ // Return
+ return defaultValidators;
+ }
+
+ // --------------------------------------------------------------------------------||
+ // Accessors / Mutators -----------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ protected JBossMetaData getMetadata()
+ {
+ return metadata;
+ }
+
+ protected void setMetadata(JBossMetaData metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ protected Set<Validator> _getValidators()
+ {
+ return validators;
+ }
+
+ protected void setValidators(Set<Validator> validators)
+ {
+ this.validators = validators;
+ }
+
+}
Added: projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/Validator.java
===================================================================
--- projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/Validator.java (rev 0)
+++ projects/metadata/trunk/src/main/java/org/jboss/metadata/validation/validator/Validator.java 2008-10-14 02:01:45 UTC (rev 79433)
@@ -0,0 +1,48 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.metadata.validation.validator;
+
+import org.jboss.metadata.ejb.jboss.JBossMetaData;
+import org.jboss.metadata.validation.ValidationException;
+
+/**
+ * Validator
+ *
+ * Defines the contract for a Validator upon
+ * metadata
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface Validator
+{
+ // --------------------------------------------------------------------------------||
+ // Contracts ----------------------------------------------------------------------||
+ // --------------------------------------------------------------------------------||
+
+ /**
+ * Validates the specified metadata against the configured
+ * validators
+ */
+ void validate(JBossMetaData md) throws ValidationException;
+
+}
More information about the jboss-cvs-commits
mailing list