开发者

Publishing and Discovering custom JXTA Advertisements

I'm using JXTA 2.5 to implement a P2P auctioning application. There I need to implement publishing and discovering "Product_Advertisement"s to advertise available products on peers in a market group. I created a custom Product_Advertisement type extending the Advertisement super class. And this is a sample advertisement that is published:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jxta:ProductAdvertisement>
<jxta:ProductAdvertisement xml:space="default" xmlns:jxta="http://jxta.org">
<ID>
    urn:jxta:jxta-Null
</ID>
<name>
Sample Product
<n开发者_StackOverflow中文版ame/>

<price>
    23.50
</price>
<quantity>
    4
</quantity>
<exchangeProducts/>
</jxta:ProductAdvertisement>

Even though the "Product_Advertisement" is published without a problem, The discovery of the Advertisement is not happing as I expected. When I use the discoveryService of the peergroup and catch the advertisement published, here's what I'm receiving when I use .toString() of the received advertisement:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jxta:MIA>
<jxta:MIA xml:space="default" xmlns:jxta="http://jxta.org">
<MSID>
    urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE000000010206
</MSID>
<Desc>
    Default Network PeerGroup reference implementation
</Desc>
<Comp>
    <Efmt>
        JDK1.4.1
    </Efmt>
    <Bind>
        V2.0 Ref Impl
    </Bind>
</Comp>
<Code>
    net.jxta.impl.peergroup.ShadowPeerGroup
</Code>
<PURI>
    http://jxta-jxse.dev.java.net/download/jxta.jar
</PURI>
<Prov>
    sun.com
</Prov>
<Parm>
    <Svc>
        urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE000000100106
    </Svc>
    <Svc>
        urn:jxta:uuid-DEADBEEFDEAFBABAFEEDBABE0000000E0106
    </Svc>
    <Svc>
</Parm>
</jxta:MIA>

Can somebody tell me what I have done wrong?

Thanks in advance, Dileepa


Customized advertisements is a bit tricky in JXTA. To make it simple, take a look at the Practical JXTA II book available online at Scribd for an example.

From what you mention, there is surely an issue with your search code. There is also a high probability that your advertisement in not 'registered'. If you are using peers behind NATs, keep in mind that 2.5 is bugged. You need to use 2.6 or 2.7.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜