Question about using tutorial code as a template for a new project..

46 views
Skip to first unread message

Rick Flower

unread,
Feb 1, 2013, 8:07:12 PM2/1/13
to web4j...@googlegroups.com
So, I started using the working tutorial to use as a jumping point for my own toy application -- just trying to get some DB accesses to work..
 
Anyhow, I renamed the WEB-INF/classes/hirondelle directory tree to be something like WEB-INF/classes/mycoolapp and let the subdirectories beneath it alone (e.g. the web4j/config and other 'logic' directories containing new code that could deal with my database fields, etc..  Upon launching the code it started running fine until I pressed a link and it tried to do something more than paint an HTML page -- something that required web4j logic and it failed.. In looking at the logs it was not able to find the various web4j config files that normally reside in the WEB-INF/classes/hirondelle/web4j/config.. 
 
So, that made me think that perhaps my new app should leave that entire tree alone (and remove the electricity tutorial bits obviously) and put them into a new tree structure similar to :
 
WEB-INF/classes/hirondelle/web4j/config
WEB-INF/classes/mycoolapp/foo/bar
etc..
 
Is that the right approach to go about making a new app based off of the tutorial code -- or should I just rename the hirondelle directory to be the name of my app and relocate the web4j config files into that tree and add some calls to inform the web4j framework to the location of the various config files (e.g. appInfo,etc)?
 
I'm leaning towards having the tree outlined above and leave the hirondelle pieces alongside my app's new code.
 
Comments/suggestions?
 
 
 

John O'Hanley

unread,
Feb 3, 2013, 10:25:38 AM2/3/13
to web4j-users
Hi Rick,

Yes, that's the right approach.

Please see for reference :
http://www.web4j.com/UserGuide.jsp#ConfiguringClasses
http://www.web4j.com/UserGuide.jsp#ListingInterfaces

There are 2 different ways of doing this :

1. use your own package tree for your app's main code, PLUS tell web4j
what it needs to know by using the conventional package-and-class-
names under hirondelle.web4j.config - these are found automatically at
startup, without any further config on your part.

This is the style used in the example apps, for example:
hirondelle.electricity... (the main body of the app)
hirondelle.web4j.config (how the app needs to configure web4j; this
uses conventional names)

For your app, this would translate into the structure you described
above:
mycoolapp.foo.bar...
hirondelle.web4j.config

2. use entirely only your own package tree, and tell web4j what it
needs to know by an explicitly mapping (in web.xml) interface names to
the names of concrete classes. (This style doesn't use conventional
names of classes; it uses arbitrary names.)

Personally, I find style 1 more pleasing, since it means you don't
have to do any extra mapping in the web.xml file. But this is really a
matter of taste. Some might find it distasteful to place their code in
"someone else's package", so to speak.

- John

Rick Flower

unread,
Feb 17, 2013, 1:24:32 AM2/17/13
to web4j...@googlegroups.com
Thanks! 
Reply all
Reply to author
Forward
0 new messages