|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Setting up a JAXB plugin development environment in EclipseHi,
does anyone here have an easy "recipe" for setting up an environment to write JAXB plugins in Eclipse? -- Anders |
|
|
Re: Setting up a JAXB plugin development environment in EclipseOn Thu, 2009-10-01 at 00:04 +0200, Anders Hessellund wrote:
> Hi, > > does anyone here have an easy "recipe" for setting up an environment > to write JAXB plugins in Eclipse? > > -- Anders Assuming that you ask for a "quick setup allowing one to trace into (already written or under develpment) plugins", one may try this to replace the xjc launching sequence with: a. stick the jaxb libraries (downloading them rather than using the one distributed with the standard jsdk) in your classpath ("User libraries" - specifying the "Source code location" for the jars will also improve you chances during the steps below) b. start an equivalent xjc processing using the following snipped of code (fill-in the gaps on exception-catching and other imports needed): import com.sun.tools.xjc.Driver; public class Launcher { static public void main(String[] args) { Class drvClass=Driver.class; try { Method mainEntryPoint= drvClass.getDeclaredMethod( "_main", new Class[] { String[].class } ) ; mainEntryPoint.setAccessible(true); // the _main method is private mainEntryPoint.invoke(null, new Object[] { args }); } catch(/* various exceptions here */) { } } } I found the above trick as needed (... eer...chmmm... at least working... other approaches may also be possible) to get around different "hacks" in the jaxb's xjc utility, causing it to fall into using the jaxb libraries packed within jsdk (instead of using the ones in your classpath)... to the result of no0ne (that's me) not being able to trace in the jaxb tools' source code. Then: c. grab the JAXB specification to have it handy d. take the source code of whatever already existing plugin you feel closer to your liking and create a project from them sources. (warning: shameless boasting here. The http://www.no0ne.org/general-purpose/PropListInjector/index.html has a nice balance between the complexity of overwriting/reusing in a twisted way the classes in the com.sun.tools.xjc.generator.bean package and the number of such classes to chew. It also may expose some design flaws... but hey, it's working. Would you feel it's too complex, "fall back" on simpler plugins, like the CamelCase one) e. happy tracing (and googling-for/reading other documentation in the same time. Having something you can trace during execution will enable one to quickly select from the documentation what's relevant to one's needs and... stay clueless on other details outside the scope of the said needs... the way I'm staying now. Good strategy for a starter, maybe not perfect for a PhD in jaxb, but it worked for me). f. don't forget that you still want to write some plugin code. Use the same strategy/setup to develop/trace/debug with your own code. Best regards, no0ne --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Setting up a JAXB plugin development environment in EclipseHi,
> does anyone here have an easy "recipe" for setting up an environment to > write JAXB plugins in Eclipse? I've developed a number of JAXB plugins, using Eclipse as IDE. In order to ease development, I also needed to develop a tools package and a testing infrastructure. Take a look at this project: https://jaxb2-commons-svn.dev.java.net/svn/jaxb2-commons-svn/trunk/basics/ If you're interested in a test case, see org.jvnet.jaxb2_commons.tests.issues.RunIssuesPlugin in tests/issues/src/test/java. It runs XJC with specified parameters: public class RunIssuesPlugin extends RunXJC2Mojo { @Override protected void configureMojo(AbstractXJC2Mojo mojo) { super.configureMojo(mojo); mojo.setExtension(true); } @Override public List<String> getArgs() { final List<String> args = new ArrayList<String>(super.getArgs()); args.add("-XtoString"); args.add("-Xequals"); args.add("-XhashCode"); args.add("-Xcopyable"); args.add("-Xmergeable"); return args; } } This runnable as unit test from Eclipse which allows tracing/debuggin plugins quite nicely. Bye. /lexi --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@... For additional commands, e-mail: users-help@... |
|
|
Re: Setting up a JAXB plugin development environment in EclipseThanks a lot, guys!
This is very helpful. -- Anders On Thu, Oct 1, 2009 at 8:02 AM, Aleksei Valikov <valikov@...> wrote:
-- Anders Hessellund www.itu.dk/people/hessellund/ |
| Free embeddable forum powered by Nabble | Forum Help |