找了老半天,终于找到了,资料的整理很重要
1 package jxtaserviceexample.util;
2
3 import net.jxta.id.IDFactory;
4 import net.jxta.peergroup.PeerGroup;
5 import net.jxta.peergroup.PeerGroupID;
6 import net.jxta.platform.ModuleClassID;
7 import net.jxta.platform.ModuleSpecID;
8
9 /**
10 * A simple application to generate a Module Class ID, Module Specification ID, Peer
11 * Group ID, and Module Specification ID based on the standard peer group Module Class ID.
12 *
13 * @author cuizhenfu@gmail.com
14 *
15 */
16 public class GeneratorID {
17
18 /**
19 * Generates the IDs.
20 *
21 * @param args the command-line arguments. Ignored by this app.
22 */
23 public static void main(String[] args) {
24 // Create an entirely new Module Class ID.
25 ModuleClassID classID = IDFactory.newModuleClassID();
26
27 // Create a Module Specification ID based on the generated Module Class ID.
28 ModuleSpecID specID = IDFactory.newModuleSpecID(classID);
29
30 // Create an entirely new Peer Group ID.
31 PeerGroupID groupID = IDFactory.newPeerGroupID();
32
33 // Create a Module Specification ID based on the peer group Module Class ID.
34 ModuleSpecID groupSpecID = IDFactory.newModuleSpecID(PeerGroup.allPurposePeerGroupSpecID.getBaseClass());
35
36 // Print out the generated IDs.
37 System.out.println("Module Class ID: " + classID.toURI());
38 System.out.println("Module Spec ID: " + specID.toURI());
39 System.out.println("Peer Group ID: " + groupID.toURI());
40 System.out.println("Peer Group Module Spec ID: " + groupSpecID.toURI());
41 }
42
43 }
2
3 import net.jxta.id.IDFactory;
4 import net.jxta.peergroup.PeerGroup;
5 import net.jxta.peergroup.PeerGroupID;
6 import net.jxta.platform.ModuleClassID;
7 import net.jxta.platform.ModuleSpecID;
8
9 /**
10 * A simple application to generate a Module Class ID, Module Specification ID, Peer
11 * Group ID, and Module Specification ID based on the standard peer group Module Class ID.
12 *
13 * @author cuizhenfu@gmail.com
14 *
15 */
16 public class GeneratorID {
17
18 /**
19 * Generates the IDs.
20 *
21 * @param args the command-line arguments. Ignored by this app.
22 */
23 public static void main(String[] args) {
24 // Create an entirely new Module Class ID.
25 ModuleClassID classID = IDFactory.newModuleClassID();
26
27 // Create a Module Specification ID based on the generated Module Class ID.
28 ModuleSpecID specID = IDFactory.newModuleSpecID(classID);
29
30 // Create an entirely new Peer Group ID.
31 PeerGroupID groupID = IDFactory.newPeerGroupID();
32
33 // Create a Module Specification ID based on the peer group Module Class ID.
34 ModuleSpecID groupSpecID = IDFactory.newModuleSpecID(PeerGroup.allPurposePeerGroupSpecID.getBaseClass());
35
36 // Print out the generated IDs.
37 System.out.println("Module Class ID: " + classID.toURI());
38 System.out.println("Module Spec ID: " + specID.toURI());
39 System.out.println("Peer Group ID: " + groupID.toURI());
40 System.out.println("Peer Group Module Spec ID: " + groupSpecID.toURI());
41 }
42
43 }
附带一个以前写的jxta自定义服务的例子
说明:
jxtaserviceexample.SimpleServiceTest
测试类,执行该类可以看到,新建的group提供了SimpleService服务,并且通过该group获得该服务,并执行服务提供的alert方法。
jxtaserviceexample.impl.protocol.SimpleServiceImpl
服务的实现类
jxtaserviceexample.protocol.SimpleService
服务接口,仅增加了alert方法,供测试用
jxtaserviceexample.util.GeneratorID
用于生成Service所需的各种ID
测试类,执行该类可以看到,新建的group提供了SimpleService服务,并且通过该group获得该服务,并执行服务提供的alert方法。
jxtaserviceexample.impl.protocol.SimpleServiceImpl
服务的实现类
jxtaserviceexample.protocol.SimpleService
服务接口,仅增加了alert方法,供测试用
jxtaserviceexample.util.GeneratorID
用于生成Service所需的各种ID
——————————————————————————————————
傲轩游戏网
傲轩游戏网