TC6 AnnotationProcessor has been replaced completely by Marks new
InstanceManager class for TC7
without the refactor your struts embedded-jsp-plugin will gack in TC7
I've refactored struts2 embedded-plugin src to work with marks code..collecting
annotations from Fields from the servlet parameter
here is the code:
java.util.HashMap<String,String> injections=new
java.util.HashMap();
/* add in all of the injections map of injections for this
class */
java.lang.Class clazz=servlet.getClass();
if (clazz != null)
{
java.lang.reflect.Field[] fields =
clazz.getDeclaredFields();
int ctr=0;
for (java.lang.reflect.Field field : fields)
{
java.lang.annotation.Annotation[] annotations =
field.getDeclaredAnnotations();;
for(java.lang.annotation.Annotation annotation:
annotations)
{
//injections.add("org.apache.struts2.jasper.compiler.Generator.VAR_ANNOTATIONPROCESSOR","_jsp_annotationprocessor");
String
annotationType=(String)annotation.annotationType().toString();
String value
=(String)annotation.toString();
Object
obj=(Object)injections.put(annotationType,value);
ctr++;
}
}
} //end clazz!=null
java.util.Map<String, java.util.Map<String, String>>
injectionMap=new java.util.HashMap();
String injectionString=new String("injectionMap");
injectionMap.put(injectionString,injections);
org.apache.catalina.core.NamingContextListener
namingContextListener = new org.apache.catalina.core.NamingContextListener();
namingContextListener.setName(com.opensymphony.xwork2.ActionContext.getContext().getName());
org.apache.naming.NamingContext
naming_context=namingContextListener.getNamingContext();
org.apache.catalina.Context
context=(org.apache.catalina.Context)com.opensymphony.xwork2.ActionContext.getContext();
DefaultInstanceManagerImpl manager=new
DefaultInstanceManagerImpl((javax.naming.Context)naming_context,(java.util.Map<String,
java.util.Map<String,
String>>)injectionMap,(org.apache.catalina.Context)context,(java.lang.ClassLoader)com.opensymphony.xwork2.ActionContext.getContext().getClass().getClassLoader());
if(manager!=null)
{
try
{
manager.processAnnotations( (Object)servlet,
(java.util.Map<String,String>)injections);
}
catch(IllegalAccessException iae)
{
log.debug("Manager.processAnnotations throws
IllegalAccessException message="+iae.getMessage());
}
catch(InvocationTargetException ite)
{
log.debug("Manager.processAnnotations throws
InvocationTargetException message="+ite.getMessage());
}
catch(NamingException name_excp)
{
log.debug("manager.processAnnotations throws
NamingException message="+name_excp.getMessage());
}
struts currently doesnt support injector configuration read from web.xml
so populating annotations acquired from (servlet) Fields will have to do
Struts supports all containers i'm looking for a variable that I can use to
detect the TC7 container maybe
check for TOMCAT_HOME?
WDYT?
Martin
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger
sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung
oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem
Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung.
Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung
fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
destinataire prévu, nous te demandons avec bonté que pour satisfaire informez
l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est
interdite. Ce message sert à l'information seulement et n'aura pas n'importe
quel effet légalement obligatoire. Étant donné que les email peuvent facilement
être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité
pour le contenu fourni.
> Date: Fri, 11 Mar 2011 17:39:08 -0500
> From: [email protected]
> To: [email protected]
> Subject: Re: [OT] Migrated from 6.0.29 to 7.0.10, Now I get "INFO: TLD
> skipped. URI: http://struts.apache.org/tags-bean is already defined"
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Brian,
>
> On 3/9/2011 3:42 PM, Brian Braun wrote:
> > Actually, I had already unzipped my .war file and inspected every file
> > inside, and arrived to that conclution: The only place where the TLD files
> > are also present is the JARs that correspond to Struts (don't laugh, but I'm
> > still using it) and other components.
>
> Why would anyone laugh that you are using Struts?
>
> I think it's a great framework, and it's still maintained by a dedicated
> group of people.
>
> Would you prefer something else? Or, does Struts just have a long enough
> history to make it un-cool?
>
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk16pIsACgkQ9CaO5/Lv0PAbEQCgl3JHfnkXpx0h1TYaAalJkWty
> 0SwAnRvOjKTjagdLGMhN/IIz1P8XuXTT
> =NQKX
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>