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

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

?? restopeer.java

?? JXTA技術手冊 書上3.4.5章的源代碼
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
import java.io.*;import java.util.*;import java.net.URL;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.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.peergroup.PeerGroupID;import net.jxta.membership.MembershipService;import net.jxta.membership.Authenticator;import net.jxta.credential.AuthenticationCredential;import net.jxta.impl.peergroup.StdPeerGroupParamAdv;import net.jxta.impl.id.UUID.ModuleClassID;import net.jxta.impl.membership.PasswdMembershipService;// RestoPeer represents a restaurant that receives auction requests// for french fries from HungryPeers. RestoPeers offers three sizes of// french fries (small, large, medium). Each restaurant assignes a// different price to each size. Each restaurant also offers a special// offering.//// Each restaurant is uniquely identified by its brand name.public class RestoPeer {    private PeerGroup netpg = null;      // The NetPeerGroup    private PeerGroup restoNet = null;   // The restoNet Peergroup    private String brand = "Chez JXTA";        // Brand of this restaurant    private String specials = "large ($3.00)"; // Current restaurant special    // Services within the RestoNet peergroup    private DiscoveryService disco = null;  // Discovery service    private PipeService pipes = null;       // Pipe service    private PipeAdvertisement myAdv = null; // My RestoPeer pipe advertisement    private InputPipe pipeIn = null;        // Input pipe that we listen to                                            // for requests from Hungry Peers    private int timeout = 3000;          // discovery wait timeout    private int rtimeout = 8000;         // resolver pipe timeout    private ModuleClassID membershipClassID;    private static PeerGroupID restoPeerGroupID;    static {        try {            restoPeerGroupID =            (PeerGroupID) IDFactory.fromURL(new URL(                  "urn", "", "jxta:uuid-058C59E291174BEFB804AACB9C6A3B5002"));        } catch (Exception e) {            throw new RuntimeException("Can't load RestoPeer");        }    }    public static void main(String args[]) {        RestoPeer myapp = new RestoPeer();        myapp.startJxta();        System.exit(0);    }    // Method to start the JXTA platform, join the RestoNet peergroup and    // advertise the RestoPeer service    private void startJxta() {        try {            //Discover and join (or start) the default peergroup            netpg = PeerGroupFactory.newNetPeerGroup();        } catch (PeerGroupException e) {            //Couldn't initialize; can't continue            System.out.println("Fatal error : creating the NetPeerGroup");            System.exit(1);        }        // Discover (or create) and join the RestoNet peergroup        try {            joinRestoNet();        } catch (Exception e) {            System.out.println("Can't join or create RestoNet");            System.exit(1);        }        // Discover (or create) and publish a RestoPeer pipe to receive        // auction request for fries from HungryPeers        if (!createRestoPipe()) {            System.out.println("Aborting due to failure to create RestoPeer pipe");            System.exit(1);        }        // Start the RestoPeer server loop to respond to Hungry peers        // fries requests.        handleFriesRequest();    }    // Discover (or create) and join the RestoNet peergroup    private void joinRestoNet() throws Exception {        int count = 3;   // maximun number of attempts to discover        System.out.println("Attempting to Discover the RestoNet PeerGroup");        // Get the discovery service from the NetPeergroup        DiscoveryService hdisco = netpg.getDiscoveryService();        Enumeration ae = null;   // Holds the discovered peers        // Loop until wediscover the RestoNet or        // until we've exhausted the desired number of attempts        while (count-- > 0) {            try {                // search first in the peer local cache to find                // the RestoNet peergroup advertisement                ae = hdisco.getLocalAdvertisements(DiscoveryService.GROUP,                                          "Name", "RestoNetAuth");                // If we found the RestoNet advertisement we are done                if ((ae != null) && ae.hasMoreElements())                    break;                // If we did not find it, we send a discovery request                hdisco.getRemoteAdvertisements(null,                       DiscoveryService.GROUP, "Name", "RestoNetAuth", 1, null);                // Sleep to allow time for peers to respond to the                // discovery request                try {                    Thread.sleep(timeout);                } catch (InterruptedException ie) {}            } catch (IOException e){                // Found nothing! Move on            }        }        PeerGroupAdvertisement restoNetAdv = null;        // Check if we found the RestoNet advertisement.        // If we didn't, then either        //       we are the first peer to join or        //       no other RestoNet peers are up.        // In either case, we must create the RestoNet peergroup        if (ae == null || !ae.hasMoreElements()) {            System.out.println(                 "Could not find the RestoNet peergroup; creating one");            try {                // Create a new, all-purpose peergroup. Because we                // have a custom peergroup advertisement, we must                // create the module impl advertisement and then                // the peergroup advertisement (just as we did when                // we created the peergroup as a service).                ModuleImplAdvertisement implAdv =                    createAuthPeerGroupModuleImplAdv(netpg);                hdisco.publish(implAdv, DiscoveryService.ADV,                        PeerGroup.DEFAULT_LIFETIME,                        PeerGroup.DEFAULT_EXPIRATION);                hdisco.remotePublish(implAdv, DiscoveryService.ADV,                        PeerGroup.DEFAULT_EXPIRATION);                restoNetAdv =                    createPeerGroupAdvertisement(implAdv, "RestoNetAuth");                // The peergroup advertisement membership service needs                // to have a parameter that initializes the valid                // users and passwords. Create a document that holds that                // information. There can be any number of login:passwd:                // pairs in the login tag value.                StructuredTextDocument pwds = (StructuredTextDocument)                    StructuredDocumentFactory.newStructuredDocument(                    new MimeMediaType("text/xml"), "Parm");                Element e = pwds.createElement("login",                    "hungrypeer:" +                    PasswdMembershipService.makePsswd("password") + ":");                pwds.appendChild(e);                restoNetAdv.putServiceParam(membershipClassID, pwds);                // Now publish the modified advertisement as usual                hdisco.publish(restoNetAdv, DiscoveryService.GROUP,                        PeerGroup.DEFAULT_LIFETIME,                        PeerGroup.DEFAULT_EXPIRATION);                hdisco.remotePublish(restoNetAdv, DiscoveryService.GROUP,                        PeerGroup.DEFAULT_EXPIRATION);                restoNet = netpg.newGroup(restoNetAdv);            } catch (Exception e) {                System.out.println("Error in creating RestoNet Peergroup " + e);                throw e;            }        } else {            // The RestoNet advertisement was found in the cache;            // that means we can join the existing RestoNet peergroup            try {                restoNetAdv = (PeerGroupAdvertisement) ae.nextElement();                restoNet = netpg.newGroup(restoNetAdv);                System.out.println(                    "Found the RestoNet Peergroup advertisement");            } catch (Exception e) {                System.out.println("Error in creating RestoNet PeerGroup from existing adv");                throw e;            }        }        // Instead of just joining, we must authenticate too        authenticateAndJoin(restoNet);        try {            // Get the discovery and pipe services for the RestoNet Peergroup            disco = restoNet.getDiscoveryService();            pipes = restoNet.getPipeService();        } catch (Exception e) {            System.out.println("Error getting services from RestoNet");            throw e;        }        System.out.println("RestoNet Restaurant (" + brand + ") is on-line");        return;    }    // Method 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 void handleFriesRequest() {        InputStream ip = null;               // Input Stream to read message        PipeAdvertisement hungryPipe = null; // HungryPeer Requester pipe        StructuredDocument request = null;   // Request document        StructuredDocument bid = null;       // Response document        // Document mime types        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        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                        else if (attr.equals("Fries")) {                            size = value;                            continue;                        }                    }                } catch (Exception e) {                    continue; // Broken content; silently discard                }                System.out.println("Received Request from HungryPeer "                               + name                               + " for "                               + size                               + " Fries.");                // The auction request is valid. We can

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
99久久婷婷国产综合精品电影| 欧美丝袜丝交足nylons| 成人sese在线| 欧美老肥妇做.爰bbww视频| 久久综合久久综合九色| 亚洲午夜免费电影| 91一区在线观看| 久久在线免费观看| 老司机精品视频一区二区三区| 成人av在线一区二区| 亚洲精品在线免费观看视频| 亚洲精品乱码久久久久久| 国产成人一区在线| 精品对白一区国产伦| 日韩精品一二三四| 欧美体内she精高潮| 亚洲人午夜精品天堂一二香蕉| 精品亚洲国产成人av制服丝袜| 欧美精品日韩一本| 亚洲国产一区二区三区 | 一区二区三区四区五区视频在线观看 | 国产女同互慰高潮91漫画| 日韩综合一区二区| 欧美午夜电影在线播放| 中文字幕日韩一区二区| 国产成人啪免费观看软件 | 欧美巨大另类极品videosbest| 亚洲日本乱码在线观看| 97精品电影院| 亚洲精品自拍动漫在线| 色综合久久99| 一区二区三区四区高清精品免费观看| av一区二区三区| 亚洲欧美在线aaa| 成人av网址在线观看| 国产精品久久久久影院老司 | 国产精品麻豆欧美日韩ww| 丁香一区二区三区| 国产精品久久久久影院亚瑟 | 日韩精品一区二区三区视频播放| 日韩成人午夜电影| 欧美大肚乱孕交hd孕妇| 精彩视频一区二区三区| 久久久不卡影院| 91麻豆视频网站| 香港成人在线视频| 久久综合久久综合亚洲| 成人av午夜影院| 午夜欧美2019年伦理| 精品久久五月天| av一二三不卡影片| 亚洲国产你懂的| 精品国产91亚洲一区二区三区婷婷| 精品夜夜嗨av一区二区三区| 国产免费观看久久| 欧洲亚洲国产日韩| 狠狠色狠狠色合久久伊人| 国产精品久久久久久久久免费相片| 91蜜桃在线观看| 免费日本视频一区| 国产精品久久三区| 日韩一级片在线播放| 国产99一区视频免费| 亚洲国产成人av网| 日本一区二区三区视频视频| 在线观看日韩精品| 另类的小说在线视频另类成人小视频在线 | 风间由美一区二区三区在线观看| 亚洲私人影院在线观看| 欧美一个色资源| 成人国产精品免费观看视频| 亚洲午夜一区二区| 国产欧美一区二区精品婷婷| 欧美视频中文字幕| 国产suv精品一区二区三区| 亚洲成a人v欧美综合天堂下载| 久久久综合网站| 欧美亚洲国产bt| 成人午夜伦理影院| 美女视频黄 久久| 亚洲精品乱码久久久久久黑人 | 欧美精品色一区二区三区| 国产一区 二区 三区一级| 亚洲国产美国国产综合一区二区| 国产调教视频一区| 日韩一级片在线播放| 在线观看一区二区视频| av不卡一区二区三区| 国产在线精品一区在线观看麻豆| 午夜视频一区在线观看| 亚洲乱码国产乱码精品精的特点| 久久久久久电影| 91精品国产综合久久久久久久久久| av中文字幕不卡| 懂色av中文一区二区三区| 蜜臀久久99精品久久久久久9| 亚洲韩国精品一区| 亚洲最大的成人av| 亚洲综合丁香婷婷六月香| 久久人人爽爽爽人久久久| 日韩午夜在线观看| 91精品在线免费| 欧美日本免费一区二区三区| 色哟哟欧美精品| jlzzjlzz亚洲日本少妇| 国产精品一区在线| 国产精品911| 国产成人精品免费在线| 黑人巨大精品欧美黑白配亚洲| 美女视频一区二区三区| 日韩成人午夜精品| 免费人成在线不卡| 美腿丝袜亚洲综合| 午夜精品久久久久久久久久| 亚洲一区二区av在线| 亚洲一线二线三线视频| 亚洲精品成人少妇| 亚洲午夜精品17c| 午夜精品久久久久久不卡8050| 亚洲一区二区三区四区五区中文| 亚洲综合在线电影| 亚洲国产wwwccc36天堂| 日韩国产在线观看| 久久国产精品区| 国产精品一区二区91| 国产成人精品一区二区三区四区| 国产成人亚洲综合a∨婷婷| 成人一区二区三区中文字幕| voyeur盗摄精品| 在线观看视频91| 日韩免费看的电影| 国产欧美一区二区三区网站| 日韩美女啊v在线免费观看| 亚洲综合区在线| 日韩高清不卡一区二区三区| 日本在线不卡视频| 国产黄色91视频| 99久久婷婷国产| 91麻豆精品久久久久蜜臀| 国产调教视频一区| 亚洲一区二区影院| 久久99国产精品久久99果冻传媒| 成人影视亚洲图片在线| 欧美日韩国产小视频| 久久精品日韩一区二区三区| 亚洲激情五月婷婷| 蜜臀av在线播放一区二区三区| 国产91高潮流白浆在线麻豆| 色噜噜久久综合| 精品国产电影一区二区| 亚洲激情图片一区| 国产一区二区导航在线播放| 色婷婷国产精品| 久久理论电影网| 亚洲第一会所有码转帖| 国产成人免费9x9x人网站视频| 色欧美片视频在线观看在线视频| 欧美成人精品3d动漫h| 亚洲视频在线一区二区| 日本欧美一区二区在线观看| 97超碰欧美中文字幕| 欧美变态tickling挠脚心| 亚洲精品视频观看| 国产精品正在播放| 91精品国产福利| 亚洲欧美日韩国产一区二区三区 | 在线影视一区二区三区| 欧美一级理论片| 一区二区三区四区视频精品免费 | 93久久精品日日躁夜夜躁欧美| 7777精品伊人久久久大香线蕉超级流畅 | 国产福利一区二区三区视频在线 | 国产精品一区二区在线观看网站 | 久久99国产精品久久99| 色婷婷综合五月| 国产欧美日本一区视频| 久久成人免费日本黄色| 欧美亚洲国产怡红院影院| 国产精品入口麻豆九色| 国模少妇一区二区三区| 91精品国产一区二区三区| 亚洲一区在线播放| 色综合天天综合网天天狠天天| 国产日韩欧美高清| 精品综合久久久久久8888| 3d动漫精品啪啪一区二区竹菊| 亚洲精品高清视频在线观看| 成人网页在线观看| 国产精品麻豆久久久| 不卡的av电影| 国产精品萝li| 成人av网站在线观看| 亚洲国产成人在线| 国产经典欧美精品| 日本一区二区三区dvd视频在线| 国内成人免费视频| 26uuu精品一区二区| 丰满少妇在线播放bd日韩电影| 久久久久久久免费视频了| 国产高清精品久久久久|