You can download an example at
http://www.carmanconsulting.com/svn/public/tapernate-example/trunk.   

There is some "magic" going on here.  There are a number of HiveMind modules
(hivemind-utils, spring-transaction, spring-hibernate3) in the /WEB-INF/lib
directory that take care of a LOT for you and a really cool APT processor
(inspired by Chris Nelson's work in Trails).  To develop a DAO, all you have
to do is extend com.javaforge.hivemind.spring.hibernate3.HibernateService
(which extends HibernateDaoSupport) or directly extend the
HibernateDaoSupport.  You declare your DAOs in your hivemodule.xml file like
this:

<service-point id="MessageDao"
interface="com.carmanconsulting.tapernate.example.domain.dao.MessageDao">
  <invoke-factory>
    <construct
class="com.carmanconsulting.tapernate.example.domain.dao.impl.MessageDaoImpl
"/>
  </invoke-factory>
  <interceptor service-id="spring.transaction.TransactionInterceptor">
    <transaction-attributes>
      <method name="*" attributes="PROPAGATION_REQUIRED"/>
    </transaction-attributes>
  </interceptor>
</service-point>

To configure Hibernate, you do this in your hivemodule.xml file:

<contribution configuration-id="spring.hibernate3.Configuration">
  <configuration-file>hibernate.cfg.xml</configuration-file>
  <property name="hibernate.dialect" value="..."/>
  <property name="hibernate.connection.driver_class" value="..."/>
  <property name="hibernate.connection.url" value="..."/>
  <property name="hibernate.connection.username" value="..."/>
  <property name="hibernate.connection.password" value="..."/>
  <property name="hibernate.current_session_context_class" value="..."/>
  <property name="hibernate.cache.provider_class" value="..."/>
  <property name="hibernate.show_sql" value="..."/>
  <property name="hibernate.hbm2ddl.auto" value="..."/>
</contribution>

The "configuration-file" is automatically generated for you using the APT
processor factory that I wrote (it's in lib/compile/hibernate-apt.jar and
it's also available from my public SVN site in the hibernate-apt project)
and it will include "mapping" elements for any class in your source
directory which has the @javax.persistence.Entity annotation.  You can use
whatever you want for the properties and add any other properties (like c3p0
properties or something) as you see fit.  The "tapernate" library contains
classes to handle the "open-session-in-view" pattern and has some other cool
features like a data "squeezer" which only writes identity information out
to the client instead of the entire entity.  It also includes an entity
property persistence strategy which I'm still working on to make sure I've
got it working properly.  The nested session support is what's throwing me
right now, I think.  Hope that helps.

-----Original Message-----
From: James Carman [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 16, 2006 9:24 AM
To: 'Tapestry users'
Subject: RE: POJO dependency injection (with interface) into TAP4
application

Why don't you put your DAOs into HiveMind?  I've got code out there that
will allow you to do it.  Email me directly and I'll send you a zipped up
file of an example project (or you can download it via SVN from my
webisite).

-----Original Message-----
From: Adam Zimowski [mailto:[EMAIL PROTECTED] 
Sent: Thursday, March 16, 2006 9:04 AM
To: Tapestry users
Subject: Re: POJO dependency injection (with interface) into TAP4
application

How could I do this? I don't know Hivemind very well, yet because it's
integrated with Tapestry I highly prefer it over Spring IOC. Any
chance you may have an example?

On 3/16/06, Mike Snare <[EMAIL PROTECTED]> wrote:
> By the way, if any tap developers are reading this, it would be great
> if you could declare an interface for an ASO similar to the way you
> can for a service...
>
> -Mike
>
> On 3/16/06, Mike Snare <[EMAIL PROTECTED]> wrote:
> > That will work, but doesn't enforce your intent on other developers
> > (they would be free to inject the ASO as a SessionDAO and not an
> > ISessionDAO).  Perhaps a better way would be to create a service whose
> > sole purpose would be to retrieve an instance of the ISessionDAO from
> > the ApplicationStateManager, which can be auto-wired to your
> > ISessionDAORetriever service.  Noone would then know the type.
> >
> > -Mike
> >
> > On 3/16/06, Adam Zimowski <[EMAIL PROTECTED]> wrote:
> > > Silly me :-)  How simple and elegant !  I've been thinking in the
> > > spring context, yet Tap/Hivemind make it so simple..
> > >
> > > Thanks!
> > >
> > > On 3/16/06, Kristian Marinkovic <[EMAIL PROTECTED]>
wrote:
> > > > hi Adam,
> > > >
> > > > @InjectState("sessionDAO")
> > > > public abstract ISessionDAO getSessionDAO();
> > > >
> > > > works fine too; i'm using it with tapestry-spring
> > > >
> > > >
> > > >
> > > >
> > > >              "Adam Zimowski"
> > > >              <[EMAIL PROTECTED]
> > > >              .com>
An
> > > >                                         "Tapestry users"
> > > >              16.03.2006 14:11
<[email protected]>
> > > >
Kopie
> > > >
> > > >               Bitte antworten
Thema
> > > >                     an                  POJO dependency injection
(with
> > > >              "Tapestry users"           interface) into TAP4
application
> > > >              <[EMAIL PROTECTED]
> > > >              karta.apache.org>
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > Hi there,
> > > >
> > > > I'd like to inject my DAOs from Hivemind as an interface such that
my
> > > > app is not aware of implementation. I only know I can do this:
> > > >
> > > > <contribution configuration-id="tapestry.state.ApplicationObjects">
> > > >  <state-object name="sessionDAO" scope="application">
> > > >   <create-instance class="data.dao.SessionDAO"/>
> > > >  </state-object>
> > > > </contribution>
> > > >
> > > > Then, in my class I'd do:
> > > >
> > > > @InjectState("sessionDAO")
> > > > public abstract SessionDAO getSessionDAO();
> > > >
> > > > I have a few problems with this:
> > > >
> > > > 1) I'd like to inject an interface ISessionDAO, not the concrete
> > > > implementation.
> > > >
> > > > 2) Question: will Hivemind give me a singleton? I don't want my
DAO's
> > > > be a bunch of short lived objects. I'd like to be sure they are
> > > > singletons. I think they are because the scope is application, but
I'm
> > > > not sure.
> > > >
> > > > 3) I'd like to be able to inject it to other POJOs, not just
Tapestry
> > > > derived objects (pages, components, etc). I probably could use
> > > > Registry object, but I really prefer to do this with annotations?
They
> > > > are so elegant.. Does Hivemind has annotation support ?
> > > >
> > > > As always, I appreciate your help up front.
> > > >
> > > > Regards,
> > > > Adam
> > > >
> > > >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
[EMAIL PROTECTED]
> > > >
> > > >
> > > >
> > > >
> > > >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail:
[EMAIL PROTECTED]
> > > >
> > > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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




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



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

Reply via email to