com.sun.jmx.mbeanserver.Util Java Examples

The following examples show how to use com.sun.jmx.mbeanserver.Util. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JvmRuntimeImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
static String[] getClassPath(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getClassPath";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final String[] args = splitPath(getRuntimeMXBean().getClassPath());

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #2
Source File: JvmRuntimeImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
static String[] getLibraryPath(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getLibraryPath";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final String[] args = splitPath(getRuntimeMXBean().getLibraryPath());

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #3
Source File: RMIConnector.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
private Integer addListenerWithSubject(ObjectName name,
                                       MarshalledObject<NotificationFilter> filter,
                                       Subject delegationSubject,
                                       boolean reconnect)
    throws InstanceNotFoundException, IOException {

    final boolean debug = logger.debugOn();
    if (debug)
        logger.debug("addListenerWithSubject",
                "(ObjectName,MarshalledObject,Subject)");

    final ObjectName[] names = new ObjectName[] {name};
    final MarshalledObject<NotificationFilter>[] filters =
            Util.cast(new MarshalledObject<?>[] {filter});
    final Subject[] delegationSubjects = new Subject[] {
        delegationSubject
    };

    final Integer[] listenerIDs =
            addListenersWithSubjects(names,filters,delegationSubjects,
            reconnect);

    if (debug) logger.debug("addListenerWithSubject","listenerID="
            + listenerIDs[0]);
    return listenerIDs[0];
}
 
Example #4
Source File: SnmpNamedListTableCache.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update cahed datas.
 * Obtains a {@link List} of raw datas by calling
 * {@link #getRawDatas(Map,String) getRawDatas((Map)context,getRawDatasKey())}.<br>
 * Then allocate a new {@link TreeMap} to serve as temporary map between
 * names and indexes, and call {@link #updateCachedDatas(Object,List)}
 * with that temporary map as context.<br>
 * Finally replaces the {@link #names} TreeMap by the temporary
 * TreeMap.
 * @param context The request contextual cache allocated by the
 *        {@link JvmContextFactory}.
 **/
protected SnmpCachedData updateCachedDatas(Object context) {

    final Map<Object, Object> userData =
        (context instanceof Map)?Util.<Map<Object, Object>>cast(context):null;

    // Look for memory manager list in request contextual cache.
    final List<?> rawDatas = getRawDatas(userData,getRawDatasKey());

    log.debug("updateCachedDatas","rawDatas.size()=" +
          ((rawDatas==null)?"<no data>":""+rawDatas.size()));

    TreeMap<String,SnmpOid> ctxt = new TreeMap<>();
    final SnmpCachedData result =
        super.updateCachedDatas(ctxt,rawDatas);
    names = ctxt;
    return result;
}
 
Example #5
Source File: SnmpNamedListTableCache.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Update cahed datas.
 * Obtains a {@link List} of raw datas by calling
 * {@link #getRawDatas(Map,String) getRawDatas((Map)context,getRawDatasKey())}.<br>
 * Then allocate a new {@link TreeMap} to serve as temporary map between
 * names and indexes, and call {@link #updateCachedDatas(Object,List)}
 * with that temporary map as context.<br>
 * Finally replaces the {@link #names} TreeMap by the temporary
 * TreeMap.
 * @param context The request contextual cache allocated by the
 *        {@link JvmContextFactory}.
 **/
protected SnmpCachedData updateCachedDatas(Object context) {

    final Map<Object, Object> userData =
        (context instanceof Map)?Util.<Map<Object, Object>>cast(context):null;

    // Look for memory manager list in request contextual cache.
    final List<?> rawDatas = getRawDatas(userData,getRawDatasKey());

    log.debug("updateCachedDatas","rawDatas.size()=" +
          ((rawDatas==null)?"<no data>":""+rawDatas.size()));

    TreeMap<String,SnmpOid> ctxt = new TreeMap<>();
    final SnmpCachedData result =
        super.updateCachedDatas(ctxt,rawDatas);
    names = ctxt;
    return result;
}
 
Example #6
Source File: JvmRuntimeImpl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static String[] getInputArguments(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getInputArguments";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final List<String> l = getRuntimeMXBean().getInputArguments();
    final String[] args = l.toArray(new String[0]);

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #7
Source File: RMIConnector.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private Integer addListenerWithSubject(ObjectName name,
                                       MarshalledObject<NotificationFilter> filter,
                                       Subject delegationSubject,
                                       boolean reconnect)
    throws InstanceNotFoundException, IOException {

    final boolean debug = logger.debugOn();
    if (debug)
        logger.debug("addListenerWithSubject",
                "(ObjectName,MarshalledObject,Subject)");

    final ObjectName[] names = new ObjectName[] {name};
    final MarshalledObject<NotificationFilter>[] filters =
            Util.cast(new MarshalledObject<?>[] {filter});
    final Subject[] delegationSubjects = new Subject[] {
        delegationSubject
    };

    final Integer[] listenerIDs =
            addListenersWithSubjects(names,filters,delegationSubjects,
            reconnect);

    if (debug) logger.debug("addListenerWithSubject","listenerID="
            + listenerIDs[0]);
    return listenerIDs[0];
}
 
Example #8
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
private Integer addListenerWithSubject(ObjectName name,
                                       MarshalledObject<NotificationFilter> filter,
                                       Subject delegationSubject,
                                       boolean reconnect)
    throws InstanceNotFoundException, IOException {

    final boolean debug = logger.debugOn();
    if (debug)
        logger.debug("addListenerWithSubject",
                "(ObjectName,MarshalledObject,Subject)");

    final ObjectName[] names = new ObjectName[] {name};
    final MarshalledObject<NotificationFilter>[] filters =
            Util.cast(new MarshalledObject<?>[] {filter});
    final Subject[] delegationSubjects = new Subject[] {
        delegationSubject
    };

    final Integer[] listenerIDs =
            addListenersWithSubjects(names,filters,delegationSubjects,
            reconnect);

    if (debug) logger.debug("addListenerWithSubject","listenerID="
            + listenerIDs[0]);
    return listenerIDs[0];
}
 
Example #9
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the list of memory pool associated with the
 * given MemoryManagerMXBean.
 **/
protected String[] getMemoryPools(Object userData,
                              MemoryManagerMXBean mmm, long mmarc) {
    final String listTag =
        "JvmMemManager." + mmarc + ".getMemoryPools";

    String[] result=null;
    if (userData instanceof Map) {
        result = (String[])((Map)userData).get(listTag);
        if (result != null) return result;
    }

    if (mmm!=null) {
        result = mmm.getMemoryPoolNames();
    }
    if ((result!=null)&&(userData instanceof Map)) {
        Map<Object, Object> map = Util.cast(userData);
        map.put(listTag,result);
    }

    return result;
}
 
Example #10
Source File: JvmRuntimeImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
static String[] getLibraryPath(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getLibraryPath";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final String[] args = splitPath(getRuntimeMXBean().getLibraryPath());

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #11
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the list of memory pool associated with the
 * given MemoryManagerMXBean.
 **/
protected String[] getMemoryPools(Object userData,
                              MemoryManagerMXBean mmm, long mmarc) {
    final String listTag =
        "JvmMemManager." + mmarc + ".getMemoryPools";

    String[] result=null;
    if (userData instanceof Map) {
        result = (String[])((Map)userData).get(listTag);
        if (result != null) return result;
    }

    if (mmm!=null) {
        result = mmm.getMemoryPoolNames();
    }
    if ((result!=null)&&(userData instanceof Map)) {
        Map<Object, Object> map = Util.cast(userData);
        map.put(listTag,result);
    }

    return result;
}
 
Example #12
Source File: JvmRuntimeImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
static String[] getInputArguments(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getInputArguments";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final List<String> l = getRuntimeMXBean().getInputArguments();
    final String[] args = l.toArray(new String[0]);

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #13
Source File: JvmMemMgrPoolRelTableMetaImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Get the list of memory pool associated with the
 * given MemoryManagerMXBean.
 **/
protected String[] getMemoryPools(Object userData,
                              MemoryManagerMXBean mmm, long mmarc) {
    final String listTag =
        "JvmMemManager." + mmarc + ".getMemoryPools";

    String[] result=null;
    if (userData instanceof Map) {
        result = (String[])((Map)userData).get(listTag);
        if (result != null) return result;
    }

    if (mmm!=null) {
        result = mmm.getMemoryPoolNames();
    }
    if ((result!=null)&&(userData instanceof Map)) {
        Map<Object, Object> map = Util.cast(userData);
        map.put(listTag,result);
    }

    return result;
}
 
Example #14
Source File: JvmRuntimeImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static String[] getBootClassPath(Object userData) {
    if (!getRuntimeMXBean().isBootClassPathSupported())
    return new String[0];

    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getBootClassPath";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final String[] args = splitPath(getRuntimeMXBean().getBootClassPath());

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #15
Source File: JvmRuntimeImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
static String[] getLibraryPath(Object userData) {
    final Map<Object, Object> m =
            Util.cast((userData instanceof Map)?userData:null);
    final String tag = "JvmRuntime.getLibraryPath";

    // If the list is in the cache, simply return it.
    //
    if (m != null) {
        final String[] cached = (String[])m.get(tag);
        if (cached != null) return cached;
    }

    final String[] args = splitPath(getRuntimeMXBean().getLibraryPath());

    if (m != null) m.put(tag,args);
    return args;
}
 
Example #16
Source File: RMIConnector.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private Integer addListenerWithSubject(ObjectName name,
                                       MarshalledObject<NotificationFilter> filter,
                                       Subject delegationSubject,
                                       boolean reconnect)
    throws InstanceNotFoundException, IOException {

    final boolean debug = logger.debugOn();
    if (debug)
        logger.debug("addListenerWithSubject",
                "(ObjectName,MarshalledObject,Subject)");

    final ObjectName[] names = new ObjectName[] {name};
    final MarshalledObject<NotificationFilter>[] filters =
            Util.cast(new MarshalledObject<?>[] {filter});
    final Subject[] delegationSubjects = new Subject[] {
        delegationSubject
    };

    final Integer[] listenerIDs =
            addListenersWithSubjects(names,filters,delegationSubjects,
            reconnect);

    if (debug) logger.debug("addListenerWithSubject","listenerID="
            + listenerIDs[0]);
    return listenerIDs[0];
}
 
Example #17
Source File: FileLoginModule.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize this <code>LoginModule</code>.
 *
 * @param subject the <code>Subject</code> to be authenticated.
 * @param callbackHandler a <code>CallbackHandler</code> to acquire the
 *                  user's name and password.
 * @param sharedState shared <code>LoginModule</code> state.
 * @param options options specified in the login
 *                  <code>Configuration</code> for this particular
 *                  <code>LoginModule</code>.
 */
public void initialize(Subject subject, CallbackHandler callbackHandler,
                       Map<String,?> sharedState,
                       Map<String,?> options)
{

    this.subject = subject;
    this.callbackHandler = callbackHandler;
    this.sharedState = Util.cast(sharedState);
    this.options = options;

    // initialize any configured options
    tryFirstPass =
            "true".equalsIgnoreCase((String)options.get("tryFirstPass"));
    useFirstPass =
            "true".equalsIgnoreCase((String)options.get("useFirstPass"));
    storePass =
            "true".equalsIgnoreCase((String)options.get("storePass"));
    clearPass =
            "true".equalsIgnoreCase((String)options.get("clearPass"));

    passwordFile = (String)options.get("passwordFile");
    passwordFileDisplayName = passwordFile;
    userSuppliedPasswordFile = true;

    // set the location of the password file
    if (passwordFile == null) {
        passwordFile = DEFAULT_PASSWORD_FILE_NAME;
        userSuppliedPasswordFile = false;
        try {
            System.getProperty("java.home");
            hasJavaHomePermission = true;
            passwordFileDisplayName = passwordFile;
        } catch (SecurityException e) {
            hasJavaHomePermission = false;
            passwordFileDisplayName =
                    ConnectorBootstrap.DefaultValues.PASSWORD_FILE_NAME;
        }
    }
}
 
Example #18
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private ObjectName nonDefaultDomain(ObjectName name) {
    if (name == null || name.getDomain().length() > 0)
        return name;

    /* The ObjectName looks like ":a=b", and that's what its
       toString() will return in this implementation.  So
       we can just stick the default domain in front of it
       to get a non-default-domain name.  We depend on the
       fact that toString() works like that and that it
       leaves wildcards in place (so we can detect an error
       if one is supplied where it shouldn't be).  */
    final String completeName = domain + name;

    return Util.newObjectName(completeName);
}
 
Example #19
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public String[] getDomains()  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        // Check if the caller has the right to invoke 'getDomains'
        //
        checkMBeanPermission((String) null, null, null, "getDomains");

        // Return domains
        //
        String[] domains = repository.getDomains();

        // Check if the caller has the right to invoke 'getDomains'
        // on each specific domain in the list.
        //
        List<String> result = new ArrayList<String>(domains.length);
        for (int i = 0; i < domains.length; i++) {
            try {
                ObjectName dom = Util.newObjectName(domains[i] + ":x=x");
                checkMBeanPermission((String) null, null, dom, "getDomains");
                result.add(domains[i]);
            } catch (SecurityException e) {
                // OK: Do not add this domain to the list
            }
        }

        // Make an array from result.
        //
        return result.toArray(new String[result.size()]);
    } else {
        return repository.getDomains();
    }
}
 
Example #20
Source File: FileLoginModule.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize this <code>LoginModule</code>.
 *
 * @param subject the <code>Subject</code> to be authenticated.
 * @param callbackHandler a <code>CallbackHandler</code> to acquire the
 *                  user's name and password.
 * @param sharedState shared <code>LoginModule</code> state.
 * @param options options specified in the login
 *                  <code>Configuration</code> for this particular
 *                  <code>LoginModule</code>.
 */
public void initialize(Subject subject, CallbackHandler callbackHandler,
                       Map<String,?> sharedState,
                       Map<String,?> options)
{

    this.subject = subject;
    this.callbackHandler = callbackHandler;
    this.sharedState = Util.cast(sharedState);
    this.options = options;

    // initialize any configured options
    tryFirstPass =
            "true".equalsIgnoreCase((String)options.get("tryFirstPass"));
    useFirstPass =
            "true".equalsIgnoreCase((String)options.get("useFirstPass"));
    storePass =
            "true".equalsIgnoreCase((String)options.get("storePass"));
    clearPass =
            "true".equalsIgnoreCase((String)options.get("clearPass"));

    passwordFile = (String)options.get("passwordFile");
    passwordFileDisplayName = passwordFile;
    userSuppliedPasswordFile = true;

    // set the location of the password file
    if (passwordFile == null) {
        passwordFile = DEFAULT_PASSWORD_FILE_NAME;
        userSuppliedPasswordFile = false;
        try {
            System.getProperty("java.home");
            hasJavaHomePermission = true;
            passwordFileDisplayName = passwordFile;
        } catch (SecurityException e) {
            hasJavaHomePermission = false;
            passwordFileDisplayName =
                    ConnectorBootstrap.DefaultValues.PASSWORD_FILE_NAME;
        }
    }
}
 
Example #21
Source File: RMIConnector.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
Example #22
Source File: StandardMBean.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Make a DynamicMBean out of <var>implementation</var>, using the
 * specified <var>mbeanInterface</var> class.
 * @param implementation The implementation of this MBean.
 *        If <code>null</code>, and null implementation is allowed,
 *        then the implementation is assumed to be <var>this</var>.
 * @param mbeanInterface The Management Interface exported by this
 *        MBean's implementation. If <code>null</code>, then this
 *        object will use standard JMX design pattern to determine
 *        the management interface associated with the given
 *        implementation.
 * @param nullImplementationAllowed <code>true</code> if a null
 *        implementation is allowed. If null implementation is allowed,
 *        and a null implementation is passed, then the implementation
 *        is assumed to be <var>this</var>.
 * @exception IllegalArgumentException if the given
 *    <var>implementation</var> is null, and null is not allowed.
 **/
private <T> void construct(T implementation, Class<T> mbeanInterface,
                           boolean nullImplementationAllowed,
                           boolean isMXBean)
                           throws NotCompliantMBeanException {
    if (implementation == null) {
        // Have to use (T)this rather than mbeanInterface.cast(this)
        // because mbeanInterface might be null.
        if (nullImplementationAllowed)
            implementation = Util.<T>cast(this);
        else throw new IllegalArgumentException("implementation is null");
    }
    if (isMXBean) {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getMXBeanInterface(
                    implementation.getClass()));
        }
        this.mbean = new MXBeanSupport(implementation, mbeanInterface);
    } else {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getStandardMBeanInterface(
                    implementation.getClass()));
        }
        this.mbean =
                new StandardMBeanSupport(implementation, mbeanInterface);
    }
}
 
Example #23
Source File: RMIConnector.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
Example #24
Source File: RMIConnector.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
protected Integer addListenerForMBeanRemovedNotif()
throws IOException, InstanceNotFoundException {
    NotificationFilterSupport clientFilter =
            new NotificationFilterSupport();
    clientFilter.enableType(
            MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
    MarshalledObject<NotificationFilter> sFilter =
        new MarshalledObject<NotificationFilter>(clientFilter);

    Integer[] listenerIDs;
    final ObjectName[] names =
        new ObjectName[] {MBeanServerDelegate.DELEGATE_NAME};
    final MarshalledObject<NotificationFilter>[] filters =
        Util.cast(new MarshalledObject<?>[] {sFilter});
    final Subject[] subjects = new Subject[] {null};
    try {
        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);

    } catch (IOException ioe) {
        communicatorAdmin.gotIOException(ioe);

        listenerIDs =
                connection.addNotificationListeners(names,
                filters,
                subjects);
    }
    return listenerIDs[0];
}
 
Example #25
Source File: ObjectName.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private final boolean matchDomains(ObjectName name) {
    if (_domain_pattern) {
        // wildmatch domains
        // This ObjectName is the pattern
        // The other ObjectName is the string.
        return Util.wildmatch(name.getDomain(),getDomain());
    }
    return getDomain().equals(name.getDomain());
}
 
Example #26
Source File: ObjectName.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private final boolean matchDomains(ObjectName name) {
    if (_domain_pattern) {
        // wildmatch domains
        // This ObjectName is the pattern
        // The other ObjectName is the string.
        return Util.wildmatch(name.getDomain(),getDomain());
    }
    return getDomain().equals(name.getDomain());
}
 
Example #27
Source File: StandardMBean.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Make a DynamicMBean out of <var>implementation</var>, using the
 * specified <var>mbeanInterface</var> class.
 * @param implementation The implementation of this MBean.
 *        If <code>null</code>, and null implementation is allowed,
 *        then the implementation is assumed to be <var>this</var>.
 * @param mbeanInterface The Management Interface exported by this
 *        MBean's implementation. If <code>null</code>, then this
 *        object will use standard JMX design pattern to determine
 *        the management interface associated with the given
 *        implementation.
 * @param nullImplementationAllowed <code>true</code> if a null
 *        implementation is allowed. If null implementation is allowed,
 *        and a null implementation is passed, then the implementation
 *        is assumed to be <var>this</var>.
 * @exception IllegalArgumentException if the given
 *    <var>implementation</var> is null, and null is not allowed.
 **/
private <T> void construct(T implementation, Class<T> mbeanInterface,
                           boolean nullImplementationAllowed,
                           boolean isMXBean)
                           throws NotCompliantMBeanException {
    if (implementation == null) {
        // Have to use (T)this rather than mbeanInterface.cast(this)
        // because mbeanInterface might be null.
        if (nullImplementationAllowed)
            implementation = Util.<T>cast(this);
        else throw new IllegalArgumentException("implementation is null");
    }
    if (isMXBean) {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getMXBeanInterface(
                    implementation.getClass()));
        }
        this.mbean = new MXBeanSupport(implementation, mbeanInterface);
    } else {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getStandardMBeanInterface(
                    implementation.getClass()));
        }
        this.mbean =
                new StandardMBeanSupport(implementation, mbeanInterface);
    }
}
 
Example #28
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public String[] getDomains()  {
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        // Check if the caller has the right to invoke 'getDomains'
        //
        checkMBeanPermission((String) null, null, null, "getDomains");

        // Return domains
        //
        String[] domains = repository.getDomains();

        // Check if the caller has the right to invoke 'getDomains'
        // on each specific domain in the list.
        //
        List<String> result = new ArrayList<String>(domains.length);
        for (int i = 0; i < domains.length; i++) {
            try {
                ObjectName dom = Util.newObjectName(domains[i] + ":x=x");
                checkMBeanPermission((String) null, null, dom, "getDomains");
                result.add(domains[i]);
            } catch (SecurityException e) {
                // OK: Do not add this domain to the list
            }
        }

        // Make an array from result.
        //
        return result.toArray(new String[result.size()]);
    } else {
        return repository.getDomains();
    }
}
 
Example #29
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private ObjectName nonDefaultDomain(ObjectName name) {
    if (name == null || name.getDomain().length() > 0)
        return name;

    /* The ObjectName looks like ":a=b", and that's what its
       toString() will return in this implementation.  So
       we can just stick the default domain in front of it
       to get a non-default-domain name.  We depend on the
       fact that toString() works like that and that it
       leaves wildcards in place (so we can detect an error
       if one is supplied where it shouldn't be).  */
    final String completeName = domain + name;

    return Util.newObjectName(completeName);
}
 
Example #30
Source File: StandardMBean.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Make a DynamicMBean out of <var>implementation</var>, using the
 * specified <var>mbeanInterface</var> class.
 * @param implementation The implementation of this MBean.
 *        If <code>null</code>, and null implementation is allowed,
 *        then the implementation is assumed to be <var>this</var>.
 * @param mbeanInterface The Management Interface exported by this
 *        MBean's implementation. If <code>null</code>, then this
 *        object will use standard JMX design pattern to determine
 *        the management interface associated with the given
 *        implementation.
 * @param nullImplementationAllowed <code>true</code> if a null
 *        implementation is allowed. If null implementation is allowed,
 *        and a null implementation is passed, then the implementation
 *        is assumed to be <var>this</var>.
 * @exception IllegalArgumentException if the given
 *    <var>implementation</var> is null, and null is not allowed.
 **/
private <T> void construct(T implementation, Class<T> mbeanInterface,
                           boolean nullImplementationAllowed,
                           boolean isMXBean)
                           throws NotCompliantMBeanException {
    if (implementation == null) {
        // Have to use (T)this rather than mbeanInterface.cast(this)
        // because mbeanInterface might be null.
        if (nullImplementationAllowed)
            implementation = Util.<T>cast(this);
        else throw new IllegalArgumentException("implementation is null");
    }
    if (isMXBean) {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getMXBeanInterface(
                    implementation.getClass()));
        }
        this.mbean = new MXBeanSupport(implementation, mbeanInterface);
    } else {
        if (mbeanInterface == null) {
            mbeanInterface = Util.cast(Introspector.getStandardMBeanInterface(
                    implementation.getClass()));
        }
        this.mbean =
                new StandardMBeanSupport(implementation, mbeanInterface);
    }
}