当前位置: 首页>>代码示例>>Java>>正文


Java ObjectName.isPattern方法代码示例

本文整理汇总了Java中javax.management.ObjectName.isPattern方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectName.isPattern方法的具体用法?Java ObjectName.isPattern怎么用?Java ObjectName.isPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.management.ObjectName的用法示例。


在下文中一共展示了ObjectName.isPattern方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retrieveNamedObject

import javax.management.ObjectName; //导入方法依赖的package包/类
/**
 * Retrieves the named object contained in repository
 * from the given objectname.
 */
private NamedObject retrieveNamedObject(ObjectName name) {

    // No patterns inside reposit
    if (name.isPattern()) return null;

    // Extract the domain name.
    String dom = name.getDomain().intern();

    // Default domain case
    if (dom.length() == 0) {
        dom = domain;
    }

    Map<String,NamedObject> moiTb = domainTb.get(dom);
    if (moiTb == null) {
        return null; // No domain containing registered object names
    }

    return moiTb.get(name.getCanonicalKeyPropertyListString());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Repository.java

示例2: removeNotificationListener

import javax.management.ObjectName; //导入方法依赖的package包/类
public void removeNotificationListener(ObjectName name, Integer listenerID)
throws
    InstanceNotFoundException,
    ListenerNotFoundException,
    IOException {

    if (logger.traceOn()) {
        logger.trace("removeNotificationListener",
            "Remove the listener " + listenerID + " from " + name);
    }

    checkState();

    if (name != null && !name.isPattern()) {
        if (!mbeanServer.isRegistered(name)) {
            throw new InstanceNotFoundException("The MBean " + name +
                " is not registered.");
        }
    }

    synchronized (listenerMap) {
        // Tread carefully because if set.size() == 1 it may be a
        // Collections.singleton, which is unmodifiable.
        Set<IdAndFilter> set = listenerMap.get(name);
        IdAndFilter idaf = new IdAndFilter(listenerID, null);
        if (set == null || !set.contains(idaf))
            throw new ListenerNotFoundException("Listener not found");
        if (set.size() == 1)
            listenerMap.remove(name);
        else
            set.remove(idaf);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:ServerNotifForwarder.java

示例3: addMBean

import javax.management.ObjectName; //导入方法依赖的package包/类
/**
 * Stores an MBean associated with its object name in the repository.
 *
 * @param object  MBean to be stored in the repository.
 * @param name    MBean object name.
 * @param context A registration context. If non null, the repository
 *                will call {@link RegistrationContext#registering()
 *                context.registering()} from within the repository
 *                lock, when it has determined that the {@code object}
 *                can be stored in the repository with that {@code name}.
 *                If {@link RegistrationContext#registering()
 *                context.registering()} throws an exception, the
 *                operation is abandonned, the MBean is not added to the
 *                repository, and a {@link RuntimeOperationsException}
 *                is thrown.
 */
public void addMBean(final DynamicMBean object, ObjectName name,
        final RegistrationContext context)
    throws InstanceAlreadyExistsException {

    if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
        MBEANSERVER_LOGGER.logp(Level.FINER, Repository.class.getName(),
                "addMBean", "name = " + name);
    }

    // Extract the domain name.
    String dom = name.getDomain().intern();
    boolean to_default_domain = false;

    // Set domain to default if domain is empty and not already set
    if (dom.length() == 0)
        name = Util.newObjectName(domain + name.toString());

    // Do we have default domain ?
    if (dom == domain) {  // ES: OK (dom & domain are interned)
        to_default_domain = true;
        dom = domain;
    } else {
        to_default_domain = false;
    }

    // Validate name for an object
    if (name.isPattern()) {
        throw new RuntimeOperationsException(
         new IllegalArgumentException("Repository: cannot add mbean for " +
                                      "pattern name " + name.toString()));
    }

    lock.writeLock().lock();
    try {
        // Domain cannot be JMImplementation if entry does not exist
        if ( !to_default_domain &&
                dom.equals("JMImplementation") &&
                domainTb.containsKey("JMImplementation")) {
            throw new RuntimeOperationsException(
                    new IllegalArgumentException(
                    "Repository: domain name cannot be JMImplementation"));
        }

        // If domain does not already exist, add it to the hash table
        final Map<String,NamedObject> moiTb = domainTb.get(dom);
        if (moiTb == null) {
            addNewDomMoi(object, dom, name, context);
            return;
        } else {
            // Add instance if not already present
            String cstr = name.getCanonicalKeyPropertyListString();
            NamedObject elmt= moiTb.get(cstr);
            if (elmt != null) {
                throw new InstanceAlreadyExistsException(name.toString());
            } else {
                nbElements++;
                addMoiToTb(object,name,cstr,moiTb,context);
            }
        }

    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:81,代码来源:Repository.java

示例4: addMBean

import javax.management.ObjectName; //导入方法依赖的package包/类
/**
 * Stores an MBean associated with its object name in the repository.
 *
 * @param object  MBean to be stored in the repository.
 * @param name    MBean object name.
 * @param context A registration context. If non null, the repository
 *                will call {@link RegistrationContext#registering()
 *                context.registering()} from within the repository
 *                lock, when it has determined that the {@code object}
 *                can be stored in the repository with that {@code name}.
 *                If {@link RegistrationContext#registering()
 *                context.registering()} throws an exception, the
 *                operation is abandonned, the MBean is not added to the
 *                repository, and a {@link RuntimeOperationsException}
 *                is thrown.
 */
public void addMBean(final DynamicMBean object, ObjectName name,
        final RegistrationContext context)
    throws InstanceAlreadyExistsException {

    if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) {
        MBEANSERVER_LOGGER.log(Level.TRACE, "name = " + name);
    }

    // Extract the domain name.
    String dom = name.getDomain().intern();
    boolean to_default_domain = false;

    // Set domain to default if domain is empty and not already set
    if (dom.length() == 0)
        name = Util.newObjectName(domain + name.toString());

    // Do we have default domain ?
    if (dom == domain) {  // ES: OK (dom & domain are interned)
        to_default_domain = true;
        dom = domain;
    } else {
        to_default_domain = false;
    }

    // Validate name for an object
    if (name.isPattern()) {
        throw new RuntimeOperationsException(
         new IllegalArgumentException("Repository: cannot add mbean for " +
                                      "pattern name " + name.toString()));
    }

    lock.writeLock().lock();
    try {
        // Domain cannot be JMImplementation if entry does not exist
        if ( !to_default_domain &&
                dom.equals("JMImplementation") &&
                domainTb.containsKey("JMImplementation")) {
            throw new RuntimeOperationsException(
                    new IllegalArgumentException(
                    "Repository: domain name cannot be JMImplementation"));
        }

        // If domain does not already exist, add it to the hash table
        final Map<String,NamedObject> moiTb = domainTb.get(dom);
        if (moiTb == null) {
            addNewDomMoi(object, dom, name, context);
            return;
        } else {
            // Add instance if not already present
            String cstr = name.getCanonicalKeyPropertyListString();
            NamedObject elmt= moiTb.get(cstr);
            if (elmt != null) {
                throw new InstanceAlreadyExistsException(name.toString());
            } else {
                nbElements++;
                addMoiToTb(object,name,cstr,moiTb,context);
            }
        }

    } finally {
        lock.writeLock().unlock();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:80,代码来源:Repository.java

示例5: ObjectInstance

import javax.management.ObjectName; //导入方法依赖的package包/类
/**
 * Allows an object instance to be created given an object name and
 * the full class name, including the package name.
 *
 * @param objectName  The object name.
 * @param className  The full class name, including the package
 * name, of the object instance.  If the MBean is a Dynamic MBean
 * the class name corresponds to its {@link
 * DynamicMBean#getMBeanInfo()
 * getMBeanInfo()}<code>.getClassName()</code>.
 * If the MBean is a Dynamic MBean the class name should be retrieved
 * from the <CODE>MBeanInfo</CODE> it provides.
 *
 */
public ObjectInstance(ObjectName objectName, String className) {
    if (objectName.isPattern()) {
        final IllegalArgumentException iae =
            new IllegalArgumentException("Invalid name->"+
                                         objectName.toString());
        throw new RuntimeOperationsException(iae);
    }
    this.name= objectName;
    this.className= className;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:ObjectInstance.java


注:本文中的javax.management.ObjectName.isPattern方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。