Coverage details for base.jdbs.network.util.JxtaUtil

LineHitsSource
1 package base.jdbs.network.util;
2  
3 import java.util.Enumeration;
4 import java.util.Vector;
5  
6 import net.jxta.discovery.DiscoveryService;
7 import net.jxta.protocol.PeerAdvertisement;
8 import net.jxta.protocol.PeerGroupAdvertisement;
9  
10 import org.apache.log4j.Logger;
11  
120public class JxtaUtil {
13     
140    private static final transient Logger logger = Logger.getLogger(JxtaUtil.class.getName());
15     
16     
17     /**
18      * This method must be used to retrieve each PeerGroupAdvertisement stored in the local peer's cache.
19      * @param discoveryService The discovery service used to check the Peer Group Advertisements stored in the local cache.
20      * @return A set of PeerGroupAdvertisement found in the local peer's cache.
21      */
22     public static PeerGroupAdvertisement[] groupsInLocalCache(DiscoveryService discoveryService) {
230        Vector<PeerGroupAdvertisement> result = new Vector<PeerGroupAdvertisement>();
240        logger.debug("--- local cache (Peer Groups) ---");
25         try {
260            PeerGroupAdvertisement peerGroupAdvertisement = null;
270            Enumeration enumeration = discoveryService.getLocalAdvertisements(DiscoveryService.GROUP, null, null);
280            if (enumeration != null) {
290                while (enumeration.hasMoreElements()) {
300                    peerGroupAdvertisement = (PeerGroupAdvertisement) enumeration.nextElement();
310                    result.add(peerGroupAdvertisement);
320                    logger.debug( peerGroupAdvertisement.getName() + ", group ID = " +peerGroupAdvertisement.getPeerGroupID().toString());
330                }
34             }
350        } catch (Exception ex) {
360            ex.printStackTrace();
370        }
380        logger.debug("--- end local cache ---");
390        return result.toArray(new PeerGroupAdvertisement[0]);
40     }
41     
42     /**
43      * This method must be used to retrieve each PeerAdvertisement stored in the local peer's cache.
44      * @param discoveryService The discovery service used to check the Peer Advertisements stored in the local cache.
45      * @return A set of PeerAdvertisement found in the local peer's cache.
46      */
47     public static PeerAdvertisement[] peersInLocalCache(DiscoveryService discoveryService) {
480        Vector<PeerAdvertisement> result = new Vector<PeerAdvertisement>();
490        logger.debug("--- local cache (Peers) ---");
50         try {
510            PeerAdvertisement peerAdvertisement = null;
520            Enumeration enumeration = discoveryService.getLocalAdvertisements(DiscoveryService.PEER, null, null);
530            if (enumeration != null) {
540                while (enumeration.hasMoreElements()) {
550                    peerAdvertisement = (PeerAdvertisement) enumeration.nextElement();
560                    result.add(peerAdvertisement);
570                    logger.debug( peerAdvertisement.getName() + ", peer ID = " +peerAdvertisement.getPeerID().toString());
580                }
59             }
600        } catch (Exception ex) {
610            ex.printStackTrace();
620        }
630        logger.debug("--- end local cache ---");
640        return result.toArray(new PeerAdvertisement[0]);
65     }
66     
67     
68  
69 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.