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

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

?? groupmanager.java~

?? Java p2p程序設計2002年版
?? JAVA~
?? 第 1 頁 / 共 2 頁
字號:
package com.sams.jxta.groups;

import net.jxta.credential.AuthenticationCredential;
import net.jxta.credential.Credential;
import net.jxta.discovery.DiscoveryService;
import net.jxta.document.Advertisement;
import net.jxta.document.AdvertisementFactory;
import net.jxta.document.StructuredDocument;
import net.jxta.document.StructuredTextDocument;
import net.jxta.exception.PeerGroupException;
import net.jxta.exception.ProtocolNotSupportedException;
import net.jxta.impl.id.UUID.UUIDFactory;
import net.jxta.impl.protocol.PeerGroupAdv;
import net.jxta.peergroup.PeerGroupID;
import net.jxta.peergroup.PeerGroupFactory;
import net.jxta.impl.peergroup.StdPeerGroupParamAdv;
import net.jxta.membership.Authenticator;
import net.jxta.membership.MembershipService;
import net.jxta.peergroup.PeerGroup;
import net.jxta.protocol.ModuleImplAdvertisement;
import net.jxta.protocol.PeerGroupAdvertisement;

import java.util.Enumeration;
import java.util.Hashtable;

/**
 * This class can be used to create a new group with a pluggable 
 * Membership service.It provides simple APIs for Apply,Join and Resign
 * functionalities.
 */

public class GroupManager {

    private static final org.apache.log4j.Category LOG = 
        org.apache.log4j.Category.getInstance(GroupManager.class.getName());
    protected DiscoveryService disco;
    // The parent group of the current peer group
    protected PeerGroup parent;
    // Net peer for creating advertisements.
    protected PeerGroup netPeerGroup;
    // The current peer group
    protected PeerGroup activeGroup;
    // Any module(like a peer group) that is loaded by the parent group,must 
    // be compatible with the parent.Compatibility is checked by comparision 
    // with the stdCompactStatement 
    public StructuredTextDocument stdCompatStatement = // ??? Taken from StdPeerGroup
                mkCS();
    // An identifier to the implementation used // ??? Is it so ?
    public String stdUri = "http://www.jxta.org/download/jxta.jar";// ??? Taken from StdPeerGroup
    // The provider of the implementation // ??? Is it so ?
    public String stdProvider = "sun.com";// ??? Taken from StdPeerGroup

    // The mime type of all documents used in this example
    public static final String DOCUMENT_MIME_TYPE="text";
    // The base type of all documents
    public static final String DOCUMENT_BASE_TYPE="xml";
    // This is the root element documents created
    public static final String DOCUMENT_ROOT_ELEMENT="Comp";    
    // Key ??? What is this used for ?
    private static final String KEY="Efmt";    
    // Value ??? What is this used for ?
    private static final String VALUE="JDK1.4";
    // Key used to represent the binding
    private static final String BINDING_KEY="Bind";
    // Value of the binding key.It represents the binding 
    // of JXTA that we use.
    private static final String BINDING_VALUE="V1.0 Ref Impl";
   
    /** 
     * The constructor of the Group Manger.Initially 
     * the parent group is the also the active group.
     */
     
    public GroupManager(PeerGroup netPeerGroup, PeerGroup parent) {
   
        this.disco  = parent.getDiscoveryService();
        this.parent = parent;
        this.activeGroup = parent;
        this.netPeerGroup = netPeerGroup;
        if (netPeerGroup ==  null){
            System.out.println("netPeerGroup :"+netPeerGroup+" - aborting");
            throw new NullPointerException("netPeerGroup :"+netPeerGroup+" - aborting");
            
        }
   }
    
    /* 
     *   Method to add a new peer group and publish it.The 
     *   groupMemebershipClassName is the fully qualified class 
     *   name of the mermbership service class.
     *
     */
     
    public PeerGroup addGroup(String groupName,String groupMembershipClassName,
                              String groupDescription,
                              ModuleImplAdvertisement advertisement,
                              boolean conditional){
System.out.println("GroupManager.addGroup Successfully created SecurityDemoGroup");
        // The first thing we do is to see if a group already exists by this name.
        // If so we get the Group ID of the group. Then depending on the unconditional
        // flag we proceed.
        // If it is an conditional add ,we create a new group only if no other group
        // with the same name already exists otherwise we throw an exception.
        // If it is an unconditional add , we always create  a group.If the user had previously
        // created the group , we use the Old group ID . 
        PeerGroupID oldPeerGroupID = alreadyExists(groupName);
        if(oldPeerGroupID != null && conditional==true)
            throw new GroupManagerException("A Group by this name already exists with id :"
                                             +oldPeerGroupID);
        
        // If no Advertisement is provided, we create a fresh advertisement.
        if (advertisement == null){
            LOG.debug("Creating a new Advertisement");
            // We use the existing advertisement of the standard peer group
            // and add our service along with the other standard services 
            try{
                // This is used as a base to create the new advertisement upon    
                System.out.println("netPeerGroup :"+netPeerGroup);
                advertisement = netPeerGroup.getAllPurposePeerGroupImplAdvertisement();
                //advertisement = parent.getAllPurposePeerGroupImplAdvertisement();//<< Did not work in current platform
                StructuredDocument paramDoc = advertisement.getParam();
                System.out.println("StructuredDocument paramDoc:"+paramDoc);
                // The Param document used to make the StandradPeerGroup Advertisement
                StdPeerGroupParamAdv paramAdv = new StdPeerGroupParamAdv(paramDoc);
                // List of all the available standard services
                Hashtable services = paramAdv.getServices();
                // Make a ModuleImplAdvertisemnet for the membership service
                ModuleImplAdvertisement moduleAdv = 
                    mkImplAdvBuiltin(PeerGroup.refMembershipSpecID,groupMembershipClassName,
                                     groupDescription);
                // Add this service along the other standard services            
                services.put(PeerGroup.membershipClassID, moduleAdv);
                paramAdv.setServices(services);
                advertisement.setParam((net.jxta.document.TextElement)paramAdv.getDocument(
                              new net.jxta.document.MimeMediaType(DOCUMENT_MIME_TYPE,
                                                                  DOCUMENT_BASE_TYPE)));
            }catch(PeerGroupException peerGroupException){
                peerGroupException.printStackTrace();
                System.exit(-1);
                LOG.error("Error in creating Advertisement",peerGroupException);
                throw new GroupManagerException(peerGroupException.getMessage());
            }catch(Exception genericException){
                genericException.printStackTrace();
                LOG.error("Error in creating Advertisement",genericException);
                System.exit(-1);
                throw new GroupManagerException(genericException.getMessage());
            }
        }
        LOG.debug("Successfullt created ADVERTISEMENT");  
        
        // initialize but to no start the application
        // this is done by the join command
        LOG.debug("Creating the Peer Group");        
        PeerGroup peerGroup = null;
        try {
            // create a PeerGroup ID
            PeerGroupID peerGroupID = null;
            if(oldPeerGroupID != null){
                peerGroupID = oldPeerGroupID;
            }else{
                peerGroupID = new net.jxta.impl.id.UUID.PeerGroupID(UUIDFactory.newUUID());
            }
            // create the PeerGroup
            peerGroup = parent.newGroup(peerGroupID, advertisement, groupName, groupDescription);////
            // initialize the peergroup
            peerGroup.init(this.parent,peerGroupID, advertisement);
        } catch (PeerGroupException peerGroupException) {
            peerGroupException.printStackTrace();
            LOG.error("Unable to create a peer group !",peerGroupException);
            throw new GroupManagerException(peerGroupException.getMessage());
        }
        // For debug purposes, print advertisement to console
        //com.sams.jxta.Util.printAdvertismentDoc(advertisement);
        // Try to publish the advertisement
        LOG.debug("Trying to publish the advertisement");
        publish(peerGroup, advertisement/*original advertisement???*/);
        LOG.debug("Peer Group Advertisement successfully published");
        return peerGroup;
  
   }

    /** 
     * Will check if a peer group with the same name exists on this peer
     */

    public PeerGroupID alreadyExists(String name){
    
        DiscoveryService discovery = parent.getDiscoveryService();
        Enumeration enumeration =null;
        try{
            enumeration =
                discovery.getLocalAdvertisements(discovery.GROUP, "Name",name);
        } catch(java.io.IOException ioException) {
            LOG.debug("Error in getting local advertisements ");
            return null;
        }
        // If the group already exists either the  enumeration is null
        // or it does not contain any data 
        
        if(enumeration != null && enumeration.hasMoreElements())
            return ((PeerGroupAdv)enumeration.nextElement()).getPeerGroupID();
        else
            return null; 
    }

    // Tries to publish the newly created peer group  
    // ??? Why do we need the original Advertisement ?
    private void publish(PeerGroup child,Advertisement pgAdv
                               //PeerGroupAdvertisement origAdv
                               ) {
      System.out.println("Publishing group");
      //get the Discovery for this group
      //Publish the New Peer in its group discovery
      
      DiscoveryService discovery;
      try {
         discovery = parent.getDiscoveryService();
         discovery.publish(pgAdv, DiscoveryService.GROUP);
         // let's publish the peer adv
         //if (origAdv != null){//?????? Not sure what this does
            // we could check if it is indeed ours
            // but it does not hurt to publish it any way
         //   discovery = child.getDiscoveryService();
         //   discovery.publish(origAdv, DiscoveryService.GROUP);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩国产一级二级| 91精品国产综合久久蜜臀| 日韩精品国产欧美| 国产日韩高清在线| 欧美精品v国产精品v日韩精品| 国产一区二区三区美女| 亚洲成人7777| 亚洲视频一区在线| 日韩亚洲欧美成人一区| 色8久久精品久久久久久蜜| 国产九色精品成人porny| 亚洲国产aⅴ成人精品无吗| 中文字幕va一区二区三区| 日韩一本二本av| 欧美日韩亚洲综合在线| 91论坛在线播放| 国产成人免费视频| 国产一区二区精品久久| 免播放器亚洲一区| 亚洲成人激情自拍| 亚洲免费观看高清完整版在线观看熊| 欧美精品一区二区三| 欧美一区二区国产| 欧美日韩久久久一区| 91碰在线视频| 91在线精品一区二区三区| 国产东北露脸精品视频| 国产在线精品一区二区三区不卡| 免费黄网站欧美| 日本欧美在线看| 日韩av在线发布| 日韩中文字幕一区二区三区| 亚洲午夜免费视频| 一区二区三区精品| 亚洲综合激情另类小说区| 综合久久一区二区三区| 国产精品久久久久一区二区三区共| 国产欧美一区二区精品婷婷| 国产视频一区在线观看| 久久久亚洲欧洲日产国码αv| 日韩欧美国产麻豆| 日韩视频一区二区三区| 欧美tickling挠脚心丨vk| 日韩三级.com| 久久综合久色欧美综合狠狠| 精品卡一卡二卡三卡四在线| 日韩欧美一二三四区| 精品国产乱码久久久久久久久| 精品人伦一区二区色婷婷| 精品久久久久久无| 精品福利一区二区三区免费视频| 精品国产一区二区三区久久久蜜月| 欧美一区二区三区免费| 精品久久国产老人久久综合| 亚洲精品在线电影| 国产欧美精品区一区二区三区| 国产精品美女久久久久久久网站| 亚洲色欲色欲www在线观看| 亚洲午夜三级在线| 麻豆精品国产91久久久久久| 国产老肥熟一区二区三区| 成人三级在线视频| 91久久精品日日躁夜夜躁欧美| 欧美日韩中文字幕一区| 欧美一区二区私人影院日本| 久久综合色婷婷| 亚洲欧美一区二区久久| 亚洲成人在线免费| 国内精品久久久久影院色| 国产精品综合视频| 色综合久久久久综合体桃花网| 欧美视频完全免费看| 欧美精品一区二区三区在线播放| 国产精品国产三级国产普通话99| 亚洲一区在线观看网站| 麻豆精品在线观看| av中文一区二区三区| 欧美日韩亚洲另类| 国产亚洲视频系列| 亚洲一区二区精品3399| 黄色资源网久久资源365| 99视频在线精品| 日韩亚洲欧美综合| 亚洲黄色小说网站| 国内国产精品久久| 在线观看免费视频综合| 精品国产成人系列| 亚洲精品乱码久久久久久久久| 久久丁香综合五月国产三级网站 | 国产美女精品人人做人人爽| 99riav久久精品riav| 日韩你懂的在线观看| 综合欧美一区二区三区| 国内久久婷婷综合| 3d动漫精品啪啪| 日韩一区在线播放| 国内成人免费视频| 欧美日韩中文精品| 自拍偷拍亚洲激情| 国产精品一区二区久久精品爱涩| 欧美日韩三级在线| 亚洲天堂精品在线观看| 国产在线精品一区二区夜色| 欧美亚洲一区二区在线| 国产日韩欧美麻豆| 久久精品国产一区二区| 欧美日韩欧美一区二区| 成人免费一区二区三区视频| 国产高清无密码一区二区三区| 欧美剧情片在线观看| 中文字幕在线一区| 国产精品一二三| 精品捆绑美女sm三区| 视频一区视频二区在线观看| 91丝袜美腿高跟国产极品老师| 久久美女艺术照精彩视频福利播放 | 韩国一区二区视频| 91精品国产入口| 午夜婷婷国产麻豆精品| 色诱视频网站一区| 国产精品久久久久久妇女6080| 国产精品 日产精品 欧美精品| 欧美一区二区国产| 美腿丝袜亚洲色图| 51精品视频一区二区三区| 亚洲国产综合91精品麻豆| 在线视频国内自拍亚洲视频| 亚洲精品va在线观看| 91亚洲精品久久久蜜桃| 亚洲视频香蕉人妖| 91国产丝袜在线播放| 亚洲女同女同女同女同女同69| 99天天综合性| 一区二区三区在线播放| 色婷婷国产精品久久包臀| 亚洲三级理论片| 色婷婷狠狠综合| 亚洲成人av电影在线| 69精品人人人人| 美女国产一区二区三区| 精品国产一区二区三区av性色 | 精品一区二区日韩| 久久丝袜美腿综合| 国产白丝精品91爽爽久久| 中文字幕免费一区| 成人看片黄a免费看在线| 亚洲欧洲精品一区二区三区不卡 | 欧美日韩激情在线| 性做久久久久久| 欧美一区二区三区公司| 九九精品视频在线看| 久久久久高清精品| jizz一区二区| 亚洲精品国产第一综合99久久| 欧美性videosxxxxx| 麻豆精品一区二区综合av| 欧美一区二区三区免费视频| 国产一区二区中文字幕| 综合久久久久久| 欧美日韩久久久| 国产精品99久久久久久宅男| 国产亚洲午夜高清国产拍精品| 94-欧美-setu| 亚洲成人免费影院| 久久久久久久综合色一本| 91免费版在线| 亚洲成av人在线观看| 26uuu欧美| 成人动漫中文字幕| 亚洲二区在线视频| 精品国产91洋老外米糕| 成人av影院在线| 五月综合激情网| 欧美经典三级视频一区二区三区| jvid福利写真一区二区三区| 爽好久久久欧美精品| 久久精品一区二区三区不卡 | av中文字幕不卡| 婷婷中文字幕一区三区| 久久蜜桃av一区二区天堂| 成人综合婷婷国产精品久久| 一区二区在线观看免费| 欧美videofree性高清杂交| 国产精品亚洲人在线观看| 亚洲一区在线视频| 精品欧美一区二区久久| 在线中文字幕一区| 国产主播一区二区| 亚洲一区二区精品久久av| 国产三级欧美三级日产三级99| 91久久精品网| 免费精品99久久国产综合精品| 亚洲欧美日韩电影| 日韩精品一区二区三区在线播放| 972aa.com艺术欧美| 免费不卡在线观看| 一区二区三区在线观看国产| 久久久久久久久久久久久女国产乱| 在线观看免费成人| 成人精品一区二区三区中文字幕|