Java Reference
In-Depth Information
Download email_25/src/stripesbook/dao/impl/stripersist/MessageDaoImpl.java
@Repository("messageDao")
public class MessageDaoImpl extends BaseDaoImpl<Message,Integer>
implements MessageDao
Download email_25/src/stripesbook/dao/impl/stripersist/UserDaoImpl.java
@Repository("userDao")
public class UserDaoImpl extends BaseDaoImpl<User,Integer>
implements UserDao
{
Finally, we must configure Stripes to use its Spring interceptor 5
by
adding
to
the
list
of
extension
net.sourceforge.stripes.integration.spring
packages:
Download email_25/web/WEB-INF/web.xml
<init-param>
<param-name> Extension.Packages </param-name>
<param-value>
stripesbook.ext,
org.stripesstuff.stripersist,
net.sourceforge.stripes.integration.spring
</param-value>
</init-param>
We're now ready to use our Spring-managed DAOs.
Injecting the DAOs in the Action Beans
Remember that we previously had direct references to the implementa-
tions of the DAOs in BaseActionBean . We can now get Stripes to inject
the dependencies by retrieving them from the components loaded by
Spring. We need only to add the @SpringBean annotation:
Download email_25/src/stripesbook/action/BaseActionBean.java
public abstract class BaseActionBean implements ActionBean {
@SpringBean protected AttachmentDao attachmentDao;
@SpringBean protected ContactDao contactDao;
@SpringBean protected FolderDao folderDao;
@SpringBean protected MessageDao messageDao;
@SpringBean protected UserDao userDao;
}
An empty @SpringBean annotation uses a naming convention. Stripes
looks for the Spring-managed component with the same name as the
5. Don't worry about what an interceptor is for now. We'll discuss that topic in Sec-
tion 13.3 , Everything Is Possible: Interceptors, on page 294 .
 
 
Search WWH ::




Custom Search