Skip to main content

Cannot change to PSEMembershipService of PeerGroup

4 replies [Last post]
kranasian
Offline
Joined: 2007-10-17

I am new to JXTA and intend to create a rendezvous Peer Group with PSEMembershipService. I use JXTA 2.4.1 and creates the peer group through this code:

NetPeerGroupFactory factory;

try {
factory = new NetPeerGroupFactory(
(ConfigParams)configurator.getPlatformConfig(),
new File(jxtaHome).toURI(),
IDFactory.fromURI(new URI(NetPeerGroupID)),
NetPeerGroupName,
(XMLElement) StructuredDocumentFactory.newStructuredDocument(MimeMediaType.XMLUTF8,
"desc", NetPeerGroupName)
);
}
catch(URISyntaxException e) {
throw new Exception(e.getMessage());
}

netPeerGroup = factory.getInterface();
newGroup = netPeerGroup.newGroup(groupID,implAdv,name,desc);

But the problem is when I create a PSEMembershipService Advertisement and publish it , the PSEMembershipService is still NoneMembershipService. Im suspecting the problem lies is publishing the advertisement.. but i'm not really sure.

DiscoveryService disco = newGroup.getDiscoveryService();
disco.publish(pseImpl, PeerGroup.DEFAULT_LIFETIME, PeerGroup.DEFAULT_EXPIRATION);

However, when I use the deprecated way of creating a PeerGroup, newGroup = PeerGroupFactory.newNetPeerGroup(), it works fine.

Can anyone help me about this?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bondolo
Offline
Joined: 2003-06-11

I suspect the problem is with the implAdv you are providing to the netPeerGroup.newGroup(). How are you creating the group implementation advertisement?

kranasian
Offline
Joined: 2007-10-17

Thanks for the reply. This is how I created the group implementation:

String name = "My App Group";
String desc = "My App Group Description";
String gid = PeerGroupIDCreator.createPeerGroupID(name).toString();
String specID = PeerGroupIDCreator.createModuleSpecID(name).toString();

ModuleImplAdvertisement implAdv = netPeerGroup.getAllPurposePeerGroupImplAdvertisement();

ModuleSpecID modSpecID = (ModuleSpecID )IDFactory.fromURI(new URI(specID));
implAdv.setModuleSpecID(modSpecID);

//Create the new group using the group ID, advertisement, name, and description
PeerGroupID groupID = (PeerGroupID )IDFactory.fromURI(new URI(gid));
newGroup = netPeerGroup.newGroup(groupID,implAdv,name,desc);

kranasian
Offline
Joined: 2007-10-17

also, this is how I create the PSEMembership Group Advertisement Implementation:

ModuleImplAdvertisement newGroupImpl = netPeerGroup.getAllPurposePeerGroupImplAdvertisement();

newGroupImpl.setModuleSpecID((ModuleSpecID)IDFactory.fromURI(new URI(specID)));
newGroupImpl.setDescription("PSE Peer Group Implementation");

ModuleImplAdvertisement implAdv = (ModuleImplAdvertisement) AdvertisementFactory.newAdvertisement( ModuleImplAdvertisement.getAdvertisementType());

implAdv.setModuleSpecID(PSEMembershipService.pseMembershipSpecID);
implAdv.setCompat(newGroupImpl.getCompat());
implAdv.setCode(PSEMembershipService.class.getName());
implAdv.setUri(newGroupImpl.getUri());
implAdv.setProvider(newGroupImpl.getProvider());
implAdv.setDescription("PSE Membership Service");
DiscoveryService disco = newGroup.getDiscoveryService();
disco.publish(pseImpl, PeerGroup.DEFAULT_LIFETIME, PeerGroup.DEFAULT_EXPIRATION);

bondolo
Offline
Joined: 2003-06-11

It shouldn't be necessary to create a new moduleImplAdvertisement for the PSE Membership Service--it already has an advertisement. The key is to modify the peer group module impl advertisement for your peer group. The JXSE "CustomGroupService" tutorial covers almost exactly what you are trying to do. The key difference between the tutorial and this case is that you will be replacing the membership service rather than adding a new service Custom Group Service Tutorial