本文整理了Java中org.snmp4j.Snmp.removeTransportMapping()
方法的一些代码示例,展示了Snmp.removeTransportMapping()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Snmp.removeTransportMapping()
方法的具体详情如下:
包路径:org.snmp4j.Snmp
类名称:Snmp
方法名:removeTransportMapping
[英]Removes the specified transport mapping from this SNMP session. If the transport mapping is not currently part of this SNMP session, this method will have no effect.
[中]从此SNMP会话中删除指定的传输映射。如果传输映射当前不是此SNMP会话的一部分,则此方法将无效。
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.snmp4j
/**
* Sets the message dispatcher associated with this SNMP session. The {@link CommandResponder} registration is
* removed from the existing message dispatcher (if not {@code null}).
* @param messageDispatcher
* a message dispatcher that processes incoming SNMP {@link PDU}s.
* @since 2.5.7
*/
public void setMessageDispatcher(MessageDispatcher messageDispatcher) {
if (messageDispatcher == null) {
throw new NullPointerException();
}
Collection<TransportMapping> existingTransportMappings = new LinkedList<TransportMapping>();
if (this.messageDispatcher != null) {
existingTransportMappings = messageDispatcher.getTransportMappings();
for (TransportMapping tm : existingTransportMappings) {
removeTransportMapping(tm);
}
this.messageDispatcher.removeCommandResponder(this);
}
this.messageDispatcher = messageDispatcher;
this.messageDispatcher.addCommandResponder(this);
for (TransportMapping tm : existingTransportMappings) {
addTransportMapping(tm);
}
}
代码示例来源:origin: org.snmp4j/snmp4j
/**
* Sets the message dispatcher associated with this SNMP session. The {@link CommandResponder} registration is
* removed from the existing message dispatcher (if not {@code null}).
*
* @param messageDispatcher
* a message dispatcher that processes incoming SNMP {@link PDU}s.
*
* @since 2.5.7
*/
@SuppressWarnings("unchecked")
public void setMessageDispatcher(MessageDispatcher messageDispatcher) {
if (messageDispatcher == null) {
throw new NullPointerException();
}
Collection<TransportMapping<? extends Address>> existingTransportMappings = new LinkedList<>();
if (this.messageDispatcher != null) {
existingTransportMappings = messageDispatcher.getTransportMappings();
for (TransportMapping<?> tm : existingTransportMappings) {
removeTransportMapping(tm);
}
this.messageDispatcher.removeCommandResponder(this);
}
this.messageDispatcher = messageDispatcher;
this.messageDispatcher.addCommandResponder(this);
for (TransportMapping<?> tm : existingTransportMappings) {
addTransportMapping(tm);
}
}
内容来源于网络,如有侵权,请联系作者删除!