Source Code Cross Referenced for AgentppSimulationMib.java in  » Net » snmp4j » org » snmp4j » agent » mo » ext » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Net » snmp4j » org.snmp4j.agent.mo.ext 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*_############################################################################
002:          _## 
003:          _##  SNMP4J-Agent - AgentppSimulationMib.java  
004:          _## 
005:          _##  Copyright (C) 2005-2007  Frank Fock (SNMP4J.org)
006:          _##  
007:          _##  Licensed under the Apache License, Version 2.0 (the "License");
008:          _##  you may not use this file except in compliance with the License.
009:          _##  You may obtain a copy of the License at
010:          _##  
011:          _##      http://www.apache.org/licenses/LICENSE-2.0
012:          _##  
013:          _##  Unless required by applicable law or agreed to in writing, software
014:          _##  distributed under the License is distributed on an "AS IS" BASIS,
015:          _##  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:          _##  See the License for the specific language governing permissions and
017:          _##  limitations under the License.
018:          _##  
019:          _##########################################################################*/
020:
021:        package org.snmp4j.agent.mo.ext;
022:
023:        //--AgentGen BEGIN=_BEGIN
024:        //--AgentGen END
025:
026:        import org.snmp4j.smi.*;
027:        import org.snmp4j.mp.SnmpConstants;
028:        import org.snmp4j.agent.*;
029:        import org.snmp4j.agent.mo.*;
030:        import org.snmp4j.agent.mo.snmp.*;
031:        import org.snmp4j.agent.request.*;
032:        import org.snmp4j.log.LogFactory;
033:        import org.snmp4j.log.LogAdapter;
034:
035:        //--AgentGen BEGIN=_IMPORT
036:        //--AgentGen END
037:
038:        public class AgentppSimulationMib
039:        //--AgentGen BEGIN=_EXTENDS
040:                //--AgentGen END
041:                implements  MOGroup
042:        //--AgentGen BEGIN=_IMPLEMENTS
043:        //--AgentGen END
044:        {
045:
046:            private static final LogAdapter LOGGER = LogFactory
047:                    .getLogger(AgentppSimulationMib.class);
048:
049:            //--AgentGen BEGIN=_STATIC
050:            //--AgentGen END
051:
052:            // Factory
053:            private static MOFactory moFactory = DefaultMOFactory.getInstance();
054:
055:            // Constants
056:            public static final OID oidAgentppSimMode = new OID(new int[] { 1,
057:                    3, 6, 1, 4, 1, 4976, 2, 1, 1, 0 });
058:            public static final OID oidAgentppSimDeleteRow = new OID(new int[] {
059:                    1, 3, 6, 1, 4, 1, 4976, 2, 1, 2, 0 });
060:            public static final OID oidAgentppSimDeleteTableContents = new OID(
061:                    new int[] { 1, 3, 6, 1, 4, 1, 4976, 2, 1, 3, 0 });
062:
063:            // Enumerations
064:            public static final class AgentppSimModeEnum {
065:                public static final int oper = 1;
066:                public static final int config = 2;
067:            }
068:
069:            // TextualConventions
070:
071:            // Scalars
072:            private MOScalar agentppSimMode;
073:            private MOScalar agentppSimDeleteRow;
074:            private MOScalar agentppSimDeleteTableContents;
075:
076:            // Tables
077:
078:            //--AgentGen BEGIN=_MEMBERS
079:            private MOServer moServer;
080:            private OctetString myContext;
081:
082:            //--AgentGen END
083:
084:            public AgentppSimulationMib() {
085:                agentppSimMode = new AgentppSimMode(oidAgentppSimMode,
086:                        MOAccessImpl.ACCESS_READ_WRITE);
087:                agentppSimDeleteRow = new AgentppSimDeleteRow(
088:                        oidAgentppSimDeleteRow, MOAccessImpl.ACCESS_READ_WRITE);
089:                agentppSimDeleteTableContents = new AgentppSimDeleteTableContents(
090:                        oidAgentppSimDeleteTableContents,
091:                        MOAccessImpl.ACCESS_READ_WRITE);
092:                //--AgentGen BEGIN=_DEFAULTCONSTRUCTOR
093:                //--AgentGen END
094:            }
095:
096:            //--AgentGen BEGIN=_CONSTRUCTORS
097:            //--AgentGen END
098:
099:            public void registerMOs(MOServer server, OctetString context)
100:                    throws DuplicateRegistrationException {
101:                // Scalar Objects
102:                server.register(this .agentppSimMode, context);
103:                server.register(this .agentppSimDeleteRow, context);
104:                server.register(this .agentppSimDeleteTableContents, context);
105:                //--AgentGen BEGIN=_registerMOs
106:                moServer = server;
107:                myContext = context;
108:                //--AgentGen END
109:            }
110:
111:            public void unregisterMOs(MOServer server, OctetString context) {
112:                // Scalar Objects
113:                server.unregister(this .agentppSimMode, context);
114:                server.unregister(this .agentppSimDeleteRow, context);
115:                server.unregister(this .agentppSimDeleteTableContents, context);
116:                //--AgentGen BEGIN=_unregisterMOs
117:                moServer = null;
118:                myContext = null;
119:                //--AgentGen END
120:            }
121:
122:            // Notifications
123:
124:            // Scalars
125:            public class AgentppSimMode extends EnumeratedScalar {
126:                AgentppSimMode(OID oid, MOAccess access) {
127:                    super (oid, access, new Integer32(),
128:                            new int[] { AgentppSimModeEnum.oper,
129:                                    AgentppSimModeEnum.config });
130:                    //--AgentGen BEGIN=agentppSimMode
131:                    setValue(new Integer32(AgentppSimModeEnum.oper));
132:                    setVolatile(true);
133:                    //--AgentGen END
134:                }
135:
136:                public int setValue(Variable newValue) {
137:                    //--AgentGen BEGIN=agentppSimMode::setValue
138:                    SimMOFactory
139:                            .setSimulationModeEnabled(((Integer32) newValue)
140:                                    .getValue() == AgentppSimModeEnum.config);
141:                    //--AgentGen END
142:                    return super .setValue(newValue);
143:                }
144:
145:                //--AgentGen BEGIN=agentppSimMode::_METHODS
146:                //--AgentGen END
147:
148:            }
149:
150:            public class AgentppSimDeleteRow extends MOScalar {
151:                AgentppSimDeleteRow(OID oid, MOAccess access) {
152:                    super (oid, access, new OID());
153:                    //--AgentGen BEGIN=agentppSimDeleteRow
154:                    super .setValue(SnmpConstants.zeroDotZero);
155:                    setVolatile(true);
156:                    //--AgentGen END
157:                }
158:
159:                public int isValueOK(SubRequest request) {
160:                    Variable newValue = request.getVariableBinding()
161:                            .getVariable();
162:                    int valueOK = super .isValueOK(request);
163:                    if (valueOK != SnmpConstants.SNMP_ERROR_SUCCESS) {
164:                        return valueOK;
165:                    }
166:                    //--AgentGen BEGIN=agentppSimDeleteRow::isValueOK
167:                    if (AgentppSimulationMib.this .moServer == null) {
168:                        return SnmpConstants.SNMP_ERROR_RESOURCE_UNAVAILABLE;
169:                    }
170:                    OID oid = (OID) newValue;
171:                    ManagedObject mo = getManagedObject(oid);
172:                    if (!(mo instanceof  MOTable)) {
173:                        return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
174:                    }
175:                    MOTable table = (MOTable) mo;
176:                    OID index = new OID(oid.getValue(), table.getOID().size(),
177:                            oid.size() - table.getOID().size());
178:                    MOTableRow row = table.getModel().getRow(index);
179:                    if (row == null) {
180:                        return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
181:                    }
182:                    //--AgentGen END
183:                    return valueOK;
184:                }
185:
186:                public int setValue(Variable newValue) {
187:                    //--AgentGen BEGIN=agentppSimDeleteRow::setValue
188:                    if (AgentppSimulationMib.this .moServer == null) {
189:                        return SnmpConstants.SNMP_ERROR_COMMIT_FAILED;
190:                    }
191:                    OID oid = (OID) newValue;
192:                    ManagedObject mo = getManagedObject(oid);
193:                    if (!(mo instanceof  MOTable)) {
194:                        return SnmpConstants.SNMP_ERROR_COMMIT_FAILED;
195:                    }
196:                    MOTable table = (MOTable) mo;
197:                    OID index = new OID(oid.getValue(), table.getOID().size(),
198:                            oid.size() - table.getOID().size());
199:                    MOTableRow row = table.removeRow(index);
200:                    if (row == null) {
201:                        return SnmpConstants.SNMP_ERROR_COMMIT_FAILED;
202:                    }
203:                    //--AgentGen END
204:                    return super .setValue(newValue);
205:                }
206:
207:                //--AgentGen BEGIN=agentppSimDeleteRow::_METHODS
208:                //--AgentGen END
209:
210:            }
211:
212:            public class AgentppSimDeleteTableContents extends MOScalar {
213:                AgentppSimDeleteTableContents(OID oid, MOAccess access) {
214:                    super (oid, access, new OID());
215:                    //--AgentGen BEGIN=agentppSimDeleteTableContents
216:                    setVolatile(true);
217:                    //--AgentGen END
218:                }
219:
220:                public int isValueOK(SubRequest request) {
221:                    Variable newValue = request.getVariableBinding()
222:                            .getVariable();
223:                    int valueOK = super .isValueOK(request);
224:                    if (valueOK != SnmpConstants.SNMP_ERROR_SUCCESS) {
225:                        return valueOK;
226:                    }
227:                    //--AgentGen BEGIN=agentppSimDeleteTableContents::isValueOK
228:                    if (AgentppSimulationMib.this .moServer == null) {
229:                        return SnmpConstants.SNMP_ERROR_RESOURCE_UNAVAILABLE;
230:                    }
231:                    OID oid = (OID) newValue;
232:                    oid.append(0);
233:                    ManagedObject mo = getManagedObject(oid);
234:                    if ((!(mo instanceof  MOTable))
235:                            || (!(((MOTable) mo).getModel() instanceof  MOMutableTableModel))) {
236:                        return SnmpConstants.SNMP_ERROR_WRONG_VALUE;
237:                    }
238:                    //--AgentGen END
239:                    return valueOK;
240:                }
241:
242:                public int setValue(Variable newValue) {
243:                    //--AgentGen BEGIN=agentppSimDeleteTableContents::setValue
244:                    if (AgentppSimulationMib.this .moServer == null) {
245:                        return SnmpConstants.SNMP_ERROR_COMMIT_FAILED;
246:                    }
247:                    OID oid = (OID) newValue;
248:                    oid.append(0);
249:                    ManagedObject mo = getManagedObject(oid);
250:                    if ((!(mo instanceof  MOTable))
251:                            && (!(((MOTable) mo).getModel() instanceof  MOMutableTableModel))) {
252:                        return SnmpConstants.SNMP_ERROR_COMMIT_FAILED;
253:                    }
254:                    MOTable table = (MOTable) mo;
255:                    ((MOMutableTableModel) table.getModel()).clear();
256:                    //--AgentGen END
257:                    return super .setValue(newValue);
258:                }
259:
260:                //--AgentGen BEGIN=agentppSimDeleteTableContents::_METHODS
261:                //--AgentGen END
262:
263:            }
264:
265:            // Value Validators
266:
267:            // Rows and Factories
268:
269:            //--AgentGen BEGIN=_METHODS
270:            private synchronized ManagedObject getManagedObject(OID oid) {
271:                MOQuery query = new DefaultMOQuery(new DefaultMOContextScope(
272:                        myContext, oid, true, oid, true), true);
273:                ManagedObject mo = AgentppSimulationMib.this .moServer
274:                        .lookup(query);
275:                return mo;
276:            }
277:            //--AgentGen END
278:
279:            //--AgentGen BEGIN=_CLASSES
280:            //--AgentGen END
281:
282:            //--AgentGen BEGIN=_END
283:            //--AgentGen END
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.