⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moserver.java

📁 你个snmp的源码
💻 JAVA
字号:
/*_############################################################################
  _##
  _##  SNMP4J-Agent - MOServer.java
  _##
  _##  Copyright 2005-2006  Frank Fock (SNMP4J.org)
  _##
  _##  Licensed under the Apache License, Version 2.0 (the "License");
  _##  you may not use this file except in compliance with the License.
  _##  You may obtain a copy of the License at
  _##
  _##      http://www.apache.org/licenses/LICENSE-2.0
  _##
  _##  Unless required by applicable law or agreed to in writing, software
  _##  distributed under the License is distributed on an "AS IS" BASIS,
  _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  _##  See the License for the specific language governing permissions and
  _##  limitations under the License.
  _##
  _##########################################################################*/


package org.snmp4j.agent;

import org.snmp4j.smi.OctetString;
import java.util.Iterator;

/**
 * The managed object server interface defines the services that a repository
 * of managed objects needs to provide for a command responder.
 *
 * @author Frank Fock
 * @version 1.0
 */
public interface MOServer {

  /**
   * Adds a context listener to the server. The listener will be informed about
   * context insertion and removal.
   * @param listener
   *    a <code>ContextListener</code> instance to be informed about context
   *    changes.
   */
  void addContextListener(ContextListener listener);

  /**
   * Removes a previously added context listener.
   * @param listener
   *    a <code>ContextListener</code> instance.
   */
  void removeContextListener(ContextListener listener);

  /**
   * Adds the supplied context to the server.
   * @param context
   *    an <code>OctetString</code> representing the context name to add.
   */
  void addContext(OctetString context);

  /**
   * Removes a context from the server. Removing a context does not remove
   * any managed objects from the server's registry.
   * @param context
   *    n <code>OctetString</code> representing the context name to remove.
   */
  void removeContext(OctetString context);

  /**
   * Registers a managed object for the specified context. A managed object can
   * be registered for more than one context.
   * @param mo
   *    a <code>ManagedObject</code> instance.
   * @param context
   *    the context name for which to register the <code>mo</code> or
   *    <code>null</code> if the managed oject is to be registered for all
   *    contexts (including the default context).
   * @throws DuplicateRegistrationException
   *    if the registration conflicts (i.e. overlaps) with an already existing
   *    registration.
   */
  void register(ManagedObject mo, OctetString context)
      throws DuplicateRegistrationException;

  /**
   * Removes the registration of the supplied managed object for the specified
   * context.
   * @param mo
   *    a <code>ManagedObject</code> instance.
   * @param context
   *    the context name for which to unregister the <code>mo</code> or
   *    <code>null</code> if the managed oject is to be unregistered for all
   *    contexts (including the default context). In the latter case however,
   *    explicit registrations for a particular context will not be removed!
   */
  void unregister(ManagedObject mo, OctetString context);

  /**
   * Adds a managed object lookup listener for the supplied managed object to
   * this managed object server. A <code>MOServerLookupListener</code> is called
   * before the managed object is returned by {@link #lookup(MOQuery query)}.
   *
   * @param listener
   *    a <code>MOServerLookupListener</code> instance, for example a managed
   *    object that needs to update its state whenever it has been looked up
   * @param mo
   *    the <code>ManagedObject</code> that triggers the
   *    {@link MOServerLookupEvent} to be fired when it has been looked up.
   */
  void addLookupListener(MOServerLookupListener listener,
                         ManagedObject mo);

  /**
   * Removes a managed object lookup listener for the specified managed object.
   * @param listener
   *    a <code>MOServerLookupListener</code> instance.
   * @param mo
   *    the <code>ManagedObject</code> that triggered the
   *    {@link MOServerLookupEvent} to be fired when it has been looked up.
   * @return
   *    <code>true</code> if the listener could be removed or <code>false</code>
   *    if such a listener is not registered.
   */
  boolean removeLookupListener(MOServerLookupListener listener,
                               ManagedObject mo);

  /**
   * Lookups the first (lexicographically ordered) managed object that matches
   * the supplied query.
   * @param query
   *    a <code>MOQuery</code> instance.
   * @return
   *    the <code>ManagedObject</code> that matches the query and
   *    <code>null</code> if no such object exists.
   */
  ManagedObject lookup(MOQuery query);

  /**
   * Returns an <code>Iterator</code> over the content of this server.
   * @return
   *    the <code>Iterator</code>.
   */
  Iterator iterator();

  /**
   * Locks a ManagedObject by the supplied owner. Once a ManagedObject is
   * locked, a lookup attempt will block until it is unlocked or a predefined
   * timeout occurs.
   * @param owner
   *    an Object.
   * @param managedObject
   *    the ManagedObject to lock.
   */
  void lock(Object owner, ManagedObject managedObject);

  /**
   * Unlocks a ManagedObject that has been locked by the specified owner. If
   * the ManagedObject is currently locked by another owner this method returns
   * silently.
   * <p>
   * Note: In debug log mode a message is locked if the lock owner does not
   * match the current lock owner.
   * @param owner
   *    an Object.
   * @param managedObject
   *    the ManagedObject to unlock.
   */
  void unlock(Object owner, ManagedObject managedObject);

  /**
   * Returns the contexts known by the server.
   * @return
   *    an array of context names.
   */
  OctetString[] getContexts();

  /**
   * Checks whether the supplied context is supported (registered) by this
   * server.
   * @param context
   *    a context name.
   * @return
   *    <code>true</code> if the context is support (thus has previously added
   *    by {@link #addContext}) and <code>false</code> otherwise.
   */
  boolean isContextSupported(OctetString context);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -