當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。