From 86901e07e593bbfa03beff2f208a61ee6bf19bca Mon Sep 17 00:00:00 2001 From: msridhar1 Date: Mon, 3 Mar 2008 04:01:46 +0000 Subject: [PATCH] add code to pass in different ActionForm types to entrypoint git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@2651 f5eafffb-2e1d-0410-98e4-8ec43c5233c4 --- .../com/ibm/wala/j2ee/StrutsEntrypoints.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/StrutsEntrypoints.java b/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/StrutsEntrypoints.java index 3f9ed2947..aa661416e 100644 --- a/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/StrutsEntrypoints.java +++ b/com.ibm.wala.j2ee/src/com/ibm/wala/j2ee/StrutsEntrypoints.java @@ -10,6 +10,7 @@ *******************************************************************************/ package com.ibm.wala.j2ee; +import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -58,6 +59,8 @@ public class StrutsEntrypoints implements Iterable, EJBConstants { private final static TypeName actionName = TypeName.string2TypeName("Lorg/apache/struts/action/Action"); + private final static TypeName actionFormName = TypeName.string2TypeName("Lorg/apache/struts/action/ActionForm"); + private Map entrypoints = HashMapFactory.make(); /** @@ -66,7 +69,7 @@ public class StrutsEntrypoints implements Iterable, EJBConstants { private Set actions = HashSetFactory.make(); /** - * Mthis map controls selection of concrete types for parameters to some servlet methods. + * This map controls selection of concrete types for parameters to some servlet methods. */ private final static HashMap concreteParameterMap = HashMapFactory.make(2); static { @@ -209,6 +212,21 @@ public class StrutsEntrypoints implements Iterable, EJBConstants { if (Tprime != null) { T = Tprime; } + if (n.equals(actionFormName)) { + // return an array of all possible subtypes of ActionForm in the class hierarchy + Collection subcs = getCha().computeSubClasses(T); + Set subs = HashSetFactory.make(); + for (IClass cs : subcs) { + if (!cs.isAbstract() && !cs.isInterface()) { + // filter out those ActionForms in struts itself + TypeReference reference = cs.getReference(); + if (!reference.getName().getPackage().toString().startsWith("org/apache/struts")) { + subs.add(reference); + } + } + } + return subs.toArray(new TypeReference[subs.size()]); + } return new TypeReference[] { T }; } }