本文整理汇总了Java中org.jivesoftware.smackx.disco.ServiceDiscoveryManager.discoverInfo方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceDiscoveryManager.discoverInfo方法的具体用法?Java ServiceDiscoveryManager.discoverInfo怎么用?Java ServiceDiscoveryManager.discoverInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.disco.ServiceDiscoveryManager
的用法示例。
在下文中一共展示了ServiceDiscoveryManager.discoverInfo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkFeatures
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private void checkFeatures(ServiceDiscoveryManager discoManager, String uri) throws SmackException, XMPPErrorException {
// Get the information of a given XMPP entity
System.out.println("Discover: " + uri);
// This gets the information of the component
DiscoverInfo discoInfo = discoManager.discoverInfo(uri);
// Get the discovered identities of the remote XMPP entity
List<Identity> identities = discoInfo.getIdentities();
// Display the identities of the remote XMPP entity
for(Identity identity : identities) {
System.out.println(identity.getName());
System.out.println(identity.getType());
System.out.println(identity.getCategory());
}
// Check if component supports rest
if(discoInfo.containsFeature(XwadlIQ.NAMESPACE))
System.out.println("XWADL is supported");
else
throw new SmackException("XWADL is not supported");
if(discoInfo.containsFeature(RestIQ.NAMESPACE))
System.out.println("REST is supported");
else
throw new SmackException("REST is not supported");
}
示例2: discoverItemsByFeature
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private List<String> discoverItemsByFeature(XmppURI uri, List<String> features) throws XMPPException, IOException, SmackException {
// discover items
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(this.connectionManager.getConnection());
DiscoverItems discoverItems = discoveryManager.discoverItems(uri.getDomain());
List<DiscoverItems.Item> items = discoverItems.getItems();
List<String> result = new ArrayList<>();
// discover infos per item and check if specified feature set is supported
for (DiscoverItems.Item item : items) {
DiscoverInfo discoverInfo = discoveryManager.discoverInfo(item.getEntityID());
boolean conatinsAllFeatures = true;
for (String feature : features) {
if (!discoverInfo.containsFeature(feature)) {
conatinsAllFeatures = false;
break;
}
}
if (conatinsAllFeatures) {
result.add(item.getEntityID());
} else if (logger.isDebugEnabled()) {
logger.debug("Entity {} does not support the specified features.", item.getEntityID());
}
}
return result;
}
示例3: perform
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
@Override
public SampleResult perform(JMeterXMPPSampler sampler, SampleResult res) throws Exception {
String entID = sampler.getPropertyAsString(ENTITY_ID);
res.setSamplerData("Entity ID: " + entID);
ServiceDiscoveryManager discoMgr = ServiceDiscoveryManager.getInstanceFor(sampler.getXMPPConnection());
IQ info;
if (Type.valueOf(sampler.getPropertyAsString(TYPE)) == Type.info) {
info = discoMgr.discoverInfo(entID);
} else {
info = discoMgr.discoverItems(entID);
}
res.setResponseData(info.toXML().toString().getBytes());
return res;
}
示例4: isEmailAvailable
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* The workgroup service may be configured to send email. This queries the Workgroup Service
* to see if the email service has been configured and is available.
*
* @return true if the email service is available, otherwise return false.
* @throws SmackException
*/
public boolean isEmailAvailable() throws SmackException {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
String workgroupService = XmppStringUtils.parseDomain(workgroupJID);
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
}
catch (XMPPException e) {
return false;
}
}
示例5: determineProxies
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Returns a list of JIDs of SOCKS5 proxies by querying the XMPP server. The SOCKS5 proxies are
* in the same order as returned by the XMPP server.
*
* @return list of JIDs of SOCKS5 proxies
* @throws XMPPErrorException if there was an error querying the XMPP server for SOCKS5 proxies
* @throws NoResponseException if there was no response from the server.
* @throws NotConnectedException
*/
private List<String> determineProxies() throws NoResponseException, XMPPErrorException, NotConnectedException {
XMPPConnection connection = connection();
ServiceDiscoveryManager serviceDiscoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
List<String> proxies = new ArrayList<String>();
// get all items from XMPP server
DiscoverItems discoverItems = serviceDiscoveryManager.discoverItems(connection.getServiceName());
// query all items if they are SOCKS5 proxies
for (Item item : discoverItems.getItems()) {
// skip blacklisted servers
if (this.proxyBlacklist.contains(item.getEntityID())) {
continue;
}
DiscoverInfo proxyInfo;
try {
proxyInfo = serviceDiscoveryManager.discoverInfo(item.getEntityID());
}
catch (NoResponseException|XMPPErrorException e) {
// blacklist errornous server
proxyBlacklist.add(item.getEntityID());
continue;
}
if (proxyInfo.hasIdentity("proxy", "bytestreams")) {
proxies.add(item.getEntityID());
} else {
/*
* server is not a SOCKS5 proxy, blacklist server to skip next time a Socks5
* bytestream should be established
*/
this.proxyBlacklist.add(item.getEntityID());
}
}
return proxies;
}
示例6: serviceAvailable
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Check if the server support RTPBridge Service.
*
* @param connection
* @return true if the server supports the RTPBridge service
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public static boolean serviceAvailable(XMPPConnection connection) throws NoResponseException,
XMPPErrorException, NotConnectedException {
if (!connection.isConnected()) {
return false;
}
LOGGER.fine("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager
.getInstanceFor(connection);
// DiscoverItems items = disco.discoverItems(connection.getServiceName());
// Iterator iter = items.getItems();
// while (iter.hasNext()) {
// DiscoverItems.Item item = (DiscoverItems.Item) iter.next();
// if (item.getEntityID().startsWith("rtpbridge.")) {
// return true;
// }
// }
DiscoverInfo discoInfo = disco.discoverInfo(connection.getServiceName());
for (DiscoverInfo.Identity identity : discoInfo.getIdentities()) {
if ((identity.getName() != null) && (identity.getName().startsWith("rtpbridge"))) {
return true;
}
}
return false;
}
示例7: serviceAvailable
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Check if the server support STUN Service.
*
* @param connection the connection
* @return true if the server support STUN
* @throws SmackException
* @throws XMPPException
*/
public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException {
if (!connection.isConnected()) {
return false;
}
LOGGER.fine("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = disco.discoverItems(connection.getServiceName());
for (DiscoverItems.Item item : items.getItems()) {
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
for (DiscoverInfo.Identity identity : info.getIdentities()) {
if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
if (info.containsFeature(NAMESPACE))
return true;
}
LOGGER.fine(item.getName() + "-" + info.getType());
}
return false;
}
示例8: discover
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
private static EnumMap<Feature, JID> discover(ServiceDiscoveryManager dm, JID entity) {
DiscoverInfo info;
try {
// blocking
// NOTE: null parameter does not work
info = dm.discoverInfo(entity.toSmack());
} catch (SmackException.NoResponseException |
XMPPException.XMPPErrorException |
SmackException.NotConnectedException |
InterruptedException ex) {
// not supported by all servers/server not reachable, we only know after trying
//LOGGER.log(Level.WARNING, "can't get service discovery info", ex);
LOGGER.warning("can't get info for " + entity + " " + ex.getMessage());
return null;
}
EnumMap<Feature, JID> features = new EnumMap<>(FeatureDiscovery.Feature.class);
for (DiscoverInfo.Feature feature: info.getFeatures()) {
String var = feature.getVar();
if (FEATURE_MAP.containsKey(var)) {
features.put(FEATURE_MAP.get(var), entity);
}
}
List<DiscoverInfo.Identity> identities = info.getIdentities();
LOGGER.config("entity: " + entity
+ " identities: " + identities.stream()
.map(DiscoverInfo.Identity::toXML).collect(Collectors.toList())
+ " features: " + info.getFeatures().stream()
.map(DiscoverInfo.Feature::getVar).collect(Collectors.toList()));
return features;
}
示例9: getSupportedFeatures
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager; //导入方法依赖的package包/类
/**
* Gets the supported features of the servers pubsub implementation
* as a standard {@link DiscoverInfo} instance.
*
* @return The supported features
* @throws XMPPErrorException
* @throws NoResponseException
* @throws NotConnectedException
*/
public DiscoverInfo getSupportedFeatures() throws NoResponseException, XMPPErrorException, NotConnectedException
{
ServiceDiscoveryManager mgr = ServiceDiscoveryManager.getInstanceFor(con);
return mgr.discoverInfo(to);
}