提供應用程式框架/外殼(選單、工具列、視圖管理)、模組化 API、成熟生態。本文示範:以 RCP 建立前端,整合 Spring Remoting 呼叫後端服務。
EclipseTradeClient,勾選「Create an OSGi bundle manifest」。plugin.xml:Overview 分頁可直接啟動應用程式。View 重命名 ExplorerView(Refactor → Rename)。plugin.xml 對應的 name、class、id。ExplorerView.ID 常數對應新 ID。ViewContentProvider.getElements() 回傳 {"Watch List", "Order History"}。SpringClient (無模板),複製 Spring 必要 JAR (spring-*.jar, commons-logging.jar, log4j.jar) 至專案根目錄。MANIFEST.MF → Runtime 分頁:Classpath 加入所有 JAR,Exported Packages 全匯出。MANIFEST.MF 來源分頁加入 Eclipse-BuddyPolicy: registered 解決 ClassLoader 可見性。applicationContext.xml、beanRefFactory.xml (含 HttpInvoker 服務定義)。StockService、DTO StockDTO 至 SpringClient。SpringClientPlugin 建構子載入 Spring Context:BeanFactoryLocator locator = SingletonBeanFactoryLocator.getInstance();
BeanFactoryReference ref = locator.useBeanFactory("ctx");
beanFactory = ref.getFactory();
EclipseTradeClient 的 plugin.xml → Dependencies 加入 SpringClient。EclipseTradeClient 的 MANIFEST.MF 加入 Eclipse-RegisterBuddy: SpringClient。plugin.xml → Extensions 加入 org.eclipse.ui.views,模板 SampleView,命名 WatchListView (Table Viewer)。ITableLabelProvider (WatchListTableLabelProvider) 映射 StockDTO 欄位至表格欄。WatchListView 透過 SpringClientPlugin.getDefault().getBeanFactory() 取得 StockService,按鈕動作呼叫遠端取得股票清單並填入 TableViewer。Perspective 版面配置:左側 ExplorerView、底部 WatchListView。stocktradeserver 專案部署至 Tomcat 並啟動。EclipseTradeClient 的 plugin.xml Overview 分頁點擊「Launch an Eclipse application」。RCP 大幅減少 GUI 框架樣板碼;Spring Remoting 讓通訊協議切換容易,並享有伺服器端 Spring 優勢 (DI、AOP、事務等)。