KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > mo > MOGroupImpl


1 /*_############################################################################
2   _##
3   _## SNMP4J-Agent - MOGroupImpl.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## Licensed under the Apache License, Version 2.0 (the "License");
8   _## you may not use this file except in compliance with the License.
9   _## You may obtain a copy of the License at
10   _##
11   _## http://www.apache.org/licenses/LICENSE-2.0
12   _##
13   _## Unless required by applicable law or agreed to in writing, software
14   _## distributed under the License is distributed on an "AS IS" BASIS,
15   _## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   _## See the License for the specific language governing permissions and
17   _## limitations under the License.
18   _##
19   _##########################################################################*/

20
21
22 package org.snmp4j.agent.mo;
23
24 import org.snmp4j.agent.MOGroup;
25 import org.snmp4j.agent.MOServer;
26 import org.snmp4j.smi.OctetString;
27 import java.util.LinkedList JavaDoc;
28 import org.snmp4j.agent.ManagedObject;
29 import java.util.Iterator JavaDoc;
30 import org.snmp4j.agent.DuplicateRegistrationException;
31 import java.util.List JavaDoc;
32
33 /**
34  * The <code>MOGroupImpl</code> implements a simple object group.
35  *
36  * @author Frank Fock
37  * @version 1.0
38  */

39 public class MOGroupImpl implements MOGroup {
40
41   private List JavaDoc objects = new LinkedList JavaDoc();
42
43   public MOGroupImpl() {
44   }
45
46   public void registerMOs(MOServer server, OctetString context)
47       throws DuplicateRegistrationException
48   {
49     for (Iterator JavaDoc it = objects.iterator(); it.hasNext(); ) {
50       ManagedObject mo = (ManagedObject) it.next();
51       server.register(mo, context);
52     }
53   }
54
55   public void unregisterMOs(MOServer server, OctetString context) {
56     for (Iterator JavaDoc it = objects.iterator(); it.hasNext(); ) {
57       ManagedObject mo = (ManagedObject) it.next();
58       server.unregister(mo, context);
59     }
60   }
61
62   public boolean addInstance(ManagedObject mo) {
63     return objects.add(mo);
64   }
65
66   public boolean removeInstance(ManagedObject mo) {
67     return objects.remove(mo);
68   }
69
70 }
71
Popular Tags