portfolioclient.java
来自「100多M的J2EE培训内容」· Java 代码 · 共 73 行
JAVA
73 行
package bible.ejb.session.example2;import weblogic.rmi.*;import java.util.*;import javax.naming.*;/** * ResearchClient periodically asks server for research. */public class PortfolioClient extends TimerTask implements Runnable { /** * Method run * * */ public void run() { System.out.println("PortfolioClient running:" + new Date()); try { InitialContext ctx = Environment.getInitialContext(); Object objref = ctx.lookup("AnalyzePortfolio"); AnalyzePortfolioHome home = (AnalyzePortfolioHome) javax.rmi.PortableRemoteObject.narrow(objref, AnalyzePortfolioHome.class); AnalyzePortfolioRemote analyzer = home.create(); // Add some debts and some holdings. analyzer.addHolding("BEAS", new Integer(20000)); analyzer.addHolding("WAG", new Integer(10000)); analyzer.addHolding("MSFT", new Integer(150)); analyzer.addDebt("Car Loan", new Integer(20000)); analyzer.addDebt("Mortgage", new Integer(30000)); // Ask for first analysis. System.out.println(analyzer.getAnalysis()); // Add a big holding and ask for second analysis. analyzer.addHolding("PETS", new Integer(200000)); System.out.println(analyzer.getAnalysis()); analyzer.remove(); } catch (Exception e) { e.printStackTrace(); return; } } /** * Declare a new client and schedule it on a timer. */ public static void main(String[] args) { Timer t = new Timer(); PortfolioClient client = new PortfolioClient(); // Starting in 5 secs, run every 5 seconds. t.schedule(client, 5000, 5000); }}/*--- Formatted in Bible Style on Thu, Sep 6, '01 ---*//*------ Formatted by Jindent 3.24 Gold 1.02 --- http://www.jindent.de ------*/
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?