Skip to main content

creating custom advertisement

2 replies [Last post]
Joined: 2008-09-22

I am having problem creating custom advertisement.
the thing is i created the advertisement, and it is working, but when peer finds it, all fields are interpreted correctly, well, all except ID field in which i get null-ID value. So is there a way to pass ID field correctly?
custom advertisement class is in the attachment.
THX. for helping in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2008-09-22

well the problem was not in the code but in the cashed advertisements from early testing :). Sorry to anyone who tried to solve my problem :).

Joined: 2008-06-18


I've a problem creating a custom advertisement too. In my case, the advertisement is dinamic and I'm using the method put/getServiceParam from PeerGroupAdvertisement. This is my design (roughly):




Then, I have a problem when I want to add a file section, I do this:

public void addFile(File file) {
String name = file.getPath();
StructuredTextDocument fileElem =
(StructuredTextDocument) StructuredDocumentFactory.newStructuredDocument(new MimeMediaType("text/xml"), "File");
TextElement text = fileElem.createElement(fileNameTag, name);
putServiceParam(idFiles, fileElem);

If I want to recover the file section I do the following:

System.out.println("Service:" + repoAdv.getServiceParam(idFiles));

But, if I call addFile two times, the only file section that I can recover is the last one. I supposed that is due to the two file sections share the same id, but I dont know how to handle this.

Is there a better way to handle this kind of advertisement?