[jboss-cvs] JBossAS SVN: r95561 - projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 26 04:17:25 EDT 2009
Author: jeff.zhang
Date: 2009-10-26 04:17:25 -0400 (Mon, 26 Oct 2009)
New Revision: 95561
Modified:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Metadata.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java
Log:
[JBJCA-146] Validate metadata model for required elements
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Metadata.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Metadata.java 2009-10-26 08:10:14 UTC (rev 95560)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/Metadata.java 2009-10-26 08:17:25 UTC (rev 95561)
@@ -22,25 +22,30 @@
package org.jboss.jca.deployers.fungal;
+import org.jboss.jca.fungal.deployers.DeployException;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.jboss.logging.Logger;
-//import org.jboss.metadata.rar.jboss.JBossRA10DefaultNSMetaData;
import org.jboss.metadata.rar.jboss.JBossRA10MetaData;
import org.jboss.metadata.rar.jboss.JBossRA20DefaultNSMetaData;
import org.jboss.metadata.rar.jboss.JBossRA20MetaData;
import org.jboss.metadata.rar.jboss.JBossRAMetaData;
import org.jboss.metadata.rar.jboss.RaConfigPropertyMetaData;
import org.jboss.metadata.rar.spec.ConfigPropertyMetaData;
+import org.jboss.metadata.rar.spec.ConnectionDefinitionMetaData;
import org.jboss.metadata.rar.spec.ConnectorMetaData;
+import org.jboss.metadata.rar.spec.InboundRaMetaData;
import org.jboss.metadata.rar.spec.JCA15DTDMetaData;
import org.jboss.metadata.rar.spec.JCA15MetaData;
import org.jboss.metadata.rar.spec.JCA16DTDMetaData;
import org.jboss.metadata.rar.spec.JCA16DefaultNSMetaData;
import org.jboss.metadata.rar.spec.JCA16MetaData;
+import org.jboss.metadata.rar.spec.MessageListenerMetaData;
+import org.jboss.metadata.rar.spec.OutboundRaMetaData;
import org.jboss.xb.binding.Unmarshaller;
import org.jboss.xb.binding.UnmarshallerFactory;
import org.jboss.xb.binding.resolver.MutableSchemaResolver;
@@ -277,4 +282,72 @@
return cmd;
}
+
+ /**
+ * Validate specification metadata
+ * @param cmd The specification metadata
+ * @return The merged metadata
+ * @exception Exception Thrown if an error occurs
+ */
+ public static ConnectorMetaData validate(ConnectorMetaData cmd) throws Exception
+ {
+ //make sure all need metadata parsered and processed after annotation handle
+ if (cmd.getRa() == null)
+ throw new DeployException("ResourceAdapter metadata should be defined");
+
+ //make sure ra metadata contains inbound or outbound at least
+ boolean inboundOrOutbound = false;
+ if (validateOutbound(cmd.getRa().getOutboundRa()))
+ inboundOrOutbound = true;
+ if (validateInbound(cmd.getRa().getInboundRa()) && cmd.getRa().getRaClass() != null)
+ inboundOrOutbound = true;
+ if (!inboundOrOutbound)
+ throw new DeployException("ResourceAdapter metadata should contains inbound or outbound at least");
+ return cmd;
+ }
+
+ /**
+ * Validate outbound metadata
+ * @param omd The specification metadata
+ * @return validate
+ * @exception Exception Thrown if an error occurs
+ */
+ private static boolean validateOutbound(OutboundRaMetaData omd) throws Exception
+ {
+ if (omd == null)
+ return false;
+ if (omd.getConDefs() == null || omd.getConDefs().size() == 0)
+ return false;
+ ConnectionDefinitionMetaData cdm = omd.getConDefs().get(0);
+ if (cdm.getManagedConnectionFactoryClass() == null ||
+ cdm.getConnectionFactoryInterfaceClass() == null ||
+ cdm.getConnectionFactoryImplementationClass() == null ||
+ cdm.getConnectionInterfaceClass() == null ||
+ cdm.getConnectionImplementationClass() == null)
+ return false;
+
+ return true;
+ }
+
+ /**
+ * Validate inbound metadata
+ * @param cmd The specification metadata
+ * @return validate
+ * @exception Exception Thrown if an error occurs
+ */
+ private static boolean validateInbound(InboundRaMetaData imd) throws Exception
+ {
+ if (imd == null)
+ return false;
+ if (imd.getMessageAdapter() == null ||
+ imd.getMessageAdapter().getMessageListeners() == null ||
+ imd.getMessageAdapter().getMessageListeners().size() == 0)
+ return false;
+ MessageListenerMetaData mlmd = imd.getMessageAdapter().getMessageListeners().get(0);
+ if (mlmd.getType() == null ||
+ mlmd.getActivationSpecType() == null ||
+ mlmd.getActivationSpecType().getAsClass() == null)
+ return false;
+ return true;
+ }
}
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-10-26 08:10:14 UTC (rev 95560)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/fungal/RADeployer.java 2009-10-26 08:17:25 UTC (rev 95561)
@@ -171,6 +171,7 @@
}
// Validate metadata
+ Metadata.validate(cmd);
// Merge metadata
cmd = Metadata.merge(cmd, jrmd);
More information about the jboss-cvs-commits
mailing list