亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? restopeerservice.java

?? JXTA技術手冊 書上3.4.5章的源代碼
?? JAVA
字號:
import java.io.*;import java.util.*;import java.net.URL;import net.jxta.service.Service;import net.jxta.peergroup.PeerGroup;import net.jxta.peergroup.PeerGroupFactory;import net.jxta.exception.PeerGroupException;import net.jxta.document.AdvertisementFactory;import net.jxta.document.StructuredDocumentFactory;import net.jxta.document.Advertisement;import net.jxta.document.Element;import net.jxta.document.TextElement;import net.jxta.document.MimeMediaType;import net.jxta.document.StructuredDocument;import net.jxta.document.StructuredTextDocument;import net.jxta.discovery.DiscoveryService;import net.jxta.pipe.PipeService;import net.jxta.pipe.InputPipe;import net.jxta.pipe.OutputPipe;import net.jxta.pipe.PipeID;import net.jxta.protocol.PipeAdvertisement;import net.jxta.protocol.PeerGroupAdvertisement;import net.jxta.protocol.ModuleImplAdvertisement;import net.jxta.endpoint.Message;import net.jxta.id.IDFactory;import net.jxta.id.ID;// The class RestoPeerService is an example of a PeerGroup Service.// This service is registered as a RestoNet Peergroup service.// This service implements the RestoPeer service for Chez JXTA.public class RestoPeerService implements Service {    // Service Module Spec Index ID    public static String Module_Spec_ID =        "jxta:uuid-737D1ED776B043E7A8718B102B62055A05";    private String brand = "Chez JXTA";         // Brand of this restaurant    private String specials = "large ($3.00)";  // Current restaurant Special    private PeerGroup restoNet = null;   // The RestoNet Peergroup    private PipeService pipes = null;    // Pipe service in the RestoNet    private ModuleImplAdvertisement srvImpl = null;    private PipeAdvertisement myAdv = null;  // My pipe advertisement    private InputPipe pipeIn = null;         // Input pipe that we listening                                             // to for requests    private int rtimeout = 8000;             // Resolver pipe timeout    // Service objects are not manipulated directly to protect usage    //of the service. A Service interface is returned to access the service    public Service getInterface() {        return this;    }    // Returns the module impl advertisement for this service.    public Advertisement getImplAdvertisement() {        return srvImpl;    }    // Called when the peergroup initializes the service    public void init(PeerGroup group, ID assignedID, Advertisement impl) {        // Save the RestoNet pointer, the pipe and the RestoPeer Service        restoNet = group;        srvImpl = (ModuleImplAdvertisement) impl;        System.out.println("Initialization RestoPeer Special Service: " +                           srvImpl.getModuleSpecID());        // Extract the service pipe advertisement from the service        // module impl Advertisement. The client MUST use the same pipe        // advertisement to talk to the service. When the client        // discovers the peergroup advertisement, it will extract the        // pipe advertisement to create the connecting pipe by getting        // the module impl advertisement associated with the RestoPeer        // service.        System.out.println("Extract the pipe advertisement from the Service");        PipeAdvertisement pipeadv = null;        try {            // Extract the pipe adv from the Module impl param section            myAdv = (PipeAdvertisement)                AdvertisementFactory.newAdvertisement((TextElement)                      srvImpl.getParam().getChildren().nextElement());        } catch (Exception e) {            System.out.println("failed to read/parse pipe advertisement");            e.printStackTrace();            System.exit(-1);        }        // Start the RestoPeer service loop thread to respond to Hungry peers        // fries requests. Start a new thread for processing all the        // requests        HandleFriesRequest peerRequest = new HandleFriesRequest();        peerRequest.start();    }    // Called when the service is started    public int startApp (String args[]) {        // nothing to do here        return 0;    }    // Called just before the service is stopped    public void stopApp() {    }    // Thread to handle fries auction requests from HungryPeers.    // The method waits for HungryPeer requests pipe messages to arrive.    // Incoming requests contain a pipe advertisement to respond to the    // HungryPeers requester and a fries size.    // The method generates a bid offer for the request, opens an output    // pipe to the HungryPeer requester and send the response.    private class HandleFriesRequest extends Thread {        InputStream ip = null;               // Input Stream of message        PipeAdvertisement hungryPipe = null; // HungryPeer Requester pipe        StructuredDocument request = null;   // Request document        StructuredDocument bid = null;       // Bid response        MimeMediaType mimeType = new MimeMediaType("text", "xml");        Element el = null;                   // Element in document        String name = null;                  // Name of the sender        String size = null;                  // Fries size Requested        OutputPipe pipeOut = null;           // Output pipe to respond to                                             // HungryPeer requester        public void run() {            // Need to check that the Pipe peergroup service of            // RestoNet is initialized. Peergroup services are loaded            // dynamically. Here we just wait until the pipe service            // is initialized so we can create a new pipe.            try {                while (pipes == null) {                    Thread.sleep(2000);                    pipes = restoNet.getPipeService();                }                // Create the input pipe to receive incoming request                if (!createRestoPipe()) {                    System.out.println(                        "Aborting due to failure to create RestoPeer pipe");                    return;                }            } catch (Exception ex) {                    System.out.println(                           "Exception while creating RestoPeer pipe");                    return;            }            System.out.println("RestoNet Restaurant (" + brand +                           ") waiting for HungryPeer requests");            // Loop waiting for HungryPeer Requests            while (true) {                Message msg = null;          // incoming pipe message                try {                    // Block until a message arrive on the RestoPeer pipe                    msg = pipeIn.waitForMessage();                    // If message is null, discard message                    if (msg == null) {                        if (Thread.interrupted()) {                            // We have been asked to stop                            System.out.println("Abort: RestoPeer interrupted");                            return;                        }                    }                    // We received a message; extract the request                    try {                        // Extract the HungryPipe pipe information                        // to reply to the sender                        ip = msg.getElement("HungryPeerPipe").getStream();                        // Construct the associated pipe advertisement                        // via the AdvertisementFactory                        hungryPipe = (PipeAdvertisement)                        AdvertisementFactory.newAdvertisement(mimeType, ip);                        // Extract the sender name and fries size requested                        // building a StructuredDocument                        ip = msg.getElement("Request").getStream();                        request = StructuredDocumentFactory.                                    newStructuredDocument(mimeType, ip);                        // Extract the fields from the structured Document                        Enumeration enum = request.getChildren();                        // Loop over all the elements of the document                        while (enum.hasMoreElements()) {                            el = (Element) enum.nextElement();                            String attr = (String) el.getKey();                            String value = (String) el.getValue();                            // Extract the HungryPeer Requester Name                            if (attr.equals("Name")) {                                name = value;                                continue;                            }                            // Extract the Fries  size requested                            if (attr.equals("Fries")) {                                size = value;                                continue;                            }                        }                    } catch (Exception e) {                        // Broken Content                        continue;                    }                    System.out.println("Received Request from HungryPeer "                               + name + " for " + size + " Fries.");                    // The auction request is valid. We can                    // create the output pipe to send the response bid to                    // the HungryPeer requester                    try {                        System.out.println(                           "Attempting to create Output Pipe to HungryPeer " +                            name);                        // Create an output pipe connection to the HungryPeer                        // requester                        pipeOut = pipes.createOutputPipe(hungryPipe, rtimeout);                        // Check if we have a pipe                        if (pipeOut == null) {                            // Cannot conect the pipe                            System.out.println(                                "Could not find HungryPeer pipe");                            continue;                        }                    } catch (Exception e) {                        // Pipe creation exception                        System.out.println(                            "HungryPeer may not be listening anymore");                        continue;                    }                    // We have a pipe connection to the HungryPeer. Now                    // create the bid response document                    try {                        bid = StructuredDocumentFactory.newStructuredDocument(                                     mimeType, "RestoNet:Bid");                        // Set the Bid values (Brand, price, special)                        // in the response document                        el = bid.createElement("Brand", brand);                        bid.appendChild(el);                        el = bid.createElement("Price", ""+ friesPrice(size));                        bid.appendChild(el);                        el = bid.createElement("Specials", specials);                        bid.appendChild(el);                        // Create a new pipe message                        msg = pipes.createMessage();                        // Add the Bid offer to the message                        msg.addElement(msg.newMessageElement(                                   "Bid", mimeType, bid.getStream()));                        pipeOut.send(msg);                        pipeOut.close();                    } catch (Exception ex) {                        System.out.println(                            "Error sending bid offer to HungryPeer " + name);                    }                    System.out.println("Sent Bid Offer to HungryPeer ("                        + name  + ") Fries price = "  + friesPrice(size) +                        ", special = " + specials);                } catch (Exception e) {                    System.out.println("Abort RestoPeer interrupted");                    return;                }            }        }    }    // Determine the price of the French fries depending on the size    private String friesPrice(String size) {        if (size.equals("small"))              return "$1.50";        if (size.equals("medium"))              return "2.50";        if (size.equals("large"))              return "3.00";        return "error";    }    // Create the input endpoint    private boolean createRestoPipe() {        try {            // Create my input pipe to listen for hungry peers            // requests            pipeIn = pipes.createInputPipe(myAdv);        } catch (Exception e) {            System.out.println(                "Could not initialize the Restaurant pipe" + e.getMessage());            return false;        }        return true;    }}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产一区二区三区免费播放 | 在线电影欧美成精品| 欧美日韩国产综合一区二区三区| 精品国产精品一区二区夜夜嗨| 中文字幕av不卡| 麻豆久久久久久| 在线观看视频一区二区欧美日韩| 亚洲精品一区二区三区福利| 五月激情六月综合| 一本大道久久a久久综合婷婷| www国产成人免费观看视频 深夜成人网| 亚洲视频每日更新| 国产成人精品免费网站| 日韩美女在线视频| 天堂在线亚洲视频| 91片黄在线观看| 久久久精品综合| 久久99精品视频| 欧美另类高清zo欧美| 亚洲欧美日韩国产综合在线| 国产精品亚洲一区二区三区在线 | 欧美日韩不卡一区二区| 国产精品国产自产拍高清av| 激情综合色播激情啊| 欧美久久久久中文字幕| 亚洲国产视频a| 一本色道久久综合精品竹菊| 1区2区3区国产精品| 成人免费视频网站在线观看| 久久一区二区三区国产精品| 九九**精品视频免费播放| 正在播放亚洲一区| 日本在线不卡视频一二三区| 欧美日韩精品久久久| 舔着乳尖日韩一区| 欧美精品日韩综合在线| 亚洲成国产人片在线观看| 在线观看亚洲一区| 亚欧色一区w666天堂| 欧美高清视频不卡网| 日韩电影在线一区| 精品久久一区二区| 国产激情视频一区二区三区欧美| 久久精品在这里| 成人网男人的天堂| 1区2区3区欧美| 欧美性猛交xxxx黑人交| 香港成人在线视频| 欧美成人vps| 国产精品亚洲人在线观看| 欧美激情一区二区三区蜜桃视频| bt7086福利一区国产| 亚洲免费观看在线观看| 欧美日韩不卡在线| 麻豆成人久久精品二区三区红| 日韩免费性生活视频播放| 国产成人a级片| 亚洲三级理论片| 欧美精品粉嫩高潮一区二区| 国产精品66部| 亚洲免费观看高清在线观看| 9191久久久久久久久久久| 精品夜夜嗨av一区二区三区| 国产精品二三区| 欧美乱熟臀69xxxxxx| 国产精品亚洲一区二区三区妖精| 综合久久给合久久狠狠狠97色| 欧美三级资源在线| 国产精品一区二区你懂的| 国产精品久久久久久久久果冻传媒| 色偷偷88欧美精品久久久| 三级一区在线视频先锋 | 国产三级欧美三级日产三级99 | 亚洲视频一区二区在线观看| 91麻豆精品91久久久久同性| 免费精品99久久国产综合精品| 欧美国产一区二区| 欧美日韩亚洲综合一区| 国产成人免费网站| 亚洲第一在线综合网站| 国产日韩欧美电影| 91麻豆精品国产综合久久久久久| 成人短视频下载| 麻豆视频观看网址久久| 夜夜夜精品看看| 欧美高清在线一区二区| 日韩一卡二卡三卡国产欧美| 99视频有精品| 国产高清精品在线| 日韩高清一区在线| 一区二区在线观看不卡| 国产性做久久久久久| 日韩视频123| 91久久精品日日躁夜夜躁欧美| 国产美女视频91| 久久99久久精品欧美| 亚洲国产精品久久久久婷婷884 | 国产一区二区福利视频| 天涯成人国产亚洲精品一区av| 综合久久一区二区三区| www久久久久| 欧美大片拔萝卜| 欧美精品久久久久久久久老牛影院| 成人av网在线| 成人三级伦理片| 国产风韵犹存在线视精品| 麻豆国产精品视频| 美国十次综合导航| 日韩国产精品大片| 婷婷六月综合亚洲| 亚洲超碰97人人做人人爱| 亚洲一区二区在线免费看| 国产精品久久久久一区二区三区| 国产日韩在线不卡| 中文字幕成人在线观看| 中文字幕av资源一区| 久久新电视剧免费观看| 久久久精品国产免大香伊| 欧美哺乳videos| 久久日韩粉嫩一区二区三区| 国产三级精品三级在线专区| 国产精品天干天干在线综合| 国产精品素人视频| 亚洲人成电影网站色mp4| 亚洲欧洲精品成人久久奇米网| 亚洲欧洲日韩女同| 亚洲伊人伊色伊影伊综合网| 亚洲一区二区成人在线观看| 亚洲成人精品影院| 日韩二区三区四区| 国产一区二区三区免费播放| 成人免费视频视频| 99re这里都是精品| 欧美日韩亚洲综合| 欧美一级在线免费| 精品播放一区二区| 中文av字幕一区| 亚洲激情综合网| 日韩高清不卡一区| 国产一区二区三区久久久 | 成人性生交大片免费看在线播放 | 日韩国产精品久久久久久亚洲| 久久国内精品自在自线400部| 国产一区欧美一区| 91香蕉视频mp4| 欧美精品国产精品| 久久久久免费观看| 亚洲女同一区二区| 日av在线不卡| 99久久久精品| 欧美电影在线免费观看| 久久青草国产手机看片福利盒子 | 精品久久久久久久久久久久久久久 | 国产精品久久久一本精品| 亚洲免费观看高清完整版在线观看熊| 亚洲一区二区三区不卡国产欧美| 免费在线观看不卡| av在线这里只有精品| 欧美精品v国产精品v日韩精品| 久久这里只有精品视频网| 亚洲三级在线观看| 黄页网站大全一区二区| 日本道色综合久久| 久久亚洲影视婷婷| 午夜国产精品影院在线观看| 国产成人精品影视| 欧美三级视频在线播放| 国产情人综合久久777777| 日韩精品一区第一页| 91免费在线看| 国产午夜久久久久| 丝袜美腿亚洲一区| jlzzjlzz亚洲女人18| 日韩午夜中文字幕| 亚洲制服丝袜在线| 国产aⅴ综合色| 欧美成人猛片aaaaaaa| 亚洲精品成人悠悠色影视| 国产呦精品一区二区三区网站| 欧美图片一区二区三区| 国产精品的网站| 国产一区二区剧情av在线| 91精品久久久久久久久99蜜臂| 亚洲欧洲美洲综合色网| 国产精品一二三区在线| 欧美变态tickle挠乳网站| 日日骚欧美日韩| 精品视频免费看| 亚洲免费观看高清| 91在线精品一区二区三区| 日本一区二区三区国色天香 | 粉嫩嫩av羞羞动漫久久久 | 成人免费视频一区二区| 国产性色一区二区| 国产剧情在线观看一区二区| 久久精品72免费观看| 狠狠色狠狠色综合| 欧美系列一区二区| 国产女人18毛片水真多成人如厕 | 久久久国产午夜精品 |