jdk/src/share/classes/sun/management/snmp/jvminstr/JvmRTLibraryPathTableMetaImpl.java
author mchung
Tue, 17 Jan 2012 15:55:40 -0800
changeset 11530 a9d059c15b80
parent 5506 202f599c92aa
child 14342 8435a30053c1
permissions -rw-r--r--
7117570: Warnings in sun.mangement.* and its subpackages Reviewed-by: mchung, dsamersoff Contributed-by: kurchi.subhra.hazra@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
package sun.management.snmp.jvminstr;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
// java imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import com.sun.jmx.mbeanserver.Util;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
// jmx imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import javax.management.MBeanServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import javax.management.ObjectName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import com.sun.jmx.snmp.SnmpCounter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import com.sun.jmx.snmp.SnmpCounter64;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import com.sun.jmx.snmp.SnmpGauge;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import com.sun.jmx.snmp.SnmpInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import com.sun.jmx.snmp.SnmpUnsignedInt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import com.sun.jmx.snmp.SnmpIpAddress;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import com.sun.jmx.snmp.SnmpTimeticks;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import com.sun.jmx.snmp.SnmpOpaque;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import com.sun.jmx.snmp.SnmpString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import com.sun.jmx.snmp.SnmpStringFixed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import com.sun.jmx.snmp.SnmpOid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import com.sun.jmx.snmp.SnmpNull;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import com.sun.jmx.snmp.SnmpValue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import com.sun.jmx.snmp.SnmpVarBind;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import com.sun.jmx.snmp.SnmpStatusException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
// jdmk imports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
//
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
import com.sun.jmx.snmp.agent.SnmpIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
import com.sun.jmx.snmp.agent.SnmpMib;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
import com.sun.jmx.snmp.agent.SnmpMibTable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
import com.sun.jmx.snmp.agent.SnmpMibSubRequest;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
import com.sun.jmx.snmp.agent.SnmpStandardObjectServer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
import sun.management.snmp.jvmmib.JvmRTLibraryPathTableMeta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
import sun.management.snmp.util.SnmpCachedData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
import sun.management.snmp.util.SnmpTableCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
import sun.management.snmp.util.SnmpTableHandler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
import sun.management.snmp.util.MibLogger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
import sun.management.snmp.util.JvmContextFactory;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * The class is used for implementing the "JvmRTLibraryPathTable".
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
public class JvmRTLibraryPathTableMetaImpl extends JvmRTLibraryPathTableMeta {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    73
    static final long serialVersionUID = 6713252710712502068L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private SnmpTableCache cache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * A concrete implementation of {@link SnmpTableCache}, for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * JvmRTLibraryPathTable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private static class JvmRTLibraryPathTableCache extends SnmpTableCache {
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    81
        static final long serialVersionUID = 2035304445719393195L;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        private JvmRTLibraryPathTableMetaImpl meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        JvmRTLibraryPathTableCache(JvmRTLibraryPathTableMetaImpl meta,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
                                 long validity) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
            this.meta = meta;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            this.validity = validity;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
         * Call <code>getTableDatas(JvmContextFactory.getUserData())</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        public SnmpTableHandler getTableHandler() {
11530
a9d059c15b80 7117570: Warnings in sun.mangement.* and its subpackages
mchung
parents: 5506
diff changeset
    94
            final Map<Object,Object> userData = JvmContextFactory.getUserData();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            return getTableDatas(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
         * Return a table handler containing the Thread indexes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
         * Indexes are computed from the ThreadId.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
         **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        protected SnmpCachedData updateCachedDatas(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            // We are getting all the input args
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            final String[] path =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
                JvmRuntimeImpl.getLibraryPath(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            // Time stamp for the cache
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            final long time = System.currentTimeMillis();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            final int len = path.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            SnmpOid indexes[] = new SnmpOid[len];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            for(int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                indexes[i] = new SnmpOid(i + 1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            return new SnmpCachedData(time, indexes, path);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Constructor for the table. Initialize metadata for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     * "JvmRTLibraryPathTableMeta".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * The reference on the MBean server is updated so the entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * created through an SNMP SET will be AUTOMATICALLY REGISTERED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * in Java DMK.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public JvmRTLibraryPathTableMetaImpl(SnmpMib myMib,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                                       SnmpStandardObjectServer objserv) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        super(myMib, objserv);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        cache = new JvmRTLibraryPathTableCache(this, -1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    protected SnmpOid getNextOid(Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        // null means get the first OID.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        return getNextOid(null,userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    protected SnmpOid getNextOid(SnmpOid oid, Object userData)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        if (dbg) log.debug("getNextOid", "previous=" + oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        // Get the data handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        if (handler == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            // This should never happen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            // If we get here it's a bug.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            if (dbg) log.debug("getNextOid", "handler is null!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        // Get the next oid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        final SnmpOid next = handler.getNext(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (dbg) log.debug("*** **** **** **** getNextOid", "next=" + next);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        // if next is null: we reached the end of the table.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        if (next == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    protected boolean contains(SnmpOid oid, Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        // Get the handler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        SnmpTableHandler handler = getHandler(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        return handler.contains(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    // See com.sun.jmx.snmp.agent.SnmpMibTable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public Object getEntry(SnmpOid oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
        throws SnmpStatusException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        final boolean dbg = log.isDebugOn();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        if (dbg) log.debug("getEntry", "oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        if (oid == null || oid.getLength() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            if (dbg) log.debug("getEntry", "Invalid oid [" + oid + "]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        // Get the request contextual cache (userData).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        final Map<Object, Object> m = JvmContextFactory.getUserData();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        // We're going to use this name to store/retrieve the entry in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        // the request contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        // Revisit: Probably better programming to put all these strings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        //          in some interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        final String entryTag = ((m==null)?null:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                                 ("JvmRTLibraryPathTable.entry." +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                  oid.toString()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        // If the entry is in the cache, simply return it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
            final Object entry = m.get(entryTag);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
            if (entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                if (dbg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                    log.debug("getEntry", "Entry is already in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            } else if (dbg) log.debug("getEntry", "Entry is not in the cache");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        // The entry was not in the cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        // Get the data hanler.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        SnmpTableHandler handler = getHandler(m);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        // handler should never be null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (handler == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        // Get the data associated with our entry.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        final Object data = handler.getData(oid);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        // data may be null if the OID we were given is not valid.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        if (data == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            throw new SnmpStatusException(SnmpStatusException.noSuchInstance);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        // make the new entry (transient object that will be kept only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        // for the duration of the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (dbg) log.debug("getEntry","data is a: "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                           data.getClass().getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        final Object entry =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            new JvmRTLibraryPathEntryImpl((String) data,(int)oid.getOidArc(0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        // Put the entry in the cache in case we need it later while processing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        // the request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        //
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        if (m != null && entry != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            m.put(entryTag,entry);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        return entry;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Get the SnmpTableHandler that holds the jvmThreadInstanceTable data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * First look it up in the request contextual cache, and if it is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * not found, obtain it from the weak cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * <br>The request contextual cache will be released at the end of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * current requests, and is used only to process this request.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * <br>The weak cache is shared by all requests, and is only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * recomputed when it is found to be obsolete.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * <br>Note that the data put in the request contextual cache is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     *     never considered to be obsolete, in order to preserve data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *     coherency.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     **/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    protected SnmpTableHandler getHandler(Object userData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        final Map<Object, Object> m;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        if (userData instanceof Map) m=Util.cast(userData);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        else m=null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        // Look in the contextual cache.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (m != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            final SnmpTableHandler handler =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
                (SnmpTableHandler)m.get("JvmRTLibraryPathTable.handler");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            if (handler != null) return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        // No handler in contextual cache, make a new one.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        final SnmpTableHandler handler = cache.getTableHandler();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        if (m != null && handler != null )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            m.put("JvmRTLibraryPathTable.handler",handler);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        return handler;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    static final MibLogger log =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        new MibLogger(JvmRTLibraryPathTableMetaImpl.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
}