log.info("XmlBlaster is ready for testing subscribe MIME filter");
try {
log.info("Connecting ...");
con = glob.getXmlBlasterAccess();
ConnectQos qos = new ConnectQos(glob, name, passwd);
con.connect(qos, this); // Login to xmlBlaster
}
catch (Exception e) {
Thread.dumpStack();
log.severe("Can't connect to xmlBlaster: " + e.toString());
}
// Subscribe to a message with a supplied filter
try {
// One sport subscriber
SubscribeQos qos = new SubscribeQos(glob);
qos.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[@type='sport']"));
subscribeOid = con.subscribe("<key oid='MSG'/>", qos.toXml()).getSubscriptionId();
subscriberTable.put(subscribeOid, new Integer(0));
log.info("Success: Subscribe subscription-id=" + subscribeOid + " done");
// One culture subscriber
qos = new SubscribeQos(glob);
qos.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[@type='culture']"));
subscribeOid2 = con.subscribe("<key oid='MSG'/>", qos.toXml()).getSubscriptionId();
subscriberTable.put(subscribeOid2, new Integer(1));
log.info("Success: Subscribe subscription-id2=" + subscribeOid2 + " done");
// And one on another msg type but with the same xpath
qos = new SubscribeQos(glob);
qos.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[@type='sport' or @type='culture']"));
subscribeOid3 = con.subscribe("<key oid='AnotherMsG'/>", qos.toXml()).getSubscriptionId();
subscriberTable.put(subscribeOid3, new Integer(2));
log.info("Success: Subscribe subscription-id3=" + subscribeOid3 + " done");
// Ad with extention functions
qos = new SubscribeQos(glob);
qos.addAccessFilter(new AccessFilterQos(glob, "XPathFilter", "1.0", "/news[ contains-ignore-case( recursive-text(body), 'needle')]"));
subscribeOid4 = con.subscribe("<key oid='AnotherMsG'/>", qos.toXml()).getSubscriptionId();
subscriberTable.put(subscribeOid4, new Integer(3));
log.info("Success: Subscribe subscription-id4=" + subscribeOid4 + " done");
} catch(XmlBlasterException e) {
log.warning("XmlBlasterException: " + e.getMessage());