当前位置: 首页>>代码示例>>Java>>正文


Java MembershipService类代码示例

本文整理汇总了Java中net.jxta.membership.MembershipService的典型用法代码示例。如果您正苦于以下问题:Java MembershipService类的具体用法?Java MembershipService怎么用?Java MembershipService使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MembershipService类属于net.jxta.membership包,在下文中一共展示了MembershipService类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: joinToGroup

import net.jxta.membership.MembershipService; //导入依赖的package包/类
public static void joinToGroup(PeerGroup group) //This method will join to either found group or created group
{
    StructuredDocument creds = null;
    
    logger.debug("Joining into " + group.getPeerGroupName() + "...");    
    
    
    try{
        //Athenticate and join to group
    AuthenticationCredential authCred = new AuthenticationCredential(group,null,creds);
    MembershipService membership = group.getMembershipService();
    Authenticator auth = membership.apply(authCred);
        if(auth.isReadyForJoin()){
            Credential myCred = membership.join(auth);
            
            logger.debug("===== Group Details =====");
                         
            
            StructuredTextDocument doc = (StructuredTextDocument)myCred.getDocument(new MimeMediaType("text/plain"));
            StringWriter out = new StringWriter();
            doc.sendToWriter(out);
            
            //System.out.println(out.toString());
            if(logger.isTraceEnabled()){
                logger.trace(out.toString());
                
            }
            
            //Publishing Peer Advertisements.
            DiscoveryService groupDiscoveryService = group.getDiscoveryService();
            
            logger.debug("Peer Name : " + group.getPeerName() + " is now online :-)");
            logger.debug("Obtaining SaEeDGroup Services.");
            logger.debug("Publishing Peer Advertisement.");
            
            
            groupDiscoveryService.publish(group.getPeerAdvertisement());
            groupDiscoveryService.remotePublish(group.getPeerAdvertisement());
            
            logger.debug("[===========================]\n");
        }
        else{
    	logger.fatal("[!!]Fatal Error: Cannot Join to The Group!");
            //System.exit(-1);
        }            
    }catch(Exception e){
        	logger.fatal("[!]Fatal Error: " + e.getMessage());
            e.printStackTrace();
            //System.exit(-1);
        }
}
 
开发者ID:avasquez614,项目名称:cloud-raid,代码行数:52,代码来源:PeerGroupUtil.java


注:本文中的net.jxta.membership.MembershipService类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。