mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

mrossign
16.34.2009 55a07ce2479e1b4c74dec15ce4e78e3fdf50a27c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.server.snmp;
 
import javax.management.MBeanServer;
import javax.management.ObjectName;
import org.opends.server.loggers.debug.DebugLogger;
import org.opends.server.loggers.debug.DebugTracer;
 
/**
 * The class is the "DIRECTORY-SERVER-MIB" implementation.
 */
public class DIRECTORY_SERVER_MIBImpl extends DIRECTORY_SERVER_MIB {
 
    /**
     * The serial version identifier required to satisfy the compiler because
     * this class implements the <CODE>java.io.Serializable</CODE> interface.
     * This value was generated using the <CODE>serialver</CODE> command-line
     * utility included with the Java SDK.
     */
    private static final long serialVersionUID = 1420660265781848102L;
    /**
     * The debug log tracer for this class.
     */
    private static final DebugTracer TRACER = DebugLogger.getTracer();
    /**
     * Indicates if the SNMP Mbeans have to be registered or not.
     */
    private boolean registeredSnmpMBean = false;
    /**
     * The Current Directory Server MIB.
     */
    private DsMIBImpl dsMibGroup = null;
    /**
     * ObjectName of the Current Direcotry Server MIB.
     */
    private ObjectName mibObName;
    /**
     * ObjectName of the dsMIB group in the Directory Server MIB.
     */
    private ObjectName groupObjName;
 
    /**
     * Creates the Current Directory Server MIB.
     * @param registeredMBean indicates if the SNMP MBean has to register
     * in the Direcotry Server MBeanServer
     * @param mibName of the Directory Server MIB
     */
    public DIRECTORY_SERVER_MIBImpl(boolean registeredMBean,
            ObjectName mibName) {
        super();
        this.registeredSnmpMBean = registeredMBean;
        this.mibObName = mibName;
        if (DebugLogger.debugEnabled()) {
            TRACER.debugVerbose("DIRECTORY_SERVER_MIB=" + this.mibObName +
                    " created with registerMBean=" + this.registeredSnmpMBean);
        }
    }
 
    /**
     * {@inheritDoc}
     * @throws java.lang.Exception if the DsMib Group couls not be initialized
     */
    @Override
    protected void initDsMIB(MBeanServer server)
            throws Exception {
 
        final String oid = getGroupOid("DsMIB", "1.3.6.1.2.1.66");
        if (server != null) {
            groupObjName = new ObjectName(
                    SNMPConnectionHandlerDefinitions.SNMP_DOMAIN +
                    "type=group,name=DsMib");
        }
        final DsMIBMeta meta = createDsMIBMetaNode("DsMIB", oid, groupObjName,
                server);
        if (meta != null) {
            meta.registerTableNodes(this, server);
 
            // Note that when using standard metadata,
            // the returned object must implement the "DsMIBMBean"
            // interface.
            //
            final DsMIBMBean group = (DsMIBMBean) createDsMIBMBean("DsMIB", oid,
                    groupObjName, server);
            meta.setInstance(group);
            registerGroupNode("DsMIB", oid, groupObjName, meta, group, server);
        }
    }
 
    /**
     * {@inheritDoc}
     */
    @Override
    protected Object createDsMIBMBean(String groupName,
            String groupOid, ObjectName groupObjname, MBeanServer server) {
        this.dsMibGroup = new DsMIBImpl(this, server, this.registeredSnmpMBean);
        return this.dsMibGroup;
    }
 
    /**
     * Returns the created dsMIB group.
     * @return the DsMIBImpl
     */
    protected DsMIBImpl getMib() {
        return this.dsMibGroup;
    }
 
    /**
     * Returns the ObjectName of the dsMIB group.
     * @return the ObjectName of the created dsMIB group
     */
    protected ObjectName getObjectName() {
        return this.groupObjName;
    }
}