本文整理汇总了Java中org.androidpn.server.xmpp.handler.IQHandler类的典型用法代码示例。如果您正苦于以下问题:Java IQHandler类的具体用法?Java IQHandler怎么用?Java IQHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IQHandler类属于org.androidpn.server.xmpp.handler包,在下文中一共展示了IQHandler类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
private IQHandler getHandler(String namespace) {
IQHandler handler = namespace2Handlers.get(namespace);
if (handler == null) {
for (IQHandler handlerCandidate : iqHandlers) {
IQHandlerInfo handlerInfo = handlerCandidate.getInfo();
if (handlerInfo != null
&& namespace.equalsIgnoreCase(handlerInfo
.getNamespace())) {
handler = handlerCandidate;
namespace2Handlers.put(namespace, handler);
break;
}
}
}
return handler;
}
示例2: handle
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* 处理IQ
*
* @param packet
*/
private void handle(IQ packet) {
try {
Element childElement = packet.getChildElement();
String namespace = null;
if (childElement != null) {
namespace = childElement.getNamespaceURI();
}
if (namespace == null) {
if (packet.getType() != IQ.Type.result
&& packet.getType() != IQ.Type.error) {
log.warn("未知的包 " + packet);
}
} else {
IQHandler handler = getHandler(namespace);
if (handler == null) {
sendErrorPacket(packet,
PacketError.Condition.service_unavailable);
} else {
handler.process(packet);
}
}
} catch (Exception e) {
log.error("不能路由数据包", e);
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
IQ reply = IQ.createResultIQ(packet);
reply.setError(PacketError.Condition.internal_server_error);
session.process(reply);
}
}
}
示例3: addHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* 增加一个新的IQHandler来注册处理程序列表。
*
* @param handler
*/
public void addHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException("IQHandler已由server提供");
}
namespace2Handlers.put(handler.getNamespace(), handler);
}
示例4: removeHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* 从注册处理程序列表移除一个IQHandler
*
* @param handler
*/
public void removeHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException("无法一个移除由Server提供的IQHandler");
}
namespace2Handlers.remove(handler.getNamespace());
}
示例5: getHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* 根据提供的namespace返回一个IQHandler
*/
private IQHandler getHandler(String namespace) {
IQHandler handler = namespace2Handlers.get(namespace);
if (handler == null) {
for (IQHandler handlerCandidate : iqHandlers) {
if (namespace.equalsIgnoreCase(handlerCandidate.getNamespace())) {
handler = handlerCandidate;
namespace2Handlers.put(namespace, handler);
break;
}
}
}
return handler;
}
示例6: handle
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
private void handle(IQ packet) {
try {
Element childElement = packet.getChildElement();
String namespace = null;
if (childElement != null) {
namespace = childElement.getNamespaceURI();
}
if (namespace == null) {
if (packet.getType() != IQ.Type.result
&& packet.getType() != IQ.Type.error) {
log.warn("Unknown packet " + packet);
}
} else {
IQHandler handler = getHandler(namespace);
if (handler == null) {
sendErrorPacket(packet,
PacketError.Condition.service_unavailable);
} else {
handler.process(packet);
}
}
} catch (Exception e) {
log.error("Could not route packet", e);
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
IQ reply = IQ.createResultIQ(packet);
reply.setError(PacketError.Condition.internal_server_error);
session.process(reply);
}
}
}
示例7: addHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* Adds a new IQHandler to the list of registered handler.
*
* @param handler the IQHandler
*/
public void addHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException(
"IQHandler already provided by the server");
}
namespace2Handlers.put(handler.getNamespace(), handler);
}
示例8: removeHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* Removes an IQHandler from the list of registered handler.
*
* @param handler the IQHandler
*/
public void removeHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException(
"Cannot remove an IQHandler provided by the server");
}
namespace2Handlers.remove(handler.getNamespace());
}
示例9: getHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
/**
* Returns an IQHandler with the given namespace.
*/
private IQHandler getHandler(String namespace) {
IQHandler handler = namespace2Handlers.get(namespace);
if (handler == null) {
for (IQHandler handlerCandidate : iqHandlers) {
if (namespace.equalsIgnoreCase(handlerCandidate.getNamespace())) {
handler = handlerCandidate;
namespace2Handlers.put(namespace, handler);
break;
}
}
}
return handler;
}
示例10: addHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
public void addHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException(
"IQHandler already provided by the server");
}
namespace2Handlers.put(handler.getInfo().getNamespace(), handler);
}
示例11: removeHandler
import org.androidpn.server.xmpp.handler.IQHandler; //导入依赖的package包/类
public void removeHandler(IQHandler handler) {
if (iqHandlers.contains(handler)) {
throw new IllegalArgumentException(
"Cannot remove an IQHandler provided by the server");
}
namespace2Handlers.remove(handler.getInfo().getNamespace());
}