锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲黄色网址在线观看,亚洲一本大道无码av天堂,亚洲乱妇熟女爽到高潮的片http://www.tkk7.com/wangxinsh55/category/30592.htmlzh-cnThu, 03 Apr 2008 07:00:58 GMTThu, 03 Apr 2008 07:00:58 GMT60java RMI 鐩稿叧http://www.tkk7.com/wangxinsh55/archive/2008/04/03/190605.htmlSIMONESIMONEThu, 03 Apr 2008 05:32:00 GMThttp://www.tkk7.com/wangxinsh55/archive/2008/04/03/190605.htmlhttp://www.tkk7.com/wangxinsh55/comments/190605.htmlhttp://www.tkk7.com/wangxinsh55/archive/2008/04/03/190605.html#Feedback0http://www.tkk7.com/wangxinsh55/comments/commentRss/190605.htmlhttp://www.tkk7.com/wangxinsh55/services/trackbacks/190605.html闃呰鍏ㄦ枃

SIMONE 2008-04-03 13:32 鍙戣〃璇勮
]]>
JAVA-RMI瀛︿範蹇冨緱http://www.tkk7.com/wangxinsh55/archive/2008/04/03/190600.htmlSIMONESIMONEThu, 03 Apr 2008 05:25:00 GMThttp://www.tkk7.com/wangxinsh55/archive/2008/04/03/190600.htmlhttp://www.tkk7.com/wangxinsh55/comments/190600.htmlhttp://www.tkk7.com/wangxinsh55/archive/2008/04/03/190600.html#Feedback0http://www.tkk7.com/wangxinsh55/comments/commentRss/190600.htmlhttp://www.tkk7.com/wangxinsh55/services/trackbacks/190600.html瀛︿範java tutorial涓殑rmi绔犺妭錛岃涔︾瑪璁?/p>

JAVA-RMI 鎵閲囩敤鐨勬満鍒訛細

1. 鏌怬bject闇瑕乺emote call 錛屽垯瀹冩墍鏈夌殑鏂規硶閮芥斁鍦ㄤ竴涓柊澹版槑鐨勬帴鍙d腑錛岃鎺ュ彛蹇呴』extends          Remote鎺ュ彛

   Compute鎺ュ彛涓瓨鏀炬墍鏈夐渶瑕佽繘琛岃繙紼嬭皟鐢ㄧ殑鏂規硶錛岃瀹炵幇璇ユ帴鍙g殑綾繪潵瀹炵幇榪欎簺琚繙紼嬭皟鐢ㄧ殑鏂規硶

package compute;

import java.rmi.Remote;
import java.rmi.RemoteException;

public interface Compute extends Remote {
    Object executeTask(Task t) throws RemoteException;
}


2.閲囩敤榪滅▼璋冪敤鐨勬柟娉曞悓鏍鋒湁涓浜涘弬鏁板拰榪斿洖鍊鹼紝瀵逛簬榪欎簺鍙傛暟鍜岃繑鍥炲鹼紝鍦ㄤ笉鍚孞AVA铏氭嫙鏈洪棿浼犺緭錛孯M  I閲囧彇鐨勬槸鍊間紶閫掞紝鎵浠ユ墍鏈夌殑鍙傛暟鍜岃繑鍥炲煎繀欏籩xtends Serializable

package compute;

import java.io.Serializable;

public interface Task extends Serializable {
    Object execute();
}


/*******************************************************************************************
涓婇潰涓虹涓閮ㄥ垎錛屽湪榪欏綋涓紝鎴戜滑璁捐浜嗕竴涓帴鍙o紝鍏朵腑鍖呭惈闇瑕佽繙紼嬭皟鐢ㄧ殑鏂規硶錛岀劧鍚庤璇ユ帴鍙g殑瀹炵幇鑰咃紙鍗寵繙紼嬪璞$殑owner錛夋潵瀹炵幇榪欎簺鏂規硶
*******************************************************************************************/


3. 鐜板湪鎴戜滑涓轟簡寰楀埌榪滅▼瀵硅薄錛屽氨鏉ュ疄鐜頒竴涓嬩笂闈㈠畾涔夌殑鎺ュ彛錛?br />    main鍑芥暟涓紝鏂板緩涓涓繙紼嬪璞ngine,騫跺皢瀹冧笌鍚嶅瓧name閭﹀畾錛歂aming.rebind(name, engine);

娉細The superclass UnicastRemoteObject supplies implementations for a number of     java.lang.Object methods (equals, hashCode, toString) so that they are defined     appropriately for remote objects. UnicastRemoteObjectalso includes constructors and     static methods used to export a remote object, that is, make the remote object available     to receive incoming calls from clients.

package engine;

import java.rmi.*;
import java.rmi.server.*;
import compute.*;

public class ComputeEngine extends UnicastRemoteObject
                           implements Compute
{
    public ComputeEngine() throws RemoteException {
        super();
    }

    public Object executeTask(Task t) {
        return t.execute();
    }

    public static void main(String[] args) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        String name = "http://host/Compute";
        try {
            Compute engine = new ComputeEngine();
            Naming.rebind(name, engine);
            System.out.println("ComputeEngine bound");
        } catch (Exception e) {
            System.err.println("ComputeEngine exception: " +
          e.getMessage());
            e.printStackTrace();
        }
    }
}

/*******************************************************************************************
涓婇潰涓虹浜岄儴鍒嗭紝鍦ㄨ繖褰撲腑錛屾垜浠緱鍒頒簡涓涓疄鐜頒簡Compute鎺ュ彛鐨勮繙紼嬪璞ngine錛屾敞鎰忥細engine涓彧鏈夐偅浜汣ompute鎺ュ彛涓殑鏂規硶鑳藉琚繙紼嬭皟鐢紝鍏朵粬鏂規硶鍙兘鏈湴璋冪敤銆傜幇鍦紝灝嗚繙紼嬪璞ngine閭﹀畾鍒癛MI Registry 銆?client鍙互浠巖egistry閭i噷寰楀埌engine鐨勫紩鐢紝瀹為檯涓婃槸涓涓猻tub錛岀浉褰撲簬涓涓猠ngine鐨勪唬鐞嗭紝榪滅▼鏂規硶琚玞lient璋冪敤浠ュ悗錛屽彲浠ユ敼鍙榚ngine鐨勭姸鎬?br /> *******************************************************************************************/
  
4. 涓嬮潰鎴戜滑瀹炵幇閭d簺榪滅▼鏂規硶璋冪敤鏃舵墍瑕佺敤鍒扮殑鍙傛暟錛歍ask

package client;

import compute.*;
import java.math.*;

public class Pi implements Task {

    /** constants used in pi computation */
    private static final BigDecimal ZERO =
        BigDecimal.valueOf(0);
    private static final BigDecimal  ONE =
        BigDecimal.valueOf(1);
    private static final BigDecimal FOUR =
        BigDecimal.valueOf(4);

    /** rounding mode to use during pi computation */
    private static final int roundingMode =
        BigDecimal.ROUND_HALF_EVEN;

    /** digits of precision after the decimal point */
    private int digits;
   
    /**
     * Construct a task to calculate pi to the specified
     * precision.
     */
    public Pi(int digits) {
        this.digits = digits;
    }

    /**
     * Calculate pi.
     */
    public Object execute() {
        return computePi(digits);
    }

    /**
     * Compute the value of pi to the specified number of
     * digits after the decimal point.  The value is
     * computed using Machin's formula:
     *
     *          pi/4 = 4*arctan(1/5) - arctan(1/239)
     *
     * and a power series expansion of arctan(x) to
     * sufficient precision.
     */
    public static BigDecimal computePi(int digits) {
        int scale = digits + 5;
        BigDecimal arctan1_5 = arctan(5, scale);
        BigDecimal arctan1_239 = arctan(239, scale);
        BigDecimal pi = arctan1_5.multiply(FOUR).subtract(
                                  arctan1_239).multiply(FOUR);
        return pi.setScale(digits,
                           BigDecimal.ROUND_HALF_UP);
    }
    /**
     * Compute the value, in radians, of the arctangent of
     * the inverse of the supplied integer to the speficied
     * number of digits after the decimal point.  The value
     * is computed using the power series expansion for the
     * arc tangent:
     *
     * arctan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 +
     *     (x^9)/9 ...
     */  
    public static BigDecimal arctan(int inverseX,
                                  int scale)
    {
        BigDecimal result, numer, term;
        BigDecimal invX = BigDecimal.valueOf(inverseX);
        BigDecimal invX2 =
            BigDecimal.valueOf(inverseX * inverseX);

        numer = ONE.divide(invX, scale, roundingMode);

        result = numer;
        int i = 1;
        do {
            numer =
                numer.divide(invX2, scale, roundingMode);
            int denom = 2 * i + 1;
            term =
                numer.divide(BigDecimal.valueOf(denom),
                             scale, roundingMode);
            if ((i % 2) != 0) {
                result = result.subtract(term);
            } else {
                result = result.add(term);
            }
            i++;
        } while (term.compareTo(ZERO) != 0);
        return result;
    }
}

5. 鏈鍚庢垜浠疄鐜癱lient瀵硅薄
   榪滅▼瀵硅薄comp鏄氳繃RMI鐨勬敞鍐岃〃鏉ユ煡鎵懼埌鐨?/p>

package client;

import java.rmi.*;
import java.math.*;
import compute.*;

public class ComputePi {
    public static void main(String args[]) {
        if (System.getSecurityManager() == null) {
            System.setSecurityManager(new RMISecurityManager());
        }
        try {
            String name = "http://" + args[0] + "/Compute";
            Compute comp = (Compute) Naming.lookup(name);
            Pi task = new Pi(Integer.parseInt(args[1]));
            BigDecimal pi = (BigDecimal) (comp.executeTask(task));
            System.out.println(pi);
        } catch (Exception e) {
            System.err.println("ComputePi exception: " +
                               e.getMessage());
            e.printStackTrace();
        }
    }
}



SIMONE 2008-04-03 13:25 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 中国极品美軳免费观看| 久久久久女教师免费一区| 日韩版码免费福利视频| 亚洲特级aaaaaa毛片| 在线观看免费中文视频| 亚洲成A∨人片在线观看无码| 57pao一国产成永久免费| 亚洲成av人片不卡无码| 欧美a级在线现免费观看| 亚洲欧美国产欧美色欲| 国产精品视_精品国产免费| 麻豆69堂免费视频| 国产av无码专区亚洲av果冻传媒 | 国产成人免费福利网站| 青青免费在线视频| 亚洲精品无码专区久久久| 午夜精品一区二区三区免费视频| 亚洲精品动漫在线| 美女被免费视频网站a国产| 窝窝影视午夜看片免费| 亚洲国产成人精品无码区在线观看| 99久久国产免费-99久久国产免费 99久久国产免费中文无字幕 | 日本三级在线观看免费| 亚洲黄色片免费看| 免费无码黄动漫在线观看| 一级一看免费完整版毛片| 亚洲国产一区二区a毛片| 成人黄18免费视频| 久青草视频在线观看免费| 亚洲理论精品午夜电影| 国产极品粉嫩泬免费观看 | 狠狠亚洲婷婷综合色香五月排名 | 国产精品亚洲av色欲三区| 亚洲人成图片小说网站| 亚洲人成网站免费播放| 成人国产精品免费视频| 亚洲依依成人精品| 亚洲日韩精品无码专区网址| 久久精品免费全国观看国产| 精品国产污污免费网站入口| 亚洲最新黄色网址|