I asked a while ago if someone had a sample app that used both Hibernate and
the shipping version of Turbine 2.3, including for the security system. No
one did, so I created one. I can't guarantee this app will work for you, but
it should at least give some hints as to how you pull Avalon into the mix.

The application is based on the one created by the TDK, so it is pretty
simple. To build this app, I started with a TDK generated application, then
moved the directories around to work better with Maven. I then got the
latest code of Avalon security (alpha-6) and the Turbine/Avalon adaptor and
got the configuration working. I also generated the Hibernate config files
needed to run the security system (which are mysteriously missing from
Avalon Security source control, as far as I could tell).

Note that the way this app is set up, the hibernate config files are loaded
as resources, which means they have to be part of the classpath. You can do
this in three ways:

1) At the WEB-INF\conf directory to the classpath. I do this while
debugging, because Eclipse's Tomcat plugin makes it easy to tack on
additions to the path.

2) Copy or move the WEB-INF/conf/*hibernate* files into the WEB-INF/classes
folder before running.

3) If using Maven, add the WEB-INF/conf/*hibernate* files to the resources
section of your project.xml file. I didn't do this because I tend to use
Eclipse for day to day debugging/rebuild cycles and Maven only for setup and
final builds.

If people have other solutions, please post them. The app is also a little
odd in that it compiles into its own source tree (putting classes/ and lib/
into src/webapp/WEB-INF). This is done solely to make in-place debugging
with Eclipse easier. If you use Maven, you might need to copy the jar files
in src/webapp/WEB-INF/lib into your Maven repository as many of them do not
exist on public Maven repositories. Note that running "maven eclipse" will
invoke a postGoal in the maven.xml file that sets up the application,
Eclipse and Tomcat to work like this automatically (if it works).


If using this application as a model, the following files are important:

WEB-INF/web.xml - The Java standard descriptor for a web application. This
performs a couple of vital tasks, including loading the Turbine properties
and setting the URL to servlet mappings.

WEB-INF/conf/TurbineResources.properties - The Turbine properties. This
references Log4j properties. It differs from the standard TDK by turning on
and configuring Avalon and changing the security service to use the Fulcrum
service.

WEB-INF/conf/componentConfiguration.xml - An Avalon configuration file,
setting up the security system to use fulcrum, load the Hibernate Avalon
component and reference the Hibernate config file.

WEB-INF/conf/componentRoles.xml - Another Avalon configuration, which seems
redundant to me (having much of the same information as the
componentConfiguration.xml file), but someone who knows more about Avalon
could probably explain it better. Near as I can tell, this file specifies
what classes are allocated by factories used by given component. I think.
It's unclear to me why you wouldn't just define that in the configuration
file with the component but, again, I don't claim to know much about Avalon.

WEB-INF/conf/hibernate.cfg.xml - The Hibernate config file. The one included
in the download uses MySQL, so you WILL need to alter it to match you actual
database parameters. Note that src/sql contains files to create and populate
the tables you might need. Note that this file loads
dynamichibernate.hbm.xml as a resource.

WEB-INF/conf/dynamichibernate.hbm.xml - A hibernate file detailing the
database/object mapping. Note that these map directly to Fulcrum security
objects.


Again, not sure this will actually work for anyone, but should get you over
the major hurdles in moving everything (including security) in Turbine 2.3
to use Hibernate.

The application can be found here:

ftp://ftp.divnull.com/pub/java/runway-1.5.0-src.tar.gz

If anyone wants to mirror it, be my guest.

Wordman
http://www.divnull.com/lward/

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to