Re: how to create own tags using qtags
Justin Case <[email protected]> Tue, 16 Jun 2009 01:50:56 -0700 (PDT)
| Newsgroups | gmane.comp.java.xdoclet.user |
|---|---|
| Message-ID | <[email protected]> |
Sure, I'm moving it there. However, given there's no mention of that list whatsoever on the project's = page, and googling its name gives a whooping 12 matches, sorry but I really= missed it :) Thanks a lot, M --- On Tue, 6/16/09, Konstantin Priblouda <[email protected]> wrote: > From: Konstantin Priblouda <[email protected]> > Subject: Re: [Xdoclet-user] how to create own tags using qtags > To: "End-user support for the XDoclet code generator" <xdoclet-user@lists= .sourceforge.net> > Date: Tuesday, June 16, 2009, 1:44 AM > = > This discussion belongs on xdoclet-plugin-interest mailing > list!!!!! > = > --- On Mon, 6/15/09, Justin Case <[email protected]> > wrote: > = > > From: Justin Case <[email protected]> > > Subject: [Xdoclet-user] how to create own tags using > qtags > > To: "End-user support for the XDoclet code generator" > <[email protected]> > > Date: Monday, June 15, 2009, 6:01 PM > > = > > Hi all, > > = > > Velocity code generation works fine with a VM file. I > > thought I'd use also the qtags special annotations to > > implement easier restrictions instead of checking > everything > > in the VM file. = > > = > > However I can't seem to understand how to activate > them. I > > created the tags as needed, put restrictions in their > > annotations, started the Ant build with some broken > files, > > the process flows happily ignoring all the qtags > > restrictions I've got there. Shouldn't I get some kind > of > > error? Do you see anything unusual below - or > forgotten? > = > For the qtags to work properly you shall first generate = > their implementations (there is xdoclet plugin for this = > puprose). Then you can registzer this tag library, and = > magic can begin. = > = > You can see how qtags plugin is invoked in xd2 plugin > sources, > and tag library registration (for example) in hibernate > plugin. = > = > = > = > > Note: I couldn't really figure out what the > "namespace" > > attributes need to contain, but I picked something > hopefully > > appropriate. > = > namespace is first part of tag name > = > > Thanks a lot, > > M > > = > > Here more info: > > = > > ---------The tag class: > > package org.xdoclet.plugin.myplugin.qtags; > > import > com.thoughtworks.qdox.model.AbstractJavaEntity; > > import org.xdoclet.XDocletTag; > > /** > >=A0 * @qtags.location class > >=A0 * @qtags.once > >=A0 */ > > public class MyClassTag extends XDocletTag { > > = > > -------- the VM file: > > #set( $class =3D $metadata ) > > public interface I${class.getName()} { > > =A0 #set( $parameterTagsClass =3D > > $class.getTagsByName("mytag.classlvl") ) > > =A0 #foreach( $parameterTagClass in > $parameterTagsClass > > ) > > =A0=A0=A0 #if > > ($parameterTagClass.getNamedParameter("table")) > > =A0=A0=A0 =A0 public static final String TABLE > > =3D "$parameterTagClass.getNamedParameter("table")"; > > =A0=A0=A0 #end > > =A0 #end > > = > > ---------- the build.xml > > =A0=A0=A0 =A0=A0=A0 <taskdef > > name=3D"xdoclet2" > > =A0=A0=A0 =A0=A0=A0 =A0 =A0 =A0 > > =A0=A0=A0classname=3D"org.xdoclet.ant.XDocletTask" > > =A0=A0=A0 =A0=A0=A0 =A0 =A0 =A0 > > =A0=A0=A0classpathref=3D"lib2.class.path" /> > > =A0=A0=A0 =A0=A0=A0 <xdoclet2> > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > <fileset dir=3D"${src.java.dir}"> > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0=A0=A0 <include name=3D"**/test/*Base.java" > > /> > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > </fileset> > > = > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > classname=3D"org.generama.VelocityTemplateEngine"/> > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > classname=3D"org.generama.JellyTemplateEngine"/> > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > > classname=3D"org.xdoclet.plugin.qtags.impl.QTagImplPlugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > destdir=3D"${build2.java.dir}" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > /> > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > > classname=3D"org.xdoclet.plugin.qtags.impl.QTagLibraryPlugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > destdir=3D"${build2.java.dir}" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > packagereplace=3D"org.xdoclet.plugin.myplugin.qtags" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > /> > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > > classname=3D"org.xdoclet.plugin.qtags.xdoc.QTagXDocPlugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > destdir=3D"${build2.java.dir}/generated-xdocs" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > namespace=3D"myplugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > /> > > =A0 =A0 =A0 =A0 =A0 =A0 <component > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > > classname=3D"org.xdoclet.plugin.qtags.confluence.QTagConfluencePlugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > destdir=3D"${build2.java.dir}/confluence" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > namespace=3D"myplugin" > > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 > > /> > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > <component > > classname=3D"org.xdoclet.plugin.myplugin.MyPlugin" > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0 =A0 =A0 =A0 > > =A0=A0=A0destdir=3D"${build2.java.dir}" > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0 =A0 =A0 =A0 > > =A0=A0=A0fileregex=3D"(.*)(.java)" > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0 =A0 =A0 =A0 > > =A0=A0=A0filereplace=3D"I$1.java" > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0 =A0 =A0 =A0 > > =A0=A0=A0packageregex=3D"test" > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0 =A0 =A0 =A0 > > =A0=A0=A0packagereplace=3D"test.generated" /> > > = > > --------tags registration: > > package org.xdoclet.plugin.myplugin; > > import org.generama.QDoxCapableMetadataProvider; > > import org.generama.VelocityTemplateEngine; > > import org.generama.WriterMapper; > > import org.generama.defaults.JavaGeneratingPlugin; > > import > org.xdoclet.plugin.sqlinterface.qtags.MyClassTag; > > = > > public class MyPlugin extends JavaGeneratingPlugin { > > = > > =A0=A0=A0 public MyPlugin(VelocityTemplateEngine > > templateEngine, > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > QDoxCapableMetadataProvider metadataProvider, > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > WriterMapper writerMapper) { > > =A0=A0=A0 =A0=A0=A0 super(templateEngine, > > metadataProvider, writerMapper); > > =A0=A0=A0 =A0=A0=A0 > > setMultioutput(true); > > = > > =A0=A0=A0 =A0=A0=A0 > > > metadataProvider.getDocletTagFactory().registerTag(MyClassTag.NAME, > > =A0=A0=A0 =A0=A0=A0 =A0=A0=A0 > > =A0=A0=A0 MyClassTag.class); > > = > > --------- and the broken Java source > > package com.test; > > /** > >=A0 * @mytag.classlvl table=3D"firstone" > >=A0 * @mytag.classlvl table=3D"second" > >=A0 **/ > = > = > = > =A0 =A0 =A0 = > = > -------------------------------------------------------------------------= ----- > Crystal Reports - New Free Runtime and 30 Day Trial > Check out the new simplified licensing option that enables > unlimited > royalty-free distribution of the report engine for > externally facing = > server and web deployment. > http://p.sf.net/sfu/businessobjects > _______________________________________________ > xdoclet-user mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/xdoclet-user > = = ---------------------------------------------------------------------------= --- Crystal Reports - New Free Runtime and 30 Day Trial Check out the new simplified licensing option that enables unlimited royalty-free distribution of the report engine for externally facing = server and web deployment. http://p.sf.net/sfu/businessobjects