雖然對Spring不熟悉
可以肯定
以下是自己的閱讀體會
一
Jpetstore使用了門面模式
門面接口的實現類
public class PetStoreImpl implements PetStoreFacade
{
private AccountDao accountDao;
private CategoryDao categoryDao;
private ProductDao productDao;
private ItemDao itemDao;
private OrderDao orderDao;
//
// Setter methods for dependency injection
//
public void setAccountDao(AccountDao accountDao)
{
this
}
//省略余下的四個setter
//
// Operation methods
//
public Account getAccount(String username)
{
return this
}
public Account getAccount(String username
{
return this
}
public void insertAccount(Account account)
{
this
}
public void updateAccount(Account account)
{
this
}
//省略其它的crud方法
}
暫時先不管 OrderService 這個接口
PetStoreImpl的那些setter方法正是spring的注入方法
在配置文件中
<bean id=
<property name=
<property name=
<property name=
<property name=
<property name=
</bean>
單例模式中
There is one instance of this class in the JPetStore application
單例的PetStoreImpl
在Struts當控制器時
public abstract class BaseAction extends Action
{
private PetStoreFacade petStore;
public void setServlet(ActionServlet actionServlet)
{
super
if (actionServlet != null)
{
ServletContext servletContext = actionServlet
WebApplicationContext wac = WebApplicationContextUtils
this
}
}
protected PetStoreFacade getPetStore()
{
return petStore;
}
}
ORM工具用iBatis
<select id=
select
signon
account
account
account
account
account
account
account
account
account
untry
account
profile
profile
profile
profile
bannerdata
from account
where account
and signon
and profile
and profile
</select>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28442.html