#副標= IoC解放大法(1)
#大標=春神來了-讓Spring解放你的程式碼
#眉標=J2EE
#作者=文/歐宣修
================ box 程式1 ===============
ServiceLocator sl = new ServiceLocator();
CustomerLocalHome home =(CustomerLocalHome)
sl.getLocalHome(JNDINames.
CUSTOMER_EJBHOME);
customer = home.findByPrimaryKey(userId);
==================== end ===================
============== box 程式2 ==============
public class MyServlet extends HttpServlet {
public void init() { …}
public void doGet(HttpServletRequest request,
HttpServletResponse response) { … }
public void doPost(HttpServletRequest request,
HttpServletResponse response) { … }
public void destroy() { … }
}
=================== end =================
=============== box 程式3 =================
//Class
public class SimpleRealtimeServer implements
RealtimeServer, Runnable {
public SimpleRealtimeServer(IOReader ioreader,
ScanJudge scanjudge) { //…(1)
this.ioreader = ioreader;
this.scanjudge = scanjudge;
}
}
//Configuration
…
${connection.url}
${connection.driver_class}
${connection.username}
${connection.password}
===================== end ===================
============== box 程式8 =============
================ end ===============
=============== box 程式9 =============
ApplicationContext context = new
FileSystemXmlApplicationContext("sccbo.xml");
RealtimeServer server = (RealtimeServer)context.
getBean("realtimeServer");
================== end ===============