[jboss-cvs] JBossAS SVN: r111916 - in projects/jboss-jca/trunk: deployers/src/main/java/org/jboss/jca/deployers/common and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 3 10:54:43 EDT 2011
Author: jesper.pedersen
Date: 2011-08-03 10:54:42 -0400 (Wed, 03 Aug 2011)
New Revision: 111916
Modified:
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java
projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
Log:
[JBJCA-640] Verify objects before casting
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java 2011-08-03 13:45:02 UTC (rev 111915)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/DeployersBundle.java 2011-08-03 14:54:42 UTC (rev 111916)
@@ -78,4 +78,28 @@
*/
@Message(id = 20056, value = "Deployment failed: %s")
public String deploymentFailed(String url);
+
+ /**
+ * Invalid managed connection factory
+ * @param clz The class name
+ * @return The value
+ */
+ @Message(id = 20057, value = "Invalid ManagedConnectionFactory class: %s")
+ public String invalidManagedConnectionFactory(String clz);
+
+ /**
+ * Invalid activation spec
+ * @param clz The class name
+ * @return The value
+ */
+ @Message(id = 20058, value = "Invalid ActivationSpec class: %s")
+ public String invalidActivationSpec(String clz);
+
+ /**
+ * Invalid resource adapter
+ * @param clz The class name
+ * @return The value
+ */
+ @Message(id = 20059, value = "Invalid ResourceAdapter class: %s")
+ public String invalidResourceAdapter(String clz);
}
Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-08-03 13:45:02 UTC (rev 111915)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java 2011-08-03 14:54:42 UTC (rev 111916)
@@ -567,8 +567,13 @@
List<? extends ConfigProperty> cpm = mlMD.getActivationspec().getConfigProperties();
String asClass = mlMD.getActivationspec().getActivationspecClass().getValue();
- ActivationSpec as = (ActivationSpec)initAndInject(asClass, cpm, cl);
+ Object oa = initAndInject(asClass, cpm, cl);
+ if (oa == null || !(oa instanceof ActivationSpec))
+ throw new DeployException(bundle.invalidActivationSpec(asClass));
+
+ ActivationSpec as = (ActivationSpec)oa;
+
if (trace)
{
log.trace("ActivationSpec: " + as.getClass().getName());
@@ -623,7 +628,7 @@
ResourceAdapter1516 ra1516 = (ResourceAdapter1516) cmd.getResourceadapter();
if (ra1516 != null && ra1516.getAdminObjects() != null)
{
- List<AdminObject> aoMetas = ((ResourceAdapter1516) cmd.getResourceadapter()).getAdminObjects();
+ List<AdminObject> aoMetas = ra1516.getAdminObjects();
if (aoMetas.size() > 0)
{
@@ -805,9 +810,14 @@
{
if (activateDeployment)
{
- resourceAdapter = (ResourceAdapter) initAndInject(ra1516.getResourceadapterClass(),
- ra1516.getConfigProperties(), cl);
+ String raClz = ra1516.getResourceadapterClass();
+ Object or = initAndInject(raClz, ra1516.getConfigProperties(), cl);
+ if (or == null || !(or instanceof ResourceAdapter))
+ throw new DeployException(bundle.invalidResourceAdapter(raClz));
+
+ resourceAdapter = (ResourceAdapter)or;
+
if (trace)
{
log.trace("ResourceAdapter: " + resourceAdapter.getClass().getName());
@@ -854,9 +864,14 @@
if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
{
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(ra10
- .getManagedConnectionFactoryClass().getValue(), ra10.getConfigProperties(), cl);
+ String mcfClz = ra10.getManagedConnectionFactoryClass().getValue();
+ Object om = initAndInject(mcfClz, ra10.getConfigProperties(), cl);
+ if (om == null || !(om instanceof ManagedConnectionFactory))
+ throw new DeployException(bundle.invalidManagedConnectionFactory(mcfClz));
+
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory)om;
+
if (trace)
{
log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
@@ -967,7 +982,7 @@
}
else
{
- tsmd = ((ResourceAdapter10) cmd.getResourceadapter()).getTransactionSupport();
+ tsmd = ra10.getTransactionSupport();
}
TransactionSupportLevel tsl = TransactionSupportLevel.NoTransaction;
@@ -1220,9 +1235,14 @@
if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
{
- ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cdMeta
- .getManagedConnectionFactoryClass().getValue(), cdMeta.getConfigProperties(), cl);
+ String mcfClz = cdMeta.getManagedConnectionFactoryClass().getValue();
+ Object om = initAndInject(mcfClz, cdMeta.getConfigProperties(), cl);
+ if (om == null || !(om instanceof ManagedConnectionFactory))
+ throw new DeployException(bundle.invalidManagedConnectionFactory(mcfClz));
+
+ ManagedConnectionFactory mcf = (ManagedConnectionFactory)om;
+
if (trace)
{
log.trace("ManagedConnectionFactory: " + mcf.getClass().getName());
Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml 2011-08-03 13:45:02 UTC (rev 111915)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/logging.xml 2011-08-03 14:54:42 UTC (rev 111916)
@@ -784,6 +784,21 @@
<entry><code>EXCEPTION</code></entry>
<entry>Deployment failed</entry>
</row>
+ <row>
+ <entry>20057</entry>
+ <entry><code>EXCEPTION</code></entry>
+ <entry>Invalid ManagedConnectionFactory class</entry>
+ </row>
+ <row>
+ <entry>20058</entry>
+ <entry><code>EXCEPTION</code></entry>
+ <entry>Invalid ActivationSpec class</entry>
+ </row>
+ <row>
+ <entry>20059</entry>
+ <entry><code>EXCEPTION</code></entry>
+ <entry>Invalid ResourceAdapter class</entry>
+ </row>
</tbody>
</tgroup>
</table>
More information about the jboss-cvs-commits
mailing list