KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snmp4j > agent > agentx > subagent > test > AgentppTestMib


1 /*_############################################################################
2   _##
3   _## SNMP4J-AgentX - AgentppTestMib.java
4   _##
5   _## Copyright (C) 2005-2007 Frank Fock (SNMP4J.org)
6   _##
7   _## This program is free software; you can redistribute it and/or modify
8   _## it under the terms of the GNU General Public License version 2 as
9   _## published by the Free Software Foundation.
10   _##
11   _## This program is distributed in the hope that it will be useful,
12   _## but WITHOUT ANY WARRANTY; without even the implied warranty of
13   _## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14   _## GNU General Public License for more details.
15   _##
16   _## You should have received a copy of the GNU General Public License
17   _## along with this program; if not, write to the Free Software
18   _## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19   _## MA 02110-1301 USA
20   _##
21   _##########################################################################*/

22
23 package org.snmp4j.agent.agentx.subagent.test;
24
25 //--AgentGen BEGIN=_BEGIN
26
//--AgentGen END
27

28 import org.snmp4j.smi.*;
29 import org.snmp4j.mp.SnmpConstants;
30 import org.snmp4j.agent.*;
31 import org.snmp4j.agent.mo.*;
32 import org.snmp4j.agent.mo.snmp.*;
33 import org.snmp4j.agent.mo.snmp.smi.*;
34 import org.snmp4j.agent.request.*;
35 import org.snmp4j.log.LogFactory;
36 import org.snmp4j.log.LogAdapter;
37 import org.snmp4j.agent.agentx.subagent.DefaultAgentXSharedMOTable;
38 import org.snmp4j.agent.agentx.subagent.AgentXSharedMOTableSupport;
39 import org.snmp4j.agent.agentx.subagent.index.AnyNewIndexOID;
40 import java.util.GregorianCalendar JavaDoc;
41
42 //--AgentGen BEGIN=_IMPORT
43
//--AgentGen END
44

45 public class AgentppTestMib
46 //--AgentGen BEGIN=_EXTENDS
47
//--AgentGen END
48
implements MOGroup
49 //--AgentGen BEGIN=_IMPLEMENTS
50
//--AgentGen END
51
{
52
53   private static final LogAdapter LOGGER =
54       LogFactory.getLogger(AgentppTestMib.class);
55
56 //--AgentGen BEGIN=_STATIC
57
//--AgentGen END
58

59   // Factory
60
private MOFactory moFactory =
61     DefaultMOFactory.getInstance();
62
63   // Constants
64
public static final OID oidAgentppTestTimeout =
65     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,1,0 });
66
67   // Scalars
68
private MOScalar agentppTestTimeout;
69
70   // Tables
71
public static final OID oidAgentppTestSharedEntry =
72     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,3,1 });
73
74   // Index OID definitions
75
public static final OID oidAgentppTestSharedTableIndex =
76     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,3,1,1 });
77
78   // Column TC defintions for agentppTestSharedEntry:
79
public static final String JavaDoc tcModuleSNMPv2Tc = "SNMPv2-TC";
80   public static final String JavaDoc tcDefDateAndTime = "DateAndTime";
81   public static final String JavaDoc tcDefRowStatus = "RowStatus";
82
83   // Column sub-identifer defintions for agentppTestSharedEntry:
84
public static final int colAgentppTestSharedTableCreationTime = 2;
85   public static final int colAgentppTestSharedTableDelay = 3;
86   public static final int colAgentppTestSharedTableSession = 4;
87   public static final int colAgentppTestSharedTableRowStatus = 5;
88
89   // Column index defintions for agentppTestSharedEntry:
90
public static final int idxAgentppTestSharedTableCreationTime = 0;
91   public static final int idxAgentppTestSharedTableDelay = 1;
92   public static final int idxAgentppTestSharedTableSession = 2;
93   public static final int idxAgentppTestSharedTableRowStatus = 3;
94
95   private MOTableSubIndex[] agentppTestSharedEntryIndexes;
96   private MOTableIndex agentppTestSharedEntryIndex;
97
98   private MOTable agentppTestSharedEntry;
99   private MOTableModel agentppTestSharedEntryModel;
100   public static final OID oidAgentppTestSessionsEntry =
101     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,4,1 });
102
103   // Index OID definitions
104
public static final OID oidAgentppTestSessionIndex =
105     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,4,1,1 });
106
107   // Column TC defintions for agentppTestSessionsEntry:
108

109   // Column sub-identifer defintions for agentppTestSessionsEntry:
110
public static final int colAgentppTestRowCreation = 2;
111
112   // Column index defintions for agentppTestSessionsEntry:
113
public static final int idxAgentppTestRowCreation = 0;
114
115   private MOTableSubIndex[] agentppTestSessionsEntryIndexes;
116   private MOTableIndex agentppTestSessionsEntryIndex;
117
118   private MOTable agentppTestSessionsEntry;
119   private MOTableModel agentppTestSessionsEntryModel;
120   public static final OID oidAgentppTestSparseEntry =
121     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,5,1 });
122
123   // Index OID definitions
124
public static final OID oidAgentppTestSparseIndex =
125     new OID(new int[] { 1,3,6,1,4,1,4976,6,3,1,5,1,1 });
126
127   // Column TC defintions for agentppTestSparseEntry:
128

129   // Column sub-identifer defintions for agentppTestSparseEntry:
130
public static final int colAgentppTestSparseCol1 = 2;
131   public static final int colAgentppTestSparseCol2 = 3;
132   public static final int colAgentppTestSparseCol3 = 4;
133   public static final int colAgentppTestSparseRowStatus = 5;
134
135   // Column index defintions for agentppTestSparseEntry:
136
public static final int idxAgentppTestSparseCol1 = 0;
137   public static final int idxAgentppTestSparseCol2 = 1;
138   public static final int idxAgentppTestSparseCol3 = 2;
139   public static final int idxAgentppTestSparseRowStatus = 3;
140
141   private MOTableSubIndex[] agentppTestSparseEntryIndexes;
142   private MOTableIndex agentppTestSparseEntryIndex;
143
144   private MOTable agentppTestSparseEntry;
145   private MOTableModel agentppTestSparseEntryModel;
146
147
148 //--AgentGen BEGIN=_MEMBERS
149
//--AgentGen END
150

151   /**
152    * Constructs a AgentppTestMib instance without actually creating its
153    * <code>ManagedObject</code> instances. This has to be done in a
154    * sub-class constructor or after construction by calling
155    * {@link #createMO(MOFactory moFactory)}.
156    */

157   protected AgentppTestMib() {
158 //--AgentGen BEGIN=_DEFAULTCONSTRUCTOR
159
//--AgentGen END
160
}
161
162   /**
163    * Constructs a AgentppTestMib instance and actually creates its
164    * <code>ManagedObject</code> instances using the supplied
165    * <code>MOFactory</code> (by calling
166    * {@link #createMO(MOFactory moFactory)}).
167    * @param moFactory
168    * the <code>MOFactory</code> to be used to create the
169    * managed objects for this module.
170    */

171   public AgentppTestMib(MOFactory moFactory) {
172     createMO(moFactory);
173 //--AgentGen BEGIN=_FACTORYCONSTRUCTOR
174
//--AgentGen END
175
}
176
177 //--AgentGen BEGIN=_CONSTRUCTORS
178
//--AgentGen END
179

180   /**
181    * Create the ManagedObjects defined for this MIB module
182    * using the specified {@link MOFactory}.
183    * @param moFactory
184    * the <code>MOFactory</code> instance to use for object
185    * creation.
186    */

187   protected void createMO(MOFactory moFactory) {
188     agentppTestTimeout =
189       new AgentppTestTimeout(oidAgentppTestTimeout,
190                              moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_WRITE));
191     agentppTestTimeout.addMOValueValidationListener(new AgentppTestTimeoutValidator());
192     createAgentppTestSharedEntry(moFactory);
193     createAgentppTestSessionsEntry(moFactory);
194     createAgentppTestSparseEntry(moFactory);
195   }
196
197
198   public MOTable getAgentppTestSharedEntry() {
199     return agentppTestSharedEntry;
200   }
201
202
203   private void createAgentppTestSharedEntry(MOFactory moFactory) {
204     // Index definition
205
agentppTestSharedEntryIndexes =
206       new MOTableSubIndex[] {
207       moFactory.createSubIndex(oidAgentppTestSharedTableIndex,
208                                SMIConstants.SYNTAX_INTEGER, 1, 1) };
209
210     agentppTestSharedEntryIndex =
211       moFactory.createIndex(agentppTestSharedEntryIndexes,
212                             false,
213                             new MOTableIndexValidator() {
214       public boolean isValidIndex(OID index) {
215         boolean isValidIndex = true;
216      //--AgentGen BEGIN=agentppTestSharedEntry::isValidIndex
217
//--AgentGen END
218
return isValidIndex;
219       }
220     });
221
222     // Columns
223
MOColumn[] agentppTestSharedEntryColumns = new MOColumn[4];
224     agentppTestSharedEntryColumns[idxAgentppTestSharedTableCreationTime] =
225       moFactory.createColumn(colAgentppTestSharedTableCreationTime,
226                              SMIConstants.SYNTAX_OCTET_STRING,
227                              moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY),
228                              tcModuleSNMPv2Tc,
229                              tcDefDateAndTime);
230     agentppTestSharedEntryColumns[idxAgentppTestSharedTableDelay] =
231       moFactory.createColumn(colAgentppTestSharedTableDelay,
232                           SMIConstants.SYNTAX_INTEGER32,
233                           moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
234                              new Integer32(0),
235                              true);
236     ValueConstraint agentppTestSharedTableDelayVC = new ConstraintsImpl();
237     ((ConstraintsImpl)agentppTestSharedTableDelayVC).add(new Constraint(0L, 6000L));
238     ((MOMutableColumn)agentppTestSharedEntryColumns[idxAgentppTestSharedTableDelay]).
239       addMOValueValidationListener(new ValueConstraintValidator(agentppTestSharedTableDelayVC));
240     ((MOMutableColumn)agentppTestSharedEntryColumns[idxAgentppTestSharedTableDelay]).
241       addMOValueValidationListener(new AgentppTestSharedTableDelayValidator());
242     agentppTestSharedEntryColumns[idxAgentppTestSharedTableSession] =
243       moFactory.createColumn(colAgentppTestSharedTableSession,
244                              SMIConstants.SYNTAX_GAUGE32,
245                              moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_ONLY));
246     agentppTestSharedEntryColumns[idxAgentppTestSharedTableRowStatus] =
247       moFactory.createColumn(colAgentppTestSharedTableRowStatus,
248                              SMIConstants.SYNTAX_INTEGER,
249                              moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
250                              tcModuleSNMPv2Tc,
251                              tcDefRowStatus);
252     ((MOMutableColumn)agentppTestSharedEntryColumns[idxAgentppTestSharedTableRowStatus]).
253       addMOValueValidationListener(new AgentppTestSharedTableRowStatusValidator());
254     // Table model
255
agentppTestSharedEntryModel =
256       moFactory.createTableModel(oidAgentppTestSharedEntry,
257                                  agentppTestSharedEntryIndex,
258                                  agentppTestSharedEntryColumns);
259     ((MOMutableTableModel)agentppTestSharedEntryModel).setRowFactory(
260       new AgentppTestSharedEntryRowFactory());
261     agentppTestSharedEntry =
262       moFactory.createTable(oidAgentppTestSharedEntry,
263                             agentppTestSharedEntryIndex,
264                             agentppTestSharedEntryColumns,
265                             agentppTestSharedEntryModel);
266   }
267
268   public MOTable getAgentppTestSessionsEntry() {
269     return agentppTestSessionsEntry;
270   }
271
272
273   private void createAgentppTestSessionsEntry(MOFactory moFactory) {
274     // Index definition
275
agentppTestSessionsEntryIndexes =
276       new MOTableSubIndex[] {
277       moFactory.createSubIndex(oidAgentppTestSessionIndex,
278                                SMIConstants.SYNTAX_INTEGER, 1, 1) };
279
280     agentppTestSessionsEntryIndex =
281       moFactory.createIndex(agentppTestSessionsEntryIndexes,
282                             false,
283                             new MOTableIndexValidator() {
284       public boolean isValidIndex(OID index) {
285         boolean isValidIndex = true;
286      //--AgentGen BEGIN=agentppTestSessionsEntry::isValidIndex
287
//--AgentGen END
288
return isValidIndex;
289       }
290     });
291
292     // Columns
293
MOColumn[] agentppTestSessionsEntryColumns = new MOColumn[1];
294     agentppTestSessionsEntryColumns[idxAgentppTestRowCreation] =
295       moFactory.createColumn(colAgentppTestRowCreation,
296                              SMIConstants.SYNTAX_GAUGE32,
297                              moFactory.createAccess(
298                                  MOAccessImpl.ACCESSIBLE_FOR_READ_WRITE),
299                              new UnsignedInteger32(0),
300                              true);
301     ((MOMutableColumn)agentppTestSessionsEntryColumns[idxAgentppTestRowCreation]).
302       addMOValueValidationListener(new AgentppTestRowCreationValidator());
303     // Table model
304
agentppTestSessionsEntryModel =
305       moFactory.createTableModel(oidAgentppTestSessionsEntry,
306                                  agentppTestSessionsEntryIndex,
307                                  agentppTestSessionsEntryColumns);
308     ((MOMutableTableModel)agentppTestSessionsEntryModel).setRowFactory(
309       new AgentppTestSessionsEntryRowFactory());
310     agentppTestSessionsEntry =
311       moFactory.createTable(oidAgentppTestSessionsEntry,
312                             agentppTestSessionsEntryIndex,
313                             agentppTestSessionsEntryColumns,
314                             agentppTestSessionsEntryModel);
315   }
316
317   public MOTable getAgentppTestSparseEntry() {
318     return agentppTestSparseEntry;
319   }
320
321
322   private void createAgentppTestSparseEntry(MOFactory moFactory) {
323     // Index definition
324
agentppTestSparseEntryIndexes =
325       new MOTableSubIndex[] {
326       moFactory.createSubIndex(oidAgentppTestSparseIndex,
327                                SMIConstants.SYNTAX_OCTET_STRING, 0, 255)
328     };
329
330     agentppTestSparseEntryIndex =
331       moFactory.createIndex(agentppTestSparseEntryIndexes,
332                             false,
333                             new MOTableIndexValidator() {
334       public boolean isValidIndex(OID index) {
335         boolean isValidIndex = true;
336      //--AgentGen BEGIN=agentppTestSparseEntry::isValidIndex
337
//--AgentGen END
338
return isValidIndex;
339       }
340     });
341
342     // Columns
343
MOColumn[] agentppTestSparseEntryColumns = new MOColumn[4];
344     agentppTestSparseEntryColumns[idxAgentppTestSparseCol1] =
345       moFactory.createColumn(colAgentppTestSparseCol1,
346                              SMIConstants.SYNTAX_INTEGER32,
347                              moFactory.createAccess(
348                                  MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
349                              new Integer32(1),
350                              true);
351     ((MOMutableColumn)agentppTestSparseEntryColumns[idxAgentppTestSparseCol1]).
352       addMOValueValidationListener(new AgentppTestSparseCol1Validator());
353     agentppTestSparseEntryColumns[idxAgentppTestSparseCol2] =
354       moFactory.createColumn(colAgentppTestSparseCol2,
355                              SMIConstants.SYNTAX_GAUGE32,
356                              moFactory.createAccess(
357                                  MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
358                              new Gauge32(2),
359                              true);
360     ((MOMutableColumn)agentppTestSparseEntryColumns[idxAgentppTestSparseCol2]).
361       addMOValueValidationListener(new AgentppTestSparseCol2Validator());
362     agentppTestSparseEntryColumns[idxAgentppTestSparseCol3] =
363       moFactory.createColumn(colAgentppTestSparseCol3,
364                           SMIConstants.SYNTAX_OCTET_STRING,
365                           moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
366                              new OctetString(new byte[] { (byte)51 }),
367                              true);
368     ValueConstraint agentppTestSparseCol3VC = new ConstraintsImpl();
369     ((ConstraintsImpl)agentppTestSparseCol3VC).add(new Constraint(0L, 255L));
370     ((MOMutableColumn)agentppTestSparseEntryColumns[idxAgentppTestSparseCol3]).
371       addMOValueValidationListener(new ValueConstraintValidator(agentppTestSparseCol3VC));
372     ((MOMutableColumn)agentppTestSparseEntryColumns[idxAgentppTestSparseCol3]).
373       addMOValueValidationListener(new AgentppTestSparseCol3Validator());
374     agentppTestSparseEntryColumns[idxAgentppTestSparseRowStatus] =
375       moFactory.createColumn(colAgentppTestSparseRowStatus,
376                              SMIConstants.SYNTAX_INTEGER,
377                              moFactory.createAccess(MOAccessImpl.ACCESSIBLE_FOR_READ_CREATE),
378                              tcModuleSNMPv2Tc,
379                              tcDefRowStatus);
380     ((MOMutableColumn)agentppTestSparseEntryColumns[idxAgentppTestSparseRowStatus]).
381       addMOValueValidationListener(new AgentppTestSparseRowStatusValidator());
382     // Table model
383
agentppTestSparseEntryModel =
384       moFactory.createTableModel(oidAgentppTestSparseEntry,
385                                  agentppTestSparseEntryIndex,
386                                  agentppTestSparseEntryColumns);
387     ((MOMutableTableModel)agentppTestSparseEntryModel).setRowFactory(
388       new AgentppTestSparseEntryRowFactory());
389     agentppTestSparseEntry =
390       moFactory.createTable(oidAgentppTestSparseEntry,
391                             agentppTestSparseEntryIndex,
392                             agentppTestSparseEntryColumns,
393                             agentppTestSparseEntryModel);
394   }
395
396
397
398   public void registerMOs(MOServer server, OctetString context)
399     throws DuplicateRegistrationException
400   {
401     // Scalar Objects
402
server.register(this.agentppTestTimeout, context);
403     server.register(this.agentppTestSharedEntry, context);
404     server.register(this.agentppTestSessionsEntry, context);
405     server.register(this.agentppTestSparseEntry, context);
406 //--AgentGen BEGIN=_registerMOs
407
for (int i=0; i<10; i++) {
408       Variable[] vbs = agentppTestSparseEntry.getDefaultValues();
409       vbs[idxAgentppTestSparseRowStatus] = new Integer32(RowStatus.active);
410       MOTableRow row =
411           agentppTestSparseEntry.createRow(new AnyNewIndexOID(
412           new int[] { 1, i }), vbs);
413       agentppTestSparseEntry.addRow(row);
414     }
415 //--AgentGen END
416
}
417
418   public void unregisterMOs(MOServer server, OctetString context) {
419     // Scalar Objects
420
server.unregister(this.agentppTestTimeout, context);
421     server.unregister(this.agentppTestSharedEntry, context);
422     server.unregister(this.agentppTestSessionsEntry, context);
423     server.unregister(this.agentppTestSparseEntry, context);
424 //--AgentGen BEGIN=_unregisterMOs
425
//--AgentGen END
426
}
427
428   // Notifications
429

430   // Scalars
431
public class AgentppTestTimeout extends MOScalar {
432     AgentppTestTimeout(OID oid, MOAccess access) {
433       super(oid, access, new UnsignedInteger32());
434 //--AgentGen BEGIN=agentppTestTimeout
435
//--AgentGen END
436
}
437
438     public int isValueOK(SubRequest request) {
439       Variable newValue =
440         request.getVariableBinding().getVariable();
441       int valueOK = super.isValueOK(request);
442       if (valueOK != SnmpConstants.SNMP_ERROR_SUCCESS) {
443         return valueOK;
444       }
445       long v = ((UnsignedInteger32)newValue).getValue();
446       if (!(((v >= 0L) && (v <= 1000000L)))) {
447         valueOK = SnmpConstants.SNMP_ERROR_WRONG_VALUE;
448       }
449      //--AgentGen BEGIN=agentppTestTimeout::isValueOK
450
//--AgentGen END
451
return valueOK;
452     }
453
454     public Variable getValue() {
455      //--AgentGen BEGIN=agentppTestTimeout::getValue
456
//--AgentGen END
457
return super.getValue();
458     }
459
460     public int setValue(Variable newValue) {
461      //--AgentGen BEGIN=agentppTestTimeout::setValue
462
//--AgentGen END
463
return super.setValue(newValue);
464     }
465
466      //--AgentGen BEGIN=agentppTestTimeout::_METHODS
467
//--AgentGen END
468

469   }
470
471
472   // Value Validators
473
/**
474    * The <code>AgentppTestTimeoutValidator</code> implements the value
475    * validation for <code>AgentppTestTimeout</code>.
476    */

477   static class AgentppTestTimeoutValidator implements MOValueValidationListener {
478
479     public void validate(MOValueValidationEvent validationEvent) {
480       Variable newValue = validationEvent.getNewValue();
481       long v = ((UnsignedInteger32)newValue).getValue();
482       if (!(((v >= 0L) && (v <= 1000000L)))) {
483         validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_VALUE);
484         return;
485       }
486      //--AgentGen BEGIN=agentppTestTimeout::validate
487
//--AgentGen END
488
}
489   }
490
491   /**
492    * The <code>AgentppTestSharedTableDelayValidator</code> implements the value
493    * validation for <code>AgentppTestSharedTableDelay</code>.
494    */

495   static class AgentppTestSharedTableDelayValidator implements MOValueValidationListener {
496
497     public void validate(MOValueValidationEvent validationEvent) {
498       Variable newValue = validationEvent.getNewValue();
499       long v = ((Integer32)newValue).getValue();
500       if (!(((v >= 0L) && (v <= 6000L)))) {
501         validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_VALUE);
502         return;
503       }
504      //--AgentGen BEGIN=agentppTestSharedTableDelay::validate
505
//--AgentGen END
506
}
507   }
508   /**
509    * The <code>AgentppTestSharedTableRowStatusValidator</code> implements the value
510    * validation for <code>AgentppTestSharedTableRowStatus</code>.
511    */

512   static class AgentppTestSharedTableRowStatusValidator implements MOValueValidationListener {
513
514     public void validate(MOValueValidationEvent validationEvent) {
515       Variable newValue = validationEvent.getNewValue();
516      //--AgentGen BEGIN=agentppTestSharedTableRowStatus::validate
517
//--AgentGen END
518
}
519   }
520   /**
521    * The <code>AgentppTestRowCreationValidator</code> implements the value
522    * validation for <code>AgentppTestRowCreation</code>.
523    */

524   static class AgentppTestRowCreationValidator implements MOValueValidationListener {
525
526     public void validate(MOValueValidationEvent validationEvent) {
527       Variable newValue = validationEvent.getNewValue();
528      //--AgentGen BEGIN=agentppTestRowCreation::validate
529
//--AgentGen END
530
}
531   }
532   /**
533    * The <code>AgentppTestSparseCol1Validator</code> implements the value
534    * validation for <code>AgentppTestSparseCol1</code>.
535    */

536   static class AgentppTestSparseCol1Validator implements MOValueValidationListener {
537
538     public void validate(MOValueValidationEvent validationEvent) {
539       Variable newValue = validationEvent.getNewValue();
540      //--AgentGen BEGIN=agentppTestSparseCol1::validate
541
//--AgentGen END
542
}
543   }
544   /**
545    * The <code>AgentppTestSparseCol2Validator</code> implements the value
546    * validation for <code>AgentppTestSparseCol2</code>.
547    */

548   static class AgentppTestSparseCol2Validator implements MOValueValidationListener {
549
550     public void validate(MOValueValidationEvent validationEvent) {
551       Variable newValue = validationEvent.getNewValue();
552      //--AgentGen BEGIN=agentppTestSparseCol2::validate
553
//--AgentGen END
554
}
555   }
556   /**
557    * The <code>AgentppTestSparseCol3Validator</code> implements the value
558    * validation for <code>AgentppTestSparseCol3</code>.
559    */

560   static class AgentppTestSparseCol3Validator implements MOValueValidationListener {
561
562     public void validate(MOValueValidationEvent validationEvent) {
563       Variable newValue = validationEvent.getNewValue();
564       OctetString os = (OctetString)newValue;
565       if (!(((os.length() >= 0) && (os.length() <= 255)))) {
566         validationEvent.setValidationStatus(SnmpConstants.SNMP_ERROR_WRONG_LENGTH);
567         return;
568       }
569      //--AgentGen BEGIN=agentppTestSparseCol3::validate
570
//--AgentGen END
571
}
572   }
573   /**
574    * The <code>AgentppTestSparseRowStatusValidator</code> implements the value
575    * validation for <code>AgentppTestSparseRowStatus</code>.
576    */

577   static class AgentppTestSparseRowStatusValidator implements MOValueValidationListener {
578
579     public void validate(MOValueValidationEvent validationEvent) {
580       Variable newValue = validationEvent.getNewValue();
581      //--AgentGen BEGIN=agentppTestSparseRowStatus::validate
582
//--AgentGen END
583
}
584   }
585
586   // Rows and Factories
587
public class AgentppTestSharedEntryRow extends DefaultMOMutableRow2PC {
588     public AgentppTestSharedEntryRow(OID index, Variable[] values) {
589       super(index, values);
590     }
591
592     public OctetString getAgentppTestSharedTableCreationTime() {
593       return (OctetString) getValue(idxAgentppTestSharedTableCreationTime);
594     }
595
596     public void setAgentppTestSharedTableCreationTime(OctetString newValue) {
597       setValue(idxAgentppTestSharedTableCreationTime, newValue);
598     }
599
600     public Integer32 getAgentppTestSharedTableDelay() {
601       return (Integer32) getValue(idxAgentppTestSharedTableDelay);
602     }
603
604     public void setAgentppTestSharedTableDelay(Integer32 newValue) {
605       setValue(idxAgentppTestSharedTableDelay, newValue);
606     }
607
608     public UnsignedInteger32 getAgentppTestSharedTableSession() {
609       return (UnsignedInteger32) getValue(idxAgentppTestSharedTableSession);
610     }
611
612     public void setAgentppTestSharedTableSession(UnsignedInteger32 newValue) {
613       setValue(idxAgentppTestSharedTableSession, newValue);
614     }
615
616     public Integer32 getAgentppTestSharedTableRowStatus() {
617       return (Integer32) getValue(idxAgentppTestSharedTableRowStatus);
618     }
619
620     public void setAgentppTestSharedTableRowStatus(Integer32 newValue) {
621       setValue(idxAgentppTestSharedTableRowStatus, newValue);
622     }
623
624     //--AgentGen BEGIN=agentppTestSharedEntry::Row
625

626     private void delayRequest() {
627       long delay = values[idxAgentppTestSharedTableDelay].toInt() * 10;
628       if (delay > 0) {
629         try {
630           Thread.sleep(delay);
631         }
632         catch (InterruptedException JavaDoc ex) {
633         }
634       }
635     }
636
637     public Variable getValue(int column) {
638       delayRequest();
639       return super.getValue(column);
640     }
641
642     public void commit(SubRequest subRequest, MOTableRow changeSet, int column) {
643       delayRequest();
644       super.commit(subRequest, changeSet, column);
645     }
646
647      //--AgentGen END
648
}
649
650   class AgentppTestSharedEntryRowFactory
651         extends DefaultMOMutableRow2PCFactory
652   {
653     public synchronized MOTableRow createRow(OID index, Variable[] values)
654         throws UnsupportedOperationException JavaDoc
655     {
656       AgentppTestSharedEntryRow row = new AgentppTestSharedEntryRow(index, values);
657      //--AgentGen BEGIN=agentppTestSharedEntry::createRow
658
//--AgentGen END
659
return row;
660     }
661
662     public synchronized void freeRow(MOTableRow row) {
663      //--AgentGen BEGIN=agentppTestSharedEntry::freeRow
664
//--AgentGen END
665
}
666
667      //--AgentGen BEGIN=agentppTestSharedEntry::RowFactory
668
//--AgentGen END
669
}
670   public class AgentppTestSessionsEntryRow extends DefaultMOMutableRow2PC {
671     public AgentppTestSessionsEntryRow(OID index, Variable[] values) {
672       super(index, values);
673     }
674
675     public UnsignedInteger32 getAgentppTestRowCreation() {
676       return (UnsignedInteger32) getValue(idxAgentppTestRowCreation);
677     }
678
679     public void setAgentppTestRowCreation(UnsignedInteger32 newValue) {
680       setValue(idxAgentppTestRowCreation, newValue);
681     }
682
683     //--AgentGen BEGIN=agentppTestSessionsEntry::Row
684
public void commitRow(SubRequest subRequest, MOTableRow changeSet) {
685       int newRowIndex =
686           changeSet.getValue(idxAgentppTestRowCreation).toInt();
687       if (newRowIndex != 0) {
688         OID newIndex = new OID(new int[] { newRowIndex});
689         Variable[] values = agentppTestSharedEntry.getDefaultValues();
690         values[idxAgentppTestSharedTableRowStatus] =
691             new Integer32(RowStatus.active);
692         values[idxAgentppTestSharedTableCreationTime] =
693             DateAndTime.makeDateAndTime(new GregorianCalendar JavaDoc());
694         values[idxAgentppTestSharedTableSession] =
695             new UnsignedInteger32(getIndex().get(0));
696         MOTableRow row = agentppTestSharedEntry.createRow(newIndex, values);
697         if (row != null) {
698           if (!agentppTestSharedEntry.addRow(row)) {
699             ((UnsignedInteger32) changeSet.getValue(idxAgentppTestRowCreation)).
700                 setValue(0);
701           }
702         }
703         else {
704           ((UnsignedInteger32) changeSet.getValue(idxAgentppTestRowCreation)).
705               setValue(0);
706         }
707       }
708     }
709     //--AgentGen END
710
}
711
712   class AgentppTestSessionsEntryRowFactory
713         extends DefaultMOMutableRow2PCFactory
714   {
715     public synchronized MOTableRow createRow(OID index, Variable[] values)
716         throws UnsupportedOperationException JavaDoc
717     {
718       AgentppTestSessionsEntryRow row = new AgentppTestSessionsEntryRow(index, values);
719      //--AgentGen BEGIN=agentppTestSessionsEntry::createRow
720
//--AgentGen END
721
return row;
722     }
723
724     public synchronized void freeRow(MOTableRow row) {
725      //--AgentGen BEGIN=agentppTestSessionsEntry::freeRow
726
//--AgentGen END
727
}
728
729      //--AgentGen BEGIN=agentppTestSessionsEntry::RowFactory
730
//--AgentGen END
731
}
732   public class AgentppTestSparseEntryRow extends DefaultMOMutableRow2PC {
733     public AgentppTestSparseEntryRow(OID index, Variable[] values) {
734       super(index, values);
735     }
736
737     public Integer32 getAgentppTestSparseCol1() {
738       return (Integer32) getValue(idxAgentppTestSparseCol1);
739     }
740
741     public void setAgentppTestSparseCol1(Integer32 newValue) {
742       setValue(idxAgentppTestSparseCol1, newValue);
743     }
744
745     public Gauge32 getAgentppTestSparseCol2() {
746       return (Gauge32) getValue(idxAgentppTestSparseCol2);
747     }
748
749     public void setAgentppTestSparseCol2(Gauge32 newValue) {
750       setValue(idxAgentppTestSparseCol2, newValue);
751     }
752
753     public OctetString getAgentppTestSparseCol3() {
754       return (OctetString) getValue(idxAgentppTestSparseCol3);
755     }
756
757     public void setAgentppTestSparseCol3(OctetString newValue) {
758       setValue(idxAgentppTestSparseCol3, newValue);
759     }
760
761     public Integer32 getAgentppTestSparseRowStatus() {
762       return (Integer32) getValue(idxAgentppTestSparseRowStatus);
763     }
764
765     public void setAgentppTestSparseRowStatus(Integer32 newValue) {
766       setValue(idxAgentppTestSparseRowStatus, newValue);
767     }
768
769     //--AgentGen BEGIN=agentppTestSparseEntry::Row
770

771     public void setValue(int column, Variable value) {
772       if (column != idxAgentppTestSparseRowStatus) {
773         if (value.equals(getValue(column))) {
774           super.setValue(column, null);
775           return;
776         }
777       }
778       super.setValue(column, value);
779     }
780
781      //--AgentGen END
782
}
783
784   class AgentppTestSparseEntryRowFactory
785         extends DefaultMOMutableRow2PCFactory
786   {
787     public synchronized MOTableRow createRow(OID index, Variable[] values)
788         throws UnsupportedOperationException JavaDoc
789     {
790       AgentppTestSparseEntryRow row = new AgentppTestSparseEntryRow(index, values);
791      //--AgentGen BEGIN=agentppTestSparseEntry::createRow
792
//--AgentGen END
793
return row;
794     }
795
796     public synchronized void freeRow(MOTableRow row) {
797      //--AgentGen BEGIN=agentppTestSparseEntry::freeRow
798
//--AgentGen END
799
}
800
801      //--AgentGen BEGIN=agentppTestSparseEntry::RowFactory
802
//--AgentGen END
803
}
804
805
806 //--AgentGen BEGIN=_METHODS
807
public static MOFactory getSharedTableFactory() {
808     return new AgentppTestMOFactory();
809   }
810 //--AgentGen END
811

812 //--AgentGen BEGIN=_CLASSES
813
static class AgentppTestMOFactory extends DefaultMOFactory {
814     public MOTable createTable(OID oid, MOTableIndex indexDef,
815                                MOColumn[] columns) {
816       if (oidAgentppTestSessionsEntry.equals(oid)) {
817         return new DefaultAgentXSharedMOTable(oid, indexDef, columns) {
818           public void setAgentXSharedMOTableSupport(AgentXSharedMOTableSupport
819               sharedTableSupport) {
820             super.setAgentXSharedMOTableSupport(sharedTableSupport);
821             ((MOMutableTableModel)model).clear();
822             OID index =
823                 new OID(new int[] { sharedTableSupport.getSession().getSessionID() });
824             MOTableRow row = createRow(index);
825             if (row != null) {
826               addRow(row);
827             }
828           }
829         };
830       }
831       return new DefaultAgentXSharedMOTable(oid, indexDef, columns);
832     }
833
834     public MOTable createTable(OID oid, MOTableIndex indexDef, MOColumn[] columns,
835                                MOTableModel model) {
836       DefaultAgentXSharedMOTable table =
837           (DefaultAgentXSharedMOTable) createTable(oid, indexDef, columns);
838       table.setModel(model);
839       return table;
840     }
841
842   }
843 //--AgentGen END
844

845 //--AgentGen BEGIN=_END
846
//--AgentGen END
847
}
848
849
850
Popular Tags